@octostar/map-component 0.10.0 → 0.11.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/dist/index.mjs CHANGED
@@ -858,12 +858,12 @@ void instance.use(ICUWithContext).init({
858
858
  interpolation: { escapeValue: false }
859
859
  });
860
860
  const CATALOGS = {
861
- it: () => import("./it-JiSfNdMa.js"),
862
- fr: () => import("./fr-ftr3hxY2.js"),
863
- de: () => import("./de-CiibAOpt.js"),
864
- es: () => import("./es-D8jViCNt.js"),
865
- "pt-BR": () => import("./pt-BR-DfnZxiOD.js"),
866
- "pt-PT": () => import("./pt-PT-Cvl_rDbf.js")
861
+ it: () => import("./it-D8wMaegA.js"),
862
+ fr: () => import("./fr-CaNTJBXD.js"),
863
+ de: () => import("./de-baB1tmXy.js"),
864
+ es: () => import("./es-BOFeFpOn.js"),
865
+ "pt-BR": () => import("./pt-BR-DU8z2z6T.js"),
866
+ "pt-PT": () => import("./pt-PT-ByMcI3iF.js")
867
867
  };
868
868
  const loaded = /* @__PURE__ */ new Set([DEFAULT_LANGUAGE]);
869
869
  const loading = /* @__PURE__ */ new Map();
@@ -1327,7 +1327,10 @@ const visualLayerSettingLabels = (t) => ({
1327
1327
  filterValues: t("Filter values…"),
1328
1328
  noMatches: t("No matches"),
1329
1329
  showLess: t("Show less"),
1330
- showAll: (count) => t("Show all ({count})", { count })
1330
+ showAll: (count) => t("Show all ({count})", { count }),
1331
+ legendCount: (count) => t("{count, number}", { count }),
1332
+ legendRowTitle: (value, count) => t("{value} ({count, number})", { value, count }),
1333
+ legendRowShare: (value, count, share) => t("{value} ({count, number}, {share, number, percent})", { value, count, share })
1331
1334
  });
1332
1335
  const pointIconLabels = (t) => ({
1333
1336
  iconSameForAll: t("Same for all", { context: "map point icon" }),
@@ -7571,6 +7574,472 @@ function PointIconSettings({
7571
7574
  ] })
7572
7575
  ] });
7573
7576
  }
