col-browser 2.2.1 → 2.2.2

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.
@@ -1,73 +1,74 @@
1
- var tt = Object.defineProperty;
2
- var nt = (e, n, r) => n in e ? tt(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[n] = r;
3
- var Z = (e, n, r) => nt(e, typeof n != "symbol" ? n + "" : n, r);
1
+ var et = Object.defineProperty;
2
+ var tt = (e, n, r) => n in e ? et(e, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[n] = r;
3
+ var X = (e, n, r) => tt(e, typeof n != "symbol" ? n + "" : n, r);
4
4
  import { j as s } from "./jsx-runtime-BzflLqGi.js";
5
5
  import * as Ne from "react";
6
- import rt, { useState as L, useRef as G, useMemo as ne, useEffect as N } from "react";
7
- import { Spin as st, Popover as ot, Radio as le } from "antd";
8
- import { isArray as we, get as $, keyBy as it, startCase as at } from "lodash-es";
9
- import { c as te, p as ct } from "./router-CssZk5qZ.js";
10
- import { c as A } from "./config-BPRXv9x8.js";
11
- import { E as lt } from "./ErrorMsg-K8k5PPTp.js";
12
- import { I as dt } from "./AntdIcon-B1nMlqyh.js";
13
- import { M as ut } from "./MergedDataBadge-DsTsn5Xu.js";
6
+ import nt, { useState as w, useRef as M, useMemo as se, useEffect as $ } from "react";
7
+ import { Spin as rt, Popover as st, Radio as ue } from "antd";
8
+ import { isArray as Le, get as A, keyBy as ot, startCase as at } from "lodash-es";
9
+ import { c as ne, p as it } from "./router-CssZk5qZ.js";
10
+ import { c as P } from "./config-BPRXv9x8.js";
11
+ import { E as ct } from "./ErrorMsg-K8k5PPTp.js";
12
+ import { I as lt } from "./AntdIcon-B1nMlqyh.js";
13
+ import { M as dt } from "./MergedDataBadge-DsTsn5Xu.js";
14
+ import { P as ut } from "./PresentationItem-C4yZ555-.js";
14
15
  import D from "maplibre-gl";
15
16
  import "maplibre-gl/dist/maplibre-gl.css";
16
17
  import { r as pt, w as ft } from "./storage-BgdCo9fV.js";
17
18
  var ht = { icon: { tag: "svg", attrs: { viewBox: "64 64 896 896", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M832 64H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V96c0-17.7-14.3-32-32-32zm-260 72h96v209.9L621.5 312 572 347.4V136zm220 752H232V136h280v296.9c0 3.3 1 6.6 3 9.3a15.9 15.9 0 0022.3 3.7l83.8-59.9 81.4 59.4c2.7 2 6 3.1 9.4 3.1 8.8 0 16-7.2 16-16V136h64v752z" } }] }, name: "book", theme: "outlined" };
18
- function fe() {
19
- return fe = Object.assign ? Object.assign.bind() : function(e) {
19
+ function ge() {
20
+ return ge = Object.assign ? Object.assign.bind() : function(e) {
20
21
  for (var n = 1; n < arguments.length; n++) {
21
22
  var r = arguments[n];
22
- for (var i in r)
23
- Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]);
23
+ for (var a in r)
24
+ Object.prototype.hasOwnProperty.call(r, a) && (e[a] = r[a]);
24
25
  }
25
26
  return e;
26
- }, fe.apply(this, arguments);
27
+ }, ge.apply(this, arguments);
27
28
  }
28
- const gt = (e, n) => /* @__PURE__ */ Ne.createElement(dt, fe({}, e, {
29
+ const gt = (e, n) => /* @__PURE__ */ Ne.createElement(lt, ge({}, e, {
29
30
  ref: n,
30
31
  icon: ht
31
32
  })), _e = /* @__PURE__ */ Ne.forwardRef(gt);
32
33
  process.env.NODE_ENV !== "production" && (_e.displayName = "BookOutlined");
33
- class mt extends rt.Component {
34
+ class mt extends nt.Component {
34
35
  constructor(r) {
35
36
  super(r);
36
- Z(this, "getData", () => {
37
- const { referenceId: r, datasetKey: i, references: o } = this.props;
37
+ X(this, "getData", () => {
38
+ const { referenceId: r, datasetKey: a, references: o } = this.props;
38
39
  if (r) {
39
- const c = we(r) ? r : [r], f = [];
40
+ const c = Le(r) ? r : [r], f = [];
40
41
  this.setState({ loading: !0 }), Promise.allSettled(
41
42
  c.map(
42
- (u) => $(o, u) ? Promise.resolve(f.push(o[u])) : te(
43
- `${A.dataApi}dataset/${i}/reference/${u}`
44
- ).then((a) => f.push(a.data)).catch((a) => this.setState({ error: a }))
43
+ (u) => A(o, u) ? Promise.resolve(f.push(o[u])) : ne(
44
+ `${P.dataApi}dataset/${a}/reference/${u}`
45
+ ).then((i) => f.push(i.data)).catch((i) => this.setState({ error: i }))
45
46
  )
46
47
  ).then(() => this.setState({ reference: f, loading: !1 }));
47
48
  }
48
49
  });
49
- Z(this, "getContent", () => {
50
- const { error: r, reference: i, loading: o } = this.state;
51
- return o ? /* @__PURE__ */ s.jsx(st, {}) : r ? /* @__PURE__ */ s.jsx(lt, { error: r }) : i.length === 1 ? i[0].citation : /* @__PURE__ */ s.jsx("ul", { children: i.map((c) => /* @__PURE__ */ s.jsx("li", { children: c.citation }, c.id)) });
50
+ X(this, "getContent", () => {
51
+ const { error: r, reference: a, loading: o } = this.state;
52
+ return o ? /* @__PURE__ */ s.jsx(rt, {}) : r ? /* @__PURE__ */ s.jsx(ct, { error: r }) : a.length === 1 ? a[0].citation : /* @__PURE__ */ s.jsx("ul", { children: a.map((c) => /* @__PURE__ */ s.jsx("li", { children: c.citation }, c.id)) });
52
53
  });
53
- Z(this, "scrollToReference", (r, i) => {
54
- const o = document.getElementById(`col-reference-${i}`);
54
+ X(this, "scrollToReference", (r, a) => {
55
+ const o = document.getElementById(`col-reference-${a}`);
55
56
  o && (r.preventDefault(), o.scrollIntoView({ behavior: "smooth", block: "start" }));
56
57
  });
57
- Z(this, "render", () => {
58
- const { referenceId: r, referenceIndexMap: i, trigger: o } = this.props, c = we(r) ? r : [r];
59
- let f = i && $(i, c[0]) ? c.map((u) => /* @__PURE__ */ s.jsx(
58
+ X(this, "render", () => {
59
+ const { referenceId: r, referenceIndexMap: a, trigger: o } = this.props, c = Le(r) ? r : [r];
60
+ let f = a && A(a, c[0]) ? c.map((u) => /* @__PURE__ */ s.jsx(
60
61
  "a",
61
62
  {
62
63
  className: "col-reference-link",
63
64
  href: `#col-reference-${u}`,
64
- onClick: (a) => this.scrollToReference(a, u),
65
- children: `[${i[u]}]`
65
+ onClick: (i) => this.scrollToReference(i, u),
66
+ children: `[${a[u]}]`
66
67
  },
67
68
  u
68
69
  )) : /* @__PURE__ */ s.jsx(_e, { style: { cursor: "pointer" } });
69
70
  return r ? /* @__PURE__ */ s.jsx("div", { id: `reference_${r}`, style: this.props.style, children: /* @__PURE__ */ s.jsx(
70
- ot,
71
+ st,
71
72
  {
72
73
  getPopupContainer: () => document.getElementById(`reference_${r}`),
73
74
  placement: this.props.placement || "left",
@@ -86,7 +87,7 @@ class mt extends rt.Component {
86
87
  };
87
88
  }
88
89
  }
89
- const se = [
90
+ const ae = [
90
91
  "subspecies",
91
92
  "variety",
92
93
  "subvariety",
@@ -95,68 +96,68 @@ const se = [
95
96
  "infraspecific name"
96
97
  ], $e = (e, n) => {
97
98
  const r = n.indexOf(e);
98
- return r === -1 ? [] : se.filter((i) => n.indexOf(i) > r);
99
+ return r === -1 ? [] : ae.filter((a) => n.indexOf(a) > r);
99
100
  }, yt = 16, bt = (e) => {
100
101
  var n, r;
101
102
  return ((n = e == null ? void 0 : e.area) == null ? void 0 : n.gazetteer) !== "text" && !!((r = e == null ? void 0 : e.area) != null && r.globalId);
102
103
  }, xt = async (e, n, r) => {
103
- const i = new Array(e.length);
104
+ const a = new Array(e.length);
104
105
  let o = 0;
105
106
  const c = Array.from({ length: Math.min(r, e.length) }, async () => {
106
107
  for (; ; ) {
107
108
  const f = o++;
108
109
  if (f >= e.length) return;
109
- i[f] = await n(e[f], f);
110
+ a[f] = await n(e[f], f);
110
111
  }
111
112
  });
112
- return await Promise.all(c), i;
113
+ return await Promise.all(c), a;
113
114
  }, vt = async (e, n, r) => {
114
115
  var u;
115
116
  if (r.length === 0) return [];
116
- const i = new URLSearchParams();
117
- i.append("TAXON_ID", n), r.forEach((a) => i.append("rank", a)), ["accepted", "provisionally accepted"].forEach(
118
- (a) => i.append("status", a)
119
- ), i.append("limit", "1000");
120
- const o = `${A.dataApi}dataset/${e}/nameusage/search?${i}`, c = await te(o);
121
- return (((u = c == null ? void 0 : c.data) == null ? void 0 : u.result) || []).filter((a) => {
117
+ const a = new URLSearchParams();
118
+ a.append("TAXON_ID", n), r.forEach((i) => a.append("rank", i)), ["accepted", "provisionally accepted"].forEach(
119
+ (i) => a.append("status", i)
120
+ ), a.append("limit", "1000");
121
+ const o = `${P.dataApi}dataset/${e}/nameusage/search?${a}`, c = await ne(o);
122
+ return (((u = c == null ? void 0 : c.data) == null ? void 0 : u.result) || []).filter((i) => {
122
123
  var p;
123
- return (p = a == null ? void 0 : a.usage) == null ? void 0 : p.id;
124
- }).map((a) => {
125
- var p, w, j, k, C, S;
124
+ return (p = i == null ? void 0 : i.usage) == null ? void 0 : p.id;
125
+ }).map((i) => {
126
+ var p, L, S, k, C, j;
126
127
  return {
127
- id: a.usage.id,
128
- scientificName: ((w = (p = a.usage) == null ? void 0 : p.name) == null ? void 0 : w.scientificName) || ((j = a.usage) == null ? void 0 : j.label) || a.usage.id,
129
- rank: (C = (k = a.usage) == null ? void 0 : k.name) == null ? void 0 : C.rank,
130
- parentId: (S = a.usage) == null ? void 0 : S.parentId
128
+ id: i.usage.id,
129
+ scientificName: ((L = (p = i.usage) == null ? void 0 : p.name) == null ? void 0 : L.scientificName) || ((S = i.usage) == null ? void 0 : S.label) || i.usage.id,
130
+ rank: (C = (k = i.usage) == null ? void 0 : k.name) == null ? void 0 : C.rank,
131
+ parentId: (j = i.usage) == null ? void 0 : j.parentId
131
132
  };
132
133
  });
133
- }, jt = async (e, n) => {
134
- const r = `${A.dataApi}dataset/${e}/taxon/${encodeURIComponent(n)}/distribution`;
134
+ }, St = async (e, n) => {
135
+ const r = `${P.dataApi}dataset/${e}/taxon/${encodeURIComponent(n)}/distribution`;
135
136
  try {
136
- const i = await te(r);
137
- return Array.isArray(i == null ? void 0 : i.data) ? i.data : [];
137
+ const a = await ne(r);
138
+ return Array.isArray(a == null ? void 0 : a.data) ? a.data : [];
138
139
  } catch {
139
140
  return [];
140
141
  }
141
- }, St = async ({ datasetKey: e, focalTaxon: n, rankOrder: r }) => {
142
- var a;
143
- const i = $e((a = n == null ? void 0 : n.name) == null ? void 0 : a.rank, r);
142
+ }, jt = async ({ datasetKey: e, focalTaxon: n, rankOrder: r }) => {
143
+ var i;
144
+ const a = $e((i = n == null ? void 0 : n.name) == null ? void 0 : i.rank, r);
144
145
  let o = !1, c = [];
145
146
  try {
146
- c = await vt(e, n.id, i);
147
+ c = await vt(e, n.id, a);
147
148
  } catch {
148
149
  return o = !0, { taxa: [], descendantsFailed: o };
149
150
  }
150
151
  const f = await xt(
151
152
  c,
152
- (p) => jt(e, p.id),
153
+ (p) => St(e, p.id),
153
154
  yt
154
155
  );
155
- return { taxa: c.map((p, w) => {
156
- const j = f[w] || [];
157
- return { ...p, distributions: j, mappable: j.filter(bt) };
156
+ return { taxa: c.map((p, L) => {
157
+ const S = f[L] || [];
158
+ return { ...p, distributions: S, mappable: S.filter(bt) };
158
159
  }), descendantsFailed: o };
159
- }, Le = [
160
+ }, ke = [
160
161
  "#E58606",
161
162
  "#5D69B1",
162
163
  "#52BCA3",
@@ -169,17 +170,17 @@ const se = [
169
170
  "#ED645A",
170
171
  "#CC3A8E",
171
172
  "#A5AA99"
172
- ], ke = (e, n) => {
173
+ ], Ce = (e, n) => {
173
174
  const r = n.indexOf(e);
174
175
  return r === -1 ? n.length : r;
175
176
  }, It = (e, n) => {
176
177
  const r = [...e].sort((o, c) => {
177
- const f = ke(o.rank, n), u = ke(c.rank, n);
178
+ const f = Ce(o.rank, n), u = Ce(c.rank, n);
178
179
  return f !== u ? f - u : o.scientificName.localeCompare(c.scientificName);
179
- }), i = {};
180
+ }), a = {};
180
181
  return r.forEach((o, c) => {
181
- i[o.id] = Le[c % Le.length];
182
- }), i;
182
+ a[o.id] = ke[c % ke.length];
183
+ }), a;
183
184
  }, wt = {
184
185
  position: "absolute",
185
186
  bottom: 8,
@@ -233,7 +234,7 @@ const se = [
233
234
  }, Ft = {
234
235
  fontStyle: "italic",
235
236
  paddingLeft: 4
236
- }, Ce = (e) => e.reduce((n, r) => n + r.taxa.length, 0), Gt = () => /* @__PURE__ */ s.jsxs("div", { style: Pe, children: [
237
+ }, Re = (e) => e.reduce((n, r) => n + r.taxa.length, 0), Gt = () => /* @__PURE__ */ s.jsxs("div", { style: Pe, children: [
237
238
  /* @__PURE__ */ s.jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", children: /* @__PURE__ */ s.jsx(
238
239
  "polygon",
239
240
  {
@@ -245,11 +246,11 @@ const se = [
245
246
  ) }),
246
247
  /* @__PURE__ */ s.jsx("span", { children: "GBIF occurrences" })
247
248
  ] }), Mt = ({ visibleGroups: e, unmappableGroups: n, showGbif: r }) => {
248
- const [i, o] = L(!1), c = Ce(e), f = Ce(n);
249
+ const [a, o] = w(!1), c = Re(e), f = Re(n);
249
250
  return c === 0 && f === 0 && !r ? null : /* @__PURE__ */ s.jsxs("div", { style: wt, children: [
250
251
  /* @__PURE__ */ s.jsxs("div", { style: Lt, children: [
251
- e.map((u, a) => /* @__PURE__ */ s.jsxs("div", { children: [
252
- /* @__PURE__ */ s.jsx("div", { style: a === 0 ? kt : Ae, children: u.label }),
252
+ e.map((u, i) => /* @__PURE__ */ s.jsxs("div", { children: [
253
+ /* @__PURE__ */ s.jsx("div", { style: i === 0 ? kt : Ae, children: u.label }),
253
254
  u.taxa.map((p) => /* @__PURE__ */ s.jsxs("div", { style: Pe, children: [
254
255
  /* @__PURE__ */ s.jsx("span", { style: Ct(p.color) }),
255
256
  /* @__PURE__ */ s.jsx("span", { style: { fontStyle: "italic" }, children: p.displayName || p.scientificName })
@@ -264,18 +265,18 @@ const se = [
264
265
  style: Rt,
265
266
  onClick: () => o((u) => !u),
266
267
  children: [
267
- i ? "− Hide" : "+",
268
+ a ? "− Hide" : "+",
268
269
  " ",
269
270
  f,
270
271
  " without map data"
271
272
  ]
272
273
  }
273
274
  ),
274
- i && /* @__PURE__ */ s.jsx("div", { style: Et, children: n.map((u, a) => /* @__PURE__ */ s.jsxs("div", { children: [
275
+ a && /* @__PURE__ */ s.jsx("div", { style: Et, children: n.map((u, i) => /* @__PURE__ */ s.jsxs("div", { children: [
275
276
  /* @__PURE__ */ s.jsx(
276
277
  "div",
277
278
  {
278
- style: a === 0 ? Bt : Oe,
279
+ style: i === 0 ? Bt : Oe,
279
280
  children: u.label
280
281
  }
281
282
  ),
@@ -304,42 +305,42 @@ const se = [
304
305
  { key: "uncertain", label: "Uncertain", color: "#8BE0A4" }
305
306
  ], ze = Object.fromEntries(
306
307
  De.map((e) => [e.key, e.color])
307
- ), oe = "#66C5CC", _t = (e) => String(e || "").toLowerCase().replace(/[^a-z]/g, ""), He = (e) => {
308
+ ), ie = "#66C5CC", _t = (e) => String(e || "").toLowerCase().replace(/[^a-z]/g, ""), He = (e) => {
308
309
  const n = e == null ? void 0 : e.establishmentMeans;
309
310
  if (n == null || n === "") return null;
310
311
  const r = _t(n);
311
312
  return ze[r] ? r : "uncertain";
312
313
  }, $t = (e) => {
313
314
  const n = He(e);
314
- return n == null ? oe : ze[n];
315
- }, At = "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json", Ve = "gbif-visible", Pt = (e) => pt(Ve, e), Re = (e) => ft(Ve, e), Ot = "/v2/map/occurrence/density/{z}/{x}/{y}@1x.png?srs=EPSG%3A3857&style=iNaturalist.poly&bin=hex&hexPerTile=64&hasCoordinate=true&hasGeospatialIssue=false&occurrenceStatus=PRESENT&checklistKey={checklistKey}&taxonKey={taxonKey}", X = "col-focal-distributions", U = "col-focal-fill", de = "col-focal-line", re = "col-gbif-occurrences", M = "col-gbif-occurrences", ue = (e) => `col-descendant-${e}`, J = (e) => `col-descendant-fill-${e}`, Q = (e) => `col-descendant-line-${e}`, pe = /* @__PURE__ */ new Map(), Ee = (e, n) => {
315
+ return n == null ? ie : ze[n];
316
+ }, At = "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json", Ve = "gbif-visible", Pt = (e) => pt(Ve, e), Ee = (e) => ft(Ve, e), Ot = "/v2/map/occurrence/density/{z}/{x}/{y}@1x.png?srs=EPSG%3A3857&style=iNaturalist.poly&bin=hex&hexPerTile=64&hasCoordinate=true&hasGeospatialIssue=false&occurrenceStatus=PRESENT&checklistKey={checklistKey}&taxonKey={taxonKey}", J = "col-focal-distributions", W = "col-focal-fill", pe = "col-focal-line", oe = "col-gbif-occurrences", _ = "col-gbif-occurrences", fe = (e) => `col-descendant-${e}`, Q = (e) => `col-descendant-fill-${e}`, ee = (e) => `col-descendant-line-${e}`, he = /* @__PURE__ */ new Map(), Be = (e, n) => {
316
317
  const r = `${e}:${n}`;
317
- if (pe.has(r)) return pe.get(r);
318
- const i = `${A.dataApi}vocab/area/${r}`, o = te(i, {
318
+ if (he.has(r)) return he.get(r);
319
+ const a = `${P.dataApi}vocab/area/${r}`, o = ne(a, {
319
320
  headers: { Accept: "application/geo+json" }
320
321
  }).then(
321
322
  (c) => c.data,
322
323
  () => null
323
324
  );
324
- return pe.set(r, o), o;
325
- }, ee = (e) => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), Ue = (e) => {
326
- var i, o;
327
- const n = ((i = e == null ? void 0 : e.area) == null ? void 0 : i.name) || ((o = e == null ? void 0 : e.area) == null ? void 0 : o.globalId) || "", r = Nt.map((c) => [c, e == null ? void 0 : e[c]]).filter(([, c]) => c != null && c !== "").map(
328
- ([c, f]) => `<div><strong>${ee(c)}:</strong> ${ee(f)}</div>`
325
+ return he.set(r, o), o;
326
+ }, te = (e) => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), Ue = (e) => {
327
+ var a, o;
328
+ const n = ((a = e == null ? void 0 : e.area) == null ? void 0 : a.name) || ((o = e == null ? void 0 : e.area) == null ? void 0 : o.globalId) || "", r = Nt.map((c) => [c, e == null ? void 0 : e[c]]).filter(([, c]) => c != null && c !== "").map(
329
+ ([c, f]) => `<div><strong>${te(c)}:</strong> ${te(f)}</div>`
329
330
  ).join("");
330
- return `<div style="min-width:180px"><div style="font-weight:600;margin-bottom:4px">${ee(
331
+ return `<div style="min-width:180px"><div style="font-weight:600;margin-bottom:4px">${te(
331
332
  n
332
333
  )}</div>${r}</div>`;
333
- }, Dt = (e, n) => `<div style="font-weight:600;font-style:italic;margin-bottom:4px">${ee(
334
+ }, Dt = (e, n) => `<div style="font-weight:600;font-style:italic;margin-bottom:4px">${te(
334
335
  e.scientificName
335
- )}</div><div style="color:#888;margin-bottom:4px">${ee(e.rank || "")}</div>` + Ue(n), zt = {
336
+ )}</div><div style="color:#888;margin-bottom:4px">${te(e.rank || "")}</div>` + Ue(n), zt = {
336
337
  subspecies: "subspecies",
337
338
  variety: "varieties",
338
339
  subvariety: "subvarieties",
339
340
  form: "forms",
340
341
  subform: "subforms",
341
342
  "infraspecific name": "infraspecific names"
342
- }, Be = (e) => zt[e] || e, We = (e) => {
343
+ }, Fe = (e) => zt[e] || e, We = (e) => {
343
344
  if (!e) return "";
344
345
  const n = e.trim().split(/\s+/);
345
346
  return n[n.length - 1];
@@ -356,30 +357,30 @@ const se = [
356
357
  /* @__PURE__ */ s.jsx("span", { children: "GBIF occurrences" })
357
358
  ] }), Vt = (e) => {
358
359
  var f;
359
- let n = 1 / 0, r = 1 / 0, i = -1 / 0, o = -1 / 0;
360
+ let n = 1 / 0, r = 1 / 0, a = -1 / 0, o = -1 / 0;
360
361
  const c = (u) => {
361
362
  if (typeof u[0] == "number") {
362
- const [a, p] = u;
363
- a < n && (n = a), a > i && (i = a), p < r && (r = p), p > o && (o = p);
363
+ const [i, p] = u;
364
+ i < n && (n = i), i > a && (a = i), p < r && (r = p), p > o && (o = p);
364
365
  } else
365
- for (let a = 0; a < u.length; a++) c(u[a]);
366
+ for (let i = 0; i < u.length; i++) c(u[i]);
366
367
  };
367
368
  for (let u = 0; u < e.length; u++) {
368
- const a = (f = e[u]) == null ? void 0 : f.geometry;
369
- a != null && a.coordinates && c(a.coordinates);
369
+ const i = (f = e[u]) == null ? void 0 : f.geometry;
370
+ i != null && i.coordinates && c(i.coordinates);
370
371
  }
371
372
  return n === 1 / 0 ? null : [
372
373
  [n, r],
373
- [i, o]
374
+ [a, o]
374
375
  ];
375
- }, Fe = (e) => e ? e.type === "FeatureCollection" ? e.features || [] : [e] : [], Ge = () => {
376
+ }, Ge = (e) => e ? e.type === "FeatureCollection" ? e.features || [] : [e] : [], Me = () => {
376
377
  var e;
377
378
  return typeof ((e = D) == null ? void 0 : e.supported) == "function" ? D.supported() : typeof WebGLRenderingContext < "u";
378
379
  }, Ut = ({
379
380
  records: e,
380
381
  onUnmappable: n,
381
382
  datasetKey: r,
382
- focalTaxon: i,
383
+ focalTaxon: a,
383
384
  rankOrder: o,
384
385
  gbifChecklistKey: c,
385
386
  // true | null → show GBIF layer; false → GBIF API returned 0 occurrences,
@@ -387,57 +388,57 @@ const se = [
387
388
  // component works without the count check.
388
389
  gbifAvailable: f = !0
389
390
  }) => {
390
- var Ie;
391
- const u = G(null), a = G(null), p = G(null), w = G(/* @__PURE__ */ new Map()), j = G(/* @__PURE__ */ new Map()), k = G(/* @__PURE__ */ new Map()), C = G(!1), S = G(!1), R = G(/* @__PURE__ */ new Set()), [I, P] = L(!1), [E, _] = L(!1), [y, m] = L({
391
+ var we;
392
+ const u = M(null), i = M(null), p = M(null), L = M(/* @__PURE__ */ new Map()), S = M(/* @__PURE__ */ new Map()), k = M(/* @__PURE__ */ new Map()), C = M(!1), j = M(!1), E = M(/* @__PURE__ */ new Set()), [B, z] = w(!1), [I, N] = w(!1), [b, m] = w({
392
393
  status: "idle",
393
394
  // idle | loading | ready | empty | error
394
395
  taxa: []
395
- }), [z, O] = L(!0), W = !!c && (!e || e.length === 0), [B, he] = L(
396
+ }), [O, K] = w(!0), me = !!c && (!e || e.length === 0), [F, T] = w(
396
397
  () => Pt(!0)
397
- ), [K, ge] = L(/* @__PURE__ */ new Set()), [Ke, me] = L(!1), ie = G(!1), Te = () => {
398
- he((t) => {
398
+ ), [R, H] = w(/* @__PURE__ */ new Set()), [re, ye] = w(!1), ce = M(!1), Ke = () => {
399
+ T((t) => {
399
400
  const d = !t;
400
- return Re(d), d;
401
+ return Ee(d), d;
401
402
  });
402
- }, ye = () => {
403
- he(!0), Re(!0);
404
- }, be = ne(() => {
403
+ }, be = () => {
404
+ T(!0), Ee(!0);
405
+ }, xe = se(() => {
405
406
  if (!(e != null && e.length)) return [];
406
407
  const t = /* @__PURE__ */ new Set();
407
408
  return e.forEach((d) => {
408
409
  const l = He(d);
409
410
  l != null && t.add(l);
410
411
  }), De.filter((d) => t.has(d.key));
411
- }, [e]), T = ne(() => y.status !== "ready" ? {} : It(
412
- y.taxa.filter((t) => t.mappable.length > 0),
412
+ }, [e]), Y = se(() => b.status !== "ready" ? {} : It(
413
+ b.taxa.filter((t) => t.mappable.length > 0),
413
414
  o || []
414
- ), [y, o]), ae = ne(() => {
415
- if (y.status !== "ready")
415
+ ), [b, o]), le = se(() => {
416
+ if (b.status !== "ready")
416
417
  return { visibleGroups: [], unmappableGroups: [] };
417
418
  const t = (h) => ({
418
419
  ...h,
419
- color: T[h.id],
420
+ color: Y[h.id],
420
421
  displayName: We(h.scientificName)
421
422
  }), d = (h) => {
422
423
  const x = {};
423
- return h.forEach((b) => {
424
- (x[b.rank] = x[b.rank] || []).push(t(b));
425
- }), se.filter((b) => x[b]).map((b) => ({
426
- rank: b,
427
- label: Be(b),
428
- taxa: x[b]
424
+ return h.forEach((y) => {
425
+ (x[y.rank] = x[y.rank] || []).push(t(y));
426
+ }), ae.filter((y) => x[y]).map((y) => ({
427
+ rank: y,
428
+ label: Fe(y),
429
+ taxa: x[y]
429
430
  }));
430
431
  }, l = d(
431
- y.taxa.filter(
432
- (h) => h.mappable.length > 0 && K.has(h.id)
432
+ b.taxa.filter(
433
+ (h) => h.mappable.length > 0 && R.has(h.id)
433
434
  )
434
435
  ), g = d(
435
- y.taxa.filter((h) => h.mappable.length === 0)
436
+ b.taxa.filter((h) => h.mappable.length === 0)
436
437
  );
437
438
  return { visibleGroups: l, unmappableGroups: g };
438
- }, [y, T, K]), xe = ae.visibleGroups.length > 0;
439
- N(() => {
440
- if (!u.current || a.current || !Ge()) return;
439
+ }, [b, Y, R]), ve = le.visibleGroups.length > 0;
440
+ $(() => {
441
+ if (!u.current || i.current || !Me()) return;
441
442
  const t = new D.Map({
442
443
  container: u.current,
443
444
  style: At,
@@ -453,23 +454,23 @@ const se = [
453
454
  ), t.addControl(
454
455
  new D.NavigationControl({ showCompass: !1 }),
455
456
  "top-left"
456
- ), a.current = t, t.on("load", () => {
457
- P(!0);
457
+ ), i.current = t, t.on("load", () => {
458
+ z(!0);
458
459
  const l = t.getContainer().querySelector(".maplibregl-ctrl-attrib");
459
460
  l && l.classList.remove("maplibregl-compact-show");
460
461
  });
461
462
  const d = typeof ResizeObserver < "u" ? new ResizeObserver(() => t.resize()) : null;
462
463
  return d && d.observe(u.current), () => {
463
- d && d.disconnect(), p.current && (p.current.remove(), p.current = null), t.remove(), a.current = null, C.current = !1, S.current = !1, R.current = /* @__PURE__ */ new Set();
464
+ d && d.disconnect(), p.current && (p.current.remove(), p.current = null), t.remove(), i.current = null, C.current = !1, j.current = !1, E.current = /* @__PURE__ */ new Set();
464
465
  };
465
- }, []), N(() => {
466
- if (!I || !(e != null && e.length)) return;
467
- const t = a.current;
466
+ }, []), $(() => {
467
+ if (!B || !(e != null && e.length)) return;
468
+ const t = i.current;
468
469
  if (!t) return;
469
470
  let d = !1;
470
- return _(!1), Promise.allSettled(
471
+ return N(!1), Promise.allSettled(
471
472
  e.map(
472
- (l) => Ee(l.area.gazetteer, l.area.id).then((g) => ({
473
+ (l) => Be(l.area.gazetteer, l.area.id).then((g) => ({
473
474
  record: l,
474
475
  geojson: g
475
476
  }))
@@ -478,182 +479,182 @@ const se = [
478
479
  if (d) return;
479
480
  const g = [], h = /* @__PURE__ */ new Map();
480
481
  let x = 0;
481
- l.forEach((v, F) => {
482
+ l.forEach((v, G) => {
482
483
  if (v.status !== "fulfilled" || !v.value.geojson) {
483
484
  x += 1;
484
485
  return;
485
486
  }
486
- const { record: H, geojson: V } = v.value, ce = $t(H), Y = `focal-${F}`;
487
- h.set(Y, H), Fe(V).forEach((q) => {
487
+ const { record: V, geojson: U } = v.value, de = $t(V), q = `focal-${G}`;
488
+ h.set(q, V), Ge(U).forEach((Z) => {
488
489
  g.push({
489
- ...q,
490
+ ...Z,
490
491
  properties: {
491
- ...q.properties || {},
492
- _recordKey: Y,
493
- _color: ce
492
+ ...Z.properties || {},
493
+ _recordKey: q,
494
+ _color: de
494
495
  }
495
496
  });
496
497
  });
497
- }), w.current = h;
498
- const b = { type: "FeatureCollection", features: g };
499
- if (t.getSource(X))
500
- t.getSource(X).setData(b);
498
+ }), L.current = h;
499
+ const y = { type: "FeatureCollection", features: g };
500
+ if (t.getSource(J))
501
+ t.getSource(J).setData(y);
501
502
  else {
502
- const v = t.getLayer(M) ? M : void 0;
503
- t.addSource(X, { type: "geojson", data: b }), t.addLayer(
503
+ const v = t.getLayer(_) ? _ : void 0;
504
+ t.addSource(J, { type: "geojson", data: y }), t.addLayer(
504
505
  {
505
- id: U,
506
+ id: W,
506
507
  type: "fill",
507
- source: X,
508
+ source: J,
508
509
  paint: {
509
- "fill-color": ["coalesce", ["get", "_color"], oe],
510
+ "fill-color": ["coalesce", ["get", "_color"], ie],
510
511
  "fill-opacity": 0.65
511
512
  }
512
513
  },
513
514
  v
514
515
  ), t.addLayer(
515
516
  {
516
- id: de,
517
+ id: pe,
517
518
  type: "line",
518
- source: X,
519
+ source: J,
519
520
  paint: {
520
- "line-color": ["coalesce", ["get", "_color"], oe],
521
+ "line-color": ["coalesce", ["get", "_color"], ie],
521
522
  "line-width": 1
522
523
  }
523
524
  },
524
525
  v
525
- ), t.on("click", U, Ye), t.on("mouseenter", U, ve), t.on("mouseleave", U, je), C.current = !0;
526
+ ), t.on("click", W, Te), t.on("mouseenter", W, Se), t.on("mouseleave", W, je), C.current = !0;
526
527
  }
527
528
  if (g.length > 0) {
528
529
  const v = Vt(g);
529
530
  v && t.fitBounds(v, { padding: 20, animate: !1 });
530
531
  }
531
- typeof n == "function" && n(x), _(!0);
532
+ typeof n == "function" && n(x), N(!0);
532
533
  }), () => {
533
534
  d = !0;
534
535
  };
535
- }, [I, e]);
536
- const Ye = (t) => {
537
- var x, b;
538
- const d = a.current;
536
+ }, [B, e]);
537
+ const Te = (t) => {
538
+ var x, y;
539
+ const d = i.current;
539
540
  if (!d) return;
540
- const l = (x = t.features) == null ? void 0 : x[0], g = (b = l == null ? void 0 : l.properties) == null ? void 0 : b._recordKey, h = g ? w.current.get(g) : null;
541
+ const l = (x = t.features) == null ? void 0 : x[0], g = (y = l == null ? void 0 : l.properties) == null ? void 0 : y._recordKey, h = g ? L.current.get(g) : null;
541
542
  h && (p.current && p.current.remove(), p.current = new D.Popup({ closeButton: !0, maxWidth: "320px" }).setLngLat(t.lngLat).setHTML(Ue(h)).addTo(d));
542
- }, ve = () => {
543
- const t = a.current;
543
+ }, Se = () => {
544
+ const t = i.current;
544
545
  t && (t.getCanvas().style.cursor = "pointer");
545
546
  }, je = () => {
546
- const t = a.current;
547
+ const t = i.current;
547
548
  t && (t.getCanvas().style.cursor = "");
548
549
  };
549
- N(() => {
550
- const t = a.current;
550
+ $(() => {
551
+ const t = i.current;
551
552
  if (!t || !C.current) return;
552
- const d = z ? "visible" : "none";
553
- t.getLayer(U) && t.setLayoutProperty(U, "visibility", d), t.getLayer(de) && t.setLayoutProperty(de, "visibility", d);
554
- }, [z, E]), N(() => {
555
- if (!I) return;
556
- const t = a.current;
553
+ const d = O ? "visible" : "none";
554
+ t.getLayer(W) && t.setLayoutProperty(W, "visibility", d), t.getLayer(pe) && t.setLayoutProperty(pe, "visibility", d);
555
+ }, [O, I]), $(() => {
556
+ if (!B) return;
557
+ const t = i.current;
557
558
  if (!t || ((() => {
558
- t.getLayer(M) && t.removeLayer(M), t.getSource(re) && t.removeSource(re), S.current = !1;
559
- })(), !c || !(i != null && i.id)) || f === !1) return;
560
- const l = (A.gbifApi + Ot).replace("{checklistKey}", encodeURIComponent(c)).replace("{taxonKey}", encodeURIComponent(i.id)), g = A.gbifPortal + "/occurrence/search?checklist_key=" + encodeURIComponent(c) + "&taxon_key=" + encodeURIComponent(i.id);
561
- t.addSource(re, {
559
+ t.getLayer(_) && t.removeLayer(_), t.getSource(oe) && t.removeSource(oe), j.current = !1;
560
+ })(), !c || !(a != null && a.id)) || f === !1) return;
561
+ const l = (P.gbifApi + Ot).replace("{checklistKey}", encodeURIComponent(c)).replace("{taxonKey}", encodeURIComponent(a.id)), g = P.gbifPortal + "/occurrence/search?checklist_key=" + encodeURIComponent(c) + "&taxon_key=" + encodeURIComponent(a.id);
562
+ t.addSource(oe, {
562
563
  type: "raster",
563
564
  tiles: [l],
564
565
  tileSize: 256,
565
566
  attribution: '<a href="' + g + '" target="_blank" rel="noopener">GBIF</a> occurrence data'
566
567
  }), t.addLayer({
567
- id: M,
568
+ id: _,
568
569
  type: "raster",
569
- source: re,
570
+ source: oe,
570
571
  paint: { "raster-opacity": 0.9 },
571
- layout: { visibility: B ? "visible" : "none" }
572
- }), S.current = !0;
573
- }, [I, c, i == null ? void 0 : i.id, f]), N(() => {
574
- const t = a.current;
575
- if (!t || !S.current) return;
576
- const d = B ? "visible" : "none";
577
- t.getLayer(M) && t.setLayoutProperty(M, "visibility", d);
578
- }, [B]), N(() => {
579
- if (!I) return;
580
- const t = a.current;
581
- if (!t || (R.current.forEach((l) => {
582
- t.getLayer(J(l)) && t.removeLayer(J(l)), t.getLayer(Q(l)) && t.removeLayer(Q(l)), t.getSource(ue(l)) && t.removeSource(ue(l));
583
- }), R.current = /* @__PURE__ */ new Set(), j.current = /* @__PURE__ */ new Map(), k.current = /* @__PURE__ */ new Map(), y.status !== "ready")) return;
584
- const d = T;
585
- y.taxa.forEach((l) => {
586
- l.mappable.length !== 0 && (j.current.set(l.id, l), Promise.allSettled(
572
+ layout: { visibility: F ? "visible" : "none" }
573
+ }), j.current = !0;
574
+ }, [B, c, a == null ? void 0 : a.id, f]), $(() => {
575
+ const t = i.current;
576
+ if (!t || !j.current) return;
577
+ const d = F ? "visible" : "none";
578
+ t.getLayer(_) && t.setLayoutProperty(_, "visibility", d);
579
+ }, [F]), $(() => {
580
+ if (!B) return;
581
+ const t = i.current;
582
+ if (!t || (E.current.forEach((l) => {
583
+ t.getLayer(Q(l)) && t.removeLayer(Q(l)), t.getLayer(ee(l)) && t.removeLayer(ee(l)), t.getSource(fe(l)) && t.removeSource(fe(l));
584
+ }), E.current = /* @__PURE__ */ new Set(), S.current = /* @__PURE__ */ new Map(), k.current = /* @__PURE__ */ new Map(), b.status !== "ready")) return;
585
+ const d = Y;
586
+ b.taxa.forEach((l) => {
587
+ l.mappable.length !== 0 && (S.current.set(l.id, l), Promise.allSettled(
587
588
  l.mappable.map(
588
- (g) => Ee(g.area.gazetteer, g.area.id).then((h) => ({
589
+ (g) => Be(g.area.gazetteer, g.area.id).then((h) => ({
589
590
  record: g,
590
591
  geojson: h
591
592
  }))
592
593
  )
593
594
  ).then((g) => {
594
- if (!a.current) return;
595
+ if (!i.current) return;
595
596
  const h = [];
596
- g.forEach((F, H) => {
597
- if (F.status !== "fulfilled" || !F.value.geojson) return;
598
- const { record: V, geojson: ce } = F.value, Y = `desc-${l.id}-${H}`;
599
- k.current.set(Y, { taxon: l, record: V }), Fe(ce).forEach((q) => {
597
+ g.forEach((G, V) => {
598
+ if (G.status !== "fulfilled" || !G.value.geojson) return;
599
+ const { record: U, geojson: de } = G.value, q = `desc-${l.id}-${V}`;
600
+ k.current.set(q, { taxon: l, record: U }), Ge(de).forEach((Z) => {
600
601
  h.push({
601
- ...q,
602
+ ...Z,
602
603
  properties: {
603
- ...q.properties || {},
604
- _recordKey: Y
604
+ ...Z.properties || {},
605
+ _recordKey: q
605
606
  }
606
607
  });
607
608
  });
608
609
  });
609
- const x = d[l.id] || oe, b = { type: "FeatureCollection", features: h }, v = ue(l.id);
610
- if (a.current.getSource(v))
611
- a.current.getSource(v).setData(b);
610
+ const x = d[l.id] || ie, y = { type: "FeatureCollection", features: h }, v = fe(l.id);
611
+ if (i.current.getSource(v))
612
+ i.current.getSource(v).setData(y);
612
613
  else {
613
- a.current.addSource(v, { type: "geojson", data: b });
614
- const F = J(l.id), H = Q(l.id), V = a.current.getLayer(M) ? M : void 0;
615
- a.current.addLayer(
614
+ i.current.addSource(v, { type: "geojson", data: y });
615
+ const G = Q(l.id), V = ee(l.id), U = i.current.getLayer(_) ? _ : void 0;
616
+ i.current.addLayer(
616
617
  {
617
- id: F,
618
+ id: G,
618
619
  type: "fill",
619
620
  source: v,
620
621
  paint: { "fill-color": x, "fill-opacity": 0.55 },
621
622
  layout: { visibility: "none" }
622
623
  },
623
- V
624
- ), a.current.addLayer(
624
+ U
625
+ ), i.current.addLayer(
625
626
  {
626
- id: H,
627
+ id: V,
627
628
  type: "line",
628
629
  source: v,
629
630
  paint: { "line-color": x, "line-width": 2 },
630
631
  layout: { visibility: "none" }
631
632
  },
632
- V
633
- ), a.current.on("click", F, qe), a.current.on("mouseenter", F, ve), a.current.on("mouseleave", F, je), R.current.add(l.id);
633
+ U
634
+ ), i.current.on("click", G, Ye), i.current.on("mouseenter", G, Se), i.current.on("mouseleave", G, je), E.current.add(l.id);
634
635
  }
635
636
  }));
636
637
  });
637
- }, [I, y, T]);
638
- const qe = (t) => {
639
- var x, b;
640
- const d = a.current;
638
+ }, [B, b, Y]);
639
+ const Ye = (t) => {
640
+ var x, y;
641
+ const d = i.current;
641
642
  if (!d) return;
642
- const l = (x = t.features) == null ? void 0 : x[0], g = (b = l == null ? void 0 : l.properties) == null ? void 0 : b._recordKey, h = g ? k.current.get(g) : null;
643
+ const l = (x = t.features) == null ? void 0 : x[0], g = (y = l == null ? void 0 : l.properties) == null ? void 0 : y._recordKey, h = g ? k.current.get(g) : null;
643
644
  h && (p.current && p.current.remove(), p.current = new D.Popup({ closeButton: !0, maxWidth: "320px" }).setLngLat(t.lngLat).setHTML(Dt(h.taxon, h.record)).addTo(d));
644
645
  };
645
- N(() => {
646
- const t = a.current;
647
- t && R.current.forEach((d) => {
648
- const l = K.has(d) ? "visible" : "none";
649
- t.getLayer(J(d)) && t.setLayoutProperty(J(d), "visibility", l), t.getLayer(Q(d)) && t.setLayoutProperty(Q(d), "visibility", l);
646
+ $(() => {
647
+ const t = i.current;
648
+ t && E.current.forEach((d) => {
649
+ const l = R.has(d) ? "visible" : "none";
650
+ t.getLayer(Q(d)) && t.setLayoutProperty(Q(d), "visibility", l), t.getLayer(ee(d)) && t.setLayoutProperty(ee(d), "visibility", l);
650
651
  });
651
- }, [K, y]);
652
- const Se = () => {
652
+ }, [R, b]);
653
+ const Ie = () => {
653
654
  var l;
654
- if (ie.current || !r || !i || !o) return;
655
- const t = (l = i == null ? void 0 : i.name) == null ? void 0 : l.rank;
656
- !t || t !== "species" && !se.includes(t) || $e(t, o).length === 0 || (ie.current = !0, m({ status: "loading", taxa: [] }), St({ datasetKey: r, focalTaxon: i, rankOrder: o }).then(
655
+ if (ce.current || !r || !a || !o) return;
656
+ const t = (l = a == null ? void 0 : a.name) == null ? void 0 : l.rank;
657
+ !t || t !== "species" && !ae.includes(t) || $e(t, o).length === 0 || (ce.current = !0, m({ status: "loading", taxa: [] }), jt({ datasetKey: r, focalTaxon: a, rankOrder: o }).then(
657
658
  ({ taxa: g, descendantsFailed: h }) => {
658
659
  if (h) {
659
660
  m({ status: "error", taxa: [] });
@@ -666,34 +667,34 @@ const se = [
666
667
  m({ status: "ready", taxa: g });
667
668
  }
668
669
  ));
669
- }, Ze = () => {
670
- me(!0), Se();
671
- }, Xe = ne(() => {
672
- if (y.status !== "ready") return [];
670
+ }, qe = () => {
671
+ ye(!0), Ie();
672
+ }, Ze = se(() => {
673
+ if (b.status !== "ready") return [];
673
674
  const t = {};
674
- return y.taxa.filter((d) => d.mappable.length > 0).forEach((d) => {
675
+ return b.taxa.filter((d) => d.mappable.length > 0).forEach((d) => {
675
676
  (t[d.rank] = t[d.rank] || []).push(d);
676
- }), se.filter((d) => t[d]).map((d) => ({
677
+ }), ae.filter((d) => t[d]).map((d) => ({
677
678
  rank: d,
678
- label: Be(d),
679
+ label: Fe(d),
679
680
  taxa: t[d].slice().sort(
680
681
  (l, g) => l.scientificName.localeCompare(g.scientificName)
681
682
  )
682
683
  }));
683
- }, [y]), Je = (t) => {
684
- ge((d) => {
684
+ }, [b]), Xe = (t) => {
685
+ H((d) => {
685
686
  const l = new Set(d);
686
687
  return l.has(t) ? l.delete(t) : l.add(t), l;
687
688
  });
688
- }, Qe = (t) => {
689
- ge((d) => {
689
+ }, Je = (t) => {
690
+ H((d) => {
690
691
  const l = new Set(d), g = t.every((h) => d.has(h.id));
691
692
  return t.forEach((h) => {
692
693
  g ? l.delete(h.id) : l.add(h.id);
693
694
  }), l;
694
695
  });
695
696
  };
696
- if (!Ge())
697
+ if (!Me())
697
698
  return /* @__PURE__ */ s.jsx(
698
699
  "div",
699
700
  {
@@ -708,7 +709,7 @@ const se = [
708
709
  children: "Maps require WebGL, which your browser doesn't support."
709
710
  }
710
711
  );
711
- if (W && !B)
712
+ if (me && !F)
712
713
  return /* @__PURE__ */ s.jsxs(
713
714
  "div",
714
715
  {
@@ -732,9 +733,9 @@ const se = [
732
733
  role: "button",
733
734
  tabIndex: 0,
734
735
  style: { cursor: "pointer" },
735
- onClick: ye,
736
+ onClick: be,
736
737
  onKeyDown: (t) => {
737
- (t.key === "Enter" || t.key === " ") && (t.preventDefault(), ye());
738
+ (t.key === "Enter" || t.key === " ") && (t.preventDefault(), be());
738
739
  },
739
740
  children: "Show GBIF occurrences"
740
741
  }
@@ -742,7 +743,7 @@ const se = [
742
743
  ]
743
744
  }
744
745
  );
745
- const et = ((Ie = i == null ? void 0 : i.name) == null ? void 0 : Ie.scientificName) || "This taxon";
746
+ const Qe = ((we = a == null ? void 0 : a.name) == null ? void 0 : we.scientificName) || "This taxon";
746
747
  return /* @__PURE__ */ s.jsxs("div", { className: "col-distributions-map", style: { position: "relative" }, children: [
747
748
  /* @__PURE__ */ s.jsx(
748
749
  "div",
@@ -754,29 +755,29 @@ const se = [
754
755
  /* @__PURE__ */ s.jsx(
755
756
  Wt,
756
757
  {
757
- open: Ke,
758
- onOpen: Ze,
759
- onClose: () => me(!1),
760
- focalName: et,
761
- focalReady: E,
762
- focalVisible: z,
763
- onToggleFocal: () => O((t) => !t),
758
+ open: re,
759
+ onOpen: qe,
760
+ onClose: () => ye(!1),
761
+ focalName: Qe,
762
+ focalReady: I,
763
+ focalVisible: O,
764
+ onToggleFocal: () => K((t) => !t),
764
765
  gbifEnabled: !!c,
765
- gbifVisible: B,
766
+ gbifVisible: F,
766
767
  gbifAvailable: f,
767
- onToggleGbif: Te,
768
- descendantStatus: y.status,
769
- descendantsByRank: Xe,
770
- descendantColors: T,
771
- visibleTaxonIds: K,
772
- onToggleTaxon: Je,
773
- onToggleRankGroup: Qe,
768
+ onToggleGbif: Ke,
769
+ descendantStatus: b.status,
770
+ descendantsByRank: Ze,
771
+ descendantColors: Y,
772
+ visibleTaxonIds: R,
773
+ onToggleTaxon: Xe,
774
+ onToggleRankGroup: Je,
774
775
  onRetry: () => {
775
- ie.current = !1, m({ status: "idle", taxa: [] }), Se();
776
+ ce.current = !1, m({ status: "idle", taxa: [] }), Ie();
776
777
  }
777
778
  }
778
779
  ),
779
- !xe && (be.length > 0 || c && f !== !1 && B) && /* @__PURE__ */ s.jsxs(
780
+ !ve && (xe.length > 0 || c && f !== !1 && F) && /* @__PURE__ */ s.jsxs(
780
781
  "div",
781
782
  {
782
783
  style: {
@@ -792,7 +793,7 @@ const se = [
792
793
  lineHeight: 1.5
793
794
  },
794
795
  children: [
795
- be.map((t) => /* @__PURE__ */ s.jsxs(
796
+ xe.map((t) => /* @__PURE__ */ s.jsxs(
796
797
  "div",
797
798
  {
798
799
  style: { display: "flex", alignItems: "center", gap: 6 },
@@ -815,16 +816,16 @@ const se = [
815
816
  },
816
817
  t.key
817
818
  )),
818
- c && f !== !1 && B && /* @__PURE__ */ s.jsx(Ht, {})
819
+ c && f !== !1 && F && /* @__PURE__ */ s.jsx(Ht, {})
819
820
  ]
820
821
  }
821
822
  ),
822
- xe && /* @__PURE__ */ s.jsx(
823
+ ve && /* @__PURE__ */ s.jsx(
823
824
  Mt,
824
825
  {
825
- visibleGroups: ae.visibleGroups,
826
- unmappableGroups: ae.unmappableGroups,
827
- showGbif: !!c && f !== !1 && B
826
+ visibleGroups: le.visibleGroups,
827
+ unmappableGroups: le.unmappableGroups,
828
+ showGbif: !!c && f !== !1 && F
828
829
  }
829
830
  )
830
831
  ] });
@@ -832,21 +833,21 @@ const se = [
832
833
  open: e,
833
834
  onOpen: n,
834
835
  onClose: r,
835
- focalName: i,
836
+ focalName: a,
836
837
  focalReady: o,
837
838
  focalVisible: c,
838
839
  onToggleFocal: f,
839
840
  gbifEnabled: u,
840
- gbifVisible: a,
841
+ gbifVisible: i,
841
842
  gbifAvailable: p,
842
- onToggleGbif: w,
843
- descendantStatus: j,
843
+ onToggleGbif: L,
844
+ descendantStatus: S,
844
845
  descendantsByRank: k,
845
846
  descendantColors: C,
846
- visibleTaxonIds: S,
847
- onToggleTaxon: R,
848
- onToggleRankGroup: I,
849
- onRetry: P
847
+ visibleTaxonIds: j,
848
+ onToggleTaxon: E,
849
+ onToggleRankGroup: B,
850
+ onRetry: z
850
851
  }) => e ? /* @__PURE__ */ s.jsxs(
851
852
  "div",
852
853
  {
@@ -877,7 +878,7 @@ const se = [
877
878
  onChange: f
878
879
  }
879
880
  ),
880
- /* @__PURE__ */ s.jsx("span", { style: { fontStyle: "italic" }, children: i })
881
+ /* @__PURE__ */ s.jsx("span", { style: { fontStyle: "italic" }, children: a })
881
882
  ] }),
882
883
  u && /* @__PURE__ */ s.jsxs(
883
884
  "div",
@@ -894,23 +895,23 @@ const se = [
894
895
  "input",
895
896
  {
896
897
  type: "checkbox",
897
- checked: p === !1 ? !1 : a,
898
+ checked: p === !1 ? !1 : i,
898
899
  disabled: p === !1,
899
- onChange: w
900
+ onChange: L
900
901
  }
901
902
  ),
902
903
  /* @__PURE__ */ s.jsx("span", { children: "GBIF occurrences" })
903
904
  ]
904
905
  }
905
906
  ),
906
- j === "loading" && /* @__PURE__ */ s.jsx("div", { style: { marginTop: 6, color: "#888" }, children: "Loading descendants…" }),
907
- j === "error" && /* @__PURE__ */ s.jsxs("div", { style: { marginTop: 6, color: "#888" }, children: [
907
+ S === "loading" && /* @__PURE__ */ s.jsx("div", { style: { marginTop: 6, color: "#888" }, children: "Loading descendants…" }),
908
+ S === "error" && /* @__PURE__ */ s.jsxs("div", { style: { marginTop: 6, color: "#888" }, children: [
908
909
  "Couldn't load descendants.",
909
910
  " ",
910
- /* @__PURE__ */ s.jsx("a", { onClick: P, style: { cursor: "pointer" }, children: "Retry" })
911
+ /* @__PURE__ */ s.jsx("a", { onClick: z, style: { cursor: "pointer" }, children: "Retry" })
911
912
  ] }),
912
- j === "ready" && k.map((E) => {
913
- const _ = E.taxa.every((m) => S.has(m.id)), y = E.taxa.some((m) => S.has(m.id));
913
+ S === "ready" && k.map((I) => {
914
+ const N = I.taxa.every((m) => j.has(m.id)), b = I.taxa.some((m) => j.has(m.id));
914
915
  return /* @__PURE__ */ s.jsxs("div", { style: { marginTop: 6 }, children: [
915
916
  /* @__PURE__ */ s.jsxs(
916
917
  "label",
@@ -926,18 +927,18 @@ const se = [
926
927
  "input",
927
928
  {
928
929
  type: "checkbox",
929
- checked: _,
930
+ checked: N,
930
931
  ref: (m) => {
931
- m && (m.indeterminate = !_ && y);
932
+ m && (m.indeterminate = !N && b);
932
933
  },
933
- onChange: () => I(E.taxa)
934
+ onChange: () => B(I.taxa)
934
935
  }
935
936
  ),
936
- E.label
937
+ I.label
937
938
  ]
938
939
  }
939
940
  ),
940
- /* @__PURE__ */ s.jsx("div", { style: { paddingLeft: 18 }, children: E.taxa.map((m) => /* @__PURE__ */ s.jsxs(
941
+ /* @__PURE__ */ s.jsx("div", { style: { paddingLeft: 18 }, children: I.taxa.map((m) => /* @__PURE__ */ s.jsxs(
941
942
  "label",
942
943
  {
943
944
  style: {
@@ -950,8 +951,8 @@ const se = [
950
951
  "input",
951
952
  {
952
953
  type: "checkbox",
953
- checked: S.has(m.id),
954
- onChange: () => R(m.id)
954
+ checked: j.has(m.id),
955
+ onChange: () => E(m.id)
955
956
  }
956
957
  ),
957
958
  /* @__PURE__ */ s.jsx(
@@ -972,7 +973,7 @@ const se = [
972
973
  },
973
974
  m.id
974
975
  )) })
975
- ] }, E.rank);
976
+ ] }, I.rank);
976
977
  })
977
978
  ]
978
979
  }
@@ -1004,21 +1005,21 @@ const se = [
1004
1005
  ), Kt = (e) => {
1005
1006
  var n, r;
1006
1007
  return ((n = e == null ? void 0 : e.area) == null ? void 0 : n.gazetteer) !== "text" && !!((r = e == null ? void 0 : e.area) != null && r.globalId);
1007
- }, Me = ({ datasetKey: e, data: n }) => {
1008
- const [r, i] = L({});
1009
- return N(() => {
1008
+ }, Tt = ({ datasetKey: e, data: n }) => {
1009
+ const [r, a] = w({});
1010
+ return $(() => {
1010
1011
  let o = !1;
1011
1012
  for (let c = 0; c < n.length; c++)
1012
1013
  if (n[c].gazetteer === "iso") {
1013
1014
  o = !0;
1014
1015
  break;
1015
1016
  }
1016
- o && te(`${A.dataApi}vocab/country`).then((c) => {
1017
- i(it(c.data, "alpha3"));
1017
+ o && ne(`${P.dataApi}vocab/country`).then((c) => {
1018
+ a(ot(c.data, "alpha3"));
1018
1019
  });
1019
1020
  }, []), /* @__PURE__ */ s.jsx("div", { children: n.map((o, c) => /* @__PURE__ */ s.jsxs("span", { children: [
1020
1021
  (o == null ? void 0 : o.merged) && /* @__PURE__ */ s.jsx(
1021
- ut,
1022
+ dt,
1022
1023
  {
1023
1024
  createdBy: o == null ? void 0 : o.createdBy,
1024
1025
  datasetKey: o.datasetKey,
@@ -1027,7 +1028,7 @@ const se = [
1027
1028
  style: { marginRight: "4px" }
1028
1029
  }
1029
1030
  ),
1030
- ($(r, `[${$(o, "area.name")}].name`) ? at($(r, `[${$(o, "area.name")}].name`)) : null) || $(o, "area.name") || $(o, "area.globalId"),
1031
+ (A(r, `[${A(o, "area.name")}].name`) ? at(A(r, `[${A(o, "area.name")}].name`)) : null) || A(o, "area.name") || A(o, "area.globalId"),
1031
1032
  " ",
1032
1033
  o.referenceId && /* @__PURE__ */ s.jsx(
1033
1034
  mt,
@@ -1039,24 +1040,26 @@ const se = [
1039
1040
  ),
1040
1041
  c < n.length - 1 && ", "
1041
1042
  ] }, c)) });
1042
- }, an = ({
1043
+ }, ln = ({
1043
1044
  datasetKey: e,
1044
1045
  data: n,
1045
1046
  style: r,
1046
- showDistributionMap: i,
1047
+ showDistributionMap: a,
1047
1048
  focalTaxon: o,
1048
1049
  rankOrder: c,
1049
- gbifChecklistKey: f
1050
+ gbifChecklistKey: f,
1051
+ label: u,
1052
+ md: i
1050
1053
  }) => {
1051
- const u = n.filter(Kt), a = n.length - u.length, p = !!f, w = n.length > 0, [j, k] = L("map"), [C, S] = L(0), [R, I] = L(null);
1052
- N(() => {
1054
+ const p = n.filter(Kt), L = n.length - p.length, S = !!f, k = n.length > 0, [C, j] = w("map"), [E, B] = w(0), [z, I] = w(null);
1055
+ $(() => {
1053
1056
  if (!f || !(o != null && o.id)) {
1054
1057
  I(null);
1055
1058
  return;
1056
1059
  }
1057
1060
  I(null);
1058
- let O = !1;
1059
- return ct.get(`${A.gbifApi}/v1/occurrence/search`, {
1061
+ let R = !1;
1062
+ return it.get(`${P.gbifApi}/v1/occurrence/search`, {
1060
1063
  params: {
1061
1064
  checklistKey: f,
1062
1065
  taxonKey: o.id,
@@ -1066,34 +1069,30 @@ const se = [
1066
1069
  limit: 0
1067
1070
  }
1068
1071
  }).then(
1069
- (W) => {
1070
- var B;
1071
- O || I(((B = W == null ? void 0 : W.data) == null ? void 0 : B.count) ?? 0);
1072
+ (H) => {
1073
+ var re;
1074
+ R || I(((re = H == null ? void 0 : H.data) == null ? void 0 : re.count) ?? 0);
1072
1075
  },
1073
1076
  () => {
1074
- O || I(null);
1077
+ R || I(null);
1075
1078
  }
1076
1079
  ), () => {
1077
- O = !0;
1080
+ R = !0;
1078
1081
  };
1079
1082
  }, [f, o == null ? void 0 : o.id]);
1080
- const P = p ? R === null || R > 0 : !1, E = u.length > 0 && C >= u.length, _ = i && (u.length > 0 || P) && !(u.length > 0 && E && !P);
1081
- if (!_ && p && u.length === 0 && R === 0)
1082
- return /* @__PURE__ */ s.jsx("div", { style: r, children: /* @__PURE__ */ s.jsx("span", { style: { color: "#888" }, children: "No occurrence data on GBIF for this taxon." }) });
1083
- if (!_)
1084
- return w ? /* @__PURE__ */ s.jsx("div", { style: r, children: /* @__PURE__ */ s.jsx(Me, { datasetKey: e, data: n }) }) : null;
1085
- const y = a + C, m = w, z = m ? j : "map";
1086
- return /* @__PURE__ */ s.jsxs("div", { style: r, children: [
1087
- m ? /* @__PURE__ */ s.jsxs(
1088
- le.Group,
1083
+ const N = S ? z === null || z > 0 : !1, b = p.length > 0 && E >= p.length, m = a && (p.length > 0 || N) && !(p.length > 0 && b && !N);
1084
+ if (!m && !k) return null;
1085
+ const O = L + E, K = k, F = (m && K ? C : m ? "map" : "list") === "map" ? /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
1086
+ K ? /* @__PURE__ */ s.jsxs(
1087
+ ue.Group,
1089
1088
  {
1090
1089
  size: "small",
1091
- value: z,
1092
- onChange: (O) => k(O.target.value),
1090
+ value: C,
1091
+ onChange: (R) => j(R.target.value),
1093
1092
  style: { marginBottom: 8 },
1094
1093
  children: [
1095
- /* @__PURE__ */ s.jsx(le.Button, { value: "map", children: "Map" }),
1096
- /* @__PURE__ */ s.jsx(le.Button, { value: "list", children: "List" })
1094
+ /* @__PURE__ */ s.jsx(ue.Button, { value: "map", children: "Map" }),
1095
+ /* @__PURE__ */ s.jsx(ue.Button, { value: "list", children: "List" })
1097
1096
  ]
1098
1097
  }
1099
1098
  ) : (
@@ -1101,31 +1100,33 @@ const se = [
1101
1100
  // map's top edge lines up with the "Distributions" label.
1102
1101
  /* @__PURE__ */ s.jsx("div", { style: { height: 24, marginBottom: 8 } })
1103
1102
  ),
1104
- z === "map" ? /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
1105
- /* @__PURE__ */ s.jsx(
1106
- Ut,
1107
- {
1108
- records: u,
1109
- onUnmappable: S,
1110
- datasetKey: e,
1111
- focalTaxon: o,
1112
- rankOrder: c,
1113
- gbifChecklistKey: f,
1114
- gbifAvailable: P
1115
- }
1116
- ),
1117
- m && y > 0 && /* @__PURE__ */ s.jsx("div", { style: { marginTop: 6 }, children: /* @__PURE__ */ s.jsxs("a", { onClick: () => k("list"), style: { cursor: "pointer" }, children: [
1118
- "+",
1119
- y,
1120
- " distribution",
1121
- y === 1 ? "" : "s",
1122
- " not on map"
1123
- ] }) })
1124
- ] }) : /* @__PURE__ */ s.jsx(Me, { datasetKey: e, data: n })
1125
- ] });
1103
+ /* @__PURE__ */ s.jsx(
1104
+ Ut,
1105
+ {
1106
+ records: p,
1107
+ onUnmappable: B,
1108
+ datasetKey: e,
1109
+ focalTaxon: o,
1110
+ rankOrder: c,
1111
+ gbifChecklistKey: f,
1112
+ gbifAvailable: N
1113
+ }
1114
+ ),
1115
+ K && O > 0 && /* @__PURE__ */ s.jsx("div", { style: { marginTop: 6 }, children: /* @__PURE__ */ s.jsxs("a", { onClick: () => j("list"), style: { cursor: "pointer" }, children: [
1116
+ "+",
1117
+ O,
1118
+ " distribution",
1119
+ O === 1 ? "" : "s",
1120
+ " not on map"
1121
+ ] }) })
1122
+ ] }) : (
1123
+ // List view: either the user toggled to it, or there is no map to show.
1124
+ /* @__PURE__ */ s.jsx(Tt, { datasetKey: e, data: n })
1125
+ ), T = /* @__PURE__ */ s.jsx("div", { style: r, children: F });
1126
+ return u ? /* @__PURE__ */ s.jsx(ut, { md: i, label: u, children: T }) : T;
1126
1127
  };
1127
1128
  export {
1128
- an as D,
1129
+ ln as D,
1129
1130
  mt as R
1130
1131
  };
1131
- //# sourceMappingURL=Distributions-CXIEJ6e6.js.map
1132
+ //# sourceMappingURL=Distributions-Cwl_75VG.js.map