col-browser 2.6.6 → 2.8.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 CHANGED
@@ -61,7 +61,7 @@ Then mount any component using `ColBrowser.React` and `ColBrowser.ReactDOM`:
61
61
  </script>
62
62
  ```
63
63
 
64
- (`ColBrowser.Taxon` and `ColBrowser.TaxonDistribution` additionally need MapLibre GL JS loaded separately — see those components below.)
64
+ (`ColBrowser.Taxon` and `ColBrowser.TaxonDistribution` additionally need MapLibre GL JS 6 loaded separately, from a module script — see [those components below](#colbrowsertaxon).)
65
65
 
66
66
  The full version list is on the [releases page](https://github.com/CatalogueOfLife/portal-components/releases).
67
67
 
@@ -282,12 +282,13 @@ A [browsable taxonomic tree](https://www.catalogueoflife.org/data/browse). Compo
282
282
  1. `datasetKey` - the dataset key from the [Catalogue of Life ChecklistBank](https://www.checklistbank.org/).
283
283
  2. `expandedTaxonKey` - (Optional, controlled) which taxon the tree is expanded down to. Pair with `onExpandedTaxonKeyChange` to keep host state in sync.
284
284
  3. `onExpandedTaxonKeyChange` - (Optional) called with the new key when the user expands a different taxon.
285
- 4. `defaultTaxonKey` - (Optional, uncontrolled fallback) initial taxon to expand to when `expandedTaxonKey` is not provided. Nothing is expanded unless one of these is set — pass a root id to open it on load, e.g. `defaultTaxonKey="CS5HF"` opens Eukaryota in current Catalogue of Life releases.
285
+ 4. `defaultTaxonKey` - (Optional, uncontrolled fallback) initial taxon to expand to when `expandedTaxonKey` is not provided. Nothing is expanded unless one of these is set — pass a root id to open it on load, e.g. `defaultTaxonKey="CS5HF"` opens Eukaryota in current Catalogue of Life releases. The page scrolls to an `expandedTaxonKey` on load, but not to a `defaultTaxonKey`.
286
286
  5. `showTreeOptions` - (Optional) show toggles for extinct taxa and info (estimates, providers etc).
287
287
  6. `linkToSpeciesPage` - (Optional) when the searchbox finds a species or infraspecific taxon, jump directly to the taxon page rather than opening the tree.
288
288
  7. `citation` - (Optional) either `"top"` or `"bottom"`; include the necessary dataset citation above or below the tree component.
289
289
  8. `type` - (Optional) e.g. `type="project"` will show info about contributing sources on the tree nodes.
290
290
  9. `insertPlaceholder` - (Optional, defaults to `true`) when true, the API virtually groups children of lower ranks into a "Not assigned" placeholder node for a more compact browsing experience. Pass `false` to disable.
291
+ 10. `autoFocus` - (Optional, defaults to `true`) focus the search box when the tree loads. Pass `false` when the tree is not the main thing on the page, so it does not take the focus or scroll the page to itself.
291
292
 
292
293
  ```html
293
294
  <div id="tree"></div> <!-- Dom element for the tree to attach to -->