7577
+ const OTHER_BUCKET_KEY = "__other__";
7578
+ const OTHER_BUCKET_COLOR = "#9ca3af";
7579
+ function toDisplayName(name, otherLabel) {
7580
+ return name === OTHER_BUCKET_KEY ? otherLabel : name;
7581
+ }
7582
+ function createPieSVG(categories, total, otherLabel, size = 44, onSliceHover, badgeValue) {
7583
+ const container = document.createElement("div");
7584
+ container.style.width = `${size}px`;
7585
+ container.style.height = `${size}px`;
7586
+ container.style.cursor = "pointer";
7587
+ const radius = size / 2;
7588
+ const innerRadius = radius * 0.5;
7589
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
7590
+ svg.setAttribute("width", String(size));
7591
+ svg.setAttribute("height", String(size));
7592
+ svg.setAttribute("viewBox", `0 0 ${size} ${size}`);
7593
+ svg.style.display = "block";
7594
+ const bgCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
7595
+ bgCircle.setAttribute("cx", String(radius));
7596
+ bgCircle.setAttribute("cy", String(radius));
7597
+ bgCircle.setAttribute("r", String(radius));
7598
+ bgCircle.setAttribute("fill", "white");
7599
+ svg.appendChild(bgCircle);
7600
+ const slicesSum = categories.reduce((s, c) => s + c.count, 0);
7601
+ const remainder = Math.max(0, total - slicesSum);
7602
+ const renderList = remainder > 0 ? [...categories, { name: "__remainder__", displayName: otherLabel, count: remainder, color: OTHER_BUCKET_COLOR }] : categories;
7603
+ const nonZeroSlices = renderList.filter((c) => c.count > 0);
7604
+ const isSingleFullSlice = nonZeroSlices.length === 1 && nonZeroSlices[0].count >= total;
7605
+ if (isSingleFullSlice) {
7606
+ const cat = nonZeroSlices[0];
7607
+ const ring = document.createElementNS("http://www.w3.org/2000/svg", "path");
7608
+ const d = [
7609
+ `M 0 ${radius}`,
7610
+ `a ${radius} ${radius} 0 1 0 ${radius * 2} 0`,
7611
+ `a ${radius} ${radius} 0 1 0 ${-radius * 2} 0`,
7612
+ `M ${radius - innerRadius} ${radius}`,
7613
+ `a ${innerRadius} ${innerRadius} 0 1 1 ${innerRadius * 2} 0`,
7614
+ `a ${innerRadius} ${innerRadius} 0 1 1 ${-innerRadius * 2} 0`,
7615
+ "Z"
7616
+ ].join(" ");
7617
+ ring.setAttribute("d", d);
7618
+ ring.setAttribute("fill-rule", "evenodd");
7619
+ ring.setAttribute("fill", cat.color);
7620
+ ring.setAttribute("stroke", "white");
7621
+ ring.setAttribute("stroke-width", "1");
7622
+ ring.style.transition = "opacity 0.15s";
7623
+ ring.addEventListener("mouseenter", (e) => {
7624
+ ring.style.opacity = "0.8";
7625
+ if (onSliceHover) onSliceHover(cat, e);
7626
+ });
7627
+ ring.addEventListener("mouseleave", (e) => {
7628
+ ring.style.opacity = "1";
7629
+ if (onSliceHover) onSliceHover(null, e);
7630
+ });
7631
+ svg.appendChild(ring);
7632
+ }
7633
+ let currentAngle = -90;
7634
+ (isSingleFullSlice ? [] : renderList).forEach((cat) => {
7635
+ if (cat.count === 0) return;
7636
+ const sliceAngle = cat.count / total * 360;
7637
+ const startAngle = currentAngle;
7638
+ const endAngle = currentAngle + sliceAngle;
7639
+ const startRad = startAngle * Math.PI / 180;
7640
+ const endRad = endAngle * Math.PI / 180;
7641
+ const x1 = radius + radius * Math.cos(startRad);
7642
+ const y1 = radius + radius * Math.sin(startRad);
7643
+ const x2 = radius + radius * Math.cos(endRad);
7644
+ const y2 = radius + radius * Math.sin(endRad);
7645
+ const x3 = radius + innerRadius * Math.cos(endRad);
7646
+ const y3 = radius + innerRadius * Math.sin(endRad);
7647
+ const x4 = radius + innerRadius * Math.cos(startRad);
7648
+ const y4 = radius + innerRadius * Math.sin(startRad);
7649
+ const largeArc = sliceAngle > 180 ? 1 : 0;
7650
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
7651
+ const d = [
7652
+ `M ${x1} ${y1}`,
7653
+ `A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2}`,
7654
+ `L ${x3} ${y3}`,
7655
+ `A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${x4} ${y4}`,
7656
+ "Z"
7657
+ ].join(" ");
7658
+ path.setAttribute("d", d);
7659
+ path.setAttribute("fill", cat.color);
7660
+ path.setAttribute("stroke", "white");
7661
+ path.setAttribute("stroke-width", "1");
7662
+ path.style.transition = "opacity 0.15s";
7663
+ path.addEventListener("mouseenter", (e) => {
7664
+ path.style.opacity = "0.8";
7665
+ if (onSliceHover) onSliceHover(cat, e);
7666
+ });
7667
+ path.addEventListener("mouseleave", (e) => {
7668
+ path.style.opacity = "1";
7669
+ if (onSliceHover) onSliceHover(null, e);
7670
+ });
7671
+ svg.appendChild(path);
7672
+ currentAngle = endAngle;
7673
+ });
7674
+ const centerCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
7675
+ centerCircle.setAttribute("cx", String(radius));
7676
+ centerCircle.setAttribute("cy", String(radius));
7677
+ centerCircle.setAttribute("r", String(innerRadius - 2));
7678
+ centerCircle.setAttribute("fill", "#1f2937");
7679
+ svg.appendChild(centerCircle);
7680
+ const badgeText = formatClusterBadge(badgeValue ?? total);
7681
+ const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
7682
+ text.setAttribute("x", String(radius));
7683
+ text.setAttribute("y", String(radius));
7684
+ text.setAttribute("text-anchor", "middle");
7685
+ text.setAttribute("dominant-baseline", "central");
7686
+ text.setAttribute("fill", "white");
7687
+ text.setAttribute("font-size", badgeText.length >= 6 ? "8" : badgeText.length >= 4 ? "9" : badgeText.length >= 3 ? "10" : "11");
7688
+ text.setAttribute("font-weight", "bold");
7689
+ text.setAttribute("font-family", "system-ui, sans-serif");
7690
+ text.textContent = badgeText;
7691
+ svg.appendChild(text);
7692
+ container.appendChild(svg);
7693
+ return container;
7694
+ }
7695
+ let tooltipEl = null;
7696
+ function showTooltip(cat, x, y) {
7697
+ if (!tooltipEl) {
7698
+ tooltipEl = document.createElement("div");
7699
+ tooltipEl.style.cssText = `
7700
+ position: fixed;
7701
+ background: rgba(0,0,0,0.85);
7702
+ color: white;
7703
+ padding: 6px 10px;
7704
+ border-radius: 4px;
7705
+ font-size: 12px;
7706
+ font-family: system-ui, sans-serif;
7707
+ pointer-events: none;
7708
+ z-index: 10000;
7709
+ white-space: nowrap;
7710
+ box-shadow: 0 2px 8px rgba(0,0,0,0.3);
7711
+ `;
7712
+ document.body.appendChild(tooltipEl);
7713
+ }
7714
+ while (tooltipEl.firstChild) tooltipEl.removeChild(tooltipEl.firstChild);
7715
+ const row = document.createElement("div");
7716
+ row.style.cssText = "display: flex; align-items: center; gap: 6px;";
7717
+ const swatch = document.createElement("span");
7718
+ swatch.style.cssText = "width: 10px; height: 10px; border-radius: 2px;";
7719
+ swatch.style.backgroundColor = cat.color;
7720
+ row.appendChild(swatch);
7721
+ const label = document.createElement("span");
7722
+ const name = document.createElement("strong");
7723
+ name.textContent = cat.displayName;
7724
+ label.appendChild(name);
7725
+ label.appendChild(document.createTextNode(`: ${cat.count}`));
7726
+ row.appendChild(label);
7727
+ tooltipEl.appendChild(row);
7728
+ tooltipEl.style.left = `${x + 12}px`;
7729
+ tooltipEl.style.top = `${y - 10}px`;
7730
+ tooltipEl.style.display = "block";
7731
+ }
7732
+ function hideTooltip() {
7733
+ if (tooltipEl) {
7734
+ tooltipEl.style.display = "none";
7735
+ }
7736
+ }
7737
+ function fingerprintCluster(pointCount, counts2, size, badgeValue) {
7738
+ return `${size}|${pointCount}|${badgeValue ?? ""}|${counts2.join(",")}`;
7739
+ }
7740
+ function buildPieElement(categories, pointCount, otherLabel, size, source, clusterId, map, coords, badgeValue) {
7741
+ const el = createPieSVG(categories, pointCount, otherLabel, size, (cat, event) => {
7742
+ if (cat) {
7743
+ showTooltip(cat, event.clientX, event.clientY);
7744
+ } else {
7745
+ hideTooltip();
7746
+ }
7747
+ }, badgeValue);
7748
+ el.addEventListener("click", () => {
7749
+ source.getClusterExpansionZoom(clusterId).then((zoom) => {
7750
+ if (typeof zoom === "number") {
7751
+ map.easeTo({ center: coords, zoom: zoom + 0.5 });
7752
+ }
7753
+ }).catch(() => {
7754
+ });
7755
+ });
7756
+ return el;
7757
+ }
7758
+ function renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers, otherLabel) {
7759
+ const source = map.getSource(sourceId);
7760
+ if (!source) return;
7761
+ const clusters = map.querySourceFeatures(sourceId, {
7762
+ filter: ["has", "point_count"]
7763
+ });
7764
+ const visibleClusterIds = /* @__PURE__ */ new Set();
7765
+ clusters.forEach((feature) => {
7766
+ var _a, _b, _c;
7767
+ const clusterId = (_a = feature.properties) == null ? void 0 : _a.cluster_id;
7768
+ if (clusterId === void 0) return;
7769
+ const clusterKey = `${clusterId}`;
7770
+ visibleClusterIds.add(clusterKey);
7771
+ const coords = feature.geometry.coordinates;
7772
+ const pointCount = ((_b = feature.properties) == null ? void 0 : _b.point_count) || 0;
7773
+ const sumRaw = (_c = feature.properties) == null ? void 0 : _c[CLUSTER_SUM_PROP];
7774
+ const sumNum = typeof sumRaw === "number" ? sumRaw : sumRaw != null ? Number(sumRaw) : NaN;
7775
+ const badgeValue = Number.isFinite(sumNum) ? sumNum : void 0;
7776
+ const allCounts = categoryValues.map((_, i) => {
7777
+ var _a2;
7778
+ return Number(((_a2 = feature.properties) == null ? void 0 : _a2[`cat_${i}`]) || 0);
7779
+ });
7780
+ const categories = categoryValues.map((cat, i) => ({
7781
+ name: cat,
7782
+ displayName: toDisplayName(cat, otherLabel),
7783
+ count: allCounts[i],
7784
+ color: categoryColorMap[cat] || "#3b82f6"
7785
+ })).filter((c) => c.count > 0);
7786
+ const size = pointCount < 100 ? 40 : pointCount < 750 ? 50 : 60;
7787
+ const fingerprint = fingerprintCluster(pointCount, allCounts, size, badgeValue);
7788
+ const existing = markers.get(clusterKey);
7789
+ if (existing && existing.fingerprint === fingerprint) {
7790
+ existing.marker.setLngLat(coords);
7791
+ return;
7792
+ }
7793
+ const el = buildPieElement(categories, pointCount, otherLabel, size, source, clusterId, map, coords, badgeValue);
7794
+ if (existing) {
7795
+ existing.marker.remove();
7796
+ }
7797
+ const marker = new maplibregl.Marker({ element: el }).setLngLat(coords).addTo(map);
7798
+ markers.set(clusterKey, { marker, fingerprint });
7799
+ });
7800
+ markers.forEach((entry, key) => {
7801
+ if (!visibleClusterIds.has(key)) {
7802
+ entry.marker.remove();
7803
+ markers.delete(key);
7804
+ }
7805
+ });
7806
+ }
7807
+ function createClusterPieManager(map, sourceId, categoryValues, categoryColorMap, otherLabel = DEFAULT_MAP_LABELS.canvas.clusterOther) {
7808
+ const markers = /* @__PURE__ */ new Map();
7809
+ let updateScheduled = false;
7810
+ function scheduleUpdate() {
7811
+ if (updateScheduled) return;
7812
+ updateScheduled = true;
7813
+ requestAnimationFrame(() => {
7814
+ updateScheduled = false;
7815
+ renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers, otherLabel);
7816
+ });
7817
+ }
7818
+ function onData(e) {
7819
+ if (e.dataType === "source" && e.sourceId === sourceId) {
7820
+ scheduleUpdate();
7821
+ }
7822
+ }
7823
+ map.on("moveend", scheduleUpdate);
7824
+ map.on("data", onData);
7825
+ scheduleUpdate();
7826
+ return {
7827
+ update: scheduleUpdate,
7828
+ destroy: () => {
7829
+ map.off("moveend", scheduleUpdate);
7830
+ map.off("data", onData);
7831
+ markers.forEach((entry) => entry.marker.remove());
7832
+ markers.clear();
7833
+ hideTooltip();
7834
+ }
7835
+ };
7836
+ }
7837
+ function ClusterPieManager(props) {
7838
+ const { map, sourceId, categoryValues, categoryColorMap, visible } = props;
7839
+ const otherLabel = useMapLabels().canvas.clusterOther;
7840
+ const markersRef = useRef(/* @__PURE__ */ new Map());
7841
+ const updateScheduled = useRef(false);
7842
+ const updateMarkers = useCallback(() => {
7843
+ if (!map || !visible) {
7844
+ markersRef.current.forEach((entry) => entry.marker.remove());
7845
+ markersRef.current.clear();
7846
+ return;
7847
+ }
7848
+ renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markersRef.current, otherLabel);
7849
+ }, [map, sourceId, categoryValues, categoryColorMap, visible, otherLabel]);
7850
+ useEffect(() => {
7851
+ if (!map) return;
7852
+ const scheduleUpdate = () => {
7853
+ if (updateScheduled.current) return;
7854
+ updateScheduled.current = true;
7855
+ requestAnimationFrame(() => {
7856
+ updateScheduled.current = false;
7857
+ updateMarkers();
7858
+ });
7859
+ };
7860
+ const onData = (e) => {
7861
+ if (e.dataType === "source" && e.sourceId === sourceId) {
7862
+ scheduleUpdate();
7863
+ }
7864
+ };
7865
+ scheduleUpdate();
7866
+ map.on("moveend", scheduleUpdate);
7867
+ map.on("data", onData);
7868
+ return () => {
7869
+ map.off("moveend", scheduleUpdate);
7870
+ map.off("data", onData);
7871
+ markersRef.current.forEach((entry) => entry.marker.remove());
7872
+ markersRef.current.clear();
7873
+ hideTooltip();
7874
+ };
7875
+ }, [map, sourceId, updateMarkers]);
7876
+ useEffect(() => {
7877
+ if (!visible) {
7878
+ markersRef.current.forEach((entry) => entry.marker.remove());
7879
+ markersRef.current.clear();
7880
+ hideTooltip();
7881
+ } else {
7882
+ updateMarkers();
7883
+ }
7884
+ }, [visible, updateMarkers]);
7885
+ return null;
7886
+ }
7887
+ const LEGEND_MAX_VALUES = 50;
7888
+ const LEGEND_INITIAL_VISIBLE = 8;
7889
+ function LegendTitle({ children }) {
7890
+ return /* @__PURE__ */ jsx("div", { className: "text-[10px] font-semibold uppercase tracking-wide text-foreground mb-1.5", children });
7891
+ }
7892
+ function LegendRowView({
7893
+ row,
7894
+ maxCount,
7895
+ total,
7896
+ bucket = false
7897
+ }) {
7898
+ const { layerSettings: labels } = useMapLabels();
7899
+ return /* @__PURE__ */ jsxs(
7900
+ "div",
7901
+ {
7902
+ className: "relative flex items-center gap-2 px-1 py-0.5 text-[11px]",
7903
+ title: total ? labels.legendRowShare(row.value, row.count, row.count / total) : labels.legendRowTitle(row.value, row.count),
7904
+ "data-testid": "legend-row",
7905
+ children: [
7906
+ /* @__PURE__ */ jsx(
7907
+ "span",
7908
+ {
7909
+ "aria-hidden": true,
7910
+ className: "absolute inset-y-0 left-0 rounded-sm bg-muted/60",
7911
+ style: { width: `${row.count / maxCount * 100}%` }
7912
+ }
7913
+ ),
7914
+ /* @__PURE__ */ jsx(
7915
+ "span",
7916
+ {
7917
+ className: "relative inline-block w-3 h-3 rounded-full shrink-0 ring-1 ring-inset ring-black/15",
7918
+ style: { backgroundColor: row.color },
7919
+ "data-testid": "legend-swatch"
7920
+ }
7921
+ ),
7922
+ /* @__PURE__ */ jsx(
7923
+ "span",
7924
+ {
7925
+ className: `relative truncate flex-1 ${bucket ? "italic text-muted-foreground" : "text-foreground"}`,
7926
+ "data-testid": "legend-value",
7927
+ children: row.value
7928
+ }
7929
+ ),
7930
+ /* @__PURE__ */ jsx("span", { className: "relative text-muted-foreground tabular-nums", "data-testid": "legend-count", children: labels.legendCount(row.count) })
7931
+ ]
7932
+ }
7933
+ );
7934
+ }
7935
+ function ValueLegend({
7936
+ testId,
7937
+ title,
7938
+ rows,
7939
+ pinned,
7940
+ total,
7941
+ layerId,
7942
+ fieldName
7943
+ }) {
7944
+ const { layerSettings: labels } = useMapLabels();
7945
+ const [expanded, setExpanded] = useState(false);
7946
+ const [filter, setFilter] = useState("");
7947
+ useEffect(() => {
7948
+ setFilter("");
7949
+ setExpanded(false);
7950
+ }, [layerId, fieldName]);
7951
+ const filtered = useMemo(() => {
7952
+ const q = filter.trim().toLowerCase();
7953
+ if (!q) return rows;
7954
+ return rows.filter((r) => r.value.toLowerCase().includes(q));
7955
+ }, [rows, filter]);
7956
+ if (rows.length === 0 && !pinned) return null;
7957
+ const visible = expanded ? filtered : filtered.slice(0, LEGEND_INITIAL_VISIBLE);
7958
+ const hiddenCount = filtered.length - visible.length;
7959
+ const maxCount = Math.max(1, ...rows.map((r) => r.count), (pinned == null ? void 0 : pinned.count) ?? 0);
7960
+ return /* @__PURE__ */ jsxs("div", { className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5", "data-testid": testId, children: [
7961
+ /* @__PURE__ */ jsx(LegendTitle, { children: title }),
7962
+ (rows.length > LEGEND_INITIAL_VISIBLE || expanded) && /* @__PURE__ */ jsx(
7963
+ Input,
7964
+ {
7965
+ size: "small",
7966
+ allowClear: true,
7967
+ placeholder: labels.filterValues,
7968
+ value: filter,
7969
+ onChange: (e) => setFilter(e.target.value),
7970
+ className: "mb-1 !text-[11px]",
7971
+ "data-testid": `${testId}-filter`
7972
+ }
7973
+ ),
7974
+ /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 max-h-48 overflow-y-auto", "data-testid": `${testId}-rows`, children: [
7975
+ visible.map((row) => /* @__PURE__ */ jsx(LegendRowView, { row, maxCount, total }, row.value)),
7976
+ visible.length === 0 && rows.length > 0 && /* @__PURE__ */ jsx("div", { className: "text-[11px] text-muted-foreground italic", children: labels.noMatches })
7977
+ ] }),
7978
+ pinned && /* @__PURE__ */ jsx("div", { className: "mt-0.5 pt-0.5 border-t border-border/50", "data-testid": `${testId}-pinned`, children: /* @__PURE__ */ jsx(LegendRowView, { row: pinned, maxCount, total, bucket: true }) }),
7979
+ (hiddenCount > 0 || expanded && filtered.length > LEGEND_INITIAL_VISIBLE) && /* @__PURE__ */ jsx(
7980
+ "button",
7981
+ {
7982
+ type: "button",
7983
+ className: "mt-1 text-[11px] text-primary hover:underline",
7984
+ onClick: () => setExpanded((e) => !e),
7985
+ "data-testid": `${testId}-toggle`,
7986
+ children: expanded ? labels.showLess : labels.showAll(filtered.length)
7987
+ }
7988
+ )
7989
+ ] });
7990
+ }
7991
+ function ColorByFieldLegend({
7992
+ layerId,
7993
+ fieldName,
7994
+ getFieldValueDistribution
7995
+ }) {
7996
+ const { layerSettings: labels } = useMapLabels();
7997
+ const distribution = useMemo(
7998
+ () => getFieldValueDistribution(layerId, fieldName, LEGEND_MAX_VALUES),
7999
+ [getFieldValueDistribution, layerId, fieldName]
8000
+ );
8001
+ const rows = useMemo(() => distribution.map((d) => ({ ...d, color: hashStringToColor(d.value) })), [distribution]);
8002
+ return /* @__PURE__ */ jsx(
8003
+ ValueLegend,
8004
+ {
8005
+ testId: `legend-color-by-${layerId}`,
8006
+ title: distribution.length >= LEGEND_MAX_VALUES ? labels.legendTop(LEGEND_MAX_VALUES) : labels.legend,
8007
+ rows,
8008
+ layerId,
8009
+ fieldName
8010
+ }
8011
+ );
8012
+ }
8013
+ function ClusterPieLegend({
8014
+ layerId,
8015
+ fieldName,
8016
+ getClusterPieCategories
8017
+ }) {
8018
+ const { layerSettings: labels, canvas } = useMapLabels();
8019
+ const categories = useMemo(
8020
+ () => getClusterPieCategories(layerId, fieldName),
8021
+ [getClusterPieCategories, layerId, fieldName]
8022
+ );
8023
+ const rows = useMemo(
8024
+ () => ((categories == null ? void 0 : categories.values) ?? []).map((v) => ({ ...v, color: hashStringToColor(v.value) })),
8025
+ [categories]
8026
+ );
8027
+ if (!categories) return null;
8028
+ const { otherCount } = categories;
8029
+ const total = rows.reduce((sum, r) => sum + r.count, otherCount);
8030
+ return /* @__PURE__ */ jsx(
8031
+ ValueLegend,
8032
+ {
8033
+ testId: `legend-cluster-pie-${layerId}`,
8034
+ title: labels.legend,
8035
+ rows,
8036
+ pinned: otherCount > 0 ? { value: canvas.clusterOther, count: otherCount, color: OTHER_BUCKET_COLOR } : void 0,
8037
+ total,
8038
+ layerId,
8039
+ fieldName
8040
+ }
8041
+ );
8042
+ }
7574
8043
  const MAP_STYLES = [
7575
8044
  { id: "streets", name: "Streets", icon: Map$1 },
7576
8045
  { id: "satellite", name: "Satellite", icon: Satellite },
@@ -7588,87 +8057,6 @@ function builtInBasemapName(id, labels) {
7588
8057
  return void 0;
7589
8058
  }
7590
8059
  }
