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