@@ -378,7 +379,7 @@ ColBrowser.ReactDOM.createRoot(document.querySelector('#search')).render(
378
379
  2. `taxonKey` - (controlled) the taxon to render. Read by the host from its URL and passed in.
379
380
  3. `pageTitleTemplate` - (Optional) a template for formatting the page title. A string containing the variable `__taxon__` that will be replaced with the taxon name.
380
381
  4. `identifierLabel` - (Optional) label for the identifier listed on top of the taxon view. Defaults to `"Identifier"`.
381
- 5. `showDistributionMap` - (Optional) When `true`, render an interactive MapLibre GL map for distributions whose areas have a known geometry, with a toggle to switch to the plain text list view. The basemap defaults to the keyless CARTO Positron vector style; override it with the `basemapStyle` prop below or globally via [`configure()`](#api-endpoint-optional). **Requires the consumer to load MapLibre GL JS 4+ or 5+ and its CSS** (peer dependency).
382
+ 5. `showDistributionMap` - (Optional) When `true`, render an interactive MapLibre GL map for distributions whose areas have a known geometry, with a toggle to switch to the plain text list view. The basemap defaults to the keyless CARTO Positron vector style; override it with the `basemapStyle` prop below or globally via [`configure()`](#api-endpoint-optional). **Requires the consumer to load MapLibre GL JS 6.4.1+ and its CSS** (peer dependency).
382
383
  6. `gbifChecklistKey` - (Optional) When set, the distribution map adds a GBIF occurrence overlay (iNaturalist.poly hex bins) for the focal taxon, using the GBIF v2 multitaxonomy tile endpoint. The value is passed as the `checklistKey` query parameter; the focal taxon's id is passed as `taxonKey`. **The consumer is responsible for only setting this when the configured `datasetKey` actually uses identifiers that GBIF recognises under the given checklist.** For datasets keyed by COL identifiers, use the Catalogue of Life backbone UUID:
383
384
 
384
385
  ```
@@ -389,12 +390,30 @@ ColBrowser.ReactDOM.createRoot(document.querySelector('#search')).render(
389
390
 
390
391
  To use the map, include MapLibre GL JS alongside React in your page:
391
392
 
393
+ MapLibre 6 ships ES modules only, so load it from a module script and expose it as the `maplibregl` global the UMD bundle expects. Load `col-browser` with `defer` and mount from a module script, so all three run in document order after the page has parsed:
394
+
392
395
  ```html
393
- <link rel="stylesheet" href="https://unpkg.com/maplibre-gl@5/dist/maplibre-gl.css" />
394
- <script src="https://unpkg.com/maplibre-gl@5/dist/maplibre-gl.js"></script>
396
+ <link rel="stylesheet" href="https://unpkg.com/maplibre-gl@6/dist/maplibre-gl.css" />
397
+ <script type="module">
398
+ import * as maplibregl from "https://unpkg.com/maplibre-gl@6/dist/maplibre-gl.mjs";
399
+ window.maplibregl = maplibregl;
400
+ </script>
401
+ <script defer src="https://cdn.jsdelivr.net/gh/CatalogueOfLife/portal-components@2/umd/col-browser.min.js"></script>
402
+ <script type="module">
403
+ // ColBrowser.ReactDOM.createRoot(...).render(...)
404
+ </script>
395
405
  ```
396
406
 
397
- ES module consumers: `npm install maplibre-gl` and `import "maplibre-gl/dist/maplibre-gl.css"` in your bundle entry.
407
+ ES module consumers: `npm install maplibre-gl@6`, import its CSS in your bundle entry, and tell MapLibre where its worker is. MapLibre 6 can't find the worker inside a bundle, so call `setWorkerUrl` once before any map is created. With Vite (including Astro):
408
+
409
+ ```js
410
+ import "maplibre-gl/dist/maplibre-gl.css";
411
+ import { setWorkerUrl } from "maplibre-gl";
412
+ import workerUrl from "maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url";
413
+ setWorkerUrl(workerUrl);
414
+ ```
415
+
416
+ Other bundlers: see [MapLibre's installation guide](https://maplibre.org/maplibre-gl-js/docs/#installation).
398
417
 
399
418
  ```html
400
419
  <div id="taxon"></div>
@@ -444,11 +463,11 @@ ColBrowser.ReactDOM.createRoot(document.querySelector('#taxon')).render(
444
463
 
445
464
  ### ColBrowser.TaxonBreakdown
446
465
 
447
- A Highcharts pie chart breaking the accepted children of a taxon down by rank, with click-to-drill into each child. Rendered inside the Taxon page but also exported standalone for use on dashboards or summary pages. Component-specific props:
466
+ A Highcharts pie chart breaking the accepted children of a taxon down by rank, with click-to-drill into each child. The API decides what the slices count (species, or genera where genera outnumber species more than twofold) and which ranks form the rings, and adds a "Not assigned" slice for what sits in no child. Rendered inside the Taxon page but also exported standalone for use on dashboards or summary pages. Component-specific props:
448
467
 
449
468
  1. `datasetKey` - the dataset key from the [Catalogue of Life ChecklistBank](https://www.checklistbank.org/).
450
- 2. `taxonId` - (controlled) the taxon to break down. The chart loads the taxon, its rank vocabulary, and the dataset citation itself, so no preloading is needed.
451
- 3. `level` - (Optional, `1` or `2`, default `1`) controls how deep the breakdown nests. `1` renders a single-ring donut (direct children of `taxonId`). `2` renders a two-ring donut adding grandchildren. The value is passed through as the `level` query parameter on the `/dataset/{key}/taxon/{id}/breakdown` API.
469
+ 2. `taxonId` - (controlled) the taxon to break down. The chart loads the taxon and the dataset citation itself, so no preloading is needed.
470
+ 3. `level` - (Optional, `1` or `2`, default `1`) the most rings to draw. `1` renders a single-ring donut (direct children of `taxonId`). `2` adds grandchildren as a second ring, unless the API decides that ring is not worth drawing (it would be the counted rank itself, or hold more than 1000 taxa). The value is passed through as the `level` query parameter on the `/dataset/{key}/taxon/{id}/breakdown` API, which returns a `TaxonBreakdown` object since ChecklistBank API 2026-11; older API versions are not supported.
452
471
  4. `showLevelSwitch` - (Optional, default `false`) when `true`, render an in-chart antd `Switch` that lets the user toggle between level 1 and 2 at runtime.
453
472
  5. `darkMode` - (Optional) when `true`, use the dark-mode outer-ring gap colour. Falls back to `prefers-color-scheme` when unset.
454
473
 
@@ -498,12 +517,9 @@ The Taxon page's distribution block — a MapLibre GL vector map of the taxon's
498
517
  4. `style` - (Optional) inline style passed through to the outer wrapper. Note this is the wrapper's CSS, not the map style — see `basemapStyle` below.
499
518
  5. `basemapStyle` - (Optional) MapLibre style for the basemap under the distribution polygons — a style URL with your provider's API key baked in, or an inline style object. Overrides the global [`configure({ basemapStyle })`](#basemap) default for this map only, and can be changed at runtime: the map rebuilds on the new style in place. Pass an inline style object from a stable reference, not an object literal.
500
519
 
501
- **Requires the consumer to load MapLibre GL JS 4+ or 5+ and its CSS** (peer dependency), same as `ColBrowser.Taxon` with `showDistributionMap`:
520
+ **Requires the consumer to load MapLibre GL JS 6.4.1+ and its CSS** (peer dependency), same as `ColBrowser.Taxon` with `showDistributionMap`:
502
521
 
503
- ```html
504
- <link rel="stylesheet" href="https://unpkg.com/maplibre-gl@5/dist/maplibre-gl.css" />
505
- <script src="https://unpkg.com/maplibre-gl@5/dist/maplibre-gl.js"></script>
506
- ```
522
+ See [`ColBrowser.Taxon`](#colbrowsertaxon) for how to load MapLibre 6 next to the UMD bundle.
507
523
 
508
524
  ```html
509
525
  <div id="distribution"></div>
@@ -12,7 +12,7 @@ import { E as vt, M as jt } from "./ErrorMsg-D5nALHuK.js";
12
12
  import { R as St } from "./LinkOutlined-2IkQWTV7.js";
13
13
  import { I as wt } from "./AntdIcon-B1nMlqyh.js";
14
14
  import { P as It } from "./PresentationItem-C4yZ555-.js";
15
- import Y from "maplibre-gl";
15
+ import * as Y from "maplibre-gl";
16
16
  import "maplibre-gl/dist/maplibre-gl.css";
17
17
  import { r as Lt, w as kt } from "./storage-BgdCo9fV.js";
18
18
  var Rt = { 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" };
@@ -333,10 +333,10 @@ const de = [
333
333
  let me = null;
334
334
  const Jt = () => {
335
335
  var e, n;
336
- if (typeof window > "u" || !window.WebGLRenderingContext)
336
+ if (typeof window > "u" || !window.WebGL2RenderingContext)
337
337
  return !1;
338
338
  try {
339
- const s = document.createElement("canvas"), o = s.getContext("webgl2") || s.getContext("webgl");
339
+ const o = document.createElement("canvas").getContext("webgl2");
340
340
  return !o || typeof o.getParameter != "function" ? !1 : ((n = (e = o.getExtension) == null ? void 0 : e.call(o, "WEBGL_lose_context")) == null || n.loseContext(), !0);
341
341
  } catch {
342
342
  return !1;
@@ -1127,7 +1127,7 @@ const Jt = () => {
1127
1127
  ),
1128
1128
  c < n.length - 1 && ", "
1129
1129
  ] }, c)) });
1130
- }, kn = ({
1130
+ }, Ln = ({
1131
1131
  datasetKey: e,
1132
1132
  data: n,
1133
1133
  style: s,
@@ -1225,8 +1225,8 @@ const Jt = () => {
1225
1225
  return d ? /* @__PURE__ */ r.jsx(It, { md: p, label: d, children: A }) : A;
1226
1226
  };
1227
1227
  export {
1228
- kn as D,
1228
+ Ln as D,
1229
1229
  Me as R,
1230
1230
  Bt as a
1231
1231
  };
1232
- //# sourceMappingURL=Distributions-CHjEIZ3F.js.map
1232
+ //# sourceMappingURL=Distributions-DKMGoRMJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Distributions-DKMGoRMJ.js","sources":["../../node_modules/@ant-design/icons-svg/es/asn/BookOutlined.js","../../node_modules/@ant-design/icons/es/icons/BookOutlined.js","../../src/components/ReferenceLink.js","../../src/Taxon/ReferencePopover.js","../../src/Taxon/DistributionsMap/descendantRanks.js","../../src/Taxon/DistributionsMap/descendantFetch.js","../../src/Taxon/DistributionsMap/colorAssignment.js","../../src/Taxon/DistributionsMap/basemap.js","../../src/Taxon/DistributionsMap/IncludedTaxaLegend.js","../../src/Taxon/DistributionsMap/webgl.js","../../src/Taxon/DistributionsMap/index.js","../../src/Taxon/Distributions.js"],"sourcesContent":["// This icon file is generated automatically.\nvar BookOutlined = { \"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\" };\nexport default BookOutlined;\n","function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n// GENERATE BY ./scripts/generate.ts\n// DON NOT EDIT IT MANUALLY\n\nimport * as React from 'react';\nimport BookOutlinedSvg from \"@ant-design/icons-svg/es/asn/BookOutlined\";\nimport AntdIcon from \"../components/AntdIcon\";\nconst BookOutlined = (props, ref) => /*#__PURE__*/React.createElement(AntdIcon, _extends({}, props, {\n ref: ref,\n icon: BookOutlinedSvg\n}));\n\n/**![book](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAiIGhlaWdodD0iNTAiIGZpbGw9IiNjYWNhY2EiIHZpZXdCb3g9IjY0IDY0IDg5NiA4OTYiIGZvY3VzYWJsZT0iZmFsc2UiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTgzMiA2NEgxOTJjLTE3LjcgMC0zMiAxNC4zLTMyIDMydjgzMmMwIDE3LjcgMTQuMyAzMiAzMiAzMmg2NDBjMTcuNyAwIDMyLTE0LjMgMzItMzJWOTZjMC0xNy43LTE0LjMtMzItMzItMzJ6bS0yNjAgNzJoOTZ2MjA5LjlMNjIxLjUgMzEyIDU3MiAzNDcuNFYxMzZ6bTIyMCA3NTJIMjMyVjEzNmgyODB2Mjk2LjljMCAzLjMgMSA2LjYgMyA5LjNhMTUuOSAxNS45IDAgMDAyMi4zIDMuN2w4My44LTU5LjkgODEuNCA1OS40YzIuNyAyIDYgMy4xIDkuNCAzLjEgOC44IDAgMTYtNy4yIDE2LTE2VjEzNmg2NHY3NTJ6IiAvPjwvc3ZnPg==) */\nconst RefIcon = /*#__PURE__*/React.forwardRef(BookOutlined);\nif (process.env.NODE_ENV !== 'production') {\n RefIcon.displayName = 'BookOutlined';\n}\nexport default RefIcon;","import { LinkOutlined } from \"@ant-design/icons\";\n\n// DOIs arrive in several spellings: bare, \"doi:\"-prefixed or as a resolver URL.\nconst DOI_PREFIX_RE = /^(doi:|https?:\\/\\/(dx\\.)?doi\\.org\\/)/i;\n\n/**\n * The link of a reference: its csl.URL (e.g. a BHL page), else a doi.org link\n * for its csl.DOI. Both usually live only in the CSL data, not in the\n * citation string.\n */\nexport const referenceHref = (reference) => {\n const csl = reference?.csl;\n if (csl?.URL) return csl.URL;\n if (csl?.DOI) return `https://doi.org/${csl.DOI.trim().replace(DOI_PREFIX_RE, \"\")}`;\n return undefined;\n};\n\n/**\n * A link icon pointing at the reference's URL or DOI. Renders nothing when\n * there is none, or when the citation already contains that exact link (it is\n * linkified there).\n */\nconst ReferenceLink = ({ reference }) => {\n const href = referenceHref(reference);\n if (!href || reference.citation?.includes(href)) return null;\n return (\n <>\n {\" \"}\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\">\n <LinkOutlined />\n </a>\n </>\n );\n};\n\nexport default ReferenceLink;\n","import React from \"react\";\nimport { BookOutlined } from \"@ant-design/icons\";\nimport { Popover, Spin } from \"antd\";\nimport client from \"../api/client\";\nimport config from \"../config\";\nimport { get, isArray } from \"lodash-es\";\nimport ErrorMsg from \"../components/ErrorMsg\";\nimport ReferenceLink from \"../components/ReferenceLink\";\n\nclass ReferencePopover extends React.Component {\n constructor(props) {\n super(props);\n\n this.state = {\n reference: [],\n loading: false,\n error: null,\n };\n }\n\n getData = () => {\n const { referenceId, datasetKey, references } = this.props;\n if (referenceId) {\n const refIds = !isArray(referenceId) ? [referenceId] : referenceId;\n const reference = [];\n this.setState({ loading: true });\n Promise.allSettled(\n refIds.map((id) => get(references, id) ? Promise.resolve(reference.push(references[id])) :\n\n client(\n `${config.dataApi}dataset/${datasetKey}/reference/${id}`\n ).then((res) => reference.push(res.data)).catch(err => this.setState({error: err}))\n\n \n )\n ).then(() => this.setState({ reference, loading: false }));\n }\n };\n\n getContent = () => {\n const { error, reference, loading } = this.state;\n if (loading) {\n return <Spin />;\n } else if (error) {\n return <ErrorMsg error={error}/>;\n } else if (reference.length === 1) {\n return (\n <>\n {reference[0].citation}\n <ReferenceLink reference={reference[0]} />\n </>\n );\n } else {\n return (\n <ul>\n {reference.map((r) => (\n <li key={r.id}>\n {r.citation}\n <ReferenceLink reference={r} />\n </li>\n ))}\n </ul>\n );\n }\n };\n\n scrollToReference = (e, id) => {\n // Default <a href=\"#col-reference-{id}\"> behaviour writes the hash into\n // window.location, which hijacks hosts using hash-based routing (the\n // GitHub Pages demo, COL portal preview). Scroll without touching the\n // URL.\n const el = document.getElementById(`col-reference-${id}`);\n if (el) {\n e.preventDefault();\n el.scrollIntoView({ behavior: \"smooth\", block: \"start\" });\n }\n };\n\n render = () => {\n const { referenceId, referenceIndexMap, trigger } = this.props;\n // Cap the inline [n] markers so a name linked to many references does not\n // render an unreadable trail across the row. Overflow collapses into a\n // \"+N\" indicator; the hover popover still lists every citation.\n const maxInline = this.props.maxInline || 4;\n const refIds = !isArray(referenceId) ? [referenceId] : referenceId;\n let icon = referenceIndexMap && get(referenceIndexMap, refIds[0])\n ? (() => {\n const shown = refIds.slice(0, maxInline);\n const overflow = refIds.length - shown.length;\n return [\n ...shown.map((r) => (\n <a\n key={r}\n className=\"col-reference-link\"\n href={`#col-reference-${r}`}\n onClick={(e) => this.scrollToReference(e, r)}\n >\n {`[${referenceIndexMap[r]}]`}\n </a>\n )),\n overflow > 0 ? (\n <span key=\"overflow\" className=\"col-reference-link\">\n {` +${overflow}`}\n </span>\n ) : null,\n ];\n })()\n : <BookOutlined style={{ cursor: \"pointer\" }} />;\n\n return referenceId ? (\n <div id={`reference_${referenceId}`} key={`reference_${referenceId}`} style={this.props.style}>\n <Popover\n getPopupContainer={() =>\n document.getElementById(`reference_${referenceId}`)\n }\n placement={this.props.placement || \"left\"}\n title=\"Reference\"\n onOpenChange={(visible) => visible && this.getData()}\n content={\n <div\n style={{\n maxWidth: \"500px\",\n maxHeight: \"60vh\",\n overflowY: \"auto\",\n }}\n >\n {this.getContent()}\n </div>\n }\n trigger={trigger || \"hover\"}\n >\n {icon}\n </Popover>\n </div>\n ) : (\n \"\"\n );\n };\n}\n\nexport default ReferencePopover;\n","export const INFRASPECIFIC_RANKS = [\n \"subspecies\",\n \"variety\",\n \"subvariety\",\n \"form\",\n \"subform\",\n \"infraspecific name\",\n];\n\nexport const getDescendantRanks = (focalRank, rankOrder) => {\n const focalIdx = rankOrder.indexOf(focalRank);\n if (focalIdx === -1) return [];\n return INFRASPECIFIC_RANKS.filter((r) => {\n const i = rankOrder.indexOf(r);\n return i > focalIdx;\n });\n};\n","import client from \"../../api/client\";\nimport config from \"../../config\";\nimport { getDescendantRanks } from \"./descendantRanks\";\n\nconst POOL_SIZE = 16;\n\nconst isMappable = (r) =>\n r?.area?.gazetteer !== \"text\" && !!r?.area?.globalId;\n\nconst runPool = async (items, worker, size) => {\n const results = new Array(items.length);\n let next = 0;\n const runners = Array.from({ length: Math.min(size, items.length) }, async () => {\n while (true) {\n const i = next++;\n if (i >= items.length) return;\n results[i] = await worker(items[i], i);\n }\n });\n await Promise.all(runners);\n return results;\n};\n\nconst searchDescendants = async (datasetKey, focalId, ranks) => {\n if (ranks.length === 0) return [];\n const params = new URLSearchParams();\n params.append(\"TAXON_ID\", focalId);\n ranks.forEach((r) => params.append(\"rank\", r));\n [\"accepted\", \"provisionally accepted\"].forEach((s) =>\n params.append(\"status\", s)\n );\n params.append(\"limit\", \"1000\");\n const url = `${config.dataApi}dataset/${datasetKey}/nameusage/search?${params}`;\n const res = await client(url);\n const list = res?.data?.result || [];\n return list\n .filter((u) => u?.usage?.id)\n .map((u) => ({\n id: u.usage.id,\n scientificName:\n u.usage?.name?.scientificName || u.usage?.label || u.usage.id,\n rank: u.usage?.name?.rank,\n parentId: u.usage?.parentId,\n }));\n};\n\nconst fetchDistributions = async (datasetKey, taxonId) => {\n const url = `${config.dataApi}dataset/${datasetKey}/taxon/${encodeURIComponent(taxonId)}/distribution`;\n try {\n const res = await client(url);\n return Array.isArray(res?.data) ? res.data : [];\n } catch {\n return [];\n }\n};\n\n/**\n * Fetch all infraspecific descendants of `focalTaxon` and their distributions.\n * Returns { taxa, descendantsFailed } where each taxon carries `mappable` (the\n * mappable subset of its distributions) and `distributions` (the full list).\n */\nexport const fetchDescendants = async ({ datasetKey, focalTaxon, rankOrder }) => {\n const ranks = getDescendantRanks(focalTaxon?.name?.rank, rankOrder);\n let descendantsFailed = false;\n let list = [];\n try {\n list = await searchDescendants(datasetKey, focalTaxon.id, ranks);\n } catch {\n descendantsFailed = true;\n return { taxa: [], descendantsFailed };\n }\n\n const distributions = await runPool(\n list,\n (t) => fetchDistributions(datasetKey, t.id),\n POOL_SIZE\n );\n\n const taxa = list.map((t, i) => {\n const all = distributions[i] || [];\n return { ...t, distributions: all, mappable: all.filter(isMappable) };\n });\n return { taxa, descendantsFailed };\n};\n","export const VIVID_PALETTE = [\n \"#E58606\",\n \"#5D69B1\",\n \"#52BCA3\",\n \"#99C945\",\n \"#CC61B0\",\n \"#24796C\",\n \"#DAA51B\",\n \"#2F8AC4\",\n \"#764E9F\",\n \"#ED645A\",\n \"#CC3A8E\",\n \"#A5AA99\",\n];\n\nconst rankIndex = (rank, rankOrder) => {\n const i = rankOrder.indexOf(rank);\n return i === -1 ? rankOrder.length : i;\n};\n\nexport const assignColors = (taxa, rankOrder) => {\n const sorted = [...taxa].sort((a, b) => {\n const ra = rankIndex(a.rank, rankOrder);\n const rb = rankIndex(b.rank, rankOrder);\n if (ra !== rb) return ra - rb;\n return a.scientificName.localeCompare(b.scientificName);\n });\n const out = {};\n sorted.forEach((t, i) => {\n out[t.id] = VIVID_PALETTE[i % VIVID_PALETTE.length];\n });\n return out;\n};\n","import config from \"../../config\";\n\n/**\n * The MapLibre style spec the distribution map should render on.\n *\n * A per-instance `basemapStyle` prop wins over the global `configure()`\n * default. Either may be a style URL or an inline style object — whatever\n * MapLibre accepts as `style`.\n */\nexport const resolveBasemapStyle = (prop) => prop ?? config.basemapStyle;\n\n// CARTO serves the style from basemaps.cartocdn.com and the tiles, glyphs and\n// sprites from tiles*.basemaps.cartocdn.com.\nconst CARTO_HOST = /(^|\\.)cartocdn\\.com$/i;\n\n/**\n * A MapLibre `transformRequest` that authenticates CARTO basemap traffic.\n *\n * CARTO's published styles are static files whose `glyphs`, `sprite` and\n * vector-source URLs are absolute and key-free, so baking `?key=` into the\n * style URL authenticates that one request and nothing else. CARTO meters\n * *tile* requests, so the key has to ride on all of them — this appends it to\n * every cartocdn.com request the map makes and leaves other hosts (GBIF\n * occurrence tiles, ChecklistBank) untouched.\n *\n * Returns undefined when no key is set, so MapLibre keeps its own default.\n */\nexport const cartoTransformRequest = (key = config.cartoKey) => {\n if (!key) return undefined;\n return (url) => {\n let parsed;\n try {\n parsed = new URL(url);\n } catch {\n return { url };\n }\n // Leave a key already baked into the style URL alone.\n if (!CARTO_HOST.test(parsed.hostname) || parsed.searchParams.has(\"key\")) {\n return { url };\n }\n parsed.searchParams.set(\"key\", key);\n return { url: parsed.toString() };\n };\n};\n","import { useState } from \"react\";\n\nconst wrapStyle = {\n position: \"absolute\",\n bottom: 8,\n left: 8,\n zIndex: 1000,\n background: \"#fff\",\n borderRadius: 4,\n boxShadow: \"0 1px 4px rgba(0,0,0,0.2)\",\n padding: \"6px 8px\",\n fontSize: 12,\n lineHeight: 1.5,\n maxWidth: 260,\n};\n\nconst scrollStyle = {\n maxHeight: 240,\n overflowY: \"auto\",\n};\n\nconst groupHeadingStyle = {\n fontWeight: 600,\n marginTop: 4,\n};\n\nconst firstGroupHeadingStyle = {\n ...groupHeadingStyle,\n marginTop: 0,\n};\n\nconst rowStyle = {\n display: \"flex\",\n alignItems: \"center\",\n gap: 6,\n paddingLeft: 4,\n};\n\nconst swatchStyle = (color) => ({\n display: \"inline-block\",\n width: 12,\n height: 12,\n background: color,\n border: \"1px solid rgba(0,0,0,0.15)\",\n borderRadius: 2,\n flex: \"0 0 auto\",\n});\n\nconst footerToggleStyle = {\n marginTop: 6,\n cursor: \"pointer\",\n color: \"#1890ff\",\n fontSize: 11,\n};\n\nconst footerWrapStyle = {\n marginTop: 4,\n borderTop: \"1px solid #eee\",\n paddingTop: 4,\n color: \"#666\",\n};\n\nconst footerGroupHeadingStyle = {\n fontWeight: 600,\n marginTop: 4,\n};\n\nconst footerFirstGroupHeadingStyle = {\n ...footerGroupHeadingStyle,\n marginTop: 0,\n};\n\nconst footerNameStyle = {\n fontStyle: \"italic\",\n paddingLeft: 4,\n};\n\nconst totalCount = (groups) =>\n groups.reduce((sum, g) => sum + g.taxa.length, 0);\n\nconst GbifHexEntry = () => (\n <div style={rowStyle}>\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n <polygon\n points=\"3,1 9,1 11,6 9,11 3,11 1,6\"\n fill=\"#de1e6e\"\n stroke=\"rgba(0,0,0,0.25)\"\n strokeWidth=\"0.75\"\n />\n </svg>\n <span>GBIF occurrences</span>\n </div>\n);\n\nconst IncludedTaxaLegend = ({ visibleGroups, unmappableGroups, showGbif }) => {\n const [showUnmappable, setShowUnmappable] = useState(false);\n const visibleCount = totalCount(visibleGroups);\n const unmappableCount = totalCount(unmappableGroups);\n if (visibleCount === 0 && unmappableCount === 0 && !showGbif) return null;\n return (\n <div style={wrapStyle}>\n <div style={scrollStyle}>\n {visibleGroups.map((g, i) => (\n <div key={g.rank}>\n <div style={i === 0 ? firstGroupHeadingStyle : groupHeadingStyle}>\n {g.label}\n </div>\n {g.taxa.map((t) => (\n <div key={t.id} style={rowStyle}>\n <span style={swatchStyle(t.color)} />\n <span style={{ fontStyle: \"italic\" }}>\n {t.displayName || t.scientificName}\n </span>\n </div>\n ))}\n </div>\n ))}\n {showGbif && <GbifHexEntry />}\n </div>\n {unmappableCount > 0 && (\n <>\n <div\n style={footerToggleStyle}\n onClick={() => setShowUnmappable((v) => !v)}\n >\n {showUnmappable ? \"− Hide\" : \"+\"} {unmappableCount} without map data\n </div>\n {showUnmappable && (\n <div style={footerWrapStyle}>\n {unmappableGroups.map((g, i) => (\n <div key={g.rank}>\n <div\n style={\n i === 0\n ? footerFirstGroupHeadingStyle\n : footerGroupHeadingStyle\n }\n >\n {g.label}\n </div>\n {g.taxa.map((t) => (\n <div key={t.id} style={footerNameStyle}>\n {t.displayName || t.scientificName}\n </div>\n ))}\n </div>\n ))}\n </div>\n )}\n </>\n )}\n </div>\n );\n};\n\nexport default IncludedTaxaLegend;\n","// WebGL feature detection for MapLibre, adapted from\n// https://maplibre.org/maplibre-gl-js/docs/examples/check-if-webgl-is-supported/\n// MapLibre no longer ships `maplibregl.supported()`, and a defined\n// `WebGL2RenderingContext` constructor says nothing about whether a context can\n// actually be created (e.g. a Linux box with misconfigured graphics drivers).\n// MapLibre 6 dropped WebGL 1, so only a WebGL 2 context counts.\n\nlet cached = null;\n\nconst probe = () => {\n if (typeof window === \"undefined\" || !window.WebGL2RenderingContext) {\n return false;\n }\n try {\n const canvas = document.createElement(\"canvas\");\n const ctx = canvas.getContext(\"webgl2\");\n if (!ctx || typeof ctx.getParameter !== \"function\") return false;\n // Browsers cap the number of live contexts, so free the probe right away.\n ctx.getExtension?.(\"WEBGL_lose_context\")?.loseContext();\n return true;\n } catch (e) {\n // WebGL exists but is disabled or broken.\n return false;\n }\n};\n\nexport const isWebglSupported = () => {\n if (cached === null) cached = probe();\n return cached;\n};\n\n// Test-only: force the next call to probe again.\nexport const resetWebglSupportCache = () => {\n cached = null;\n};\n","import { useEffect, useMemo, useRef, useState } from \"react\";\nimport * as maplibregl from \"maplibre-gl\";\nimport \"maplibre-gl/dist/maplibre-gl.css\";\nimport \"./treeControl.css\";\nimport client from \"../../api/client\";\nimport config from \"../../config\";\nimport { fetchDescendants } from \"./descendantFetch\";\nimport { getDescendantRanks, INFRASPECIFIC_RANKS } from \"./descendantRanks\";\nimport { assignColors } from \"./colorAssignment\";\nimport { cartoTransformRequest, resolveBasemapStyle } from \"./basemap\";\nimport IncludedTaxaLegend from \"./IncludedTaxaLegend\";\nimport { readSetting, writeSetting } from \"../../storage\";\nimport { isWebglSupported } from \"./webgl\";\n\nconst POPUP_FIELDS = [\n \"establishmentMeans\",\n \"degreeOfEstablishment\",\n \"pathway\",\n \"threatStatus\",\n \"year\",\n \"lifeStage\",\n];\n\nexport const ESTABLISHMENT_MEANS = [\n { key: \"nativeendemic\", label: \"Native endemic\", color: \"#0F8554\" },\n { key: \"native\", label: \"Native\", color: \"#87C55F\" },\n { key: \"nativereintroduced\", label: \"Native reintroduced\", color: \"#C9DB74\" },\n { key: \"introduced\", label: \"Introduced\", color: \"#FE88B1\" },\n {\n key: \"introducedassistedcolonisation\",\n label: \"Introduced assisted colonisation\",\n color: \"#DCB0F2\",\n },\n { key: \"vagrant\", label: \"Vagrant\", color: \"#F6CF71\" },\n { key: \"uncertain\", label: \"Uncertain\", color: \"#8BE0A4\" },\n];\n\nconst ESTABLISHMENT_COLORS = Object.fromEntries(\n ESTABLISHMENT_MEANS.map((m) => [m.key, m.color])\n);\nexport const MISSING_COLOR = \"#66C5CC\";\n\nconst normalizeKey = (v) =>\n String(v || \"\")\n .toLowerCase()\n .replace(/[^a-z]/g, \"\");\n\nconst resolveKey = (record) => {\n const raw = record?.establishmentMeans;\n if (raw == null || raw === \"\") return null;\n const k = normalizeKey(raw);\n return ESTABLISHMENT_COLORS[k] ? k : \"uncertain\";\n};\n\nconst colorFor = (record) => {\n const k = resolveKey(record);\n return k == null ? MISSING_COLOR : ESTABLISHMENT_COLORS[k];\n};\n\n// localStorage-backed GBIF overlay preference: a user who turns the overlay off\n// keeps it off across page loads and sessions. Applies to all maps, including\n// GBIF-only ones — there, turning it off collapses the (otherwise empty) map to\n// a small activate bar (see the render below).\nconst GBIF_VISIBLE_KEY = \"gbif-visible\";\nconst readStoredGbifVisible = (defaultValue) =>\n readSetting(GBIF_VISIBLE_KEY, defaultValue);\nconst writeStoredGbifVisible = (visible) =>\n writeSetting(GBIF_VISIBLE_KEY, visible);\n\n// GBIF v2 occurrence-density tile path (multitaxonomy). Concatenated with\n// config.gbifApi at request time.\nconst GBIF_TILE_PATH =\n \"/v2/map/occurrence/density/{z}/{x}/{y}@1x.png\" +\n \"?srs=EPSG%3A3857&style=iNaturalist.poly&bin=hex&hexPerTile=64\" +\n \"&hasCoordinate=true&hasGeospatialIssue=false&occurrenceStatus=PRESENT\" +\n \"&checklistKey={checklistKey}&taxonKey={taxonKey}\";\n\n// Layer IDs\nconst FOCAL_SOURCE = \"col-focal-distributions\";\nconst FOCAL_FILL = \"col-focal-fill\";\nconst FOCAL_LINE = \"col-focal-line\";\nconst GBIF_SOURCE = \"col-gbif-occurrences\";\nconst GBIF_LAYER = \"col-gbif-occurrences\";\nconst descendantSourceId = (id) => `col-descendant-${id}`;\nconst descendantFillId = (id) => `col-descendant-fill-${id}`;\nconst descendantLineId = (id) => `col-descendant-line-${id}`;\n\nconst cache = new Map();\n\nconst fetchShape = (gazetteer, id) => {\n const key = `${gazetteer}:${id}`;\n if (cache.has(key)) return cache.get(key);\n const url = `${config.dataApi}vocab/area/${key}`;\n const p = client(url, {\n headers: { Accept: \"application/geo+json\" },\n }).then(\n (r) => r.data,\n () => null\n );\n cache.set(key, p);\n return p;\n};\n\nconst escapeHtml = (s) =>\n String(s)\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\");\n\nconst popupHtml = (record) => {\n const title = record?.area?.name || record?.area?.globalId || \"\";\n const rows = POPUP_FIELDS.map((f) => [f, record?.[f]])\n .filter(([, v]) => v != null && v !== \"\")\n .map(\n ([k, v]) =>\n `<div><strong>${escapeHtml(k)}:</strong> ${escapeHtml(v)}</div>`\n )\n .join(\"\");\n return `<div style=\"min-width:180px\"><div style=\"font-weight:600;margin-bottom:4px\">${escapeHtml(\n title\n )}</div>${rows}</div>`;\n};\n\nconst descendantPopupHtml = (taxon, record) => {\n const head =\n `<div style=\"font-weight:600;font-style:italic;margin-bottom:4px\">${escapeHtml(\n taxon.scientificName\n )}</div>` +\n `<div style=\"color:#888;margin-bottom:4px\">${escapeHtml(taxon.rank || \"\")}</div>`;\n return head + popupHtml(record);\n};\n\nconst RANK_LABEL_PLURAL = {\n subspecies: \"subspecies\",\n variety: \"varieties\",\n subvariety: \"subvarieties\",\n form: \"forms\",\n subform: \"subforms\",\n \"infraspecific name\": \"infraspecific names\",\n};\nconst rankLabelPlural = (rank) => RANK_LABEL_PLURAL[rank] || rank;\n\nconst epithet = (scientificName) => {\n if (!scientificName) return \"\";\n const tokens = scientificName.trim().split(/\\s+/);\n return tokens[tokens.length - 1];\n};\n\n// Hex swatch + label for the GBIF density layer.\nconst GbifLegendEntry = () => (\n <div style={{ display: \"flex\", alignItems: \"center\", gap: 6 }}>\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n <polygon\n points=\"3,1 9,1 11,6 9,11 3,11 1,6\"\n fill=\"#de1e6e\"\n stroke=\"rgba(0,0,0,0.25)\"\n strokeWidth=\"0.75\"\n />\n </svg>\n <span>GBIF occurrences</span>\n </div>\n);\n\n// Compute bounds [[minLng,minLat],[maxLng,maxLat]] of a FeatureCollection.\nconst computeBounds = (features) => {\n let minLng = Infinity,\n minLat = Infinity,\n maxLng = -Infinity,\n maxLat = -Infinity;\n const visit = (coords) => {\n if (typeof coords[0] === \"number\") {\n const [lng, lat] = coords;\n if (lng < minLng) minLng = lng;\n if (lng > maxLng) maxLng = lng;\n if (lat < minLat) minLat = lat;\n if (lat > maxLat) maxLat = lat;\n } else {\n for (let i = 0; i < coords.length; i++) visit(coords[i]);\n }\n };\n for (let i = 0; i < features.length; i++) {\n const g = features[i]?.geometry;\n if (g?.coordinates) visit(g.coordinates);\n }\n if (minLng === Infinity) return null;\n return [\n [minLng, minLat],\n [maxLng, maxLat],\n ];\n};\n\nconst flattenFeatures = (geojson) => {\n if (!geojson) return [];\n if (geojson.type === \"FeatureCollection\") return geojson.features || [];\n return [geojson];\n};\n\nconst DistributionsMap = ({\n records,\n onUnmappable,\n datasetKey,\n focalTaxon,\n rankOrder,\n gbifChecklistKey,\n // true | null → show GBIF layer; false → GBIF API returned 0 occurrences,\n // grey out the toggle and skip loading tiles. Defaults to true so the\n // component works without the count check.\n gbifAvailable = true,\n // MapLibre style URL or inline style object; falls back to the global\n // `configure({ basemapStyle })` value. Changing it rebuilds the map.\n basemapStyle,\n // Called from the no-WebGL notice to switch the host to its list view.\n onShowList,\n}) => {\n const containerRef = useRef(null);\n const wrapperRef = useRef(null);\n const mapRef = useRef(null);\n const popupRef = useRef(null);\n const recordMapRef = useRef(new Map()); // recordKey → record\n const descendantTaxonMapRef = useRef(new Map()); // taxonId → taxon\n const descendantRecordMapRef = useRef(new Map()); // recordKey → { taxon, record }\n const focalAttachedRef = useRef(false);\n const gbifAttachedRef = useRef(false);\n const descendantLayersRef = useRef(new Set()); // taxonIds currently attached\n\n const [webglFailed, setWebglFailed] = useState(false);\n const [readyMap, setReadyMap] = useState(null);\n const [focalReady, setFocalReady] = useState(false);\n const [descendantState, setDescendantState] = useState({\n status: \"idle\", // idle | loading | ready | empty | error\n taxa: [],\n });\n const [focalVisible, setFocalVisible] = useState(true);\n const isGbifOnly = !!gbifChecklistKey && (!records || records.length === 0);\n // Respect the saved GBIF preference on every map. On a GBIF-only map, an\n // off preference collapses to a small activate bar instead of an empty map.\n const [gbifVisible, setGbifVisible] = useState(() =>\n readStoredGbifVisible(true)\n );\n const [visibleTaxonIds, setVisibleTaxonIds] = useState(new Set());\n const [controlOpen, setControlOpen] = useState(false);\n const fetchTriggeredRef = useRef(false);\n\n const handleToggleGbif = () => {\n setGbifVisible((v) => {\n const next = !v;\n writeStoredGbifVisible(next);\n return next;\n });\n };\n\n const activateGbif = () => {\n setGbifVisible(true);\n writeStoredGbifVisible(true);\n };\n\n const presentMeans = useMemo(() => {\n if (!records?.length) return [];\n const seen = new Set();\n records.forEach((r) => {\n const k = resolveKey(r);\n if (k != null) seen.add(k);\n });\n return ESTABLISHMENT_MEANS.filter((m) => seen.has(m.key));\n }, [records]);\n\n const descendantColors = useMemo(() => {\n if (descendantState.status !== \"ready\") return {};\n return assignColors(\n descendantState.taxa.filter((t) => t.mappable.length > 0),\n rankOrder || []\n );\n }, [descendantState, rankOrder]);\n\n const descendantLegend = useMemo(() => {\n if (descendantState.status !== \"ready\") {\n return { visibleGroups: [], unmappableGroups: [] };\n }\n const decorate = (t) => ({\n ...t,\n color: descendantColors[t.id],\n displayName: epithet(t.scientificName),\n });\n const groupByRank = (taxa) => {\n const byRank = {};\n taxa.forEach((t) => {\n (byRank[t.rank] = byRank[t.rank] || []).push(decorate(t));\n });\n return INFRASPECIFIC_RANKS.filter((r) => byRank[r]).map((r) => ({\n rank: r,\n label: rankLabelPlural(r),\n taxa: byRank[r],\n }));\n };\n const visibleGroups = groupByRank(\n descendantState.taxa.filter(\n (t) => t.mappable.length > 0 && visibleTaxonIds.has(t.id)\n )\n );\n const unmappableGroups = groupByRank(\n descendantState.taxa.filter((t) => t.mappable.length === 0)\n );\n return { visibleGroups, unmappableGroups };\n }, [descendantState, descendantColors, visibleTaxonIds]);\n\n const showDescendantLegend = descendantLegend.visibleGroups.length > 0;\n\n const styleSpec = resolveBasemapStyle(basemapStyle);\n const cartoKey = config.cartoKey;\n // Depend on a stable key, not the spec itself: an inline style object passed\n // as a prop is a fresh reference on every render and would otherwise rebuild\n // the map continuously. The CARTO key is folded in so that configuring one\n // after first render rebuilds the map onto authenticated tiles.\n const styleKey = `${\n typeof styleSpec === \"string\" ? styleSpec : JSON.stringify(styleSpec)\n }|${cartoKey || \"\"}`;\n\n // Mount the map. Re-runs when the basemap style changes: the cleanup below\n // tears the old map down completely, so the layer effects rebuild onto the\n // new style.\n useEffect(() => {\n if (!containerRef.current || mapRef.current) return;\n if (!isWebglSupported()) return;\n let map;\n try {\n map = new maplibregl.Map({\n container: containerRef.current,\n style: styleSpec,\n transformRequest: cartoTransformRequest(cartoKey),\n center: [0, 20],\n zoom: 1,\n minZoom: 0,\n attributionControl: false,\n renderWorldCopies: true,\n });\n } catch (e) {\n // The probe can pass while MapLibre's own context request still fails.\n console.warn(\"Distribution map disabled:\", e);\n setWebglFailed(true);\n return;\n }\n map.addControl(\n new maplibregl.AttributionControl({ compact: true }),\n \"bottom-right\"\n );\n map.addControl(\n new maplibregl.NavigationControl({ showCompass: false }),\n \"top-left\"\n );\n // Fullscreen toggle, top-right. Expand the whole wrapper (not just the map\n // canvas) so the legend and the layer control come along into fullscreen.\n // The custom layer \"+\" button is positioned just below this control.\n map.addControl(\n new maplibregl.FullscreenControl({ container: wrapperRef.current }),\n \"top-right\"\n );\n mapRef.current = map;\n\n map.on(\"load\", () => {\n setReadyMap(map);\n // Start the attribution control collapsed. MapLibre opens it by\n // default in compact mode and only closes it on drag; remove the\n // `compact-show` class to hide the inner attribution text until the\n // user clicks the (i) button.\n const attrib = map\n .getContainer()\n .querySelector(\".maplibregl-ctrl-attrib\");\n if (attrib) attrib.classList.remove(\"maplibregl-compact-show\");\n });\n\n const resizeObserver =\n typeof ResizeObserver !== \"undefined\"\n ? new ResizeObserver(() => map.resize())\n : null;\n if (resizeObserver) resizeObserver.observe(containerRef.current);\n\n return () => {\n if (resizeObserver) resizeObserver.disconnect();\n if (popupRef.current) {\n popupRef.current.remove();\n popupRef.current = null;\n }\n map.remove();\n mapRef.current = null;\n focalAttachedRef.current = false;\n gbifAttachedRef.current = false;\n descendantLayersRef.current = new Set();\n // The layer effects below key off this. Clearing it on teardown — and\n // setting it again only from the new map's \"load\" — means they can never\n // run against a map that is gone or whose style has not loaded yet.\n setReadyMap(null);\n };\n }, [styleKey]);\n\n // Focal taxon polygons.\n useEffect(() => {\n const map = readyMap;\n if (!map || !records?.length) return;\n let cancelled = false;\n setFocalReady(false);\n\n Promise.allSettled(\n records.map((r) =>\n fetchShape(r.area.gazetteer, r.area.id).then((geojson) => ({\n record: r,\n geojson,\n }))\n )\n ).then((results) => {\n if (cancelled || mapRef.current !== map) return;\n const features = [];\n const recordMap = new Map();\n let failures = 0;\n results.forEach((res, i) => {\n if (res.status !== \"fulfilled\" || !res.value.geojson) {\n failures += 1;\n return;\n }\n const { record, geojson } = res.value;\n const color = colorFor(record);\n const recordKey = `focal-${i}`;\n recordMap.set(recordKey, record);\n flattenFeatures(geojson).forEach((f) => {\n features.push({\n ...f,\n properties: {\n ...(f.properties || {}),\n _recordKey: recordKey,\n _color: color,\n },\n });\n });\n });\n recordMapRef.current = recordMap;\n\n const data = { type: \"FeatureCollection\", features };\n if (map.getSource(FOCAL_SOURCE)) {\n map.getSource(FOCAL_SOURCE).setData(data);\n } else {\n // GBIF raster may already be on the map (its effect runs synchronously\n // while this one is async). Insert focal layers below GBIF so the\n // occurrence overlay always paints on top.\n const beforeId = map.getLayer(GBIF_LAYER) ? GBIF_LAYER : undefined;\n map.addSource(FOCAL_SOURCE, { type: \"geojson\", data });\n map.addLayer(\n {\n id: FOCAL_FILL,\n type: \"fill\",\n source: FOCAL_SOURCE,\n paint: {\n \"fill-color\": [\"coalesce\", [\"get\", \"_color\"], MISSING_COLOR],\n \"fill-opacity\": 0.65,\n },\n },\n beforeId\n );\n map.addLayer(\n {\n id: FOCAL_LINE,\n type: \"line\",\n source: FOCAL_SOURCE,\n paint: {\n \"line-color\": [\"coalesce\", [\"get\", \"_color\"], MISSING_COLOR],\n \"line-width\": 1,\n },\n },\n beforeId\n );\n map.on(\"click\", FOCAL_FILL, onFocalClick);\n map.on(\"mouseenter\", FOCAL_FILL, onMouseEnter);\n map.on(\"mouseleave\", FOCAL_FILL, onMouseLeave);\n focalAttachedRef.current = true;\n }\n\n if (features.length > 0) {\n const bounds = computeBounds(features);\n if (bounds) map.fitBounds(bounds, { padding: 20, animate: false });\n }\n if (typeof onUnmappable === \"function\") onUnmappable(failures);\n setFocalReady(true);\n });\n\n return () => {\n cancelled = true;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [readyMap, records]);\n\n // Focal click handler — defined as stable closure that reads ref.\n const onFocalClick = (e) => {\n const map = mapRef.current;\n if (!map) return;\n const feature = e.features?.[0];\n const key = feature?.properties?._recordKey;\n const record = key ? recordMapRef.current.get(key) : null;\n if (!record) return;\n if (popupRef.current) popupRef.current.remove();\n popupRef.current = new maplibregl.Popup({ closeButton: true, maxWidth: \"320px\" })\n .setLngLat(e.lngLat)\n .setHTML(popupHtml(record))\n .addTo(map);\n };\n\n const onMouseEnter = () => {\n const map = mapRef.current;\n if (map) map.getCanvas().style.cursor = \"pointer\";\n };\n const onMouseLeave = () => {\n const map = mapRef.current;\n if (map) map.getCanvas().style.cursor = \"\";\n };\n\n // Sync focal visibility.\n useEffect(() => {\n const map = mapRef.current;\n if (!map || !focalAttachedRef.current) return;\n const v = focalVisible ? \"visible\" : \"none\";\n if (map.getLayer(FOCAL_FILL)) map.setLayoutProperty(FOCAL_FILL, \"visibility\", v);\n if (map.getLayer(FOCAL_LINE)) map.setLayoutProperty(FOCAL_LINE, \"visibility\", v);\n }, [focalVisible, focalReady]);\n\n // GBIF raster layer — added always last so it sits on top.\n useEffect(() => {\n const map = readyMap;\n if (!map) return;\n const removeGbif = () => {\n if (map.getLayer(GBIF_LAYER)) map.removeLayer(GBIF_LAYER);\n if (map.getSource(GBIF_SOURCE)) map.removeSource(GBIF_SOURCE);\n gbifAttachedRef.current = false;\n };\n removeGbif();\n if (!gbifChecklistKey || !focalTaxon?.id) return;\n // GBIF API said this taxon has 0 occurrences — skip the tile request.\n if (gbifAvailable === false) return;\n const url = (config.gbifApi + GBIF_TILE_PATH)\n .replace(\"{checklistKey}\", encodeURIComponent(gbifChecklistKey))\n .replace(\"{taxonKey}\", encodeURIComponent(focalTaxon.id));\n // Link to GBIF's multitaxonomy occurrence search for the focal taxon on\n // the production portal (config.gbifPortal); same checklistKey we pass to\n // the tile API.\n const searchUrl =\n config.gbifPortal +\n \"/occurrence/search?checklist_key=\" +\n encodeURIComponent(gbifChecklistKey) +\n \"&taxon_key=\" +\n encodeURIComponent(focalTaxon.id);\n map.addSource(GBIF_SOURCE, {\n type: \"raster\",\n tiles: [url],\n tileSize: 256,\n attribution:\n '<a href=\"' +\n searchUrl +\n '\" target=\"_blank\" rel=\"noopener\">GBIF</a> occurrence data',\n });\n map.addLayer({\n id: GBIF_LAYER,\n type: \"raster\",\n source: GBIF_SOURCE,\n paint: { \"raster-opacity\": 0.9 },\n layout: { visibility: gbifVisible ? \"visible\" : \"none\" },\n });\n gbifAttachedRef.current = true;\n // Intentionally no cleanup return: deps changes are handled by the\n // removeGbif() call at the top of the next run, and unmount is handled\n // by the mount effect's map.remove() which disposes everything. If we\n // returned removeGbif here, it could run after map.remove() (React\n // runs cleanups in reverse declaration order on unmount) and throw\n // because MapLibre nulls map.style during remove().\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [readyMap, gbifChecklistKey, focalTaxon?.id, gbifAvailable]);\n\n // Sync GBIF visibility.\n useEffect(() => {\n const map = mapRef.current;\n if (!map || !gbifAttachedRef.current) return;\n const v = gbifVisible ? \"visible\" : \"none\";\n if (map.getLayer(GBIF_LAYER)) map.setLayoutProperty(GBIF_LAYER, \"visibility\", v);\n }, [gbifVisible]);\n\n // Layers start hidden and the visibility effect below reveals the ones the\n // user has ticked. After a basemap switch they are re-added from scratch\n // while `visibleTaxonIds` is unchanged — so that effect would not re-run and\n // the selection would silently disappear. Add them at their current\n // visibility instead.\n const descendantVisibility = (id) =>\n visibleTaxonIds.has(id) ? \"visible\" : \"none\";\n\n // Descendant layers — added once when state.status becomes \"ready\".\n useEffect(() => {\n const map = readyMap;\n if (!map) return;\n // Tear down previous descendant layers.\n descendantLayersRef.current.forEach((id) => {\n if (map.getLayer(descendantFillId(id))) map.removeLayer(descendantFillId(id));\n if (map.getLayer(descendantLineId(id))) map.removeLayer(descendantLineId(id));\n if (map.getSource(descendantSourceId(id))) map.removeSource(descendantSourceId(id));\n });\n descendantLayersRef.current = new Set();\n descendantTaxonMapRef.current = new Map();\n descendantRecordMapRef.current = new Map();\n\n if (descendantState.status !== \"ready\") return;\n const colors = descendantColors;\n descendantState.taxa.forEach((t) => {\n if (t.mappable.length === 0) return;\n descendantTaxonMapRef.current.set(t.id, t);\n Promise.allSettled(\n t.mappable.map((rec) =>\n fetchShape(rec.area.gazetteer, rec.area.id).then((geojson) => ({\n record: rec,\n geojson,\n }))\n )\n ).then((results) => {\n // Same guard as the focal layer: a basemap switch mid-fetch replaces\n // the map, and these writes must not land on the new one.\n if (mapRef.current !== map) return;\n const features = [];\n results.forEach((res, i) => {\n if (res.status !== \"fulfilled\" || !res.value.geojson) return;\n const { record, geojson } = res.value;\n const recordKey = `desc-${t.id}-${i}`;\n descendantRecordMapRef.current.set(recordKey, { taxon: t, record });\n flattenFeatures(geojson).forEach((f) => {\n features.push({\n ...f,\n properties: {\n ...(f.properties || {}),\n _recordKey: recordKey,\n },\n });\n });\n });\n const color = colors[t.id] || MISSING_COLOR;\n const data = { type: \"FeatureCollection\", features };\n const srcId = descendantSourceId(t.id);\n if (mapRef.current.getSource(srcId)) {\n mapRef.current.getSource(srcId).setData(data);\n } else {\n mapRef.current.addSource(srcId, { type: \"geojson\", data });\n const fillId = descendantFillId(t.id);\n const lineId = descendantLineId(t.id);\n const beforeId = mapRef.current.getLayer(GBIF_LAYER) ? GBIF_LAYER : undefined;\n mapRef.current.addLayer(\n {\n id: fillId,\n type: \"fill\",\n source: srcId,\n paint: { \"fill-color\": color, \"fill-opacity\": 0.55 },\n layout: { visibility: descendantVisibility(t.id) },\n },\n beforeId\n );\n mapRef.current.addLayer(\n {\n id: lineId,\n type: \"line\",\n source: srcId,\n paint: { \"line-color\": color, \"line-width\": 2 },\n layout: { visibility: descendantVisibility(t.id) },\n },\n beforeId\n );\n mapRef.current.on(\"click\", fillId, onDescendantClick);\n mapRef.current.on(\"mouseenter\", fillId, onMouseEnter);\n mapRef.current.on(\"mouseleave\", fillId, onMouseLeave);\n descendantLayersRef.current.add(t.id);\n }\n });\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [readyMap, descendantState, descendantColors]);\n\n const onDescendantClick = (e) => {\n const map = mapRef.current;\n if (!map) return;\n const feature = e.features?.[0];\n const key = feature?.properties?._recordKey;\n const data = key ? descendantRecordMapRef.current.get(key) : null;\n if (!data) return;\n if (popupRef.current) popupRef.current.remove();\n popupRef.current = new maplibregl.Popup({ closeButton: true, maxWidth: \"320px\" })\n .setLngLat(e.lngLat)\n .setHTML(descendantPopupHtml(data.taxon, data.record))\n .addTo(map);\n };\n\n // Sync descendant visibility.\n useEffect(() => {\n const map = mapRef.current;\n if (!map) return;\n descendantLayersRef.current.forEach((id) => {\n const v = visibleTaxonIds.has(id) ? \"visible\" : \"none\";\n if (map.getLayer(descendantFillId(id))) {\n map.setLayoutProperty(descendantFillId(id), \"visibility\", v);\n }\n if (map.getLayer(descendantLineId(id))) {\n map.setLayoutProperty(descendantLineId(id), \"visibility\", v);\n }\n });\n }, [visibleTaxonIds, descendantState]);\n\n // Trigger descendant fetch (on control open).\n const triggerDescendantFetch = () => {\n if (fetchTriggeredRef.current) return;\n if (!datasetKey || !focalTaxon || !rankOrder) return;\n const focalRank = focalTaxon?.name?.rank;\n if (!focalRank) return;\n if (focalRank !== \"species\" && !INFRASPECIFIC_RANKS.includes(focalRank)) return;\n const ranks = getDescendantRanks(focalRank, rankOrder);\n if (ranks.length === 0) return;\n fetchTriggeredRef.current = true;\n setDescendantState({ status: \"loading\", taxa: [] });\n fetchDescendants({ datasetKey, focalTaxon, rankOrder }).then(\n ({ taxa, descendantsFailed }) => {\n if (descendantsFailed) {\n setDescendantState({ status: \"error\", taxa: [] });\n return;\n }\n if (taxa.length === 0) {\n setDescendantState({ status: \"empty\", taxa: [] });\n return;\n }\n setDescendantState({ status: \"ready\", taxa });\n }\n );\n };\n\n const openControl = () => {\n setControlOpen(true);\n triggerDescendantFetch();\n };\n\n // Group descendants by rank for the control panel.\n const descendantsByRank = useMemo(() => {\n if (descendantState.status !== \"ready\") return [];\n const byRank = {};\n descendantState.taxa\n .filter((t) => t.mappable.length > 0)\n .forEach((t) => {\n (byRank[t.rank] = byRank[t.rank] || []).push(t);\n });\n return INFRASPECIFIC_RANKS.filter((r) => byRank[r]).map((r) => ({\n rank: r,\n label: rankLabelPlural(r),\n taxa: byRank[r].slice().sort((a, b) =>\n a.scientificName.localeCompare(b.scientificName)\n ),\n }));\n }, [descendantState]);\n\n const toggleTaxon = (id) => {\n setVisibleTaxonIds((prev) => {\n const next = new Set(prev);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n return next;\n });\n };\n\n const toggleRankGroup = (rankTaxa) => {\n setVisibleTaxonIds((prev) => {\n const next = new Set(prev);\n const allOn = rankTaxa.every((t) => prev.has(t.id));\n rankTaxa.forEach((t) => {\n if (allOn) next.delete(t.id);\n else next.add(t.id);\n });\n return next;\n });\n };\n\n if (webglFailed || !isWebglSupported()) {\n return (\n <div\n style={{\n padding: 12,\n background: \"#fafafa\",\n border: \"1px solid #eee\",\n borderRadius: 4,\n color: \"#666\",\n fontSize: 12,\n }}\n >\n <strong>\n The distribution map can&apos;t be shown because WebGL is not\n available in your browser.\n </strong>{\" \"}\n This usually means hardware acceleration is turned off or the graphics\n drivers aren&apos;t set up for WebGL.\n {typeof onShowList === \"function\" && (\n <>\n {\" \"}\n <a onClick={onShowList} style={{ cursor: \"pointer\" }}>\n Show distributions as a list\n </a>\n </>\n )}\n </div>\n );\n }\n\n // A GBIF-only taxon (no curated distribution polygons) with the GBIF overlay\n // turned off would render a blank map — collapse to a slim bar that\n // re-activates the map + overlay.\n if (isGbifOnly && !gbifVisible) {\n return (\n <div\n className=\"col-distributions-map col-distributions-map--collapsed\"\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 6,\n padding: \"8px 12px\",\n background: \"#fafafa\",\n border: \"1px solid #eee\",\n borderRadius: 4,\n color: \"#666\",\n fontSize: 12,\n }}\n >\n <span>No curated distribution data.</span>\n <a\n role=\"button\"\n tabIndex={0}\n style={{ cursor: \"pointer\" }}\n onClick={activateGbif}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n activateGbif();\n }\n }}\n >\n Show GBIF occurrences\n </a>\n </div>\n );\n }\n\n const focalName = focalTaxon?.name?.scientificName || \"This taxon\";\n\n return (\n <div\n className=\"col-distributions-map\"\n ref={wrapperRef}\n style={{ position: \"relative\" }}\n >\n <div\n ref={containerRef}\n className=\"col-distributions-map__canvas\"\n style={{ height: 360, width: \"100%\", background: \"#f5f5f5\" }}\n />\n\n <LayerControl\n open={controlOpen}\n onOpen={openControl}\n onClose={() => setControlOpen(false)}\n focalName={focalName}\n focalReady={focalReady}\n focalVisible={focalVisible}\n onToggleFocal={() => setFocalVisible((v) => !v)}\n gbifEnabled={!!gbifChecklistKey}\n gbifVisible={gbifVisible}\n gbifAvailable={gbifAvailable}\n onToggleGbif={handleToggleGbif}\n descendantStatus={descendantState.status}\n descendantsByRank={descendantsByRank}\n descendantColors={descendantColors}\n visibleTaxonIds={visibleTaxonIds}\n onToggleTaxon={toggleTaxon}\n onToggleRankGroup={toggleRankGroup}\n onRetry={() => {\n fetchTriggeredRef.current = false;\n setDescendantState({ status: \"idle\", taxa: [] });\n triggerDescendantFetch();\n }}\n />\n\n {!showDescendantLegend &&\n (presentMeans.length > 0 ||\n (gbifChecklistKey && gbifAvailable !== false && gbifVisible)) && (\n <div\n style={{\n position: \"absolute\",\n bottom: 8,\n left: 8,\n zIndex: 1,\n background: \"#fff\",\n borderRadius: 4,\n boxShadow: \"0 1px 4px rgba(0,0,0,0.2)\",\n padding: \"6px 8px\",\n fontSize: 12,\n lineHeight: 1.5,\n }}\n >\n {presentMeans.map((m) => (\n <div\n key={m.key}\n style={{ display: \"flex\", alignItems: \"center\", gap: 6 }}\n >\n <span\n style={{\n display: \"inline-block\",\n width: 12,\n height: 12,\n background: m.color,\n border: \"1px solid rgba(0,0,0,0.15)\",\n borderRadius: 2,\n }}\n />\n <span>{m.label}</span>\n </div>\n ))}\n {gbifChecklistKey && gbifAvailable !== false && gbifVisible && (\n <GbifLegendEntry />\n )}\n </div>\n )}\n {showDescendantLegend && (\n <IncludedTaxaLegend\n visibleGroups={descendantLegend.visibleGroups}\n unmappableGroups={descendantLegend.unmappableGroups}\n showGbif={!!gbifChecklistKey && gbifAvailable !== false && gbifVisible}\n />\n )}\n </div>\n );\n};\n\n// Layer toggle panel — collapsed \"+\" button at top-right that expands on click.\nconst LayerControl = ({\n open,\n onOpen,\n onClose,\n focalName,\n focalReady,\n focalVisible,\n onToggleFocal,\n gbifEnabled,\n gbifVisible,\n gbifAvailable,\n onToggleGbif,\n descendantStatus,\n descendantsByRank,\n descendantColors,\n visibleTaxonIds,\n onToggleTaxon,\n onToggleRankGroup,\n onRetry,\n}) => {\n if (!open) {\n return (\n <button\n type=\"button\"\n onClick={onOpen}\n onMouseEnter={onOpen}\n title=\"Layers\"\n style={{\n position: \"absolute\",\n // Sits just below the maplibre fullscreen control (top-right).\n top: 48,\n right: 10,\n zIndex: 2,\n width: 30,\n height: 30,\n background: \"#fff\",\n border: \"1px solid rgba(0,0,0,0.2)\",\n borderRadius: 4,\n cursor: \"pointer\",\n fontSize: 18,\n lineHeight: \"26px\",\n padding: 0,\n boxShadow: \"0 1px 4px rgba(0,0,0,0.2)\",\n }}\n >\n +\n </button>\n );\n }\n return (\n <div\n style={{\n position: \"absolute\",\n // Aligns with the collapsed \"+\" button, below the fullscreen control.\n top: 48,\n right: 10,\n zIndex: 2,\n background: \"#fff\",\n borderRadius: 4,\n boxShadow: \"0 1px 4px rgba(0,0,0,0.2)\",\n padding: \"6px 10px\",\n fontSize: 12,\n lineHeight: 1.5,\n maxHeight: 320,\n overflowY: \"auto\",\n minWidth: 160,\n }}\n onMouseLeave={onClose}\n >\n <div style={{ display: \"flex\", alignItems: \"center\", gap: 6 }}>\n <input\n type=\"checkbox\"\n checked={focalVisible}\n disabled={!focalReady}\n onChange={onToggleFocal}\n />\n <span style={{ fontStyle: \"italic\" }}>{focalName}</span>\n </div>\n {gbifEnabled && (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 6,\n opacity: gbifAvailable === false ? 0.5 : 1,\n }}\n title={\n gbifAvailable === false\n ? \"GBIF has no occurrence records for this taxon.\"\n : undefined\n }\n >\n <input\n type=\"checkbox\"\n checked={gbifAvailable === false ? false : gbifVisible}\n disabled={gbifAvailable === false}\n onChange={onToggleGbif}\n />\n <span>GBIF occurrences</span>\n </div>\n )}\n {descendantStatus === \"loading\" && (\n <div style={{ marginTop: 6, color: \"#888\" }}>Loading descendants…</div>\n )}\n {descendantStatus === \"error\" && (\n <div style={{ marginTop: 6, color: \"#888\" }}>\n Couldn&apos;t load descendants.{\" \"}\n <a onClick={onRetry} style={{ cursor: \"pointer\" }}>\n Retry\n </a>\n </div>\n )}\n {descendantStatus === \"ready\" &&\n descendantsByRank.map((group) => {\n const allOn = group.taxa.every((t) => visibleTaxonIds.has(t.id));\n const someOn = group.taxa.some((t) => visibleTaxonIds.has(t.id));\n return (\n <div key={group.rank} style={{ marginTop: 6 }}>\n <label\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 6,\n fontWeight: 600,\n }}\n >\n <input\n type=\"checkbox\"\n checked={allOn}\n ref={(el) => {\n if (el) el.indeterminate = !allOn && someOn;\n }}\n onChange={() => onToggleRankGroup(group.taxa)}\n />\n {group.label}\n </label>\n <div style={{ paddingLeft: 18 }}>\n {group.taxa.map((t) => (\n <label\n key={t.id}\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 6,\n }}\n >\n <input\n type=\"checkbox\"\n checked={visibleTaxonIds.has(t.id)}\n onChange={() => onToggleTaxon(t.id)}\n />\n <span\n style={{\n display: \"inline-block\",\n width: 10,\n height: 10,\n background: descendantColors[t.id],\n border: \"1px solid rgba(0,0,0,0.15)\",\n borderRadius: 2,\n }}\n />\n <span style={{ fontStyle: \"italic\" }}>\n {epithet(t.scientificName)}\n </span>\n </label>\n ))}\n </div>\n </div>\n );\n })}\n </div>\n );\n};\n\nexport default DistributionsMap;\n","import { useState, useEffect } from \"react\";\nimport { Radio } from \"antd\";\nimport { get, keyBy, startCase } from \"lodash-es\";\nimport ReferencePopover from \"./ReferencePopover\";\nimport config from \"../config\";\n// publicClient (no CoL auth) for the third-party GBIF occurrence API below.\nimport client, { publicClient } from \"../api/client\";\nimport MergedDataBadge from \"../components/MergedDataBadge\";\nimport PresentationItem from \"../components/PresentationItem\";\nimport DistributionsMap from \"./DistributionsMap\";\nimport { isWebglSupported } from \"./DistributionsMap/webgl\";\n\nconst isMappable = (r) =>\n r?.area?.gazetteer !== \"text\" && !!r?.area?.globalId;\n\nconst ListView = ({ datasetKey, data }) => {\n const [iso3Map, setIso3Map] = useState({});\n\n useEffect(() => {\n let isIso = false;\n for (let i = 0; i < data.length; i++) {\n if (data[i].gazetteer === \"iso\") {\n isIso = true;\n break;\n }\n }\n if (isIso) {\n client(`${config.dataApi}vocab/country`).then((res) => {\n setIso3Map(keyBy(res.data, \"alpha3\"));\n });\n }\n }, []);\n\n return (\n <div>\n {data.map((s, i) => (\n <span key={i}>\n {s?.merged && (\n <MergedDataBadge\n createdBy={s?.createdBy}\n datasetKey={s.datasetKey}\n sourceDatasetKey={s?.sourceDatasetKey}\n verbatimSourceKey={s?.verbatimSourceKey}\n style={{ marginRight: \"4px\" }}\n />\n )}\n {(get(iso3Map, `[${get(s, \"area.name\")}].name`)\n ? startCase(get(iso3Map, `[${get(s, \"area.name\")}].name`))\n : null) ||\n get(s, \"area.name\") ||\n get(s, \"area.globalId\")}{\" \"}\n {s.referenceId && (\n <ReferencePopover\n datasetKey={datasetKey}\n referenceId={s.referenceId}\n placement=\"bottom\"\n />\n )}\n {i < data.length - 1 && \", \"}\n </span>\n ))}\n </div>\n );\n};\n\nconst DistributionsTable = ({\n datasetKey,\n data,\n style,\n showDistributionMap,\n focalTaxon,\n rankOrder,\n gbifChecklistKey,\n basemapStyle,\n label,\n md,\n}) => {\n const mappable = data.filter(isMappable);\n const baseUnmappable = data.length - mappable.length;\n const hasGbifConfigured = !!gbifChecklistKey;\n const hasAnyRecords = data.length > 0;\n const [view, setView] = useState(() =>\n isWebglSupported() ? \"map\" : \"list\"\n );\n const [fetchFailures, setFetchFailures] = useState(0);\n\n // null = unknown (loading or unconfigured), number = occurrence count.\n const [gbifCount, setGbifCount] = useState(null);\n useEffect(() => {\n if (!gbifChecklistKey || !focalTaxon?.id) {\n setGbifCount(null);\n return undefined;\n }\n setGbifCount(null);\n let cancelled = false;\n publicClient\n .get(`${config.gbifApi}/v1/occurrence/search`, {\n params: {\n checklistKey: gbifChecklistKey,\n taxonKey: focalTaxon.id,\n hasCoordinate: true,\n hasGeospatialIssue: false,\n occurrenceStatus: 'PRESENT',\n limit: 0,\n },\n })\n .then(\n (res) => {\n if (!cancelled) setGbifCount(res?.data?.count ?? 0);\n },\n () => {\n // On API failure, treat as \"unknown\" — leave the toggle enabled\n // rather than greying it out for an outage.\n if (!cancelled) setGbifCount(null);\n }\n );\n return () => {\n cancelled = true;\n };\n }, [gbifChecklistKey, focalTaxon?.id]);\n\n // true → GBIF has occurrences (or unknown — still loading or API failed)\n // false → GBIF returned count = 0\n const gbifAvailable = !hasGbifConfigured\n ? false\n : gbifCount === null || gbifCount > 0;\n\n const allMappableFailed =\n mappable.length > 0 && fetchFailures >= mappable.length;\n const showMap =\n showDistributionMap &&\n (mappable.length > 0 || gbifAvailable) &&\n !(mappable.length > 0 && allMappableFailed && !gbifAvailable);\n\n // Nothing to show — no map (no mappable records and no GBIF occurrences) and\n // no records to list. Hide the whole block, like other empty content blocks.\n if (!showMap && !hasAnyRecords) return null;\n\n const unmappable = baseUnmappable + fetchFailures;\n const showToggle = hasAnyRecords;\n\n let body;\n if (!showMap) {\n // No map to show — just the plain text list.\n body = <ListView datasetKey={datasetKey} data={data} />;\n } else {\n // Map available. The Map/List toggle is rendered above the view switch so\n // it stays visible in BOTH sub-views — the user can always go back to the\n // map after looking at the list.\n const activeView = showToggle ? view : \"map\";\n body = (\n <>\n {showToggle ? (\n <Radio.Group\n size=\"small\"\n value={activeView}\n onChange={(e) => setView(e.target.value)}\n style={{ marginBottom: 8 }}\n >\n <Radio.Button value=\"map\">Map</Radio.Button>\n <Radio.Button value=\"list\">List</Radio.Button>\n </Radio.Group>\n ) : (\n // Reserve the vertical space the Map/List toggle would occupy so the\n // map's top edge lines up with the \"Distributions\" label.\n <div style={{ height: 24, marginBottom: 8 }} />\n )}\n {activeView === \"map\" ? (\n <>\n <DistributionsMap\n records={mappable}\n onUnmappable={setFetchFailures}\n datasetKey={datasetKey}\n focalTaxon={focalTaxon}\n rankOrder={rankOrder}\n gbifChecklistKey={gbifChecklistKey}\n gbifAvailable={gbifAvailable}\n basemapStyle={basemapStyle}\n onShowList={showToggle ? () => setView(\"list\") : undefined}\n />\n {showToggle && unmappable > 0 && (\n <div style={{ marginTop: 6 }}>\n <a onClick={() => setView(\"list\")} style={{ cursor: \"pointer\" }}>\n +{unmappable} distribution{unmappable === 1 ? \"\" : \"s\"} not on\n map\n </a>\n </div>\n )}\n </>\n ) : (\n <ListView datasetKey={datasetKey} data={data} />\n )}\n </>\n );\n }\n\n // No negative top nudge: the map block's top element (the Map/List toggle, or\n // the spacer reserving its height) lines up with the \"Distributions\" label\n // the same way every other content row does. The plain text-only list aligns\n // naturally too.\n const content = <div style={style}>{body}</div>;\n\n // When a `label` is given (the Taxon page), own the labelled block so it\n // disappears entirely when empty (returning null above). Standalone embeds\n // pass no label and just get the bare block.\n return label ? (\n <PresentationItem md={md} label={label}>\n {content}\n </PresentationItem>\n ) : (\n content\n );\n};\n\nexport default DistributionsTable;\n"],"names":["BookOutlined","_extends","target","i","source","key","props","ref","React","AntdIcon","BookOutlinedSvg","RefIcon","DOI_PREFIX_RE","referenceHref","reference","csl","ReferenceLink","href","_a","jsxs","Fragment","jsx","LinkOutlined","ReferencePopover","__publicField","referenceId","datasetKey","references","refIds","isArray","id","get","client","config","res","err","error","loading","Spin","ErrorMsg","r","e","el","referenceIndexMap","trigger","maxInline","icon","shown","overflow","Popover","visible","INFRASPECIFIC_RANKS","getDescendantRanks","focalRank","rankOrder","focalIdx","POOL_SIZE","isMappable","_b","runPool","items","worker","size","results","next","runners","searchDescendants","focalId","ranks","params","s","url","u","_c","_e","_d","_f","fetchDistributions","taxonId","fetchDescendants","focalTaxon","descendantsFailed","list","distributions","t","all","VIVID_PALETTE","rankIndex","rank","assignColors","taxa","sorted","b","ra","rb","out","resolveBasemapStyle","prop","CARTO_HOST","cartoTransformRequest","parsed","wrapStyle","scrollStyle","groupHeadingStyle","firstGroupHeadingStyle","rowStyle","swatchStyle","color","footerToggleStyle","footerWrapStyle","footerGroupHeadingStyle","footerFirstGroupHeadingStyle","footerNameStyle","totalCount","groups","sum","g","GbifHexEntry","IncludedTaxaLegend","visibleGroups","unmappableGroups","showGbif","showUnmappable","setShowUnmappable","useState","visibleCount","unmappableCount","v","cached","probe","ctx","isWebglSupported","POPUP_FIELDS","ESTABLISHMENT_MEANS","ESTABLISHMENT_COLORS","m","MISSING_COLOR","normalizeKey","resolveKey","record","raw","k","colorFor","GBIF_VISIBLE_KEY","readStoredGbifVisible","defaultValue","readSetting","writeStoredGbifVisible","writeSetting","GBIF_TILE_PATH","FOCAL_SOURCE","FOCAL_FILL","FOCAL_LINE","GBIF_SOURCE","GBIF_LAYER","descendantSourceId","descendantFillId","descendantLineId","cache","fetchShape","gazetteer","p","escapeHtml","popupHtml","title","rows","f","descendantPopupHtml","taxon","RANK_LABEL_PLURAL","rankLabelPlural","epithet","scientificName","tokens","GbifLegendEntry","computeBounds","features","minLng","minLat","maxLng","maxLat","visit","coords","lng","lat","flattenFeatures","geojson","DistributionsMap","records","onUnmappable","gbifChecklistKey","gbifAvailable","basemapStyle","onShowList","containerRef","useRef","wrapperRef","mapRef","popupRef","recordMapRef","descendantTaxonMapRef","descendantRecordMapRef","focalAttachedRef","gbifAttachedRef","descendantLayersRef","webglFailed","setWebglFailed","readyMap","setReadyMap","focalReady","setFocalReady","descendantState","setDescendantState","focalVisible","setFocalVisible","isGbifOnly","gbifVisible","setGbifVisible","visibleTaxonIds","setVisibleTaxonIds","controlOpen","setControlOpen","fetchTriggeredRef","handleToggleGbif","activateGbif","presentMeans","useMemo","seen","descendantColors","descendantLegend","decorate","groupByRank","byRank","showDescendantLegend","styleSpec","cartoKey","styleKey","useEffect","map","maplibregl","attrib","resizeObserver","cancelled","recordMap","failures","recordKey","data","beforeId","onFocalClick","onMouseEnter","onMouseLeave","bounds","feature","searchUrl","descendantVisibility","colors","rec","srcId","fillId","lineId","onDescendantClick","triggerDescendantFetch","openControl","descendantsByRank","a","toggleTaxon","prev","toggleRankGroup","rankTaxa","allOn","focalName","LayerControl","open","onOpen","onClose","onToggleFocal","gbifEnabled","onToggleGbif","descendantStatus","onToggleTaxon","onToggleRankGroup","onRetry","group","someOn","ListView","iso3Map","setIso3Map","isIso","keyBy","MergedDataBadge","startCase","DistributionsTable","style","showDistributionMap","label","md","mappable","baseUnmappable","hasGbifConfigured","hasAnyRecords","view","setView","fetchFailures","setFetchFailures","gbifCount","setGbifCount","publicClient","allMappableFailed","showMap","unmappable","showToggle","body","activeView","Radio","content","PresentationItem"],"mappings":";;;;;;;;;;;;;;;;;AACA,IAAIA,KAAe,EAAE,MAAQ,EAAE,KAAO,OAAO,OAAS,EAAE,SAAW,iBAAiB,WAAa,QAAO,GAAI,UA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EAAAA,UAAA,EACE,UAAA;AAAA,QAAAC,gBAAAA,EAAAA;AAAAA,UAACsK;AAAA,UAAA;AAAA,YACC,SAAS6G;AAAA,YACT,cAAcO;AAAA,YACd,YAAArR;AAAA,YACA,YAAAsD;AAAA,YACA,WAAA1B;AAAA,YACA,kBAAAwI;AAAA,YACA,eAAAC;AAAA,YACA,cAAAC;AAAA,YACA,YAAYsH,IAAa,MAAMT,EAAQ,MAAM,IAAI;AAAA,UAAA;AAAA,QAAA;AAAA,QAElDS,KAAcD,IAAa,KAC1BhS,gBAAAA,MAAC,SAAI,OAAO,EAAE,WAAW,EAAA,GACvB,iCAAC,KAAA,EAAE,SAAS,MAAMwR,EAAQ,MAAM,GAAG,OAAO,EAAE,QAAQ,UAAA,GAAa,UAAA;AAAA,UAAA;AAAA,UAC7DQ;AAAA,UAAW;AAAA,UAAcA,MAAe,IAAI,KAAK;AAAA,UAAI;AAAA,QAAA,EAAA,CAEzD,EAAA,CACF;AAAA,MAAA,EAAA,CAEJ,IAEAhS,gBAAAA,EAAAA,IAACuQ,IAAA,EAAS,YAAAlQ,GAAwB,MAAA4N,EAAA,CAAY;AAAA,IAAA,GAElD;AAAA,EAEJ;AAMA,QAAMoE,IAAUrS,gBAAAA,EAAAA,IAAC,OAAA,EAAI,OAAA+Q,GAAe,UAAAmB,GAAK;AAKzC,SAAOjB,IACLjR,gBAAAA,MAACsS,IAAA,EAAiB,IAAApB,GAAQ,OAAAD,GACvB,aACH,IAEAoB;AAEJ;","x_google_ignoreList":[0,1]}
@@ -0,0 +1,174 @@
1
+ import { j as a } from "./jsx-runtime-BzflLqGi.js";
2
+ import { useState as y, useEffect as v } from "react";
3
+ import { c as q } from "./config--bs_09I6.js";
4
+ import { u as F, c as J } from "./router-CssZk5qZ.js";
5
+ import C from "highcharts";
6
+ import "highcharts/modules/exporting";
7
+ import K from "highcharts-react-official";
8
+ import { startCase as Q, get as T } from "lodash-es";
9
+ import { Row as Z, Col as L, Spin as tt, Switch as et } from "antd";
10
+ import { r as nt, w as ot } from "./storage-BgdCo9fV.js";
11
+ const R = "breakdown-level", w = 100, z = (n) => n ? `Not assigned ${n}` : "Not assigned", it = (n, d) => {
12
+ const e = (n || []).filter((r) => r.id).sort((r, u) => (u.count || 0) - (r.count || 0)).slice(0, w), c = e.reduce((r, u) => r + (u.count || 0), 0), s = T(n, "[0].rank", "");
13
+ return c < d ? [
14
+ ...e,
15
+ { name: z(s), count: d - c, children: [] }
16
+ ] : e;
17
+ }, kt = ({
18
+ taxon: n,
19
+ datasetKey: d,
20
+ dataset: e,
21
+ level: c = 1,
22
+ showLevelSwitch: s = !1,
23
+ darkMode: r
24
+ }) => {
25
+ const u = F("taxon"), [E, A] = y(null), [B, k] = y(!1), [W, x] = y(!1), [f, O] = y(
26
+ () => s ? nt(R, c) : c
27
+ );
28
+ v(() => {
29
+ s || O(c);
30
+ }, [c, s]), v(() => {
31
+ s && ot(R, f);
32
+ }, [f, s]), v(() => {
33
+ n != null && n.id && d && G();
34
+ }, [n, d, f]);
35
+ const G = async () => {
36
+ k(!0);
37
+ try {
38
+ const l = (await J(
39
+ `${q.dataApi}dataset/${d}/taxon/${encodeURIComponent(
40
+ n.id
41
+ )}/breakdown?level=${f}`
42
+ )).data || {};
43
+ if (k(!1), !l.countRank || !l.children || l.children.length === 0) {
44
+ x(!0);
45
+ return;
46
+ }
47
+ x(!1), H(l);
48
+ } catch {
49
+ k(!1), x(!0);
50
+ }
51
+ }, H = ({ children: p, total: l, countRank: j }) => {
52
+ const D = Q(j === "genus" ? "genera" : j), P = e.doi ? "https://doi.org/" + e.doi : null, N = C.getOptions().colors, S = (typeof r == "boolean" ? r : typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-color-scheme: dark)").matches) ? "#1f1f1f" : "#ffffff", $ = {
53
+ click: (t) => {
54
+ t.point._id && u(t.point._id);
55
+ }
56
+ }, g = it(p, l).map((t, o) => ({
57
+ name: t.name,
58
+ y: t.count,
59
+ _id: t.id,
60
+ color: N[o % N.length],
61
+ _kids: t.children
62
+ })), _ = [], m = g.some((t) => t._kids && t._kids.length > 0);
63
+ m && g.forEach((t) => {
64
+ const o = (t._kids || []).filter((i) => i.id).sort((i, h) => (h.count || 0) - (i.count || 0)).slice(0, w), b = o.reduce((i, h) => i + (h.count || 0), 0);
65
+ o.forEach((i, h) => {
66
+ const Y = -0.1 + (o.length > 1 ? h / (o.length - 1) : 0) * 0.4;
67
+ _.push({
68
+ name: i.name,
69
+ y: i.count,
70
+ _id: i.id,
71
+ color: C.color(t.color).brighten(Y).get()
72
+ });
73
+ }), b < t.y && _.push({
74
+ name: z(T(t._kids, "[0].rank", "")),
75
+ y: t.y - b,
76
+ color: S,
77
+ borderColor: S,
78
+ borderWidth: 0,
79
+ dataLabels: { enabled: !1 }
80
+ });
81
+ });
82
+ const U = (t) => t.map(({ _kids: o, ...b }) => b), V = l || g.reduce((t, o) => t + o.y, 0), X = m ? {
83
+ formatter: function() {
84
+ return this.y > V / 10 ? this.point.name : null;
85
+ },
86
+ distance: -30,
87
+ style: {
88
+ color: "contrast",
89
+ textOutline: "1px contrast",
90
+ fontWeight: "bold"
91
+ }
92
+ } : {
93
+ formatter: function() {
94
+ return this.y > 0 ? "<b>" + this.point.name + ":</b> " + this.y.toLocaleString("en-GB") : null;
95
+ }
96
+ }, I = [
97
+ {
98
+ name: D,
99
+ data: U(g),
100
+ size: m ? "60%" : "85%",
101
+ dataLabels: X,
102
+ point: { events: $ }
103
+ }
104
+ ];
105
+ m && I.push({
106
+ name: D,
107
+ data: _,
108
+ size: "85%",
109
+ innerSize: "60%",
110
+ dataLabels: {
111
+ formatter: function() {
112
+ return this.y > 0 ? "<b>" + this.point.name + ":</b> " + this.y.toLocaleString("en-GB") : null;
113
+ }
114
+ },
115
+ point: { events: $ }
116
+ }), A({
117
+ chart: { type: "pie" },
118
+ credits: {
119
+ text: `${n.name.scientificName} in ${e.title}${e.version ? " (" + e.version + ")" : ""}. ${(e.doi ? "DOI:" + e.doi : null) || e.url || ""}`,
120
+ href: P || e.url || ""
121
+ },
122
+ title: { text: "" },
123
+ plotOptions: { pie: { shadow: !1, center: ["50%", "50%"] } },
124
+ tooltip: {},
125
+ series: I,
126
+ responsive: {
127
+ rules: [
128
+ {
129
+ condition: { maxWidth: 400 },
130
+ chartOptions: {
131
+ series: m ? [{}, { dataLabels: { enabled: !1 } }] : [{}]
132
+ }
133
+ }
134
+ ]
135
+ },
136
+ exporting: {
137
+ chartOptions: {
138
+ plotOptions: { series: { dataLabels: { enabled: !0 } } }
139
+ },
140
+ fallbackToExportServer: !1
141
+ }
142
+ });
143
+ };
144
+ if (W) return null;
145
+ const M = s ? /* @__PURE__ */ a.jsx(
146
+ et,
147
+ {
148
+ size: "small",
149
+ checked: f === 2,
150
+ onChange: (p) => O(p ? 2 : 1),
151
+ checkedChildren: "lvl2",
152
+ unCheckedChildren: "lvl1",
153
+ style: {
154
+ position: "absolute",
155
+ top: 11,
156
+ right: 44,
157
+ zIndex: 2,
158
+ background: f === 2 ? "#8c8c8c" : "#bfbfbf"
159
+ }
160
+ }
161
+ ) : null;
162
+ return /* @__PURE__ */ a.jsxs("div", { style: { position: "relative" }, children: [
163
+ M,
164
+ B || !E ? /* @__PURE__ */ a.jsxs(Z, { style: { padding: "48px" }, children: [
165
+ /* @__PURE__ */ a.jsx(L, { flex: "auto" }),
166
+ /* @__PURE__ */ a.jsx(L, { children: /* @__PURE__ */ a.jsx(tt, { size: "large" }) }),
167
+ /* @__PURE__ */ a.jsx(L, { flex: "auto" })
168
+ ] }) : /* @__PURE__ */ a.jsx(K, { highcharts: C, options: E })
169
+ ] });
170
+ };
171
+ export {
172
+ kt as T
173
+ };
174
+ //# sourceMappingURL=TaxonBreakdown-CyHl1YES.js.map