7591
- const LEGEND_MAX_VALUES = 50;
7592
- const LEGEND_INITIAL_VISIBLE = 8;
7593
- function ColorByFieldLegend({
7594
- layerId,
7595
- fieldName,
7596
- getFieldValueDistribution
7597
- }) {
7598
- const { layerSettings: labels } = useMapLabels();
7599
- const [expanded, setExpanded] = useState(false);
7600
- const [filter, setFilter] = useState("");
7601
- useEffect(() => {
7602
- setFilter("");
7603
- setExpanded(false);
7604
- }, [layerId, fieldName]);
7605
- const distribution = useMemo(
7606
- () => getFieldValueDistribution(layerId, fieldName, LEGEND_MAX_VALUES),
7607
- [getFieldValueDistribution, layerId, fieldName]
7608
- );
7609
- const filtered = useMemo(() => {
7610
- const q = filter.trim().toLowerCase();
7611
- if (!q) return distribution;
7612
- return distribution.filter((d) => d.value.toLowerCase().includes(q));
7613
- }, [distribution, filter]);
7614
- if (distribution.length === 0) return null;
7615
- const visible = expanded ? filtered : filtered.slice(0, LEGEND_INITIAL_VISIBLE);
7616
- const hiddenCount = filtered.length - visible.length;
7617
- return /* @__PURE__ */ jsxs(
7618
- "div",
7619
- {
7620
- className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5",
7621
- "data-testid": `legend-color-by-${layerId}`,
7622
- children: [
7623
- /* @__PURE__ */ jsx("div", { className: "text-[10px] uppercase tracking-wide text-muted-foreground mb-1", children: distribution.length >= LEGEND_MAX_VALUES ? labels.legendTop(LEGEND_MAX_VALUES) : labels.legend }),
7624
- (distribution.length > LEGEND_INITIAL_VISIBLE || expanded) && /* @__PURE__ */ jsx(
7625
- Input,
7626
- {
7627
- size: "small",
7628
- allowClear: true,
7629
- placeholder: labels.filterValues,
7630
- value: filter,
7631
- onChange: (e) => setFilter(e.target.value),
7632
- className: "mb-1 !text-[11px]",
7633
- "data-testid": `legend-filter-${layerId}`
7634
- }
7635
- ),
7636
- /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 max-h-40 overflow-y-auto", children: [
7637
- visible.map(({ value, count }) => /* @__PURE__ */ jsxs(
7638
- "div",
7639
- {
7640
- className: "flex items-center gap-1.5 text-[11px]",
7641
- title: `${value} (${count})`,
7642
- children: [
7643
- /* @__PURE__ */ jsx(
7644
- "span",
7645
- {
7646
- className: "inline-block w-2.5 h-2.5 rounded-sm shrink-0 border border-black/10",
7647
- style: { backgroundColor: hashStringToColor(value) }
7648
- }
7649
- ),
7650
- /* @__PURE__ */ jsx("span", { className: "truncate flex-1 text-foreground", children: value }),
7651
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground tabular-nums", children: count })
7652
- ]
7653
- },
7654
- value
7655
- )),
7656
- visible.length === 0 && /* @__PURE__ */ jsx("div", { className: "text-[11px] text-muted-foreground italic", children: labels.noMatches })
7657
- ] }),
7658
- (hiddenCount > 0 || expanded && filtered.length > LEGEND_INITIAL_VISIBLE) && /* @__PURE__ */ jsx(
7659
- "button",
7660
- {
7661
- type: "button",
7662
- className: "mt-1 text-[11px] text-primary hover:underline",
7663
- onClick: () => setExpanded((e) => !e),
7664
- "data-testid": `legend-toggle-${layerId}`,
7665
- children: expanded ? labels.showLess : labels.showAll(filtered.length)
7666
- }
7667
- )
7668
- ]
7669
- }
7670
- );
7671
- }
7672
8060
  function ColorGradientLegend({
7673
8061
  layerId,
7674
8062
  min,
@@ -7683,7 +8071,7 @@ function ColorGradientLegend({
7683
8071
  className: "mt-1 rounded border border-border/50 bg-background/40 p-1.5",
7684
8072
  "data-testid": `legend-gradient-${layerId}`,
7685
8073
  children: [
7686
- /* @__PURE__ */ jsx("div", { className: "text-[10px] uppercase tracking-wide text-muted-foreground mb-1", children: sampled ? labels.legendSampled : labels.legend }),
8074
+ /* @__PURE__ */ jsx(LegendTitle, { children: sampled ? labels.legendSampled : labels.legend }),
7687
8075
  /* @__PURE__ */ jsx(
7688
8076
  "div",
7689
8077
  {
@@ -7728,6 +8116,7 @@ function LayersPanel({
7728
8116
  getSuggestedTraceField,
7729
8117
  getLayerFields,
7730
8118
  getFieldValueDistribution,
8119
+ getClusterPieCategories,
7731
8120
  onUpdateHeatmapConfig,
7732
8121
  onUpdateClusterConfig,
7733
8122
  onUpdateVisualConfig,
@@ -8252,7 +8641,15 @@ function LayersPanel({
8252
8641
  }
8253
8642
  ),
8254
8643
  /* @__PURE__ */ jsx("span", { className: "text-[10px]", children: settingsLabels.colorBubblesByValue })
8255
- ] })
8644
+ ] }),
8645
+ layer.clusterConfig.groupByField && getClusterPieCategories && /* @__PURE__ */ jsx(
8646
+ ClusterPieLegend,
8647
+ {
8648
+ layerId: layer.id,
8649
+ fieldName: layer.clusterConfig.groupByField,
8650
+ getClusterPieCategories
8651
+ }
8652
+ )
8256
8653
  ] })
