col-browser 2.4.0 → 2.5.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 (45) hide show
  1. package/README.md +25 -2
  2. package/es/bibtex.js +1 -1
  3. package/es/chunks/{BibTex-79CCKAOK.js → BibTex-CyUpSmpY.js} +2 -2
  4. package/es/chunks/{BibTex-79CCKAOK.js.map → BibTex-CyUpSmpY.js.map} +1 -1
  5. package/es/chunks/{DatasetCitation-BXtAmjdZ.js → DatasetCitation-BnOkKDTv.js} +2 -2
  6. package/es/chunks/{DatasetCitation-BXtAmjdZ.js.map → DatasetCitation-BnOkKDTv.js.map} +1 -1
  7. package/es/chunks/{DatasetlogoWithFallback-Dava2uqZ.js → DatasetlogoWithFallback-DJEkjMJ1.js} +2 -2
  8. package/es/chunks/{DatasetlogoWithFallback-Dava2uqZ.js.map → DatasetlogoWithFallback-DJEkjMJ1.js.map} +1 -1
  9. package/es/chunks/Distributions-Dwjo7KhA.js +1173 -0
  10. package/es/chunks/Distributions-Dwjo7KhA.js.map +1 -0
  11. package/es/chunks/{MergedDataBadge-C1CgoRFz.js → MergedDataBadge-FvHUdT7B.js} +2 -2
  12. package/es/chunks/{MergedDataBadge-C1CgoRFz.js.map → MergedDataBadge-FvHUdT7B.js.map} +1 -1
  13. package/es/chunks/{TaxonBreakdown-DeWamLu_.js → TaxonBreakdown-D9g3tYXL.js} +2 -2
  14. package/es/chunks/{TaxonBreakdown-DeWamLu_.js.map → TaxonBreakdown-D9g3tYXL.js.map} +1 -1
  15. package/es/chunks/{XrGutter-CU7_QPAp.js → XrGutter-D3PMq-Dn.js} +2 -2
  16. package/es/chunks/{XrGutter-CU7_QPAp.js.map → XrGutter-D3PMq-Dn.js.map} +1 -1
  17. package/es/chunks/config-D4b3a4Yi.js +27 -0
  18. package/es/chunks/config-D4b3a4Yi.js.map +1 -0
  19. package/es/chunks/{dataset-BL6g4w0G.js → dataset-D_gmg2Zv.js} +2 -2
  20. package/es/chunks/{dataset-BL6g4w0G.js.map → dataset-D_gmg2Zv.js.map} +1 -1
  21. package/es/chunks/{enumeration-DM8Hb36g.js → enumeration-B-nIqCor.js} +2 -2
  22. package/es/chunks/{enumeration-DM8Hb36g.js.map → enumeration-B-nIqCor.js.map} +1 -1
  23. package/es/chunks/{sector-Qeo1zPxr.js → sector-CE-w32Gs.js} +2 -2
  24. package/es/chunks/{sector-Qeo1zPxr.js.map → sector-CE-w32Gs.js.map} +1 -1
  25. package/es/config.js +1 -1
  26. package/es/index.js +1 -1
  27. package/es/search.js +5 -5
  28. package/es/sourceDataset.js +4 -4
  29. package/es/sourceDatasetList.js +4 -4
  30. package/es/taxon.js +758 -754
  31. package/es/taxon.js.map +1 -1
  32. package/es/taxonBreakdown.js +2 -2
  33. package/es/taxonDistribution.js +21 -19
  34. package/es/taxonDistribution.js.map +1 -1
  35. package/es/tree.js +5 -5
  36. package/package.json +1 -1
  37. package/types/index.d.ts +18 -0
  38. package/umd/col-browser.js +43 -25
  39. package/umd/col-browser.js.map +1 -1
  40. package/umd/col-browser.min.js +4 -4
  41. package/umd/col-browser.min.js.map +1 -1
  42. package/es/chunks/Distributions-Bd4hFYdS.js +0 -1169
  43. package/es/chunks/Distributions-Bd4hFYdS.js.map +0 -1
  44. package/es/chunks/config-D1NH4DTr.js +0 -22
  45. package/es/chunks/config-D1NH4DTr.js.map +0 -1