8257
8654
  ] })
8258
8655
  ] }),
@@ -12383,6 +12780,29 @@ function fieldValueDistribution(features, fieldName, maxValues, scanLimit = feat
12383
12780
  }
12384
12781
  return Array.from(counts2.entries()).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, maxValues).map(([value, count]) => ({ value, count }));
12385
12782
  }
12783
+ const CLUSTER_PIE_MAX_CATEGORIES = 15;
12784
+ function clusterPieKey(raw) {
12785
+ return raw !== null && typeof raw === "object" ? JSON.stringify(raw) : categoricalKey(raw);
12786
+ }
12787
+ const ranksAbove = (value, count, other) => count > other.count || count === other.count && value < other.value;
12788
+ function clusterPieCategories(points, fieldName) {
12789
+ var _a;
12790
+ const counts2 = /* @__PURE__ */ new Map();
12791
+ for (const point2 of points) {
12792
+ const key = clusterPieKey((_a = point2.properties) == null ? void 0 : _a[fieldName]);
12793
+ if (key !== null) counts2.set(key, (counts2.get(key) ?? 0) + 1);
12794
+ }
12795
+ const values = [];
12796
+ counts2.forEach((count, value) => {
12797
+ let at = values.length;
12798
+ while (at > 0 && ranksAbove(value, count, values[at - 1])) at--;
12799
+ if (at >= CLUSTER_PIE_MAX_CATEGORIES) return;
12800
+ values.splice(at, 0, { value, count });
12801
+ if (values.length > CLUSTER_PIE_MAX_CATEGORIES) values.pop();
12802
+ });
12803
+ const inSlices = values.reduce((sum, v) => sum + v.count, 0);
12804
+ return { values, otherCount: points.length - inSlices };
12805
+ }
12386
12806
  const SELECTION_OVERLAY_SOURCE_ID = "selection-overlay";