@@ -1,1169 +0,0 @@
1
- var nt = Object.defineProperty;
2
- var rt = (e, r, s) => r in e ? nt(e, r, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[r] = s;
3
- var X = (e, r, s) => rt(e, typeof r != "symbol" ? r + "" : r, s);
4
- import { j as n } from "./jsx-runtime-BzflLqGi.js";
5
- import * as _e from "react";
6
- import st, { useState as L, useRef as C, useMemo as se, useEffect as $ } from "react";
7
- import { Spin as ot, Popover as at, Radio as ue } from "antd";
8
- import { isArray as Le, get as O, keyBy as it, startCase as ct } from "lodash-es";
9
- import { c as ne, p as lt } from "./router-CssZk5qZ.js";
10
- import { c as z } from "./config-D1NH4DTr.js";
11
- import { E as dt } from "./ErrorMsg-K8k5PPTp.js";
12
- import { I as ut } from "./AntdIcon-B1nMlqyh.js";
13
- import { M as pt } from "./MergedDataBadge-C1CgoRFz.js";
14
- import { P as ft } from "./PresentationItem-C4yZ555-.js";
15
- import D from "maplibre-gl";
16
- import "maplibre-gl/dist/maplibre-gl.css";
17
- import { r as ht, w as gt } from "./storage-BgdCo9fV.js";
18
- var mt = { 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" };
19
- function ge() {
20
- return ge = Object.assign ? Object.assign.bind() : function(e) {
21
- for (var r = 1; r < arguments.length; r++) {
22
- var s = arguments[r];
23
- for (var a in s)
24
- Object.prototype.hasOwnProperty.call(s, a) && (e[a] = s[a]);
25
- }
26
- return e;
27
- }, ge.apply(this, arguments);
28
- }
29
- const yt = (e, r) => /* @__PURE__ */ _e.createElement(ut, ge({}, e, {
30
- ref: r,
31
- icon: mt
32
- })), $e = /* @__PURE__ */ _e.forwardRef(yt);
33
- process.env.NODE_ENV !== "production" && ($e.displayName = "BookOutlined");
34
- class bt extends st.Component {
35
- constructor(s) {
36
- super(s);
37
- X(this, "getData", () => {
38
- const { referenceId: s, datasetKey: a, references: o } = this.props;
39
- if (s) {
40
- const c = Le(s) ? s : [s], p = [];
41
- this.setState({ loading: !0 }), Promise.allSettled(
42
- c.map(
43
- (f) => O(o, f) ? Promise.resolve(p.push(o[f])) : ne(
44
- `${z.dataApi}dataset/${a}/reference/${f}`
45
- ).then((u) => p.push(u.data)).catch((u) => this.setState({ error: u }))
46
- )
47
- ).then(() => this.setState({ reference: p, loading: !1 }));
48
- }
49
- });
50
- X(this, "getContent", () => {
51
- const { error: s, reference: a, loading: o } = this.state;
52
- return o ? /* @__PURE__ */ n.jsx(ot, {}) : s ? /* @__PURE__ */ n.jsx(dt, { error: s }) : a.length === 1 ? a[0].citation : /* @__PURE__ */ n.jsx("ul", { children: a.map((c) => /* @__PURE__ */ n.jsx("li", { children: c.citation }, c.id)) });
53
- });
54
- X(this, "scrollToReference", (s, a) => {
55
- const o = document.getElementById(`col-reference-${a}`);
56
- o && (s.preventDefault(), o.scrollIntoView({ behavior: "smooth", block: "start" }));
57
- });
58
- X(this, "render", () => {
59
- const { referenceId: s, referenceIndexMap: a, trigger: o } = this.props, c = this.props.maxInline || 4, p = Le(s) ? s : [s];
60
- let f = a && O(a, p[0]) ? (() => {
61
- const u = p.slice(0, c), i = p.length - u.length;
62
- return [
63
- ...u.map((y) => /* @__PURE__ */ n.jsx(
64
- "a",
65
- {
66
- className: "col-reference-link",
67
- href: `#col-reference-${y}`,
68
- onClick: (x) => this.scrollToReference(x, y),
69
- children: `[${a[y]}]`
70
- },
71
- y
72
- )),
73
- i > 0 ? /* @__PURE__ */ n.jsx("span", { className: "col-reference-link", children: ` +${i}` }, "overflow") : null
74
- ];
75
- })() : /* @__PURE__ */ n.jsx($e, { style: { cursor: "pointer" } });
76
- return s ? /* @__PURE__ */ n.jsx("div", { id: `reference_${s}`, style: this.props.style, children: /* @__PURE__ */ n.jsx(
77
- at,
78
- {
79
- getPopupContainer: () => document.getElementById(`reference_${s}`),
80
- placement: this.props.placement || "left",
81
- title: "Reference",
82
- onOpenChange: (u) => u && this.getData(),
83
- content: /* @__PURE__ */ n.jsx(
84
- "div",
85
- {
86
- style: {
87
- maxWidth: "500px",
88
- maxHeight: "60vh",
89
- overflowY: "auto"
90
- },
91
- children: this.getContent()
92
- }
93
- ),
94
- trigger: o || "hover",
95
- children: f
96
- }
97
- ) }, `reference_${s}`) : "";
98
- });
99
- this.state = {
100
- reference: [],
101
- loading: !1,
102
- error: null
103
- };
104
- }
105
- }
106
- const ae = [
107
- "subspecies",
108
- "variety",
109
- "subvariety",
110
- "form",
111
- "subform",
112
- "infraspecific name"
113
- ], Ae = (e, r) => {
114
- const s = r.indexOf(e);
115
- return s === -1 ? [] : ae.filter((a) => r.indexOf(a) > s);
116
- }, xt = 16, vt = (e) => {
117
- var r, s;
118
- return ((r = e == null ? void 0 : e.area) == null ? void 0 : r.gazetteer) !== "text" && !!((s = e == null ? void 0 : e.area) != null && s.globalId);
119
- }, jt = async (e, r, s) => {
120
- const a = new Array(e.length);
121
- let o = 0;
122
- const c = Array.from({ length: Math.min(s, e.length) }, async () => {
123
- for (; ; ) {
124
- const p = o++;
125
- if (p >= e.length) return;
126
- a[p] = await r(e[p], p);
127
- }
128
- });
129
- return await Promise.all(c), a;
130
- }, St = async (e, r, s) => {
131
- var f;
132
- if (s.length === 0) return [];
133
- const a = new URLSearchParams();
134
- a.append("TAXON_ID", r), s.forEach((u) => a.append("rank", u)), ["accepted", "provisionally accepted"].forEach(
135
- (u) => a.append("status", u)
136
- ), a.append("limit", "1000");
137
- const o = `${z.dataApi}dataset/${e}/nameusage/search?${a}`, c = await ne(o);
138
- return (((f = c == null ? void 0 : c.data) == null ? void 0 : f.result) || []).filter((u) => {
139
- var i;
140
- return (i = u == null ? void 0 : u.usage) == null ? void 0 : i.id;
141
- }).map((u) => {
142
- var i, y, x, R, E, I;
143
- return {
144
- id: u.usage.id,
145
- scientificName: ((y = (i = u.usage) == null ? void 0 : i.name) == null ? void 0 : y.scientificName) || ((x = u.usage) == null ? void 0 : x.label) || u.usage.id,
146
- rank: (E = (R = u.usage) == null ? void 0 : R.name) == null ? void 0 : E.rank,
147
- parentId: (I = u.usage) == null ? void 0 : I.parentId
148
- };
149
- });
150
- }, It = async (e, r) => {
151
- const s = `${z.dataApi}dataset/${e}/taxon/${encodeURIComponent(r)}/distribution`;
152
- try {
153
- const a = await ne(s);
154
- return Array.isArray(a == null ? void 0 : a.data) ? a.data : [];
155
- } catch {
156
- return [];
157
- }
158
- }, wt = async ({ datasetKey: e, focalTaxon: r, rankOrder: s }) => {
159
- var u;
160
- const a = Ae((u = r == null ? void 0 : r.name) == null ? void 0 : u.rank, s);
161
- let o = !1, c = [];
162
- try {
163
- c = await St(e, r.id, a);
164
- } catch {
165
- return o = !0, { taxa: [], descendantsFailed: o };
166
- }
167
- const p = await jt(
168
- c,
169
- (i) => It(e, i.id),
170
- xt
171
- );
172
- return { taxa: c.map((i, y) => {
173
- const x = p[y] || [];
174
- return { ...i, distributions: x, mappable: x.filter(vt) };
175
- }), descendantsFailed: o };
176
- }, ke = [
177
- "#E58606",
178
- "#5D69B1",
179
- "#52BCA3",
180
- "#99C945",
181
- "#CC61B0",
182
- "#24796C",
183
- "#DAA51B",
184
- "#2F8AC4",
185
- "#764E9F",
186
- "#ED645A",
187
- "#CC3A8E",
188
- "#A5AA99"
189
- ], Ce = (e, r) => {
190
- const s = r.indexOf(e);
191
- return s === -1 ? r.length : s;
192
- }, Lt = (e, r) => {
193
- const s = [...e].sort((o, c) => {
194
- const p = Ce(o.rank, r), f = Ce(c.rank, r);
195
- return p !== f ? p - f : o.scientificName.localeCompare(c.scientificName);
196
- }), a = {};
197
- return s.forEach((o, c) => {
198
- a[o.id] = ke[c % ke.length];
199
- }), a;
200
- }, kt = {
201
- position: "absolute",
202
- bottom: 8,
203
- left: 8,
204
- zIndex: 1e3,
205
- background: "#fff",
206
- borderRadius: 4,
207
- boxShadow: "0 1px 4px rgba(0,0,0,0.2)",
208
- padding: "6px 8px",
209
- fontSize: 12,
210
- lineHeight: 1.5,
211
- maxWidth: 260
212
- }, Ct = {
213
- maxHeight: 240,
214
- overflowY: "auto"
215
- }, Pe = {
216
- fontWeight: 600,
217
- marginTop: 4
218
- }, Rt = {
219
- ...Pe,
220
- marginTop: 0
221
- }, Oe = {
222
- display: "flex",
223
- alignItems: "center",
224
- gap: 6,
225
- paddingLeft: 4
226
- }, Et = (e) => ({
227
- display: "inline-block",
228
- width: 12,
229
- height: 12,
230
- background: e,
231
- border: "1px solid rgba(0,0,0,0.15)",
232
- borderRadius: 2,
233
- flex: "0 0 auto"
234
- }), Ft = {
235
- marginTop: 6,
236
- cursor: "pointer",
237
- color: "#1890ff",
238
- fontSize: 11
239
- }, Bt = {
240
- marginTop: 4,
241
- borderTop: "1px solid #eee",
242
- paddingTop: 4,
243
- color: "#666"
244
- }, De = {
245
- fontWeight: 600,
246
- marginTop: 4
247
- }, Gt = {
248
- ...De,
249
- marginTop: 0
250
- }, Nt = {
251
- fontStyle: "italic",
252
- paddingLeft: 4
253
- }, Re = (e) => e.reduce((r, s) => r + s.taxa.length, 0), Mt = () => /* @__PURE__ */ n.jsxs("div", { style: Oe, children: [
254
- /* @__PURE__ */ n.jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", children: /* @__PURE__ */ n.jsx(
255
- "polygon",
256
- {
257
- points: "3,1 9,1 11,6 9,11 3,11 1,6",
258
- fill: "#de1e6e",
259
- stroke: "rgba(0,0,0,0.25)",
260
- strokeWidth: "0.75"
261
- }
262
- ) }),
263
- /* @__PURE__ */ n.jsx("span", { children: "GBIF occurrences" })
264
- ] }), _t = ({ visibleGroups: e, unmappableGroups: r, showGbif: s }) => {
265
- const [a, o] = L(!1), c = Re(e), p = Re(r);
266
- return c === 0 && p === 0 && !s ? null : /* @__PURE__ */ n.jsxs("div", { style: kt, children: [
267
- /* @__PURE__ */ n.jsxs("div", { style: Ct, children: [
268
- e.map((f, u) => /* @__PURE__ */ n.jsxs("div", { children: [
269
- /* @__PURE__ */ n.jsx("div", { style: u === 0 ? Rt : Pe, children: f.label }),
270
- f.taxa.map((i) => /* @__PURE__ */ n.jsxs("div", { style: Oe, children: [
271
- /* @__PURE__ */ n.jsx("span", { style: Et(i.color) }),
272
- /* @__PURE__ */ n.jsx("span", { style: { fontStyle: "italic" }, children: i.displayName || i.scientificName })
273
- ] }, i.id))
274
- ] }, f.rank)),
275
- s && /* @__PURE__ */ n.jsx(Mt, {})
276
- ] }),
277
- p > 0 && /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
278
- /* @__PURE__ */ n.jsxs(
279
- "div",
280
- {
281
- style: Ft,
282
- onClick: () => o((f) => !f),
283
- children: [
284
- a ? "− Hide" : "+",
285
- " ",
286
- p,
287
- " without map data"
288
- ]
289
- }
290
- ),
291
- a && /* @__PURE__ */ n.jsx("div", { style: Bt, children: r.map((f, u) => /* @__PURE__ */ n.jsxs("div", { children: [
292
- /* @__PURE__ */ n.jsx(
293
- "div",
294
- {
295
- style: u === 0 ? Gt : De,
296
- children: f.label
297
- }
298
- ),
299
- f.taxa.map((i) => /* @__PURE__ */ n.jsx("div", { style: Nt, children: i.displayName || i.scientificName }, i.id))
300
- ] }, f.rank)) })
301
- ] })
302
- ] });
303
- }, $t = [
304
- "establishmentMeans",
305
- "degreeOfEstablishment",
306
- "pathway",
307
- "threatStatus",
308
- "year",
309
- "lifeStage"
310
- ], ze = [
311
- { key: "nativeendemic", label: "Native endemic", color: "#0F8554" },
312
- { key: "native", label: "Native", color: "#87C55F" },
313
- { key: "nativereintroduced", label: "Native reintroduced", color: "#C9DB74" },
314
- { key: "introduced", label: "Introduced", color: "#FE88B1" },
315
- {
316
- key: "introducedassistedcolonisation",
317
- label: "Introduced assisted colonisation",
318
- color: "#DCB0F2"
319
- },
320
- { key: "vagrant", label: "Vagrant", color: "#F6CF71" },
321
- { key: "uncertain", label: "Uncertain", color: "#8BE0A4" }
322
- ], He = Object.fromEntries(
323
- ze.map((e) => [e.key, e.color])
324
- ), ie = "#66C5CC", At = (e) => String(e || "").toLowerCase().replace(/[^a-z]/g, ""), Ve = (e) => {
325
- const r = e == null ? void 0 : e.establishmentMeans;
326
- if (r == null || r === "") return null;
327
- const s = At(r);
328
- return He[s] ? s : "uncertain";
329
- }, Pt = (e) => {
330
- const r = Ve(e);
331
- return r == null ? ie : He[r];
332
- }, Ot = "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json", Ue = "gbif-visible", Dt = (e) => ht(Ue, e), Ee = (e) => gt(Ue, e), zt = "/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", K = "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(), Fe = (e, r) => {
333
- const s = `${e}:${r}`;
334
- if (he.has(s)) return he.get(s);
335
- const a = `${z.dataApi}vocab/area/${s}`, o = ne(a, {
336
- headers: { Accept: "application/geo+json" }
337
- }).then(
338
- (c) => c.data,
339
- () => null
340
- );
341
- return he.set(s, o), o;
342
- }, te = (e) => String(e).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"), We = (e) => {
343
- var a, o;
344
- const r = ((a = e == null ? void 0 : e.area) == null ? void 0 : a.name) || ((o = e == null ? void 0 : e.area) == null ? void 0 : o.globalId) || "", s = $t.map((c) => [c, e == null ? void 0 : e[c]]).filter(([, c]) => c != null && c !== "").map(
345
- ([c, p]) => `<div><strong>${te(c)}:</strong> ${te(p)}</div>`
346
- ).join("");
347
- return `<div style="min-width:180px"><div style="font-weight:600;margin-bottom:4px">${te(
348
- r
349
- )}</div>${s}</div>`;
350
- }, Ht = (e, r) => `<div style="font-weight:600;font-style:italic;margin-bottom:4px">${te(
351
- e.scientificName
352
- )}</div><div style="color:#888;margin-bottom:4px">${te(e.rank || "")}</div>` + We(r), Vt = {
353
- subspecies: "subspecies",
354
- variety: "varieties",
355
- subvariety: "subvarieties",
356
- form: "forms",
357
- subform: "subforms",
358
- "infraspecific name": "infraspecific names"
359
- }, Be = (e) => Vt[e] || e, Ke = (e) => {
360
- if (!e) return "";
361
- const r = e.trim().split(/\s+/);
362
- return r[r.length - 1];
363
- }, Ut = () => /* @__PURE__ */ n.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
364
- /* @__PURE__ */ n.jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", children: /* @__PURE__ */ n.jsx(
365
- "polygon",
366
- {
367
- points: "3,1 9,1 11,6 9,11 3,11 1,6",
368
- fill: "#de1e6e",
369
- stroke: "rgba(0,0,0,0.25)",
370
- strokeWidth: "0.75"
371
- }
372
- ) }),
373
- /* @__PURE__ */ n.jsx("span", { children: "GBIF occurrences" })
374
- ] }), Wt = (e) => {
375
- var p;
376
- let r = 1 / 0, s = 1 / 0, a = -1 / 0, o = -1 / 0;
377
- const c = (f) => {
378
- if (typeof f[0] == "number") {
379
- const [u, i] = f;
380
- u < r && (r = u), u > a && (a = u), i < s && (s = i), i > o && (o = i);
381
- } else
382
- for (let u = 0; u < f.length; u++) c(f[u]);
383
- };
384
- for (let f = 0; f < e.length; f++) {
385
- const u = (p = e[f]) == null ? void 0 : p.geometry;
386
- u != null && u.coordinates && c(u.coordinates);
387
- }
388
- return r === 1 / 0 ? null : [
389
- [r, s],
390
- [a, o]
391
- ];
392
- }, Ge = (e) => e ? e.type === "FeatureCollection" ? e.features || [] : [e] : [], Ne = () => {
393
- var e;
394
- return typeof ((e = D) == null ? void 0 : e.supported) == "function" ? D.supported() : typeof WebGLRenderingContext < "u";
395
- }, Kt = ({
396
- records: e,
397
- onUnmappable: r,
398
- datasetKey: s,
399
- focalTaxon: a,
400
- rankOrder: o,
401
- gbifChecklistKey: c,
402
- // true | null → show GBIF layer; false → GBIF API returned 0 occurrences,
403
- // grey out the toggle and skip loading tiles. Defaults to true so the
404
- // component works without the count check.
405
- gbifAvailable: p = !0
406
- }) => {
407
- var we;
408
- const f = C(null), u = C(null), i = C(null), y = C(null), x = C(/* @__PURE__ */ new Map()), R = C(/* @__PURE__ */ new Map()), E = C(/* @__PURE__ */ new Map()), I = C(!1), B = C(!1), G = C(/* @__PURE__ */ new Set()), [k, w] = L(!1), [N, V] = L(!1), [g, M] = L({
409
- status: "idle",
410
- // idle | loading | ready | empty | error
411
- taxa: []
412
- }), [H, T] = L(!0), re = !!c && (!e || e.length === 0), [j, A] = L(
413
- () => Dt(!0)
414
- ), [P, me] = L(/* @__PURE__ */ new Set()), [Te, ye] = L(!1), ce = C(!1), Ye = () => {
415
- A((t) => {
416
- const d = !t;
417
- return Ee(d), d;
418
- });
419
- }, be = () => {
420
- A(!0), Ee(!0);
421
- }, xe = se(() => {
422
- if (!(e != null && e.length)) return [];
423
- const t = /* @__PURE__ */ new Set();
424
- return e.forEach((d) => {
425
- const l = Ve(d);
426
- l != null && t.add(l);
427
- }), ze.filter((d) => t.has(d.key));
428
- }, [e]), Y = se(() => g.status !== "ready" ? {} : Lt(
429
- g.taxa.filter((t) => t.mappable.length > 0),
430
- o || []
431
- ), [g, o]), le = se(() => {
432
- if (g.status !== "ready")
433
- return { visibleGroups: [], unmappableGroups: [] };
434
- const t = (h) => ({
435
- ...h,
436
- color: Y[h.id],
437
- displayName: Ke(h.scientificName)
438
- }), d = (h) => {
439
- const v = {};
440
- return h.forEach((b) => {
441
- (v[b.rank] = v[b.rank] || []).push(t(b));
442
- }), ae.filter((b) => v[b]).map((b) => ({
443
- rank: b,
444
- label: Be(b),
445
- taxa: v[b]
446
- }));
447
- }, l = d(
448
- g.taxa.filter(
449
- (h) => h.mappable.length > 0 && P.has(h.id)
450
- )
451
- ), m = d(
452
- g.taxa.filter((h) => h.mappable.length === 0)
453
- );
454
- return { visibleGroups: l, unmappableGroups: m };
455
- }, [g, Y, P]), ve = le.visibleGroups.length > 0;
456
- $(() => {
457
- if (!f.current || i.current || !Ne()) return;
458
- const t = new D.Map({
459
- container: f.current,
460
- style: Ot,
461
- center: [0, 20],
462
- zoom: 1,
463
- minZoom: 0,
464
- attributionControl: !1,
465
- renderWorldCopies: !0
466
- });
467
- t.addControl(
468
- new D.AttributionControl({ compact: !0 }),
469
- "bottom-right"
470
- ), t.addControl(
471
- new D.NavigationControl({ showCompass: !1 }),
472
- "top-left"
473
- ), t.addControl(
474
- new D.FullscreenControl({ container: u.current }),
475
- "top-right"
476
- ), i.current = t, t.on("load", () => {
477
- w(!0);
478
- const l = t.getContainer().querySelector(".maplibregl-ctrl-attrib");
479
- l && l.classList.remove("maplibregl-compact-show");
480
- });
481
- const d = typeof ResizeObserver < "u" ? new ResizeObserver(() => t.resize()) : null;
482
- return d && d.observe(f.current), () => {
483
- d && d.disconnect(), y.current && (y.current.remove(), y.current = null), t.remove(), i.current = null, I.current = !1, B.current = !1, G.current = /* @__PURE__ */ new Set();
484
- };
485
- }, []), $(() => {
486
- if (!k || !(e != null && e.length)) return;
487
- const t = i.current;
488
- if (!t) return;
489
- let d = !1;
490
- return V(!1), Promise.allSettled(
491
- e.map(
492
- (l) => Fe(l.area.gazetteer, l.area.id).then((m) => ({
493
- record: l,
494
- geojson: m
495
- }))
496
- )
497
- ).then((l) => {
498
- if (d) return;
499
- const m = [], h = /* @__PURE__ */ new Map();
500
- let v = 0;
501
- l.forEach((S, F) => {
502
- if (S.status !== "fulfilled" || !S.value.geojson) {
503
- v += 1;
504
- return;
505
- }
506
- const { record: U, geojson: W } = S.value, de = Pt(U), q = `focal-${F}`;
507
- h.set(q, U), Ge(W).forEach((Z) => {
508
- m.push({
509
- ...Z,
510
- properties: {
511
- ...Z.properties || {},
512
- _recordKey: q,
513
- _color: de
514
- }
515
- });
516
- });
517
- }), x.current = h;
518
- const b = { type: "FeatureCollection", features: m };
519
- if (t.getSource(J))
520
- t.getSource(J).setData(b);
521
- else {
522
- const S = t.getLayer(_) ? _ : void 0;
523
- t.addSource(J, { type: "geojson", data: b }), t.addLayer(
524
- {
525
- id: K,
526
- type: "fill",
527
- source: J,
528
- paint: {
529
- "fill-color": ["coalesce", ["get", "_color"], ie],
530
- "fill-opacity": 0.65
531
- }
532
- },
533
- S
534
- ), t.addLayer(
535
- {
536
- id: pe,
537
- type: "line",
538
- source: J,
539
- paint: {
540
- "line-color": ["coalesce", ["get", "_color"], ie],
541
- "line-width": 1
542
- }
543
- },
544
- S
545
- ), t.on("click", K, qe), t.on("mouseenter", K, je), t.on("mouseleave", K, Se), I.current = !0;
546
- }
547
- if (m.length > 0) {
548
- const S = Wt(m);
549
- S && t.fitBounds(S, { padding: 20, animate: !1 });
550
- }
551
- typeof r == "function" && r(v), V(!0);
552
- }), () => {
553
- d = !0;
554
- };
555
- }, [k, e]);
556
- const qe = (t) => {
557
- var v, b;
558
- const d = i.current;
559
- if (!d) return;
560
- const l = (v = t.features) == null ? void 0 : v[0], m = (b = l == null ? void 0 : l.properties) == null ? void 0 : b._recordKey, h = m ? x.current.get(m) : null;
561
- h && (y.current && y.current.remove(), y.current = new D.Popup({ closeButton: !0, maxWidth: "320px" }).setLngLat(t.lngLat).setHTML(We(h)).addTo(d));
562
- }, je = () => {
563
- const t = i.current;
564
- t && (t.getCanvas().style.cursor = "pointer");
565
- }, Se = () => {
566
- const t = i.current;
567
- t && (t.getCanvas().style.cursor = "");
568
- };
569
- $(() => {
570
- const t = i.current;
571
- if (!t || !I.current) return;
572
- const d = H ? "visible" : "none";
573
- t.getLayer(K) && t.setLayoutProperty(K, "visibility", d), t.getLayer(pe) && t.setLayoutProperty(pe, "visibility", d);
574
- }, [H, N]), $(() => {
575
- if (!k) return;
576
- const t = i.current;
577
- if (!t || ((() => {
578
- t.getLayer(_) && t.removeLayer(_), t.getSource(oe) && t.removeSource(oe), B.current = !1;
579
- })(), !c || !(a != null && a.id)) || p === !1) return;
580
- const l = (z.gbifApi + zt).replace("{checklistKey}", encodeURIComponent(c)).replace("{taxonKey}", encodeURIComponent(a.id)), m = z.gbifPortal + "/occurrence/search?checklist_key=" + encodeURIComponent(c) + "&taxon_key=" + encodeURIComponent(a.id);
581
- t.addSource(oe, {
582
- type: "raster",
583
- tiles: [l],
584
- tileSize: 256,
585
- attribution: '<a href="' + m + '" target="_blank" rel="noopener">GBIF</a> occurrence data'
586
- }), t.addLayer({
587
- id: _,
588
- type: "raster",
589
- source: oe,
590
- paint: { "raster-opacity": 0.9 },
591
- layout: { visibility: j ? "visible" : "none" }
592
- }), B.current = !0;
593
- }, [k, c, a == null ? void 0 : a.id, p]), $(() => {
594
- const t = i.current;
595
- if (!t || !B.current) return;
596
- const d = j ? "visible" : "none";
597
- t.getLayer(_) && t.setLayoutProperty(_, "visibility", d);
598
- }, [j]), $(() => {
599
- if (!k) return;
600
- const t = i.current;
601
- if (!t || (G.current.forEach((l) => {
602
- t.getLayer(Q(l)) && t.removeLayer(Q(l)), t.getLayer(ee(l)) && t.removeLayer(ee(l)), t.getSource(fe(l)) && t.removeSource(fe(l));
603
- }), G.current = /* @__PURE__ */ new Set(), R.current = /* @__PURE__ */ new Map(), E.current = /* @__PURE__ */ new Map(), g.status !== "ready")) return;
604
- const d = Y;
605
- g.taxa.forEach((l) => {
606
- l.mappable.length !== 0 && (R.current.set(l.id, l), Promise.allSettled(
607
- l.mappable.map(
608
- (m) => Fe(m.area.gazetteer, m.area.id).then((h) => ({
609
- record: m,
610
- geojson: h
611
- }))
612
- )
613
- ).then((m) => {
614
- if (!i.current) return;
615
- const h = [];
616
- m.forEach((F, U) => {
617
- if (F.status !== "fulfilled" || !F.value.geojson) return;
618
- const { record: W, geojson: de } = F.value, q = `desc-${l.id}-${U}`;
619
- E.current.set(q, { taxon: l, record: W }), Ge(de).forEach((Z) => {
620
- h.push({
621
- ...Z,
622
- properties: {
623
- ...Z.properties || {},
624
- _recordKey: q
625
- }
626
- });
627
- });
628
- });
629
- const v = d[l.id] || ie, b = { type: "FeatureCollection", features: h }, S = fe(l.id);
630
- if (i.current.getSource(S))
631
- i.current.getSource(S).setData(b);
632
- else {
633
- i.current.addSource(S, { type: "geojson", data: b });
634
- const F = Q(l.id), U = ee(l.id), W = i.current.getLayer(_) ? _ : void 0;
635
- i.current.addLayer(
636
- {
637
- id: F,
638
- type: "fill",
639
- source: S,
640
- paint: { "fill-color": v, "fill-opacity": 0.55 },
641
- layout: { visibility: "none" }
642
- },
643
- W
644
- ), i.current.addLayer(
645
- {
646
- id: U,
647
- type: "line",
648
- source: S,
649
- paint: { "line-color": v, "line-width": 2 },
650
- layout: { visibility: "none" }
651
- },
652
- W
653
- ), i.current.on("click", F, Ze), i.current.on("mouseenter", F, je), i.current.on("mouseleave", F, Se), G.current.add(l.id);
654
- }
655
- }));
656
- });
657
- }, [k, g, Y]);
658
- const Ze = (t) => {
659
- var v, b;
660
- const d = i.current;
661
- if (!d) return;
662
- const l = (v = t.features) == null ? void 0 : v[0], m = (b = l == null ? void 0 : l.properties) == null ? void 0 : b._recordKey, h = m ? E.current.get(m) : null;
663
- h && (y.current && y.current.remove(), y.current = new D.Popup({ closeButton: !0, maxWidth: "320px" }).setLngLat(t.lngLat).setHTML(Ht(h.taxon, h.record)).addTo(d));
664
- };
665
- $(() => {
666
- const t = i.current;
667
- t && G.current.forEach((d) => {
668
- const l = P.has(d) ? "visible" : "none";
669
- t.getLayer(Q(d)) && t.setLayoutProperty(Q(d), "visibility", l), t.getLayer(ee(d)) && t.setLayoutProperty(ee(d), "visibility", l);
670
- });
671
- }, [P, g]);
672
- const Ie = () => {
673
- var l;
674
- if (ce.current || !s || !a || !o) return;
675
- const t = (l = a == null ? void 0 : a.name) == null ? void 0 : l.rank;
676
- !t || t !== "species" && !ae.includes(t) || Ae(t, o).length === 0 || (ce.current = !0, M({ status: "loading", taxa: [] }), wt({ datasetKey: s, focalTaxon: a, rankOrder: o }).then(
677
- ({ taxa: m, descendantsFailed: h }) => {
678
- if (h) {
679
- M({ status: "error", taxa: [] });
680
- return;
681
- }
682
- if (m.length === 0) {
683
- M({ status: "empty", taxa: [] });
684
- return;
685
- }
686
- M({ status: "ready", taxa: m });
687
- }
688
- ));
689
- }, Xe = () => {
690
- ye(!0), Ie();
691
- }, Je = se(() => {
692
- if (g.status !== "ready") return [];
693
- const t = {};
694
- return g.taxa.filter((d) => d.mappable.length > 0).forEach((d) => {
695
- (t[d.rank] = t[d.rank] || []).push(d);
696
- }), ae.filter((d) => t[d]).map((d) => ({
697
- rank: d,
698
- label: Be(d),
699
- taxa: t[d].slice().sort(
700
- (l, m) => l.scientificName.localeCompare(m.scientificName)
701
- )
702
- }));
703
- }, [g]), Qe = (t) => {
704
- me((d) => {
705
- const l = new Set(d);
706
- return l.has(t) ? l.delete(t) : l.add(t), l;
707
- });
708
- }, et = (t) => {
709
- me((d) => {
710
- const l = new Set(d), m = t.every((h) => d.has(h.id));
711
- return t.forEach((h) => {
712
- m ? l.delete(h.id) : l.add(h.id);
713
- }), l;
714
- });
715
- };
716
- if (!Ne())
717
- return /* @__PURE__ */ n.jsx(
718
- "div",
719
- {
720
- style: {
721
- padding: 12,
722
- background: "#fafafa",
723
- border: "1px solid #eee",
724
- borderRadius: 4,
725
- color: "#666",
726
- fontSize: 12
727
- },
728
- children: "Maps require WebGL, which your browser doesn't support."
729
- }
730
- );
731
- if (re && !j)
732
- return /* @__PURE__ */ n.jsxs(
733
- "div",
734
- {
735
- className: "col-distributions-map col-distributions-map--collapsed",
736
- style: {
737
- display: "flex",
738
- alignItems: "center",
739
- gap: 6,
740
- padding: "8px 12px",
741
- background: "#fafafa",
742
- border: "1px solid #eee",
743
- borderRadius: 4,
744
- color: "#666",
745
- fontSize: 12
746
- },
747
- children: [
748
- /* @__PURE__ */ n.jsx("span", { children: "No curated distribution data." }),
749
- /* @__PURE__ */ n.jsx(
750
- "a",
751
- {
752
- role: "button",
753
- tabIndex: 0,
754
- style: { cursor: "pointer" },
755
- onClick: be,
756
- onKeyDown: (t) => {
757
- (t.key === "Enter" || t.key === " ") && (t.preventDefault(), be());
758
- },
759
- children: "Show GBIF occurrences"
760
- }
761
- )
762
- ]
763
- }
764
- );
765
- const tt = ((we = a == null ? void 0 : a.name) == null ? void 0 : we.scientificName) || "This taxon";
766
- return /* @__PURE__ */ n.jsxs(
767
- "div",
768
- {
769
- className: "col-distributions-map",
770
- ref: u,
771
- style: { position: "relative" },
772
- children: [
773
- /* @__PURE__ */ n.jsx(
774
- "div",
775
- {
776
- ref: f,
777
- className: "col-distributions-map__canvas",
778
- style: { height: 360, width: "100%", background: "#f5f5f5" }
779
- }
780
- ),
781
- /* @__PURE__ */ n.jsx(
782
- Tt,
783
- {
784
- open: Te,
785
- onOpen: Xe,
786
- onClose: () => ye(!1),
787
- focalName: tt,
788
- focalReady: N,
789
- focalVisible: H,
790
- onToggleFocal: () => T((t) => !t),
791
- gbifEnabled: !!c,
792
- gbifVisible: j,
793
- gbifAvailable: p,
794
- onToggleGbif: Ye,
795
- descendantStatus: g.status,
796
- descendantsByRank: Je,
797
- descendantColors: Y,
798
- visibleTaxonIds: P,
799
- onToggleTaxon: Qe,
800
- onToggleRankGroup: et,
801
- onRetry: () => {
802
- ce.current = !1, M({ status: "idle", taxa: [] }), Ie();
803
- }
804
- }
805
- ),
806
- !ve && (xe.length > 0 || c && p !== !1 && j) && /* @__PURE__ */ n.jsxs(
807
- "div",
808
- {
809
- style: {
810
- position: "absolute",
811
- bottom: 8,
812
- left: 8,
813
- zIndex: 1,
814
- background: "#fff",
815
- borderRadius: 4,
816
- boxShadow: "0 1px 4px rgba(0,0,0,0.2)",
817
- padding: "6px 8px",
818
- fontSize: 12,
819
- lineHeight: 1.5
820
- },
821
- children: [
822
- xe.map((t) => /* @__PURE__ */ n.jsxs(
823
- "div",
824
- {
825
- style: { display: "flex", alignItems: "center", gap: 6 },
826
- children: [
827
- /* @__PURE__ */ n.jsx(
828
- "span",
829
- {
830
- style: {
831
- display: "inline-block",
832
- width: 12,
833
- height: 12,
834
- background: t.color,
835
- border: "1px solid rgba(0,0,0,0.15)",
836
- borderRadius: 2
837
- }
838
- }
839
- ),
840
- /* @__PURE__ */ n.jsx("span", { children: t.label })
841
- ]
842
- },
843
- t.key
844
- )),
845
- c && p !== !1 && j && /* @__PURE__ */ n.jsx(Ut, {})
846
- ]
847
- }
848
- ),
849
- ve && /* @__PURE__ */ n.jsx(
850
- _t,
851
- {
852
- visibleGroups: le.visibleGroups,
853
- unmappableGroups: le.unmappableGroups,
854
- showGbif: !!c && p !== !1 && j
855
- }
856
- )
857
- ]
858
- }
859
- );
860
- }, Tt = ({
861
- open: e,
862
- onOpen: r,
863
- onClose: s,
864
- focalName: a,
865
- focalReady: o,
866
- focalVisible: c,
867
- onToggleFocal: p,
868
- gbifEnabled: f,
869
- gbifVisible: u,
870
- gbifAvailable: i,
871
- onToggleGbif: y,
872
- descendantStatus: x,
873
- descendantsByRank: R,
874
- descendantColors: E,
875
- visibleTaxonIds: I,
876
- onToggleTaxon: B,
877
- onToggleRankGroup: G,
878
- onRetry: k
879
- }) => e ? /* @__PURE__ */ n.jsxs(
880
- "div",
881
- {
882
- style: {
883
- position: "absolute",
884
- // Aligns with the collapsed "+" button, below the fullscreen control.
885
- top: 48,
886
- right: 10,
887
- zIndex: 2,
888
- background: "#fff",
889
- borderRadius: 4,
890
- boxShadow: "0 1px 4px rgba(0,0,0,0.2)",
891
- padding: "6px 10px",
892
- fontSize: 12,
893
- lineHeight: 1.5,
894
- maxHeight: 320,
895
- overflowY: "auto",
896
- minWidth: 160
897
- },
898
- onMouseLeave: s,
899
- children: [
900
- /* @__PURE__ */ n.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
901
- /* @__PURE__ */ n.jsx(
902
- "input",
903
- {
904
- type: "checkbox",
905
- checked: c,
906
- disabled: !o,
907
- onChange: p
908
- }
909
- ),
910
- /* @__PURE__ */ n.jsx("span", { style: { fontStyle: "italic" }, children: a })
911
- ] }),
912
- f && /* @__PURE__ */ n.jsxs(
913
- "div",
914
- {
915
- style: {
916
- display: "flex",
917
- alignItems: "center",
918
- gap: 6,
919
- opacity: i === !1 ? 0.5 : 1
920
- },
921
- title: i === !1 ? "GBIF has no occurrence records for this taxon." : void 0,
922
- children: [
923
- /* @__PURE__ */ n.jsx(
924
- "input",
925
- {
926
- type: "checkbox",
927
- checked: i === !1 ? !1 : u,
928
- disabled: i === !1,
929
- onChange: y
930
- }
931
- ),
932
- /* @__PURE__ */ n.jsx("span", { children: "GBIF occurrences" })
933
- ]
934
- }
935
- ),
936
- x === "loading" && /* @__PURE__ */ n.jsx("div", { style: { marginTop: 6, color: "#888" }, children: "Loading descendants…" }),
937
- x === "error" && /* @__PURE__ */ n.jsxs("div", { style: { marginTop: 6, color: "#888" }, children: [
938
- "Couldn't load descendants.",
939
- " ",
940
- /* @__PURE__ */ n.jsx("a", { onClick: k, style: { cursor: "pointer" }, children: "Retry" })
941
- ] }),
942
- x === "ready" && R.map((w) => {
943
- const N = w.taxa.every((g) => I.has(g.id)), V = w.taxa.some((g) => I.has(g.id));
944
- return /* @__PURE__ */ n.jsxs("div", { style: { marginTop: 6 }, children: [
945
- /* @__PURE__ */ n.jsxs(
946
- "label",
947
- {
948
- style: {
949
- display: "flex",
950
- alignItems: "center",
951
- gap: 6,
952
- fontWeight: 600
953
- },
954
- children: [
955
- /* @__PURE__ */ n.jsx(
956
- "input",
957
- {
958
- type: "checkbox",
959
- checked: N,
960
- ref: (g) => {
961
- g && (g.indeterminate = !N && V);
962
- },
963
- onChange: () => G(w.taxa)
964
- }
965
- ),
966
- w.label
967
- ]
968
- }
969
- ),
970
- /* @__PURE__ */ n.jsx("div", { style: { paddingLeft: 18 }, children: w.taxa.map((g) => /* @__PURE__ */ n.jsxs(
971
- "label",
972
- {
973
- style: {
974
- display: "flex",
975
- alignItems: "center",
976
- gap: 6
977
- },
978
- children: [
979
- /* @__PURE__ */ n.jsx(
980
- "input",
981
- {
982
- type: "checkbox",
983
- checked: I.has(g.id),
984
- onChange: () => B(g.id)
985
- }
986
- ),
987
- /* @__PURE__ */ n.jsx(
988
- "span",
989
- {
990
- style: {
991
- display: "inline-block",
992
- width: 10,
993
- height: 10,
994
- background: E[g.id],
995
- border: "1px solid rgba(0,0,0,0.15)",
996
- borderRadius: 2
997
- }
998
- }
999
- ),
1000
- /* @__PURE__ */ n.jsx("span", { style: { fontStyle: "italic" }, children: Ke(g.scientificName) })
1001
- ]
1002
- },
1003
- g.id
1004
- )) })
1005
- ] }, w.rank);
1006
- })
1007
- ]
1008
- }
1009
- ) : /* @__PURE__ */ n.jsx(
1010
- "button",
1011
- {
1012
- type: "button",
1013
- onClick: r,
1014
- onMouseEnter: r,
1015
- title: "Layers",
1016
- style: {
1017
- position: "absolute",
1018
- // Sits just below the maplibre fullscreen control (top-right).
1019
- top: 48,
1020
- right: 10,
1021
- zIndex: 2,
1022
- width: 30,
1023
- height: 30,
1024
- background: "#fff",
1025
- border: "1px solid rgba(0,0,0,0.2)",
1026
- borderRadius: 4,
1027
- cursor: "pointer",
1028
- fontSize: 18,
1029
- lineHeight: "26px",
1030
- padding: 0,
1031
- boxShadow: "0 1px 4px rgba(0,0,0,0.2)"
1032
- },
1033
- children: "+"
1034
- }
1035
- ), Yt = (e) => {
1036
- var r, s;
1037
- return ((r = e == null ? void 0 : e.area) == null ? void 0 : r.gazetteer) !== "text" && !!((s = e == null ? void 0 : e.area) != null && s.globalId);
1038
- }, Me = ({ datasetKey: e, data: r }) => {
1039
- const [s, a] = L({});
1040
- return $(() => {
1041
- let o = !1;
1042
- for (let c = 0; c < r.length; c++)
1043
- if (r[c].gazetteer === "iso") {
1044
- o = !0;
1045
- break;
1046
- }
1047
- o && ne(`${z.dataApi}vocab/country`).then((c) => {
1048
- a(it(c.data, "alpha3"));
1049
- });
1050
- }, []), /* @__PURE__ */ n.jsx("div", { children: r.map((o, c) => /* @__PURE__ */ n.jsxs("span", { children: [
1051
- (o == null ? void 0 : o.merged) && /* @__PURE__ */ n.jsx(
1052
- pt,
1053
- {
1054
- createdBy: o == null ? void 0 : o.createdBy,
1055
- datasetKey: o.datasetKey,
1056
- sourceDatasetKey: o == null ? void 0 : o.sourceDatasetKey,
1057
- verbatimSourceKey: o == null ? void 0 : o.verbatimSourceKey,
1058
- style: { marginRight: "4px" }
1059
- }
1060
- ),
1061
- (O(s, `[${O(o, "area.name")}].name`) ? ct(O(s, `[${O(o, "area.name")}].name`)) : null) || O(o, "area.name") || O(o, "area.globalId"),
1062
- " ",
1063
- o.referenceId && /* @__PURE__ */ n.jsx(
1064
- bt,
1065
- {
1066
- datasetKey: e,
1067
- referenceId: o.referenceId,
1068
- placement: "bottom"
1069
- }
1070
- ),
1071
- c < r.length - 1 && ", "
1072
- ] }, c)) });
1073
- }, dn = ({
1074
- datasetKey: e,
1075
- data: r,
1076
- style: s,
1077
- showDistributionMap: a,
1078
- focalTaxon: o,
1079
- rankOrder: c,
1080
- gbifChecklistKey: p,
1081
- label: f,
1082
- md: u
1083
- }) => {
1084
- const i = r.filter(Yt), y = r.length - i.length, x = !!p, R = r.length > 0, [E, I] = L("map"), [B, G] = L(0), [k, w] = L(null);
1085
- $(() => {
1086
- if (!p || !(o != null && o.id)) {
1087
- w(null);
1088
- return;
1089
- }
1090
- w(null);
1091
- let j = !1;
1092
- return lt.get(`${z.gbifApi}/v1/occurrence/search`, {
1093
- params: {
1094
- checklistKey: p,
1095
- taxonKey: o.id,
1096
- hasCoordinate: !0,
1097
- hasGeospatialIssue: !1,
1098
- occurrenceStatus: "PRESENT",
1099
- limit: 0
1100
- }
1101
- }).then(
1102
- (A) => {
1103
- var P;
1104
- j || w(((P = A == null ? void 0 : A.data) == null ? void 0 : P.count) ?? 0);
1105
- },
1106
- () => {
1107
- j || w(null);
1108
- }
1109
- ), () => {
1110
- j = !0;
1111
- };
1112
- }, [p, o == null ? void 0 : o.id]);
1113
- const N = x ? k === null || k > 0 : !1, V = i.length > 0 && B >= i.length, g = a && (i.length > 0 || N) && !(i.length > 0 && V && !N);
1114
- if (!g && !R) return null;
1115
- const M = y + B, H = R;
1116
- let T;
1117
- if (!g)
1118
- T = /* @__PURE__ */ n.jsx(Me, { datasetKey: e, data: r });
1119
- else {
1120
- const j = H ? E : "map";
1121
- T = /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
1122
- H ? /* @__PURE__ */ n.jsxs(
1123
- ue.Group,
1124
- {
1125
- size: "small",
1126
- value: j,
1127
- onChange: (A) => I(A.target.value),
1128
- style: { marginBottom: 8 },
1129
- children: [
1130
- /* @__PURE__ */ n.jsx(ue.Button, { value: "map", children: "Map" }),
1131
- /* @__PURE__ */ n.jsx(ue.Button, { value: "list", children: "List" })
1132
- ]
1133
- }
1134
- ) : (
1135
- // Reserve the vertical space the Map/List toggle would occupy so the
1136
- // map's top edge lines up with the "Distributions" label.
1137
- /* @__PURE__ */ n.jsx("div", { style: { height: 24, marginBottom: 8 } })
1138
- ),
1139
- j === "map" ? /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
1140
- /* @__PURE__ */ n.jsx(
1141
- Kt,
1142
- {
1143
- records: i,
1144
- onUnmappable: G,
1145
- datasetKey: e,
1146
- focalTaxon: o,
1147
- rankOrder: c,
1148
- gbifChecklistKey: p,
1149
- gbifAvailable: N
1150
- }
1151
- ),
1152
- H && M > 0 && /* @__PURE__ */ n.jsx("div", { style: { marginTop: 6 }, children: /* @__PURE__ */ n.jsxs("a", { onClick: () => I("list"), style: { cursor: "pointer" }, children: [
1153
- "+",
1154
- M,
1155
- " distribution",
1156
- M === 1 ? "" : "s",
1157
- " not on map"
1158
- ] }) })
1159
- ] }) : /* @__PURE__ */ n.jsx(Me, { datasetKey: e, data: r })
1160
- ] });
1161
- }
1162
- const re = /* @__PURE__ */ n.jsx("div", { style: s, children: T });
1163
- return f ? /* @__PURE__ */ n.jsx(ft, { md: u, label: f, children: re }) : re;
1164
- };
1165
- export {
1166
- dn as D,
1167
- bt as R
1168
- };
1169
- //# sourceMappingURL=Distributions-Bd4hFYdS.js.map