12387
12807
  const SELECTION_OVERLAY_LAYER_IDS = {
12388
12808
  iconRing: "selection-overlay-icon-ring",
@@ -12463,518 +12883,208 @@ function buildSelectionOverlayStack(newTextLabel) {
12463
12883
  // crowded spot is stable across repaints.
12464
12884
  "symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
12465
12885
  },
12466
- paint: buildCustomLabelPaint()
12467
- }
12468
- ];
12469
- }
12470
- function buildSelectionOverlayData(ids, styleFor) {
12471
- const features = [];
12472
- ids.forEach((id) => {
12473
- styleFor(id).forEach((feature) => features.push(feature));
12474
- });
12475
- return { type: "FeatureCollection", features };
12476
- }
12477
- function renderedFeatureId(f) {
12478
- var _a;
12479
- const fromProps = (_a = f.properties) == null ? void 0 : _a.id;
12480
- if (fromProps !== void 0 && fromProps !== null && fromProps !== "") return String(fromProps);
12481
- if (f.id !== void 0 && f.id !== null && f.id !== "") return String(f.id);
12482
- return null;
12483
- }
12484
- function resolveTooltipFeature(rendered, lookup) {
12485
- const id = renderedFeatureId(rendered);
12486
- const stored = id === null ? null : lookup(id);
12487
- if (stored) {
12488
- return deepClone({
12489
- type: "Feature",
12490
- geometry: stored.geometry,
12491
- properties: stored.properties ?? {},
12492
- id: stored.id
12493
- });
12494
- }
12495
- return {
12496
- type: "Feature",
12497
- geometry: rendered.geometry,
12498
- properties: { ...rendered.properties ?? {} },
12499
- id: rendered.id
12500
- };
12501
- }
12502
- const DEFAULT_POINT_RADIUS = 5;
12503
- const DEFAULT_ICON_SIZE = 24;
12504
- const MAX_POINT_RADIUS = 24;
12505
- const SAME_SPOT_PX = 1;
12506
- const CROWD = 16;
12507
- const SCAN_LIMIT = 256;
12508
- const isDot = (m) => m.center !== null;
12509
- const distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
12510
- function paintedRadius(f) {
12511
- var _a, _b;
12512
- const p = f.properties ?? {};
12513
- const hidden = ((_a = f.state) == null ? void 0 : _a[TIMELINE_HIDDEN_KEY]) === true || p.isHiddenByCluster === 1 || p.isHiddenByHeatmap === 1;
12514
- if (hidden) return 0;
12515
- if (typeof p.icon === "string" && p.icon !== "") {
12516
- return typeof p.iconSize === "number" && Number.isFinite(p.iconSize) ? p.iconSize / 2 : DEFAULT_ICON_SIZE / 2;
12517
- }
12518
- const r = ((_b = f.state) == null ? void 0 : _b[TRACE_ENDPOINT_KEY]) === true ? p._endpointRadius : p.pointRadius;
12519
- return typeof r === "number" && Number.isFinite(r) ? r : DEFAULT_POINT_RADIUS;
12520
- }
12521
- function labelPriority(f) {
12522
- var _a;
12523
- const v = (_a = f.properties) == null ? void 0 : _a._labelPriority;
12524
- return typeof v === "number" && Number.isFinite(v) ? v : DEFAULT_LABEL_PRIORITY;
12525
- }
12526
- function members(features, project, maxDots = Infinity) {
12527
- const seen = /* @__PURE__ */ new Set();
12528
- const out = [];
12529
- let dots = 0;
12530
- for (const feature of features) {
12531
- const id = renderedFeatureId(feature);
12532
- if (id === null || seen.has(id)) continue;
12533
- if (seen.size === SCAN_LIMIT || dots === maxDots) return { members: out, cut: true };
12534
- seen.add(id);
12535
- if (feature.geometry.type !== "Point") {
12536
- out.push({ id, feature, center: null, radius: 0 });
12537
- continue;
12538
- }
12539
- const radius = paintedRadius(feature);
12540
- if (radius <= 0) continue;
12541
- out.push({ id, feature, center: project(feature.geometry.coordinates), radius });
12542
- dots++;
12543
- }
12544
- return { members: out, cut: false };
12545
- }
12546
- function searchBox(dot) {
12547
- const reach = dot.radius + MAX_POINT_RADIUS;
12548
- return [[dot.center.x - reach, dot.center.y - reach], [dot.center.x + reach, dot.center.y + reach]];
12549
- }
12550
- function featureStackAt(point2, hits, queryBox, project) {
12551
- const hit = members(hits, project, CROWD + 1).members;
12552
- const under = hit.filter(isDot);
12553
- if (under.length === 0) return { features: hit.length > 0 ? [hit[0].feature] : [], more: false };
12554
- const fromCursor = (d) => distance(d.center, point2);
12555
- const byCursor = (a, b) => fromCursor(a) - fromCursor(b);
12556
- let dots;
12557
- let more;
12558
- if (under.length > CROWD) {
12559
- dots = under.sort(byCursor).slice(0, CROWD);
12560
- more = true;
12561
- } else {
12562
- const nearest = under.reduce((a, b) => fromCursor(b) < fromCursor(a) ? b : a);
12563
- const taken = new Set(under.map((d) => d.id));
12564
- const box = members(queryBox(searchBox(nearest)), project);
12565
- const neighbours = box.members.filter(isDot).filter((m) => !taken.has(m.id) && distance(m.center, nearest.center) <= m.radius + nearest.radius);
12566
- dots = [...under, ...neighbours].sort(byCursor);
12567
- more = box.cut;
12568
- }
12569
- const spot = dots[0].center;
12570
- const onSpot = dots.filter((d) => distance(d.center, spot) < SAME_SPOT_PX).sort((a, b) => labelPriority(a.feature) - labelPriority(b.feature));
12571
- const rest = dots.filter((d) => distance(d.center, spot) >= SAME_SPOT_PX);
12572
- return { features: [...onSpot, ...rest].map((d) => d.feature), more };
12573
- }
12574
- function computeBubbleDomain(values) {
12575
- let min = Infinity;
12576
- let max = -Infinity;
12577
- for (const v of values) {
12578
- if (!Number.isFinite(v)) continue;
12579
- if (v < min) min = v;
12580
- if (v > max) max = v;
12581
- }
12582
- return isFinite(min) ? { min, max } : null;
12583
- }
12584
- function bubbleGradientColorExpression(prop, min, max) {
12585
- if (!(max > min)) return gradientColor(0.5);
12586
- const expr = ["interpolate", ["linear"], ["get", prop]];
12587
- const span = max - min;
12588
- GRADIENT_RAMP.forEach((color, i) => {
12589
- expr.push(min + span * i / (GRADIENT_RAMP.length - 1), color);
12590
- });
12591
- return expr;
12592
- }
12593
- function createClusterGradientManager(map, sourceId, options) {
12594
- const clusterProp = options.valueProp ?? "point_count";
12595
- let scheduled = false;
12596
- let lastDomainKey = "";
12597
- let reportedFailure = false;
12598
- function reportFailure(stage, error) {
12599
- if (reportedFailure) return;
12600
- reportedFailure = true;
12601
- console.error(`[map-component] cluster gradient ${stage} failed; bubbles keep their current colors:`, error);
12602
- }
12603
- function apply() {
12604
- scheduled = false;
12605
- let values;
12606
- try {
12607
- if (!map.getSource(sourceId)) return;
12608
- values = map.querySourceFeatures(sourceId, { filter: ["has", "point_count"] }).map((f) => {
12609
- var _a;
12610
- return Number((_a = f.properties) == null ? void 0 : _a[clusterProp]);
12611
- });
12612
- if (options.singleLayerId) {
12613
- const singles = map.querySourceFeatures(sourceId, {
12614
- filter: ["all", ["!", ["has", "point_count"]], [">", ["get", CLUSTER_COUNT_VALUE_PROP], 1]]
12615
- });
12616
- values.push(...singles.map((f) => {
12617
- var _a;
12618
- return Number((_a = f.properties) == null ? void 0 : _a[CLUSTER_COUNT_VALUE_PROP]);
12619
- }));
12620
- }
12621
- } catch (error) {
12622
- reportFailure("domain query", error);
12623
- return;
12624
- }
12625
- const domain = computeBubbleDomain(values);
12626
- if (!domain) return;
12627
- const key = `${domain.min}|${domain.max}`;
12628
- if (key === lastDomainKey) return;
12629
- lastDomainKey = key;
12630
- try {
12631
- if (map.getLayer(options.clustersLayerId)) {
12632
- map.setPaintProperty(
12633
- options.clustersLayerId,
12634
- "circle-color",
12635
- bubbleGradientColorExpression(clusterProp, domain.min, domain.max)
12636
- );
12637
- }
12638
- if (options.singleLayerId && map.getLayer(options.singleLayerId)) {
12639
- map.setPaintProperty(
12640
- options.singleLayerId,
12641
- "circle-color",
12642
- bubbleGradientColorExpression(CLUSTER_COUNT_VALUE_PROP, domain.min, domain.max)
12643
- );
12644
- }
12645
- } catch (error) {
12646
- reportFailure("paint update", error);
12647
- lastDomainKey = "";
12886
+ paint: buildCustomLabelPaint()
12648
12887
  }
12888
+ ];
12889
+ }
12890
+ function buildSelectionOverlayData(ids, styleFor) {
12891
+ const features = [];
12892
+ ids.forEach((id) => {
12893
+ styleFor(id).forEach((feature) => features.push(feature));
12894
+ });
12895
+ return { type: "FeatureCollection", features };
12896
+ }
12897
+ function renderedFeatureId(f) {
12898
+ var _a;
12899
+ const fromProps = (_a = f.properties) == null ? void 0 : _a.id;
12900
+ if (fromProps !== void 0 && fromProps !== null && fromProps !== "") return String(fromProps);
12901
+ if (f.id !== void 0 && f.id !== null && f.id !== "") return String(f.id);
12902
+ return null;
12903
+ }
12904
+ function resolveTooltipFeature(rendered, lookup) {
12905
+ const id = renderedFeatureId(rendered);
12906
+ const stored = id === null ? null : lookup(id);
12907
+ if (stored) {
12908
+ return deepClone({
12909
+ type: "Feature",
12910
+ geometry: stored.geometry,
12911
+ properties: stored.properties ?? {},
12912
+ id: stored.id
12913
+ });
12649
12914
  }
12650
- function schedule() {
12651
- if (scheduled) return;
12652
- scheduled = true;
12653
- requestAnimationFrame(apply);
12654
- }
12655
- function onData(e) {
12656
- if (e.dataType === "source" && e.sourceId === sourceId) schedule();
12657
- }
12658
- map.on("moveend", schedule);
12659
- map.on("data", onData);
12660
- schedule();
12661
12915
  return {
12662
- destroy: () => {
12663
- map.off("moveend", schedule);
12664
- map.off("data", onData);
12665
- }
12916
+ type: "Feature",
12917
+ geometry: rendered.geometry,
12918
+ properties: { ...rendered.properties ?? {} },
12919
+ id: rendered.id
12666
12920
  };
12667
12921
  }
12668
- const OTHER_BUCKET_KEY = "__other__";
12669
- const OTHER_BUCKET_COLOR = "#9ca3af";
12670
- function toDisplayName(name, otherLabel) {
12671
- return name === OTHER_BUCKET_KEY ? otherLabel : name;
12672
- }
12673
- function createPieSVG(categories, total, otherLabel, size = 44, onSliceHover, badgeValue) {
12674
- const container = document.createElement("div");
12675
- container.style.width = `${size}px`;
12676
- container.style.height = `${size}px`;
12677
- container.style.cursor = "pointer";
12678
- const radius = size / 2;
12679
- const innerRadius = radius * 0.5;
12680
- const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
12681
- svg.setAttribute("width", String(size));
12682
- svg.setAttribute("height", String(size));
12683
- svg.setAttribute("viewBox", `0 0 ${size} ${size}`);
12684
- svg.style.display = "block";
12685
- const bgCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
12686
- bgCircle.setAttribute("cx", String(radius));
12687
- bgCircle.setAttribute("cy", String(radius));
12688
- bgCircle.setAttribute("r", String(radius));
12689
- bgCircle.setAttribute("fill", "white");
12690
- svg.appendChild(bgCircle);
12691
- const slicesSum = categories.reduce((s, c) => s + c.count, 0);
12692
- const remainder = Math.max(0, total - slicesSum);
12693
- const renderList = remainder > 0 ? [...categories, { name: "__remainder__", displayName: otherLabel, count: remainder, color: OTHER_BUCKET_COLOR }] : categories;
12694
- const nonZeroSlices = renderList.filter((c) => c.count > 0);
12695
- const isSingleFullSlice = nonZeroSlices.length === 1 && nonZeroSlices[0].count >= total;
12696
- if (isSingleFullSlice) {
12697
- const cat = nonZeroSlices[0];
12698
- const ring = document.createElementNS("http://www.w3.org/2000/svg", "path");
12699
- const d = [
12700
- `M 0 ${radius}`,
12701
- `a ${radius} ${radius} 0 1 0 ${radius * 2} 0`,
12702
- `a ${radius} ${radius} 0 1 0 ${-radius * 2} 0`,
12703
- `M ${radius - innerRadius} ${radius}`,
12704
- `a ${innerRadius} ${innerRadius} 0 1 1 ${innerRadius * 2} 0`,
12705
- `a ${innerRadius} ${innerRadius} 0 1 1 ${-innerRadius * 2} 0`,
12706
- "Z"
12707
- ].join(" ");
12708
- ring.setAttribute("d", d);
12709
- ring.setAttribute("fill-rule", "evenodd");
12710
- ring.setAttribute("fill", cat.color);
12711
- ring.setAttribute("stroke", "white");
12712
- ring.setAttribute("stroke-width", "1");
12713
- ring.style.transition = "opacity 0.15s";
12714
- ring.addEventListener("mouseenter", (e) => {
12715
- ring.style.opacity = "0.8";
12716
- if (onSliceHover) onSliceHover(cat, e);
12717
- });
12718
- ring.addEventListener("mouseleave", (e) => {
12719
- ring.style.opacity = "1";
12720
- if (onSliceHover) onSliceHover(null, e);
12721
- });
12722
- svg.appendChild(ring);
12922
+ const DEFAULT_POINT_RADIUS = 5;
12923
+ const DEFAULT_ICON_SIZE = 24;
12924
+ const MAX_POINT_RADIUS = 24;
12925
+ const SAME_SPOT_PX = 1;
12926
+ const CROWD = 16;
12927
+ const SCAN_LIMIT = 256;
12928
+ const isDot = (m) => m.center !== null;
12929
+ const distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
12930
+ function paintedRadius(f) {
12931
+ var _a, _b;
12932
+ const p = f.properties ?? {};
12933
+ const hidden = ((_a = f.state) == null ? void 0 : _a[TIMELINE_HIDDEN_KEY]) === true || p.isHiddenByCluster === 1 || p.isHiddenByHeatmap === 1;
12934
+ if (hidden) return 0;
12935
+ if (typeof p.icon === "string" && p.icon !== "") {
12936
+ return typeof p.iconSize === "number" && Number.isFinite(p.iconSize) ? p.iconSize / 2 : DEFAULT_ICON_SIZE / 2;
12723
12937
  }
12724
- let currentAngle = -90;
12725
- (isSingleFullSlice ? [] : renderList).forEach((cat) => {
12726
- if (cat.count === 0) return;
12727
- const sliceAngle = cat.count / total * 360;
12728
- const startAngle = currentAngle;
12729
- const endAngle = currentAngle + sliceAngle;
12730
- const startRad = startAngle * Math.PI / 180;
12731
- const endRad = endAngle * Math.PI / 180;
12732
- const x1 = radius + radius * Math.cos(startRad);
12733
- const y1 = radius + radius * Math.sin(startRad);
12734
- const x2 = radius + radius * Math.cos(endRad);
12735
- const y2 = radius + radius * Math.sin(endRad);
12736
- const x3 = radius + innerRadius * Math.cos(endRad);
12737
- const y3 = radius + innerRadius * Math.sin(endRad);
12738
- const x4 = radius + innerRadius * Math.cos(startRad);
12739
- const y4 = radius + innerRadius * Math.sin(startRad);
12740
- const largeArc = sliceAngle > 180 ? 1 : 0;
12741
- const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
12742
- const d = [
12743
- `M ${x1} ${y1}`,
12744
- `A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2}`,
12745
- `L ${x3} ${y3}`,
12746
- `A ${innerRadius} ${innerRadius} 0 ${largeArc} 0 ${x4} ${y4}`,
12747
- "Z"
12748
- ].join(" ");
12749
- path.setAttribute("d", d);
12750
- path.setAttribute("fill", cat.color);
12751
- path.setAttribute("stroke", "white");
12752
- path.setAttribute("stroke-width", "1");
12753
- path.style.transition = "opacity 0.15s";
12754
- path.addEventListener("mouseenter", (e) => {
12755
- path.style.opacity = "0.8";
12756
- if (onSliceHover) onSliceHover(cat, e);
12757
- });
12758
- path.addEventListener("mouseleave", (e) => {
12759
- path.style.opacity = "1";
12760
- if (onSliceHover) onSliceHover(null, e);
12761
- });
12762
- svg.appendChild(path);
12763
- currentAngle = endAngle;
12764
- });
12765
- const centerCircle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
12766
- centerCircle.setAttribute("cx", String(radius));
12767
- centerCircle.setAttribute("cy", String(radius));
12768
- centerCircle.setAttribute("r", String(innerRadius - 2));
12769
- centerCircle.setAttribute("fill", "#1f2937");
12770
- svg.appendChild(centerCircle);
12771
- const badgeText = formatClusterBadge(badgeValue ?? total);
12772
- const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
12773
- text.setAttribute("x", String(radius));
12774
- text.setAttribute("y", String(radius));
12775
- text.setAttribute("text-anchor", "middle");
12776
- text.setAttribute("dominant-baseline", "central");
12777
- text.setAttribute("fill", "white");
12778
- text.setAttribute("font-size", badgeText.length >= 6 ? "8" : badgeText.length >= 4 ? "9" : badgeText.length >= 3 ? "10" : "11");
12779
- text.setAttribute("font-weight", "bold");
12780
- text.setAttribute("font-family", "system-ui, sans-serif");
12781
- text.textContent = badgeText;
12782
- svg.appendChild(text);
12783
- container.appendChild(svg);
12784
- return container;
12938
+ const r = ((_b = f.state) == null ? void 0 : _b[TRACE_ENDPOINT_KEY]) === true ? p._endpointRadius : p.pointRadius;
12939
+ return typeof r === "number" && Number.isFinite(r) ? r : DEFAULT_POINT_RADIUS;
12785
12940
  }
12786
- let tooltipEl = null;
12787
- function showTooltip(cat, x, y) {
12788
- if (!tooltipEl) {
12789
- tooltipEl = document.createElement("div");
12790
- tooltipEl.style.cssText = `
12791
- position: fixed;
12792
- background: rgba(0,0,0,0.85);
12793
- color: white;
12794
- padding: 6px 10px;
12795
- border-radius: 4px;
12796
- font-size: 12px;
12797
- font-family: system-ui, sans-serif;
12798
- pointer-events: none;
12799
- z-index: 10000;
12800
- white-space: nowrap;
12801
- box-shadow: 0 2px 8px rgba(0,0,0,0.3);
12802
- `;
12803
- document.body.appendChild(tooltipEl);
12941
+ function labelPriority(f) {
12942
+ var _a;
12943
+ const v = (_a = f.properties) == null ? void 0 : _a._labelPriority;
12944
+ return typeof v === "number" && Number.isFinite(v) ? v : DEFAULT_LABEL_PRIORITY;
12945
+ }
12946
+ function members(features, project, maxDots = Infinity) {
12947
+ const seen = /* @__PURE__ */ new Set();
12948
+ const out = [];
12949
+ let dots = 0;
12950
+ for (const feature of features) {
12951
+ const id = renderedFeatureId(feature);
12952
+ if (id === null || seen.has(id)) continue;
12953
+ if (seen.size === SCAN_LIMIT || dots === maxDots) return { members: out, cut: true };
12954
+ seen.add(id);
12955
+ if (feature.geometry.type !== "Point") {
12956
+ out.push({ id, feature, center: null, radius: 0 });
12957
+ continue;
12958
+ }
12959
+ const radius = paintedRadius(feature);
12960
+ if (radius <= 0) continue;
12961
+ out.push({ id, feature, center: project(feature.geometry.coordinates), radius });
12962
+ dots++;
12804
12963
  }
12805
- while (tooltipEl.firstChild) tooltipEl.removeChild(tooltipEl.firstChild);
12806
- const row = document.createElement("div");
12807
- row.style.cssText = "display: flex; align-items: center; gap: 6px;";
12808
- const swatch = document.createElement("span");
12809
- swatch.style.cssText = "width: 10px; height: 10px; border-radius: 2px;";
12810
- swatch.style.backgroundColor = cat.color;
12811
- row.appendChild(swatch);
12812
- const label = document.createElement("span");
12813
- const name = document.createElement("strong");
12814
- name.textContent = cat.displayName;
12815
- label.appendChild(name);
12816
- label.appendChild(document.createTextNode(`: ${cat.count}`));
12817
- row.appendChild(label);
12818
- tooltipEl.appendChild(row);
12819
- tooltipEl.style.left = `${x + 12}px`;
12820
- tooltipEl.style.top = `${y - 10}px`;
12821
- tooltipEl.style.display = "block";
12964
+ return { members: out, cut: false };
12822
12965
  }
12823
- function hideTooltip() {
12824
- if (tooltipEl) {
12825
- tooltipEl.style.display = "none";
12966
+ function searchBox(dot) {
12967
+ const reach = dot.radius + MAX_POINT_RADIUS;
12968
+ return [[dot.center.x - reach, dot.center.y - reach], [dot.center.x + reach, dot.center.y + reach]];
12969
+ }
12970
+ function featureStackAt(point2, hits, queryBox, project) {
12971
+ const hit = members(hits, project, CROWD + 1).members;
12972
+ const under = hit.filter(isDot);
12973
+ if (under.length === 0) return { features: hit.length > 0 ? [hit[0].feature] : [], more: false };
12974
+ const fromCursor = (d) => distance(d.center, point2);
12975
+ const byCursor = (a, b) => fromCursor(a) - fromCursor(b);
12976
+ let dots;
12977
+ let more;
12978
+ if (under.length > CROWD) {
12979
+ dots = under.sort(byCursor).slice(0, CROWD);
12980
+ more = true;
12981
+ } else {
12982
+ const nearest = under.reduce((a, b) => fromCursor(b) < fromCursor(a) ? b : a);
12983
+ const taken = new Set(under.map((d) => d.id));
12984
+ const box = members(queryBox(searchBox(nearest)), project);
12985
+ const neighbours = box.members.filter(isDot).filter((m) => !taken.has(m.id) && distance(m.center, nearest.center) <= m.radius + nearest.radius);
12986
+ dots = [...under, ...neighbours].sort(byCursor);
12987
+ more = box.cut;
12826
12988
  }
12989
+ const spot = dots[0].center;
12990
+ const onSpot = dots.filter((d) => distance(d.center, spot) < SAME_SPOT_PX).sort((a, b) => labelPriority(a.feature) - labelPriority(b.feature));
12991
+ const rest = dots.filter((d) => distance(d.center, spot) >= SAME_SPOT_PX);
12992
+ return { features: [...onSpot, ...rest].map((d) => d.feature), more };
12827
12993
  }
12828
- function fingerprintCluster(pointCount, counts2, size, badgeValue) {
12829
- return `${size}|${pointCount}|${badgeValue ?? ""}|${counts2.join(",")}`;
12994
+ function computeBubbleDomain(values) {
12995
+ let min = Infinity;
12996
+ let max = -Infinity;
12997
+ for (const v of values) {
12998
+ if (!Number.isFinite(v)) continue;
12999
+ if (v < min) min = v;
13000
+ if (v > max) max = v;
13001
+ }
13002
+ return isFinite(min) ? { min, max } : null;
12830
13003
  }
12831
- function buildPieElement(categories, pointCount, otherLabel, size, source, clusterId, map, coords, badgeValue) {
12832
- const el = createPieSVG(categories, pointCount, otherLabel, size, (cat, event) => {
12833
- if (cat) {
12834
- showTooltip(cat, event.clientX, event.clientY);
12835
- } else {
12836
- hideTooltip();
12837
- }
12838
- }, badgeValue);
12839
- el.addEventListener("click", () => {
12840
- source.getClusterExpansionZoom(clusterId).then((zoom) => {
12841
- if (typeof zoom === "number") {
12842
- map.easeTo({ center: coords, zoom: zoom + 0.5 });
12843
- }
12844
- }).catch(() => {
12845
- });
13004
+ function bubbleGradientColorExpression(prop, min, max) {
13005
+ if (!(max > min)) return gradientColor(0.5);
13006
+ const expr = ["interpolate", ["linear"], ["get", prop]];
13007
+ const span = max - min;
13008
+ GRADIENT_RAMP.forEach((color, i) => {
13009
+ expr.push(min + span * i / (GRADIENT_RAMP.length - 1), color);
12846
13010
  });
12847
- return el;
13011
+ return expr;
12848
13012
  }
12849
- function renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers, otherLabel) {
12850
- const source = map.getSource(sourceId);
12851
- if (!source) return;
12852
- const clusters = map.querySourceFeatures(sourceId, {
12853
- filter: ["has", "point_count"]
12854
- });
12855
- const visibleClusterIds = /* @__PURE__ */ new Set();
12856
- clusters.forEach((feature) => {
12857
- var _a, _b, _c;
12858
- const clusterId = (_a = feature.properties) == null ? void 0 : _a.cluster_id;
12859
- if (clusterId === void 0) return;
12860
- const clusterKey = `${clusterId}`;
12861
- visibleClusterIds.add(clusterKey);
12862
- const coords = feature.geometry.coordinates;
12863
- const pointCount = ((_b = feature.properties) == null ? void 0 : _b.point_count) || 0;
12864
- const sumRaw = (_c = feature.properties) == null ? void 0 : _c[CLUSTER_SUM_PROP];
12865
- const sumNum = typeof sumRaw === "number" ? sumRaw : sumRaw != null ? Number(sumRaw) : NaN;
12866
- const badgeValue = Number.isFinite(sumNum) ? sumNum : void 0;
12867
- const allCounts = categoryValues.map((_, i) => {
12868
- var _a2;
12869
- return Number(((_a2 = feature.properties) == null ? void 0 : _a2[`cat_${i}`]) || 0);
12870
- });
12871
- const categories = categoryValues.map((cat, i) => ({
12872
- name: cat,
12873
- displayName: toDisplayName(cat, otherLabel),
12874
- count: allCounts[i],
12875
- color: categoryColorMap[cat] || "#3b82f6"
12876
- })).filter((c) => c.count > 0);
12877
- const size = pointCount < 100 ? 40 : pointCount < 750 ? 50 : 60;
12878
- const fingerprint = fingerprintCluster(pointCount, allCounts, size, badgeValue);
12879
- const existing = markers.get(clusterKey);
12880
- if (existing && existing.fingerprint === fingerprint) {
12881
- existing.marker.setLngLat(coords);
13013
+ function createClusterGradientManager(map, sourceId, options) {
13014
+ const clusterProp = options.valueProp ?? "point_count";
13015
+ let scheduled = false;
13016
+ let lastDomainKey = "";
13017
+ let reportedFailure = false;
13018
+ function reportFailure(stage, error) {
13019
+ if (reportedFailure) return;
13020
+ reportedFailure = true;
13021
+ console.error(`[map-component] cluster gradient ${stage} failed; bubbles keep their current colors:`, error);
13022
+ }
13023
+ function apply() {
13024
+ scheduled = false;
13025
+ let values;
13026
+ try {
13027
+ if (!map.getSource(sourceId)) return;
13028
+ values = map.querySourceFeatures(sourceId, { filter: ["has", "point_count"] }).map((f) => {
13029
+ var _a;
13030
+ return Number((_a = f.properties) == null ? void 0 : _a[clusterProp]);
13031
+ });
13032
+ if (options.singleLayerId) {
13033
+ const singles = map.querySourceFeatures(sourceId, {
13034
+ filter: ["all", ["!", ["has", "point_count"]], [">", ["get", CLUSTER_COUNT_VALUE_PROP], 1]]
13035
+ });
13036
+ values.push(...singles.map((f) => {
13037
+ var _a;
13038
+ return Number((_a = f.properties) == null ? void 0 : _a[CLUSTER_COUNT_VALUE_PROP]);
13039
+ }));
13040
+ }
13041
+ } catch (error) {
13042
+ reportFailure("domain query", error);
12882
13043
  return;
12883
13044
  }
12884
- const el = buildPieElement(categories, pointCount, otherLabel, size, source, clusterId, map, coords, badgeValue);
12885
- if (existing) {
12886
- existing.marker.remove();
12887
- }
12888
- const marker = new maplibregl.Marker({ element: el }).setLngLat(coords).addTo(map);
12889
- markers.set(clusterKey, { marker, fingerprint });
12890
- });
12891
- markers.forEach((entry, key) => {
12892
- if (!visibleClusterIds.has(key)) {
12893
- entry.marker.remove();
12894
- markers.delete(key);
13045
+ const domain = computeBubbleDomain(values);
13046
+ if (!domain) return;
13047
+ const key = `${domain.min}|${domain.max}`;
13048
+ if (key === lastDomainKey) return;
13049
+ lastDomainKey = key;
13050
+ try {
13051
+ if (map.getLayer(options.clustersLayerId)) {
13052
+ map.setPaintProperty(
13053
+ options.clustersLayerId,
13054
+ "circle-color",
13055
+ bubbleGradientColorExpression(clusterProp, domain.min, domain.max)
13056
+ );
13057
+ }
13058
+ if (options.singleLayerId && map.getLayer(options.singleLayerId)) {
13059
+ map.setPaintProperty(
13060
+ options.singleLayerId,
13061
+ "circle-color",
13062
+ bubbleGradientColorExpression(CLUSTER_COUNT_VALUE_PROP, domain.min, domain.max)
13063
+ );
13064
+ }
13065
+ } catch (error) {
13066
+ reportFailure("paint update", error);
13067
+ lastDomainKey = "";
12895
13068
  }
12896
- });
12897
- }
12898
- function createClusterPieManager(map, sourceId, categoryValues, categoryColorMap, otherLabel = DEFAULT_MAP_LABELS.canvas.clusterOther) {
12899
- const markers = /* @__PURE__ */ new Map();
12900
- let updateScheduled = false;
12901
- function scheduleUpdate() {
12902
- if (updateScheduled) return;
12903
- updateScheduled = true;
12904
- requestAnimationFrame(() => {
12905
- updateScheduled = false;
12906
- renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markers, otherLabel);
12907
- });
13069
+ }
13070
+ function schedule() {
13071
+ if (scheduled) return;
13072
+ scheduled = true;
13073
+ requestAnimationFrame(apply);
12908
13074
  }
12909
13075
  function onData(e) {
12910
- if (e.dataType === "source" && e.sourceId === sourceId) {
12911
- scheduleUpdate();
12912
- }
13076
+ if (e.dataType === "source" && e.sourceId === sourceId) schedule();
12913
13077
  }
12914
- map.on("moveend", scheduleUpdate);
13078
+ map.on("moveend", schedule);
12915
13079
  map.on("data", onData);
12916
- scheduleUpdate();
13080
+ schedule();
12917
13081
  return {
12918
- update: scheduleUpdate,
12919
13082
  destroy: () => {
12920
- map.off("moveend", scheduleUpdate);
13083
+ map.off("moveend", schedule);
12921
13084
  map.off("data", onData);
12922
- markers.forEach((entry) => entry.marker.remove());
12923
- markers.clear();
12924
- hideTooltip();
12925
13085
  }
12926
13086
  };
12927
13087
  }
12928
- function ClusterPieManager(props) {
12929
- const { map, sourceId, categoryValues, categoryColorMap, visible } = props;
12930
- const otherLabel = useMapLabels().canvas.clusterOther;
12931
- const markersRef = useRef(/* @__PURE__ */ new Map());
12932
- const updateScheduled = useRef(false);
12933
- const updateMarkers = useCallback(() => {
12934
- if (!map || !visible) {
12935
- markersRef.current.forEach((entry) => entry.marker.remove());
12936
- markersRef.current.clear();
12937
- return;
12938
- }
12939
- renderClusterPies(map, sourceId, categoryValues, categoryColorMap, markersRef.current, otherLabel);
12940
- }, [map, sourceId, categoryValues, categoryColorMap, visible, otherLabel]);
12941
- useEffect(() => {
12942
- if (!map) return;
12943
- const scheduleUpdate = () => {
12944
- if (updateScheduled.current) return;
12945
- updateScheduled.current = true;
12946
- requestAnimationFrame(() => {
12947
- updateScheduled.current = false;
12948
- updateMarkers();
12949
- });
12950
- };
12951
- const onData = (e) => {
12952
- if (e.dataType === "source" && e.sourceId === sourceId) {
12953
- scheduleUpdate();
12954
- }
12955
- };
12956
- scheduleUpdate();
12957
- map.on("moveend", scheduleUpdate);
12958
- map.on("data", onData);
12959
- return () => {
12960
- map.off("moveend", scheduleUpdate);
12961
- map.off("data", onData);
12962
- markersRef.current.forEach((entry) => entry.marker.remove());
12963
- markersRef.current.clear();
12964
- hideTooltip();
12965
- };
12966
- }, [map, sourceId, updateMarkers]);
12967
- useEffect(() => {
12968
- if (!visible) {
12969
- markersRef.current.forEach((entry) => entry.marker.remove());
12970
- markersRef.current.clear();
12971
- hideTooltip();
12972
- } else {
12973
- updateMarkers();
12974
- }
12975
- }, [visible, updateMarkers]);
12976
- return null;
12977
- }
12978
13088
  const EMPTY_ID_SET = /* @__PURE__ */ new Set();
12979
13089
  const EMPTY_SOURCES = [];
12980
13090
  const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
@@ -13205,6 +13315,15 @@ function basemapInsertAnchor(map) {
13205
13315
  if (map.getLayer("custom-polygon-fill")) return "custom-polygon-fill";
13206
13316
  return void 0;
13207
13317
  }
13318
+ function layerPointFeatures(layer, stores) {
13319
+ const isPoint = (f) => {
13320
+ var _a;
13321
+ return ((_a = f == null ? void 0 : f.geometry) == null ? void 0 : _a.type) === "Point";
13322
+ };
13323
+ if (layer.readOnly) return (stores.readOnly.get(layer.id) ?? []).filter(isPoint);
13324
+ if (layer.visible) return layer.featureIds.map((id) => stores.draw.get(id)).filter(isPoint);
13325
+ return (stores.hidden.get(layer.id) ?? []).filter(isPoint);
13326
+ }
13208
13327
  function featureStateHostFor(m) {
13209
13328
  return {
13210
13329
  setFeatureState: (source, id, state) => m.setFeatureState({ source, id }, state),
@@ -18027,6 +18146,20 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
18027
18146
  },
18028
18147
  [layers]
18029
18148
  );
18149
+ const getClusterPieCategories = useCallback(
18150
+ (layerId, fieldName) => {
18151
+ const layer = layers.find((l) => l.id === layerId);
18152
+ if (!layer || !draw.current) return null;
18153
+ const points = layerPointFeatures(layer, {
18154
+ readOnly: readOnlyFeatures.current,
18155
+ hidden: hiddenFeatures.current,
18156
+ draw: draw.current
18157
+ });
18158
+ return clusterPieCategories(points, fieldName);
18159
+ },
18160
+ // Property edits change the pie counts without a new `layers`, as in the cluster effect.
18161
+ [layers, clusterDataVersion]
18162
+ );
18030
18163
  const handleFitToLayerFeatures = useCallback((layerId) => {
18031
18164
  if (!map.current) return;
18032
18165
  const customBounds = fitBoundsProvider == null ? void 0 : fitBoundsProvider(layerId);
@@ -20070,36 +20203,16 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
20070
20203
  const unclusteredLayerId = `unclustered-point-${layer.id}`;
20071
20204
  const singleValueLayerId = `cluster-single-${layer.id}`;
20072
20205
  const singleValueCountLayerId = `cluster-single-count-${layer.id}`;
20073
- let pointFeatures = [];
20074
- if (layer.visible) {
20075
- if (layer.readOnly) {
20076
- const roFeatures = readOnlyFeatures.current.get(layer.id) || [];
20077
- pointFeatures = roFeatures.filter((f) => {
20078
- var _a2;
20079
- return ((_a2 = f.geometry) == null ? void 0 : _a2.type) === "Point";
20080
- });
20081
- } else {
20082
- layer.featureIds.forEach((id) => {
20083
- var _a2;
20084
- const f = drawInstance.get(id);
20085
- if (f && ((_a2 = f.geometry) == null ? void 0 : _a2.type) === "Point") {
20086
- pointFeatures.push(f);
20087
- }
20088
- });
20089
- }
20090
- } else {
20091
- const hidden = hiddenFeatures.current.get(layer.id) || [];
20092
- pointFeatures = hidden.filter((f) => {
20093
- var _a2;
20094
- return ((_a2 = f.geometry) == null ? void 0 : _a2.type) === "Point";
20095
- });
20096
- }
20206
+ const pointFeatures = layerPointFeatures(layer, {
20207
+ readOnly: readOnlyFeatures.current,
20208
+ hidden: hiddenFeatures.current,
20209
+ draw: drawInstance
20210
+ });
20097
20211
  if (pointFeatures.length === 0) return;
20098
20212
  const groupByField = (_b = layer.clusterConfig) == null ? void 0 : _b.groupByField;
20099
20213
  const countByField = ((_c = layer.clusterConfig) == null ? void 0 : _c.countByFieldEnabled) && ((_d = layer.clusterConfig) == null ? void 0 : _d.countByField) || null;
20100
20214
  const bubbleGradient = !!((_e = layer.clusterConfig) == null ? void 0 : _e.bubbleGradient) && !groupByField;
20101
20215
  const OTHER_COLOR = OTHER_BUCKET_COLOR;
20102
- const MAX_CATEGORIES = 15;
20103
20216
  try {
20104
20217
  const layerColor = ((_g = (_f = layer.visualConfig) == null ? void 0 : _f.color) == null ? void 0 : _g.fixedColor) || "#3b82f6";
20105
20218
  let clusterProperties = {};
@@ -20107,15 +20220,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
20107
20220
  let categoryColorMap = {};
20108
20221
  let hasOtherBucket = false;
20109
20222
  if (groupByField) {
20110
- const counts2 = /* @__PURE__ */ new Map();
20111
- pointFeatures.forEach((f) => {
20112
- var _a2;
20113
- const key = categoricalKey((_a2 = f.properties) == null ? void 0 : _a2[groupByField]);
20114
- if (key === null) return;
20115
- counts2.set(key, (counts2.get(key) ?? 0) + 1);
20116
- });
20117
- const sorted = Array.from(counts2.entries()).sort((a, b) => b[1] - a[1]);
20118
- const topKeys = sorted.slice(0, MAX_CATEGORIES).map(([k]) => k);
20223
+ const topKeys = clusterPieCategories(pointFeatures, groupByField).values.map((v) => v.value);
20119
20224
  categoryValues = [...topKeys];
20120
20225
  hasOtherBucket = true;
20121
20226
  const fieldAsString = ["to-string", ["coalesce", ["get", groupByField], ""]];
@@ -20707,6 +20812,7 @@ const MapEditorCanvas = forwardRef(function MapEditorCanvas2({
20707
20812
  getAvailableTraceFields,
20708
20813
  getSuggestedTraceField,
20709
20814
  getFieldValueDistribution,
20815
+ getClusterPieCategories,
20710
20816
  iconSuggestionProvider,
20711
20817
  onUpdateHeatmapConfig: handleUpdateHeatmapConfig,
20712
20818
  onUpdateClusterConfig: handleUpdateClusterConfig,