@octostar/map-component 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/index.cjs +501 -251
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.mjs +502 -252
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
  6. package/dist/types/components/timebar.d.ts +23 -3
  7. package/dist/types/components/timebar.d.ts.map +1 -1
  8. package/dist/types/index.d.ts +3 -2
  9. package/dist/types/index.d.ts.map +1 -1
  10. package/dist/types/lib/custom-layer-stack.d.ts +20 -7
  11. package/dist/types/lib/custom-layer-stack.d.ts.map +1 -1
  12. package/dist/types/lib/label-pinning.d.ts +10 -2
  13. package/dist/types/lib/label-pinning.d.ts.map +1 -1
  14. package/dist/types/lib/paint-feature.d.ts +11 -11
  15. package/dist/types/lib/paint-feature.d.ts.map +1 -1
  16. package/dist/types/lib/selection-diff.d.ts +9 -34
  17. package/dist/types/lib/selection-diff.d.ts.map +1 -1
  18. package/dist/types/lib/selection-overlay.d.ts +53 -0
  19. package/dist/types/lib/selection-overlay.d.ts.map +1 -0
  20. package/dist/types/lib/selection-paint.d.ts +23 -0
  21. package/dist/types/lib/selection-paint.d.ts.map +1 -0
  22. package/dist/types/lib/selection-state.d.ts +60 -0
  23. package/dist/types/lib/selection-state.d.ts.map +1 -0
  24. package/dist/types/lib/shard-fingerprint.d.ts +6 -7
  25. package/dist/types/lib/shard-fingerprint.d.ts.map +1 -1
  26. package/dist/types/lib/shard-locator.d.ts +53 -0
  27. package/dist/types/lib/shard-locator.d.ts.map +1 -0
  28. package/dist/types/lib/shard-pipeline.d.ts.map +1 -1
  29. package/dist/types/lib/shard-registry.d.ts +5 -4
  30. package/dist/types/lib/shard-registry.d.ts.map +1 -1
  31. package/dist/types/lib/timeline-store.d.ts +12 -2
  32. package/dist/types/lib/timeline-store.d.ts.map +1 -1
  33. package/dist/types/lib/trace-timeline.d.ts +3 -6
  34. package/dist/types/lib/trace-timeline.d.ts.map +1 -1
  35. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -768,6 +768,10 @@ function createIngestProgressStore() {
768
768
  }
769
769
  };
770
770
  }
771
+ const SELECTED_STATE_KEY = "selected";
772
+ const SELECTED = ["boolean", ["feature-state", SELECTED_STATE_KEY], false];
773
+ const SELECTED_STATE = Object.freeze({ [SELECTED_STATE_KEY]: true });
774
+ const SELECTION_COLOR = "#06b6d4";
771
775
  const LABEL_NEVER_HIDE_PROP = "_labelNeverHide";
772
776
  const PINNED_LABEL_FILTER = ["==", ["get", LABEL_NEVER_HIDE_PROP], 1];
773
777
  const UNPINNED_LABEL_FILTER = ["!=", ["get", LABEL_NEVER_HIDE_PROP], 1];
@@ -820,7 +824,8 @@ function buildCustomLabelLayout() {
820
824
  ]
821
825
  };
822
826
  }
823
- function buildCustomLabelPaint() {
827
+ function buildCustomLabelPaint(opts) {
828
+ const visibleOpacity = ["*", 0.9, ["get", "stroke-opacity"]];
824
829
  return {
825
830
  // Text features use fontColor; others use default
826
831
  "text-color": [
@@ -839,7 +844,7 @@ function buildCustomLabelPaint() {
839
844
  2,
840
845
  1.5
841
846
  ],
842
- "text-opacity": ["*", 0.9, ["get", "stroke-opacity"]]
847
+ "text-opacity": (opts == null ? void 0 : opts.hideSelected) ? ["case", SELECTED, 0, visibleOpacity] : visibleOpacity
843
848
  };
844
849
  }
845
850
  const CUSTOM_LAYER_ROLES = [
@@ -849,13 +854,13 @@ const CUSTOM_LAYER_ROLES = [
849
854
  "point-shadow",
850
855
  "point",
851
856
  "point-icon",
852
- "point-icon-selection",
853
- "line-selection",
854
- "polygon-selection",
855
857
  "labels",
856
858
  "labels-pinned"
857
859
  ];
858
860
  const SHARED_SOURCE_ID = "custom-features";
861
+ function customSourceSpec() {
862
+ return { type: "geojson", data: { type: "FeatureCollection", features: [] }, maxzoom: 22, promoteId: "id" };
863
+ }
859
864
  const EMOJI_CANVAS_SIZE = 48;
860
865
  function customLayerId(role, sourceId) {
861
866
  return sourceId === SHARED_SOURCE_ID ? `custom-${role}` : `custom-${role}@${sourceId}`;
@@ -878,9 +883,9 @@ function geometryClassesOf(features) {
878
883
  return classes;
879
884
  }
880
885
  const ROLES_BY_CLASS = {
881
- polygon: ["polygon-fill", "polygon-stroke", "polygon-selection"],
882
- line: ["line", "line-selection"],
883
- point: ["point-shadow", "point", "point-icon", "point-icon-selection"]
886
+ polygon: ["polygon-fill", "polygon-stroke"],
887
+ line: ["line"],
888
+ point: ["point-shadow", "point", "point-icon"]
884
889
  };
885
890
  function rolesForGeometry(classes) {
886
891
  const needed = /* @__PURE__ */ new Set(["labels", "labels-pinned"]);
@@ -902,12 +907,6 @@ function shardInsertAnchor(role) {
902
907
  case "point":
903
908
  return "custom-point-icon";
904
909
  case "point-icon":
905
- return "custom-point-icon-selection";
906
- case "point-icon-selection":
907
- return "custom-line-selection";
908
- case "line-selection":
909
- return "custom-polygon-selection";
910
- case "polygon-selection":
911
910
  return "custom-arrow-heads";
912
911
  case "labels":
913
912
  return "custom-arrow-heads";
@@ -990,7 +989,8 @@ function buildLayer(role, sourceId, opts) {
990
989
  "circle-translate": [1, 1]
991
990
  }
992
991
  };
993
- // Custom point layer with data-driven selection styling (hidden when emoji icon is set)
992
+ // Custom point layer; the selection ring is paint-only and reads feature
993
+ // state (hidden when emoji icon is set)
994
994
  case "point":
995
995
  return {
996
996
  id,
@@ -1021,7 +1021,7 @@ function buildLayer(role, sourceId, opts) {
1021
1021
  0,
1022
1022
  ["coalesce", ["get", "stroke-opacity"], 1]
1023
1023
  ],
1024
- "circle-stroke-color": ["case", ["==", ["get", "isSelected"], 1], "#06b6d4", "#555555"],
1024
+ "circle-stroke-color": ["case", SELECTED, SELECTION_COLOR, "#555555"],
1025
1025
  "circle-stroke-width": [
1026
1026
  "case",
1027
1027
  ["==", ["get", "isTimelineHidden"], 1],
@@ -1032,7 +1032,7 @@ function buildLayer(role, sourceId, opts) {
1032
1032
  0,
1033
1033
  ["!=", ["get", "icon"], ""],
1034
1034
  0,
1035
- ["==", ["get", "isSelected"], 1],
1035
+ SELECTED,
1036
1036
  3,
1037
1037
  1.5
1038
1038
  ],
@@ -1072,47 +1072,6 @@ function buildLayer(role, sourceId, opts) {
1072
1072
  ]
1073
1073
  }
1074
1074
  };
1075
- // Selection ring for icon points
1076
- case "point-icon-selection":
1077
- return {
1078
- id,
1079
- type: "circle",
1080
- source: sourceId,
1081
- filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["==", "isSelected", 1], ["!=", "isHiddenByHeatmap", 1]],
1082
- paint: {
1083
- "circle-color": "transparent",
1084
- "circle-radius": ["/", ["coalesce", ["get", "iconSize"], 24], 1.6],
1085
- "circle-stroke-color": "#06b6d4",
1086
- "circle-stroke-width": 3,
1087
- "circle-stroke-opacity": 1
1088
- }
1089
- };
1090
- // Selection highlight for lines - bright cyan dashed overlay
1091
- case "line-selection":
1092
- return {
1093
- id,
1094
- type: "line",
1095
- source: sourceId,
1096
- filter: ["all", ["==", "$type", "LineString"], ["==", "isSelected", 1]],
1097
- paint: {
1098
- "line-color": "#06b6d4",
1099
- "line-width": ["+", ["get", "stroke-width"], 4],
1100
- "line-dasharray": [4, 2]
1101
- }
1102
- };
1103
- // Selection highlight for polygons - bright cyan dashed outline
1104
- case "polygon-selection":
1105
- return {
1106
- id,
1107
- type: "line",
1108
- source: sourceId,
1109
- filter: ["all", ["==", "$type", "Polygon"], ["==", "isSelected", 1]],
1110
- paint: {
1111
- "line-color": "#06b6d4",
1112
- "line-width": 4,
1113
- "line-dasharray": [4, 2]
1114
- }
1115
- };
1116
1075
  // Label layer for all features - shows 'name' property, or 'text' for text features
1117
1076
  // Trace labels are slightly bigger and bolder, hidden points have no labels
1118
1077
  // Arrow labels are handled separately by the custom-arrow-labels layer.
@@ -1138,8 +1097,11 @@ function buildLayer(role, sourceId, opts) {
1138
1097
  //
1139
1098
  // The fix has two parts:
1140
1099
  // 1. (here) Re-enable collision and use `symbol-sort-key` to control
1141
- // intra-layer priority. Selected/text/trace features win against
1142
- // ordinary points so they keep their labels when crowded.
1100
+ // intra-layer priority. Text/trace features win against
1101
+ // ordinary points so they keep their labels when crowded. A
1102
+ // selected feature's label is drawn by the selection overlay;
1103
+ // its copy here is hidden through `text-opacity` but still
1104
+ // laid out, so it claims the same collision space as before.
1143
1105
  // 2. (see `moveLabelsBeforeBasemapSymbols` in the canvas) After each
1144
1106
  // basemap load, move the label layers BEFORE basemap symbol layers
1145
1107
  // in the style stack. MapLibre processes collision in painter
@@ -1157,7 +1119,7 @@ function buildLayer(role, sourceId, opts) {
1157
1119
  // Computed per-feature in styleFeatureForPaint.
1158
1120
  "symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
1159
1121
  },
1160
- paint: buildCustomLabelPaint()
1122
+ paint: buildCustomLabelPaint({ hideSelected: true })
1161
1123
  };
1162
1124
  // Pinned twin of the labels layer for layers with visualConfig.label.neverHide.
1163
1125
  // text-allow-overlap / text-ignore-placement are data-constant in MapLibre
@@ -1183,7 +1145,7 @@ function buildLayer(role, sourceId, opts) {
1183
1145
  // (low-priority-value) labels draw over their neighbours' halos.
1184
1146
  "symbol-sort-key": ["*", -1, ["coalesce", ["get", "_labelPriority"], 100]]
1185
1147
  },
1186
- paint: buildCustomLabelPaint()
1148
+ paint: buildCustomLabelPaint({ hideSelected: true })
1187
1149
  };
1188
1150
  }
1189
1151
  }
@@ -1234,7 +1196,7 @@ function resolveShardSize(value) {
1234
1196
  }
1235
1197
  return Math.floor(value);
1236
1198
  }
1237
- function buildShardFingerprint(layer, features, selectionEnabled, shardSize) {
1199
+ function buildShardFingerprint(layer, features, shardSize) {
1238
1200
  return {
1239
1201
  features,
1240
1202
  visualConfig: layer.visualConfig,
@@ -1242,36 +1204,30 @@ function buildShardFingerprint(layer, features, selectionEnabled, shardSize) {
1242
1204
  clusterConfig: layer.clusterConfig,
1243
1205
  altitudeDisplayMode: layer.altitudeDisplayMode,
1244
1206
  hasAltitudeData: layer.hasAltitudeData,
1245
- selectionEnabled,
1246
1207
  shardSize
1247
1208
  };
1248
1209
  }
1249
1210
  function shardFingerprintsEqual(a, b) {
1250
1211
  if (!a || !b) return false;
1251
- return Object.is(a.features, b.features) && Object.is(a.visualConfig, b.visualConfig) && Object.is(a.heatmapConfig, b.heatmapConfig) && Object.is(a.clusterConfig, b.clusterConfig) && Object.is(a.altitudeDisplayMode, b.altitudeDisplayMode) && Object.is(a.hasAltitudeData, b.hasAltitudeData) && Object.is(a.selectionEnabled, b.selectionEnabled) && Object.is(a.shardSize, b.shardSize);
1212
+ return Object.is(a.features, b.features) && Object.is(a.visualConfig, b.visualConfig) && Object.is(a.heatmapConfig, b.heatmapConfig) && Object.is(a.clusterConfig, b.clusterConfig) && Object.is(a.altitudeDisplayMode, b.altitudeDisplayMode) && Object.is(a.hasAltitudeData, b.hasAltitudeData) && Object.is(a.shardSize, b.shardSize);
1252
1213
  }
1253
- const DEFAULT_LABEL_PRIORITY = 100;
1254
1214
  const DEFAULT_VISIBLE_STROKE_OPACITY = 1;
1255
1215
  const DEFAULT_VISIBLE_FILL_OPACITY = 0.2;
1256
1216
  function createSelectionPaintCache() {
1257
1217
  return {
1258
1218
  presentIds: /* @__PURE__ */ new Set(),
1259
- appliedSelectedIds: /* @__PURE__ */ new Set(),
1260
- basePriorityById: /* @__PURE__ */ new Map(),
1261
1219
  appliedHiddenIds: /* @__PURE__ */ new Set(),
1262
1220
  visibleStrokeOpacityById: /* @__PURE__ */ new Map(),
1263
1221
  visibleFillOpacityById: /* @__PURE__ */ new Map(),
1264
1222
  updatable: true
1265
1223
  };
1266
1224
  }
1267
- function recordPaintedFeature(cache2, featureId, basePriority, isSelected, visibleStrokeOpacity, visibleFillOpacity, isTimelineHidden) {
1225
+ function recordPaintedFeature(cache2, featureId, visibleStrokeOpacity, visibleFillOpacity, isTimelineHidden) {
1268
1226
  if (cache2.presentIds.has(featureId)) {
1269
1227
  cache2.updatable = false;
1270
1228
  } else {
1271
1229
  cache2.presentIds.add(featureId);
1272
1230
  }
1273
- cache2.basePriorityById.set(featureId, basePriority);
1274
- if (isSelected) cache2.appliedSelectedIds.add(featureId);
1275
1231
  if (visibleStrokeOpacity !== DEFAULT_VISIBLE_STROKE_OPACITY) {
1276
1232
  cache2.visibleStrokeOpacityById.set(featureId, visibleStrokeOpacity);
1277
1233
  }
@@ -1280,52 +1236,9 @@ function recordPaintedFeature(cache2, featureId, basePriority, isSelected, visib
1280
1236
  }
1281
1237
  if (isTimelineHidden) cache2.appliedHiddenIds.add(featureId);
1282
1238
  }
1283
- function applySelectionFastPath(cache2, nextSelectedIds, source) {
1284
- if (!cache2 || !cache2.updatable || !source) return false;
1285
- const diff = buildSelectionDiff(cache2, nextSelectedIds);
1286
- if (diff) {
1287
- try {
1288
- source.updateData(diff);
1289
- } catch {
1290
- return false;
1291
- }
1292
- }
1293
- const applied = /* @__PURE__ */ new Set();
1294
- nextSelectedIds.forEach((id) => {
1295
- if (cache2.presentIds.has(id)) applied.add(id);
1296
- });
1297
- cache2.appliedSelectedIds = applied;
1298
- return true;
1299
- }
1300
1239
  function needsDrawSelectionUpdate(input) {
1301
1240
  return input.editableSelectionCount > 0 || input.drawSelectedCount > 0 || input.currentMode !== input.targetMode;
1302
1241
  }
1303
- function buildSelectionDiff(cache2, nextSelectedIds) {
1304
- const update = [];
1305
- cache2.appliedSelectedIds.forEach((id) => {
1306
- if (!nextSelectedIds.has(id) && cache2.presentIds.has(id)) {
1307
- update.push({
1308
- id,
1309
- addOrUpdateProperties: [
1310
- { key: "isSelected", value: 0 },
1311
- { key: "_labelPriority", value: cache2.basePriorityById.get(id) ?? DEFAULT_LABEL_PRIORITY }
1312
- ]
1313
- });
1314
- }
1315
- });
1316
- nextSelectedIds.forEach((id) => {
1317
- if (!cache2.appliedSelectedIds.has(id) && cache2.presentIds.has(id)) {
1318
- update.push({
1319
- id,
1320
- addOrUpdateProperties: [
1321
- { key: "isSelected", value: 1 },
1322
- { key: "_labelPriority", value: 0 }
1323
- ]
1324
- });
1325
- }
1326
- });
1327
- return update.length > 0 ? { update } : null;
1328
- }
1329
1242
  function buildTimelineVisibilityDiff(cache2, nextVisibleSet) {
1330
1243
  const update = [];
1331
1244
  const nextHiddenIds = /* @__PURE__ */ new Set();
@@ -1369,7 +1282,6 @@ function applyTimelineFastPath(cache2, nextVisibleSet, source) {
1369
1282
  cache2.appliedHiddenIds = nextHiddenIds;
1370
1283
  return { applied: true, toggled: ((_a = diff == null ? void 0 : diff.update) == null ? void 0 : _a.length) ?? 0 };
1371
1284
  }
1372
- const EMPTY_COLLECTION = { type: "FeatureCollection", features: [] };
1373
1285
  const INTERACTIVE_ROLES = ["point", "line", "polygon-fill"];
1374
1286
  function createShardRegistry(host, hooks) {
1375
1287
  const states = /* @__PURE__ */ new Map();
@@ -1402,7 +1314,7 @@ function createShardRegistry(host, hooks) {
1402
1314
  };
1403
1315
  const createStack = (state, index, roles, data) => {
1404
1316
  const sourceId = shardSourceId(state.layerId, index);
1405
- host.addSource(sourceId, { type: "geojson", data: EMPTY_COLLECTION, maxzoom: 22 });
1317
+ host.addSource(sourceId, customSourceSpec());
1406
1318
  const specs = buildCustomLayerStack(sourceId, roles, { labelsVisible: hooks.labelsVisible() });
1407
1319
  const ordered = CUSTOM_LAYER_ROLES.filter((role) => roles.includes(role));
1408
1320
  const layerIds = [];
@@ -1543,7 +1455,7 @@ function createShardRegistry(host, hooks) {
1543
1455
  }
1544
1456
  };
1545
1457
  }
1546
- function reconcileShardCaches(registry, layerId, expectedShards, selectedIds, visibleIds) {
1458
+ function reconcileShardCaches(registry, layerId, expectedShards, visibleIds) {
1547
1459
  const state = registry.state(layerId);
1548
1460
  if (!state || state.stacks.length !== expectedShards) return false;
1549
1461
  for (let i = 0; i < expectedShards; i++) {
@@ -1552,7 +1464,6 @@ function reconcileShardCaches(registry, layerId, expectedShards, selectedIds, vi
1552
1464
  const source = registry.sourceFor(layerId, i);
1553
1465
  if (!source) return false;
1554
1466
  if (!applyTimelineFastPath(cache2, visibleIds, source).applied) return false;
1555
- if (!applySelectionFastPath(cache2, selectedIds, source)) return false;
1556
1467
  }
1557
1468
  return true;
1558
1469
  }
@@ -1807,7 +1718,7 @@ const TRACE_ENDPOINT_LABEL_PRIORITY = 5;
1807
1718
  const TRACE_POINT_RADIUS = 2;
1808
1719
  const TRACE_ENDPOINT_MIN_RADIUS = 8;
1809
1720
  function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
1810
- const diff = { pointUpdates: [], segmentAdd: [], segmentRemove: [], basePriorities: [] };
1721
+ const diff = { pointUpdates: [], segmentAdd: [], segmentRemove: [] };
1811
1722
  const paintedVisible = (id) => !paint.appliedHiddenIds.has(id);
1812
1723
  const nextVisible = timelineVisibility(nextVisibleSet);
1813
1724
  trace.groups.forEach((group, groupIndex) => {
@@ -1816,8 +1727,8 @@ function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
1816
1727
  const prevEndpoint = prev.length > 0 ? prev[prev.length - 1] : -1;
1817
1728
  const nextEndpoint = next.length > 0 ? next[next.length - 1] : -1;
1818
1729
  if (prevEndpoint !== nextEndpoint) {
1819
- if (prevEndpoint >= 0) pushEndpointUpdate(diff, trace, paint, group, group.ids[prevEndpoint], false);
1820
- if (nextEndpoint >= 0) pushEndpointUpdate(diff, trace, paint, group, group.ids[nextEndpoint], true);
1730
+ if (prevEndpoint >= 0) pushEndpointUpdate(diff, trace, group, group.ids[prevEndpoint], false);
1731
+ if (nextEndpoint >= 0) pushEndpointUpdate(diff, trace, group, group.ids[nextEndpoint], true);
1821
1732
  }
1822
1733
  diffConsecutivePairs(
1823
1734
  prev,
@@ -1828,21 +1739,19 @@ function buildTraceTimelineDiff(trace, paint, nextVisibleSet) {
1828
1739
  });
1829
1740
  return diff;
1830
1741
  }
1831
- function pushEndpointUpdate(diff, trace, paint, group, id, isEndpoint) {
1742
+ function pushEndpointUpdate(diff, trace, group, id, isEndpoint) {
1832
1743
  const point = trace.pointPaint.get(id);
1833
1744
  if (!point) return;
1834
1745
  const labelled = isEndpoint && group.label !== null;
1835
- const basePriority = labelled ? TRACE_ENDPOINT_LABEL_PRIORITY : point.basePriority;
1836
1746
  diff.pointUpdates.push({
1837
1747
  id,
1838
1748
  addOrUpdateProperties: [
1839
1749
  { key: "pointRadius", value: isEndpoint ? point.endpointRadius : TRACE_POINT_RADIUS },
1840
1750
  { key: "name", value: labelled ? group.label : point.name },
1841
1751
  { key: "isTraceLabel", value: labelled },
1842
- { key: "_labelPriority", value: paint.appliedSelectedIds.has(id) ? 0 : basePriority }
1752
+ { key: "_labelPriority", value: labelled ? TRACE_ENDPOINT_LABEL_PRIORITY : point.basePriority }
1843
1753
  ]
1844
1754
  });
1845
- diff.basePriorities.push([id, basePriority]);
1846
1755
  }
1847
1756
  function diffConsecutivePairs(prev, next, onRemove, onAdd) {
1848
1757
  let i = 0;
@@ -1864,7 +1773,7 @@ function diffConsecutivePairs(prev, next, onRemove, onAdd) {
1864
1773
  }
1865
1774
  }
1866
1775
  }
1867
- function applyTraceTimelineDiff(diff, paint, pointSource, segmentSource) {
1776
+ function applyTraceTimelineDiff(diff, pointSource, segmentSource) {
1868
1777
  try {
1869
1778
  if (diff.pointUpdates.length > 0) pointSource.updateData({ update: diff.pointUpdates });
1870
1779
  if (diff.segmentAdd.length > 0 || diff.segmentRemove.length > 0) {
@@ -1874,9 +1783,9 @@ function applyTraceTimelineDiff(diff, paint, pointSource, segmentSource) {
1874
1783
  console.error("Trace timeline fast path failed; falling back to the full sync:", error);
1875
1784
  return false;
1876
1785
  }
1877
- diff.basePriorities.forEach(([id, priority]) => paint.basePriorityById.set(id, priority));
1878
1786
  return true;
1879
1787
  }
1788
+ const DEFAULT_LABEL_PRIORITY = 100;
1880
1789
  const RENDER_PASSTHROUGH_KEYS = ["_dvl_h3"];
1881
1790
  const ANNOTATION_PASSTHROUGH_KEYS = [
1882
1791
  "kind",
@@ -1984,7 +1893,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
1984
1893
  });
1985
1894
  }
1986
1895
  }
1987
- const isFeatureSelected = ctx.selectionEnabled && ctx.selectedIds.has(featureId) ? 1 : 0;
1988
1896
  let nonTracePriority = DEFAULT_LABEL_PRIORITY;
1989
1897
  if (((_l = f.properties) == null ? void 0 : _l.kind) === "text") {
1990
1898
  nonTracePriority = ((_m = f.properties) == null ? void 0 : _m.fontWeight) === "bold" ? 8 : 10;
@@ -1997,8 +1905,7 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
1997
1905
  }
1998
1906
  nonTracePriority = DEFAULT_LABEL_PRIORITY + Math.abs(h) % 1e3;
1999
1907
  }
2000
- const basePriority = traceLabel ? TRACE_ENDPOINT_LABEL_PRIORITY : nonTracePriority;
2001
- const labelPriority = isFeatureSelected ? 0 : basePriority;
1908
+ const labelPriority = traceLabel ? TRACE_ENDPOINT_LABEL_PRIORITY : nonTracePriority;
2002
1909
  const visibleStrokeOpacity = hideFlatFor3DOnly ? 0 : baseOpacity;
2003
1910
  const visibleFillOpacity = hideFlatFor3DOnly ? 0 : ((_n = f.properties) == null ? void 0 : _n["fill-opacity"]) ?? DEFAULT_VISIBLE_FILL_OPACITY;
2004
1911
  return {
@@ -2012,7 +1919,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
2012
1919
  // Override with computed visual properties
2013
1920
  id: featureId,
2014
1921
  name: labelText,
2015
- isSelected: isFeatureSelected,
2016
1922
  isHiddenByHeatmap: hideByHeatmap ? 1 : 0,
2017
1923
  isHiddenByCluster: hideByCluster ? 1 : 0,
2018
1924
  isTracePoint: isTracePoint ? true : false,
@@ -2032,8 +1938,6 @@ function styleFeatureForPaint(f, layer, ctx, slim) {
2032
1938
  },
2033
1939
  paint: {
2034
1940
  featureId,
2035
- basePriority,
2036
- selected: isFeatureSelected === 1,
2037
1941
  visibleStrokeOpacity,
2038
1942
  visibleFillOpacity,
2039
1943
  timelineHidden: !isTimelineVisible
@@ -2088,15 +1992,7 @@ async function runShardPass(input) {
2088
1992
  var _a2;
2089
1993
  const styled = styleFeatureForPaint(f, layer, ctx, true);
2090
1994
  const p = styled.paint;
2091
- recordPaintedFeature(
2092
- cache2,
2093
- p.featureId,
2094
- p.basePriority,
2095
- p.selected,
2096
- p.visibleStrokeOpacity,
2097
- p.visibleFillOpacity,
2098
- p.timelineHidden
2099
- );
1995
+ recordPaintedFeature(cache2, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
2100
1996
  if (((_a2 = styled.feature.properties) == null ? void 0 : _a2.kind) === "arrow" && styled.feature.geometry.type === "LineString") {
2101
1997
  shardArrows.push(styled.feature);
2102
1998
  }
@@ -5519,10 +5415,10 @@ const RECORD_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
5519
5415
  // NOTE: 'description' intentionally NOT excluded — we surface it as a regular
5520
5416
  // property row instead of giving it its own labelled section.
5521
5417
  ]);
5522
- function buildKeyExclusionPredicate(set) {
5523
- const lowered = new Set(Array.from(set, (k) => k.toLowerCase()));
5418
+ function buildKeyExclusionPredicate(set2) {
5419
+ const lowered = new Set(Array.from(set2, (k) => k.toLowerCase()));
5524
5420
  return (key) => {
5525
- if (set.has(key)) return true;
5421
+ if (set2.has(key)) return true;
5526
5422
  const normalized = key.toLowerCase().replace(/^[^a-z0-9_-]+/, "");
5527
5423
  return lowered.has(normalized);
5528
5424
  };
@@ -7076,7 +6972,7 @@ function computeHistogramBins(features, minDate, maxDate, binCount = 50) {
7076
6972
  });
7077
6973
  return bins;
7078
6974
  }
7079
- const timelineStoreInitializer = (set, get) => ({
6975
+ const timelineStoreInitializer = (set2, get) => ({
7080
6976
  isEnabled: false,
7081
6977
  hasTemporalData: false,
7082
6978
  temporalFeatures: [],
@@ -7087,17 +6983,18 @@ const timelineStoreInitializer = (set, get) => ({
7087
6983
  rangeEnd: null,
7088
6984
  isPlaying: false,
7089
6985
  playbackSpeed: 1,
6986
+ playMode: "sliding",
7090
6987
  histogramBins: [],
7091
6988
  setEnabled: (enabled) => {
7092
6989
  if (enabled) {
7093
6990
  const state = get();
7094
- set({
6991
+ set2({
7095
6992
  isEnabled: true,
7096
6993
  rangeStart: state.globalMinDate,
7097
6994
  rangeEnd: state.globalMaxDate
7098
6995
  });
7099
6996
  } else {
7100
- set({ isEnabled: false, isPlaying: false });
6997
+ set2({ isEnabled: false, isPlaying: false });
7101
6998
  }
7102
6999
  },
7103
7000
  setTemporalFeatures: (features, untimedIds) => {
@@ -7106,7 +7003,7 @@ const timelineStoreInitializer = (set, get) => ({
7106
7003
  const state = get();
7107
7004
  if (timedFeatures.length === 0) {
7108
7005
  if (!state.hasTemporalData && state.temporalFeatures.length === 0) return;
7109
- set({
7006
+ set2({
7110
7007
  hasTemporalData: false,
7111
7008
  temporalFeatures: [],
7112
7009
  untimedFeatureIds: untimedIds,
@@ -7128,12 +7025,16 @@ const timelineStoreInitializer = (set, get) => ({
7128
7025
  });
7129
7026
  const computedMin = minDate;
7130
7027
  const computedMax = maxDate;
7131
- const sameFeatureIds = state.temporalFeatures.length === timedFeatures.length && timedFeatures.every((f, i) => f.id === state.temporalFeatures[i].id);
7028
+ const sameFeatures = state.temporalFeatures.length === timedFeatures.length && timedFeatures.every((f, i) => {
7029
+ var _a2, _b2, _c, _d;
7030
+ const prev = state.temporalFeatures[i];
7031
+ return f.id === prev.id && ((_a2 = f.startDate) == null ? void 0 : _a2.getTime()) === ((_b2 = prev.startDate) == null ? void 0 : _b2.getTime()) && ((_c = f.endDate) == null ? void 0 : _c.getTime()) === ((_d = prev.endDate) == null ? void 0 : _d.getTime());
7032
+ });
7132
7033
  const sameDates = ((_a = state.globalMinDate) == null ? void 0 : _a.getTime()) === (computedMin == null ? void 0 : computedMin.getTime()) && ((_b = state.globalMaxDate) == null ? void 0 : _b.getTime()) === (computedMax == null ? void 0 : computedMax.getTime());
7133
7034
  const sameUntimed = state.untimedFeatureIds.length === untimedIds.length && untimedIds.every((id, i) => id === state.untimedFeatureIds[i]);
7134
- if (sameFeatureIds && sameDates && sameUntimed && state.hasTemporalData) return;
7035
+ if (sameFeatures && sameDates && sameUntimed && state.hasTemporalData) return;
7135
7036
  const histogramBins = minDate && maxDate ? computeHistogramBins(timedFeatures, minDate, maxDate) : [];
7136
- set({
7037
+ set2({
7137
7038
  hasTemporalData: true,
7138
7039
  temporalFeatures: timedFeatures,
7139
7040
  untimedFeatureIds: untimedIds,
@@ -7144,9 +7045,10 @@ const timelineStoreInitializer = (set, get) => ({
7144
7045
  histogramBins
7145
7046
  });
7146
7047
  },
7147
- setRange: (start, end) => set({ rangeStart: start, rangeEnd: end }),
7148
- setPlaying: (playing) => set({ isPlaying: playing }),
7149
- setPlaybackSpeed: (speed) => set({ playbackSpeed: speed }),
7048
+ setRange: (start, end) => set2({ rangeStart: start, rangeEnd: end }),
7049
+ setPlaying: (playing) => set2({ isPlaying: playing }),
7050
+ setPlaybackSpeed: (speed) => set2({ playbackSpeed: speed }),
7051
+ setPlayMode: (mode) => set2({ playMode: mode }),
7150
7052
  advancePlayhead: () => {
7151
7053
  const state = get();
7152
7054
  if (!state.globalMinDate || !state.globalMaxDate || !state.rangeStart) {
@@ -7157,20 +7059,20 @@ const timelineStoreInitializer = (set, get) => ({
7157
7059
  const newStart = new Date(state.rangeStart.getTime() + stepSize);
7158
7060
  const newEnd = state.rangeEnd ? new Date(state.rangeEnd.getTime() + stepSize) : null;
7159
7061
  if (newStart >= state.globalMaxDate) {
7160
- set({
7062
+ set2({
7161
7063
  isPlaying: false,
7162
7064
  rangeStart: state.globalMinDate,
7163
7065
  rangeEnd: state.globalMaxDate
7164
7066
  });
7165
7067
  return false;
7166
7068
  }
7167
- set({
7069
+ set2({
7168
7070
  rangeStart: newStart,
7169
7071
  rangeEnd: newEnd && newEnd <= state.globalMaxDate ? newEnd : state.globalMaxDate
7170
7072
  });
7171
7073
  return true;
7172
7074
  },
7173
- reset: () => set({
7075
+ reset: () => set2({
7174
7076
  isEnabled: false,
7175
7077
  hasTemporalData: false,
7176
7078
  temporalFeatures: [],
@@ -7190,7 +7092,7 @@ const TimelineStoreContext = react.createContext(null);
7190
7092
  function useTimelineStoreApi() {
7191
7093
  const store = react.useContext(TimelineStoreContext);
7192
7094
  if (!store) {
7193
- throw new Error("useTimelineStoreApi must be used within a MapEditorCanvas (TimelineStoreContext.Provider)");
7095
+ throw new Error("useTimelineStoreApi must be used within a MapEditorCanvas or a TimelineStoreContext.Provider");
7194
7096
  }
7195
7097
  return store;
7196
7098
  }
@@ -7202,6 +7104,12 @@ function useTimelineStore(selector) {
7202
7104
  }
7203
7105
  const TIMEBAR_HEIGHT = 158;
7204
7106
  const TIMEBAR_BOTTOM_OFFSET = 12;
7107
+ const DEFAULT_LABELS = {
7108
+ play: "Play",
7109
+ pause: "Pause",
7110
+ reset: "Reset timeline",
7111
+ cumulative: "Cumulative: keep what has appeared"
7112
+ };
7205
7113
  const MINUTE_MS = 6e4;
7206
7114
  const HOUR_MS = 36e5;
7207
7115
  const DAY_MS = 864e5;
@@ -7350,7 +7258,7 @@ function Histogram({ bins, maxCount, colorGroupedBins }) {
7350
7258
  const containerRef = react.useRef(null);
7351
7259
  if (bins.length === 0 || maxCount === 0) return null;
7352
7260
  const hasColorGroups = colorGroupedBins && colorGroupedBins.length > 0 && colorGroupedBins.some((group) => group.bins.some((count) => count > 0));
7353
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative h-16", ref: containerRef, children: [
7261
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative h-16", ref: containerRef, "data-testid": "timebar-histogram", children: [
7354
7262
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-end gap-px", children: bins.map((bin, i) => {
7355
7263
  const height = bin.count / maxCount * 100;
7356
7264
  const isHovered = hoveredBin === i;
@@ -7425,7 +7333,17 @@ function TimebarToggle({ onClick, hasData }) {
7425
7333
  }
7426
7334
  );
7427
7335
  }
7428
- function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColors, className, timebarExtra }) {
7336
+ function Timebar({
7337
+ onFilterChange,
7338
+ selectedFeatureIds = [],
7339
+ selectedFeatureColors,
7340
+ selectionDisplay = "bars",
7341
+ className,
7342
+ timebarExtra,
7343
+ formatCount: formatCount2,
7344
+ labels: labelOverrides
7345
+ }) {
7346
+ const labels = { ...DEFAULT_LABELS, ...labelOverrides };
7429
7347
  const {
7430
7348
  isEnabled,
7431
7349
  hasTemporalData,
@@ -7436,19 +7354,22 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
7436
7354
  rangeStart,
7437
7355
  rangeEnd,
7438
7356
  isPlaying,
7357
+ playMode,
7439
7358
  histogramBins: storeHistogramBins,
7440
7359
  setRange,
7441
- setPlaying
7360
+ setPlaying,
7361
+ setPlayMode
7442
7362
  } = useTimelineStore();
7443
7363
  const timelineStoreApi = useTimelineStoreApi();
7444
7364
  const hasSelection = selectedFeatureIds.length > 0;
7365
+ const selectionAsLine = hasSelection && selectionDisplay === "line";
7445
7366
  const selectedTemporalFeatures = react.useMemo(() => {
7446
7367
  if (!hasSelection) return temporalFeatures;
7447
7368
  const selectedSet = new Set(selectedFeatureIds);
7448
7369
  return temporalFeatures.filter((f) => selectedSet.has(f.id));
7449
7370
  }, [hasSelection, selectedFeatureIds, temporalFeatures]);
7450
7371
  const histogramBins = react.useMemo(() => {
7451
- if (!hasSelection || storeHistogramBins.length === 0) return storeHistogramBins;
7372
+ if (!hasSelection || selectionAsLine || storeHistogramBins.length === 0) return storeHistogramBins;
7452
7373
  return storeHistogramBins.map((bin, binIndex) => {
7453
7374
  const isLastBin = binIndex === storeHistogramBins.length - 1;
7454
7375
  let count = 0;
@@ -7461,16 +7382,16 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
7461
7382
  }
7462
7383
  return { ...bin, count };
7463
7384
  });
7464
- }, [hasSelection, storeHistogramBins, selectedTemporalFeatures]);
7465
- const colorGroupedBins = histogramBins.length > 0 && hasSelection && selectedFeatureColors && selectedFeatureColors.size > 0 && globalMinDate && globalMaxDate ? (() => {
7385
+ }, [hasSelection, selectionAsLine, storeHistogramBins, selectedTemporalFeatures]);
7386
+ const colorGroupedBins = histogramBins.length > 0 && hasSelection && (selectionAsLine || selectedFeatureColors && selectedFeatureColors.size > 0) && globalMinDate && globalMaxDate ? (() => {
7466
7387
  if (selectedTemporalFeatures.length === 0) return [];
7467
7388
  const colorGroups = /* @__PURE__ */ new Map();
7468
7389
  selectedTemporalFeatures.forEach((f) => {
7469
- const color = selectedFeatureColors.get(f.id) || "#3b82f6";
7390
+ const color = (selectedFeatureColors == null ? void 0 : selectedFeatureColors.get(f.id)) || "#3b82f6";
7470
7391
  if (!colorGroups.has(color)) colorGroups.set(color, []);
7471
7392
  colorGroups.get(color).push(f);
7472
7393
  });
7473
- if (colorGroups.size <= 1) return [];
7394
+ if (!selectionAsLine && colorGroups.size <= 1) return [];
7474
7395
  const result = [];
7475
7396
  colorGroups.forEach((features, color) => {
7476
7397
  const bins = histogramBins.map((bin, binIndex) => {
@@ -7529,14 +7450,24 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
7529
7450
  setPlaying(false);
7530
7451
  return;
7531
7452
  }
7532
- const newStart = new Date(state.rangeStart.getTime() + stepPerFrame);
7533
- const newEnd = state.rangeEnd ? new Date(state.rangeEnd.getTime() + stepPerFrame) : null;
7534
- if (newStart >= state.globalMaxDate) {
7535
- setRange(state.globalMinDate, state.globalMaxDate);
7536
- setPlaying(false);
7537
- return;
7453
+ if (state.playMode === "cumulative") {
7454
+ const grown = new Date((state.rangeEnd ?? state.rangeStart).getTime() + stepPerFrame);
7455
+ if (grown >= state.globalMaxDate) {
7456
+ setRange(state.rangeStart, state.globalMaxDate);
7457
+ setPlaying(false);
7458
+ return;
7459
+ }
7460
+ setRange(state.rangeStart, grown);
7461
+ } else {
7462
+ const newStart = new Date(state.rangeStart.getTime() + stepPerFrame);
7463
+ const newEnd = state.rangeEnd ? new Date(state.rangeEnd.getTime() + stepPerFrame) : null;
7464
+ if (newStart >= state.globalMaxDate) {
7465
+ setRange(state.globalMinDate, state.globalMaxDate);
7466
+ setPlaying(false);
7467
+ return;
7468
+ }
7469
+ setRange(newStart, newEnd && newEnd <= state.globalMaxDate ? newEnd : state.globalMaxDate);
7538
7470
  }
7539
- setRange(newStart, newEnd && newEnd <= state.globalMaxDate ? newEnd : state.globalMaxDate);
7540
7471
  }
7541
7472
  animationFrameRef.current = requestAnimationFrame(animate);
7542
7473
  };
@@ -7567,11 +7498,17 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
7567
7498
  setPlaying(false);
7568
7499
  };
7569
7500
  const handlePlayPause = () => {
7570
- if (!isPlaying && rangeStart && rangeStart >= globalMaxDate) {
7501
+ if (!isPlaying && playMode === "cumulative") {
7502
+ if (!rangeEnd || rangeEnd >= globalMaxDate) {
7503
+ const from = rangeStart && rangeStart < globalMaxDate ? rangeStart : globalMinDate;
7504
+ setRange(from, from);
7505
+ }
7506
+ } else if (!isPlaying && rangeStart && rangeStart >= globalMaxDate) {
7571
7507
  setRange(globalMinDate, globalMaxDate);
7572
7508
  }
7573
7509
  setPlaying(!isPlaying);
7574
7510
  };
7511
+ const cumulative = playMode === "cumulative";
7575
7512
  return /* @__PURE__ */ jsxRuntime.jsxs(
7576
7513
  "div",
7577
7514
  {
@@ -7619,7 +7556,7 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
7619
7556
  size: "small",
7620
7557
  icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SkipBack, { className: "w-3.5 h-3.5" }),
7621
7558
  onClick: handleReset,
7622
- "aria-label": "Reset timeline",
7559
+ "aria-label": labels.reset,
7623
7560
  "data-testid": "button-timeline-reset",
7624
7561
  className: "!h-7 !w-7 !p-0 !min-w-0"
7625
7562
  }
@@ -7631,17 +7568,34 @@ function Timebar({ onFilterChange, selectedFeatureIds = [], selectedFeatureColor
7631
7568
  size: "small",
7632
7569
  icon: isPlaying ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Pause, { className: "w-3.5 h-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Play, { className: "w-3.5 h-3.5" }),
7633
7570
  onClick: handlePlayPause,
7634
- "aria-label": isPlaying ? "Pause" : "Play",
7571
+ "aria-label": isPlaying ? labels.pause : labels.play,
7635
7572
  "data-testid": "button-timeline-play",
7636
7573
  className: "!h-7 !w-7 !p-0 !min-w-0"
7637
7574
  }
7638
7575
  ),
7576
+ /* @__PURE__ */ jsxRuntime.jsx(antd.Tooltip, { title: labels.cumulative, children: /* @__PURE__ */ jsxRuntime.jsx(
7577
+ antd.Button,
7578
+ {
7579
+ size: "small",
7580
+ color: cumulative ? "primary" : "default",
7581
+ variant: cumulative ? "filled" : "text",
7582
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Layers, { className: "w-3.5 h-3.5" }),
7583
+ onClick: () => setPlayMode(cumulative ? "sliding" : "cumulative"),
7584
+ "aria-label": labels.cumulative,
7585
+ "aria-pressed": cumulative,
7586
+ "data-testid": "button-timeline-cumulative",
7587
+ className: "!h-7 !w-7 !p-0 !min-w-0"
7588
+ }
7589
+ ) }),
7639
7590
  /* @__PURE__ */ jsxRuntime.jsx(
7640
7591
  "span",
7641
7592
  {
7642
7593
  className: "text-xs text-muted-foreground ml-1",
7643
7594
  "data-testid": "text-timeline-feature-count",
7644
- children: hasSelection ? `${selectedTemporalFeatures.length} of ${temporalFeatures.length} selected` : `${temporalFeatures.length} feature${temporalFeatures.length !== 1 ? "s" : ""}`
7595
+ children: formatCount2 ? formatCount2({
7596
+ total: temporalFeatures.length,
7597
+ selected: hasSelection ? selectedTemporalFeatures.length : null
7598
+ }) : hasSelection ? `${selectedTemporalFeatures.length} of ${temporalFeatures.length} selected` : `${temporalFeatures.length} feature${temporalFeatures.length !== 1 ? "s" : ""}`
7645
7599
  }
7646
7600
  )
7647
7601
  ] }),
@@ -7948,6 +7902,129 @@ function createRafCoalescer(run, scheduler = rafScheduler) {
7948
7902
  }
7949
7903
  };
7950
7904
  }
7905
+ const EMPTY = /* @__PURE__ */ new Set();
7906
+ function isLive(host, entry) {
7907
+ return host.source(entry.sourceId) === entry.handle;
7908
+ }
7909
+ function remove(host, entry, id) {
7910
+ if (!isLive(host, entry)) return false;
7911
+ host.removeFeatureState(entry.sourceId, id);
7912
+ return true;
7913
+ }
7914
+ function set(host, sourceId, id) {
7915
+ const handle = host.source(sourceId);
7916
+ if (!handle) return null;
7917
+ host.setFeatureState(sourceId, id, SELECTED_STATE);
7918
+ return { sourceId, handle };
7919
+ }
7920
+ function setAll(host, sourceIds, id) {
7921
+ const done = [];
7922
+ sourceIds.forEach((sourceId) => {
7923
+ const entry = set(host, sourceId, id);
7924
+ if (entry) done.push(entry);
7925
+ });
7926
+ return done;
7927
+ }
7928
+ function place(applied, id, sources, host) {
7929
+ const done = setAll(host, sources, id);
7930
+ if (done.length > 0) applied.set(id, done);
7931
+ return done.length;
7932
+ }
7933
+ function applySelectionState(applied, next, gate, locate, host) {
7934
+ const target = gate ? next : EMPTY;
7935
+ let setCount = 0;
7936
+ let removed = 0;
7937
+ const gone = [];
7938
+ applied.forEach((_sources, id) => {
7939
+ if (!target.has(id)) gone.push(id);
7940
+ });
7941
+ gone.forEach((id) => {
7942
+ (applied.get(id) ?? []).forEach((entry) => {
7943
+ if (remove(host, entry, id)) removed++;
7944
+ });
7945
+ applied.delete(id);
7946
+ });
7947
+ target.forEach((id) => {
7948
+ if (applied.has(id)) return;
7949
+ setCount += place(applied, id, locate(id), host);
7950
+ });
7951
+ return { set: setCount, removed };
7952
+ }
7953
+ function reconcileSelectionSources(applied, locate, host) {
7954
+ let moved = 0;
7955
+ let pruned = 0;
7956
+ const changes = [];
7957
+ applied.forEach((have, id) => {
7958
+ const want = locate(id);
7959
+ const live = have.filter((entry) => isLive(host, entry));
7960
+ const same = want.length > 0 && live.length === have.length && want.every((sourceId) => live.some((entry) => entry.sourceId === sourceId));
7961
+ if (!same) changes.push({ id, have, live, want });
7962
+ });
7963
+ changes.forEach(({ id, have, live, want }) => {
7964
+ if (want.length === 0) {
7965
+ have.forEach((entry) => remove(host, entry, id));
7966
+ applied.delete(id);
7967
+ pruned++;
7968
+ return;
7969
+ }
7970
+ const missing = want.filter((sourceId) => !live.some((entry) => entry.sourceId === sourceId));
7971
+ const gained = setAll(host, missing, id);
7972
+ const now = [...live, ...gained];
7973
+ if (now.length > 0) applied.set(id, now);
7974
+ else applied.delete(id);
7975
+ if (gained.length > 0) moved++;
7976
+ });
7977
+ return { moved, pruned };
7978
+ }
7979
+ function createLocatorCache() {
7980
+ return /* @__PURE__ */ new WeakMap();
7981
+ }
7982
+ function indexOfIds(features, cache2) {
7983
+ const cached = cache2.get(features);
7984
+ if (cached) return cached;
7985
+ const index = { first: /* @__PURE__ */ new Map(), repeats: /* @__PURE__ */ new Map() };
7986
+ for (let i = 0; i < features.length; i++) {
7987
+ const id = features[i].id;
7988
+ if (id === void 0 || id === null) continue;
7989
+ const key = String(id);
7990
+ if (!index.first.has(key)) index.first.set(key, i);
7991
+ else {
7992
+ const more = index.repeats.get(key);
7993
+ if (more) more.push(i);
7994
+ else index.repeats.set(key, [i]);
7995
+ }
7996
+ }
7997
+ cache2.set(features, index);
7998
+ return index;
7999
+ }
8000
+ function forEachIndex(index, id, visit) {
8001
+ var _a;
8002
+ const at = index.first.get(id);
8003
+ if (at === void 0) return;
8004
+ visit(at);
8005
+ (_a = index.repeats.get(id)) == null ? void 0 : _a.forEach(visit);
8006
+ }
8007
+ function locateFeatureHolders(id, readOnly, cache2) {
8008
+ const holders = [];
8009
+ readOnly.forEach((features, layerId) => {
8010
+ forEachIndex(indexOfIds(features, cache2), id, (at) => holders.push({ layerId, feature: features[at] }));
8011
+ });
8012
+ return holders;
8013
+ }
8014
+ function locateFeatureSources(id, inputs, cache2) {
8015
+ const sources = [];
8016
+ const add = (sourceId) => {
8017
+ if (!sources.includes(sourceId)) sources.push(sourceId);
8018
+ };
8019
+ inputs.readOnly.forEach((features, layerId) => {
8020
+ const sharded = inputs.shardedLayerIds.has(layerId);
8021
+ forEachIndex(indexOfIds(features, cache2), id, (at) => {
8022
+ add(sharded ? shardSourceId(layerId, Math.floor(at / inputs.shardSize)) : SHARED_SOURCE_ID);
8023
+ });
8024
+ });
8025
+ if (sources.length === 0) add(SHARED_SOURCE_ID);
8026
+ return sources;
8027
+ }
7951
8028
  function deepClone(value) {
7952
8029
  try {
7953
8030
  return structuredClone(value);
@@ -8210,6 +8287,93 @@ function hitTestSelection(featureGroups, selectionPolygon, options) {
8210
8287
  mapPerfLog("hit-test", "selection gesture", { visited, total, selected: selectedIds.length });
8211
8288
  return selectedIds;
8212
8289
  }
8290
+ const SELECTION_OVERLAY_SOURCE_ID = "selection-overlay";
8291
+ const SELECTION_OVERLAY_LAYER_IDS = {
8292
+ iconRing: "selection-overlay-icon-ring",
8293
+ line: "selection-overlay-line",
8294
+ polygon: "selection-overlay-polygon",
8295
+ label: "selection-overlay-label"
8296
+ };
8297
+ function buildSelectionOverlayStack() {
8298
+ const source = SELECTION_OVERLAY_SOURCE_ID;
8299
+ return [
8300
+ {
8301
+ id: SELECTION_OVERLAY_LAYER_IDS.iconRing,
8302
+ type: "circle",
8303
+ source,
8304
+ filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["!=", "isHiddenByHeatmap", 1]],
8305
+ paint: {
8306
+ "circle-color": "transparent",
8307
+ "circle-radius": ["/", ["coalesce", ["get", "iconSize"], 24], 1.6],
8308
+ "circle-stroke-color": SELECTION_COLOR,
8309
+ "circle-stroke-width": 3,
8310
+ "circle-stroke-opacity": 1
8311
+ }
8312
+ },
8313
+ {
8314
+ id: SELECTION_OVERLAY_LAYER_IDS.line,
8315
+ type: "line",
8316
+ source,
8317
+ filter: ["==", "$type", "LineString"],
8318
+ paint: {
8319
+ "line-color": SELECTION_COLOR,
8320
+ "line-width": ["+", ["get", "stroke-width"], 4],
8321
+ "line-dasharray": [4, 2]
8322
+ }
8323
+ },
8324
+ {
8325
+ id: SELECTION_OVERLAY_LAYER_IDS.polygon,
8326
+ type: "line",
8327
+ source,
8328
+ filter: ["==", "$type", "Polygon"],
8329
+ paint: {
8330
+ "line-color": SELECTION_COLOR,
8331
+ "line-width": 4,
8332
+ "line-dasharray": [4, 2]
8333
+ }
8334
+ },
8335
+ {
8336
+ id: SELECTION_OVERLAY_LAYER_IDS.label,
8337
+ type: "symbol",
8338
+ source,
8339
+ layout: {
8340
+ ...buildCustomLabelLayout(),
8341
+ // Never hidden by the auto-label density cap, which only flips the
8342
+ // unpinned base layer: with base labels off, the selected ones stay.
8343
+ visibility: "visible",
8344
+ // Full collision; topmost, so placed first (see the module comment):
8345
+ // selected labels thin among themselves and win against every other.
8346
+ "text-allow-overlap": false,
8347
+ "text-ignore-placement": false,
8348
+ "text-optional": true,
8349
+ // Same ranking as the base layers, so which selected label wins a
8350
+ // crowded spot is stable across repaints.
8351
+ "symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
8352
+ },
8353
+ paint: buildCustomLabelPaint()
8354
+ }
8355
+ ];
8356
+ }
8357
+ function overlayTimelineInputs(ids, visible) {
8358
+ const hidden = /* @__PURE__ */ new Set();
8359
+ if (visible !== null) ids.forEach((id) => {
8360
+ if (!visible.has(id)) hidden.add(id);
8361
+ });
8362
+ return { ids, hidden };
8363
+ }
8364
+ function sameIds(a, b) {
8365
+ return a.size === b.size && Array.from(a).every((id) => b.has(id));
8366
+ }
8367
+ function sameOverlayTimelineInputs(a, b) {
8368
+ return sameIds(a.ids, b.ids) && sameIds(a.hidden, b.hidden);
8369
+ }
8370
+ function buildSelectionOverlayData(ids, styleFor) {
8371
+ const features = [];
8372
+ ids.forEach((id) => {
8373
+ styleFor(id).forEach((feature) => features.push(feature));
8374
+ });
8375
+ return { type: "FeatureCollection", features };
8376
+ }
8213
8377
  function renderedFeatureId(f) {
8214
8378
  var _a;
8215
8379
  const fromProps = (_a = f.properties) == null ? void 0 : _a.id;
@@ -8739,6 +8903,8 @@ function ClusterPieManager(props) {
8739
8903
  return null;
8740
8904
  }
8741
8905
  const EMPTY_ID_SET = /* @__PURE__ */ new Set();
8906
+ const EMPTY_SOURCES = [];
8907
+ const TOOLTIP_EXCLUDED_KEYS = ["stroke", "stroke-width", "stroke-opacity", "fill", "fill-opacity", "pointRadius", "kind", "meta:type", "circleCenter", "circleRadius", "icon", "iconSize", "pointIcon", "pointIconSize", "fontSize", "fontColor", "fontWeight", "arrowSize", "label", "entityType"];
8742
8908
  const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
8743
8909
  function renderEmojiToCanvas(emoji, size = EMOJI_CANVAS_SIZE) {
8744
8910
  const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
@@ -8944,6 +9110,13 @@ function basemapInsertAnchor(map) {
8944
9110
  if (map.getLayer("custom-polygon-fill")) return "custom-polygon-fill";
8945
9111
  return void 0;
8946
9112
  }
9113
+ function featureStateHostFor(m) {
9114
+ return {
9115
+ setFeatureState: (source, id, state) => m.setFeatureState({ source, id }, state),
9116
+ removeFeatureState: (source, id) => m.removeFeatureState({ source, id }),
9117
+ source: (source) => m.getSource(source)
9118
+ };
9119
+ }
8947
9120
  const BASEMAP_LAYER_PREFIXES = {
8948
9121
  streets: "streets-",
8949
9122
  satellite: "satellite-",
@@ -9293,6 +9466,19 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9293
9466
  }
9294
9467
  return getReadOnlyFeatureById(id);
9295
9468
  }, [getReadOnlyFeatureById]);
9469
+ const appliedSelectionRef = react.useRef(/* @__PURE__ */ new Map());
9470
+ const locatorCacheRef = react.useRef(createLocatorCache());
9471
+ const shardedLayerIdsRef = react.useRef(EMPTY_ID_SET);
9472
+ const overlayPaintContextRef = react.useRef(null);
9473
+ const shardFieldRangesRef = react.useRef(/* @__PURE__ */ new Map());
9474
+ const locateSelectionSources = react.useCallback((id) => {
9475
+ if (getFeatureById(id) === null) return EMPTY_SOURCES;
9476
+ return locateFeatureSources(
9477
+ id,
9478
+ { readOnly: readOnlyFeatures.current, shardedLayerIds: shardedLayerIdsRef.current, shardSize: shardSizeRef.current },
9479
+ locatorCacheRef.current
9480
+ );
9481
+ }, [getFeatureById]);
9296
9482
  const canDeleteSelected = react.useMemo(() => {
9297
9483
  if (selectedFeatureIds.length === 0) return false;
9298
9484
  return selectedFeatureIds.some((id) => {
@@ -9314,7 +9500,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9314
9500
  return true;
9315
9501
  });
9316
9502
  }, [selectedFeatureIds, hiddenDrawingTools, getFeatureById]);
9317
- const applySelectionState = react.useCallback((nextIds, options) => {
9503
+ const applySelectionState$1 = react.useCallback((nextIds, options) => {
9318
9504
  if (!isMapLoaded || !draw.current) {
9319
9505
  setSelectedFeatureIds(nextIds);
9320
9506
  if (options == null ? void 0 : options.focusProperties) setShowProperties(nextIds.length > 0);
@@ -9385,6 +9571,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9385
9571
  });
9386
9572
  const trySelectionFastPathRef = react.useRef(null);
9387
9573
  const tryTimelineFastPathRef = react.useRef(null);
9574
+ const reconcileSelectionRef = react.useRef(null);
9388
9575
  const syncCoalescerRef = react.useRef(null);
9389
9576
  if (syncCoalescerRef.current === null) {
9390
9577
  syncCoalescerRef.current = createRafCoalescer((reasons) => {
@@ -9585,7 +9772,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9585
9772
  }
9586
9773
  }, []);
9587
9774
  const syncFeaturesToCustomLayers = react.useCallback(() => {
9588
- var _a, _b;
9775
+ var _a, _b, _c;
9589
9776
  if (!map.current) return;
9590
9777
  if (isSyncingRef.current) return;
9591
9778
  isSyncingRef.current = true;
@@ -9594,11 +9781,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9594
9781
  const source = map.current.getSource("custom-features");
9595
9782
  if (!source) return;
9596
9783
  const drawFeatures = draw.current ? draw.current.getAll() : { type: "FeatureCollection", features: [] };
9597
- const drawSelectedIds = draw.current ? draw.current.getSelectedIds() : [];
9598
- const componentSelectedIds = selectedFeatureIdsRef.current;
9599
- const selectedIdSet = /* @__PURE__ */ new Set();
9600
- drawSelectedIds.forEach((id) => selectedIdSet.add(String(id)));
9601
- componentSelectedIds.forEach((id) => selectedIdSet.add(String(id)));
9602
9784
  const visibleSet = timelineVisibleIdsRef.current;
9603
9785
  const currentLayers = layersRef.current;
9604
9786
  const isLayerVisible = (layer) => {
@@ -9610,6 +9792,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9610
9792
  const count = ((_a2 = readOnlyFeatures.current.get(layer.id)) == null ? void 0 : _a2.length) ?? 0;
9611
9793
  if (isShardEligible(layer, count, shardSizeRef.current)) shardedLayerIds.add(layer.id);
9612
9794
  });
9795
+ shardedLayerIdsRef.current = shardedLayerIds;
9613
9796
  const allFeatures = [...drawFeatures.features];
9614
9797
  readOnlyFeatures.current.forEach((features, layerId) => {
9615
9798
  if (shardedLayerIds.has(layerId)) return;
@@ -9694,8 +9877,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9694
9877
  const paintCache = createSelectionPaintCache();
9695
9878
  const paintContext = {
9696
9879
  timelineVisibleIds: visibleSet,
9697
- selectedIds: selectedIdSet,
9698
- selectionEnabled: enableSelectionRef.current || enableDrawingRef.current,
9699
9880
  sizeFieldRanges,
9700
9881
  colorFieldRanges,
9701
9882
  tracePointIds,
@@ -9709,21 +9890,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9709
9890
  features: allFeatures.map((f, i) => {
9710
9891
  const styled = styleFeatureForPaint(f, featureToLayer.get(String(f.id)), paintContext, i >= drawFeatureCount);
9711
9892
  const p = styled.paint;
9712
- recordPaintedFeature(
9713
- paintCache,
9714
- p.featureId,
9715
- p.basePriority,
9716
- p.selected,
9717
- p.visibleStrokeOpacity,
9718
- p.visibleFillOpacity,
9719
- p.timelineHidden
9720
- );
9893
+ recordPaintedFeature(paintCache, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
9721
9894
  if (styled.tracePaint) tracePointPaint.set(p.featureId, styled.tracePaint);
9722
9895
  return styled.feature;
9723
9896
  })
9724
9897
  };
9725
9898
  source.setData(sourceData);
9726
9899
  selectionPaintCacheRef.current = paintCache;
9900
+ overlayPaintContextRef.current = paintContext;
9901
+ (_a = reconcileSelectionRef.current) == null ? void 0 : _a.call(reconcileSelectionRef);
9727
9902
  const traceSource = map.current.getSource("trace-features");
9728
9903
  if (traceSource) traceSource.setData({ type: "FeatureCollection", features: traceSegments });
9729
9904
  tracePaintCacheRef.current = traceSource && paintedTraceGroups.length > 0 ? { groups: paintedTraceGroups, pointPaint: tracePointPaint } : null;
@@ -9737,7 +9912,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9737
9912
  sawArrowFeature = true;
9738
9913
  if (f.geometry.type === "LineString") arrowLines.push(f);
9739
9914
  });
9740
- const shardArrows = ((_a = shardRegistryRef.current) == null ? void 0 : _a.arrowLines((id) => {
9915
+ const shardArrows = ((_b = shardRegistryRef.current) == null ? void 0 : _b.arrowLines((id) => {
9741
9916
  var _a2;
9742
9917
  return ((_a2 = currentLayers.find((l) => l.id === id)) == null ? void 0 : _a2.visible) === true;
9743
9918
  })) ?? [];
@@ -9757,7 +9932,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9757
9932
  setVisibleFeatureCount(countVisibleFeatures(threshold));
9758
9933
  setLabelsSuppressed(false);
9759
9934
  }
9760
- (_b = applyShardedLayersRef.current) == null ? void 0 : _b.call(applyShardedLayersRef);
9935
+ (_c = applyShardedLayersRef.current) == null ? void 0 : _c.call(applyShardedLayersRef);
9761
9936
  const requestedBy = fullSyncCallersRef.current.splice(0);
9762
9937
  let shardedFeatures = 0;
9763
9938
  shardedLayerIds.forEach((id) => {
@@ -9854,21 +10029,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9854
10029
  if (!m || !registry) return;
9855
10030
  const currentLayers = layersRef.current;
9856
10031
  const shardSize2 = shardSizeRef.current;
9857
- const selectionEnabled = enableSelectionRef.current || enableDrawingRef.current;
9858
- const currentSelectedIds = () => {
9859
- var _a;
9860
- const ids = /* @__PURE__ */ new Set();
9861
- if (selectionEnabled) {
9862
- (((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => ids.add(String(id)));
9863
- selectedFeatureIdsRef.current.forEach((id) => ids.add(String(id)));
9864
- }
9865
- return ids;
9866
- };
9867
10032
  currentLayers.forEach((layer) => {
9868
10033
  var _a;
9869
10034
  const features = readOnlyFeatures.current.get(layer.id) ?? [];
9870
10035
  if (!isShardEligible(layer, features.length, shardSize2)) {
9871
10036
  registry.remove(layer.id);
10037
+ shardFieldRangesRef.current.delete(layer.id);
9872
10038
  setLayerImporting(layer.id, false);
9873
10039
  return;
9874
10040
  }
@@ -9878,10 +10044,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9878
10044
  setLayerImporting(layer.id, false);
9879
10045
  return;
9880
10046
  }
9881
- const fingerprint = buildShardFingerprint(layer, features, selectionEnabled, shardSize2);
10047
+ const fingerprint = buildShardFingerprint(layer, features, shardSize2);
9882
10048
  const expectedShards = shardRanges(features.length, shardSize2).length;
9883
10049
  if (shardFingerprintsEqual(state.fingerprint, fingerprint) && state.stacks.length === expectedShards) {
9884
- if (reconcileShardCaches(registry, state.layerId, expectedShards, currentSelectedIds(), timelineVisibleIdsRef.current)) {
10050
+ if (reconcileShardCaches(registry, state.layerId, expectedShards, timelineVisibleIdsRef.current)) {
9885
10051
  setLayerImporting(layer.id, false);
9886
10052
  mapPerfLog("shards", "pass skipped (fingerprint)", { layerId: layer.id, shards: expectedShards });
9887
10053
  return;
@@ -9901,10 +10067,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9901
10067
  const ranges = layerFieldRanges(layer.visualConfig, (visit) => {
9902
10068
  for (let i = 0; i < features.length; i++) visit(features[i].properties);
9903
10069
  });
10070
+ shardFieldRangesRef.current.set(layer.id, ranges);
9904
10071
  const sizeFieldRanges = /* @__PURE__ */ new Map();
9905
10072
  const colorFieldRanges = /* @__PURE__ */ new Map();
9906
10073
  if (ranges.size) sizeFieldRanges.set(layer.id, ranges.size);
9907
10074
  if (ranges.color) colorFieldRanges.set(layer.id, ranges.color);
10075
+ let overlayRestyled = false;
9908
10076
  void runShardPass({
9909
10077
  layer,
9910
10078
  features,
@@ -9915,8 +10083,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9915
10083
  contextForShard: () => {
9916
10084
  return {
9917
10085
  timelineVisibleIds: timelineVisibleIdsRef.current,
9918
- selectedIds: currentSelectedIds(),
9919
- selectionEnabled,
9920
10086
  sizeFieldRanges,
9921
10087
  colorFieldRanges,
9922
10088
  // Trace-enabled layers are never sharded, so these are empty by construction.
@@ -9927,7 +10093,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9927
10093
  };
9928
10094
  },
9929
10095
  onShardPainted: (index, cache2) => {
10096
+ var _a2;
9930
10097
  state.caches[index] = cache2;
10098
+ (_a2 = reconcileSelectionRef.current) == null ? void 0 : _a2.call(reconcileSelectionRef, { overlay: !overlayRestyled });
10099
+ overlayRestyled = true;
9931
10100
  },
9932
10101
  onProgress: (painted) => progress == null ? void 0 : progress.update(painted)
9933
10102
  }).then((result) => {
@@ -10118,7 +10287,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10118
10287
  });
10119
10288
  const registry = shardRegistryRef.current;
10120
10289
  registry == null ? void 0 : registry.trackedLayerIds().forEach((layerId) => {
10121
- if (!liveLayerIds.has(layerId)) registry.remove(layerId);
10290
+ if (!liveLayerIds.has(layerId)) {
10291
+ registry.remove(layerId);
10292
+ shardFieldRangesRef.current.delete(layerId);
10293
+ }
10122
10294
  });
10123
10295
  Object.keys((style == null ? void 0 : style.sources) ?? {}).forEach((sid) => {
10124
10296
  const parsed = parseShardSourceId(sid);
@@ -10241,15 +10413,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10241
10413
  coalesceKey,
10242
10414
  undo: () => {
10243
10415
  applyHistoryState(featureIds, layerIds, beforeF, beforeL);
10244
- applySelectionState(beforeSelectedIds, { focusProperties: false });
10416
+ applySelectionState$1(beforeSelectedIds, { focusProperties: false });
10245
10417
  },
10246
10418
  redo: () => {
10247
10419
  applyHistoryState(featureIds, layerIds, afterF, afterL);
10248
- applySelectionState(afterSelectedIds, { focusProperties: false });
10420
+ applySelectionState$1(afterSelectedIds, { focusProperties: false });
10249
10421
  }
10250
10422
  };
10251
10423
  },
10252
- [applyHistoryState, applySelectionState]
10424
+ [applyHistoryState, applySelectionState$1]
10253
10425
  );
10254
10426
  const finalizeCapture = react.useCallback(() => {
10255
10427
  const pending = pendingCaptureRef.current;
@@ -10373,11 +10545,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10373
10545
  var _a, _b;
10374
10546
  map.current = mapInstance;
10375
10547
  draw.current = drawInstance;
10376
- mapInstance.addSource("custom-features", {
10377
- type: "geojson",
10378
- data: { type: "FeatureCollection", features: [] },
10379
- maxzoom: 22
10380
- });
10548
+ mapInstance.addSource(SHARED_SOURCE_ID, customSourceSpec());
10381
10549
  const sharedStack = buildCustomLayerStack(SHARED_SOURCE_ID, CUSTOM_LAYER_ROLES, { labelsVisible: false });
10382
10550
  sharedStack.forEach((spec) => mapInstance.addLayer(spec));
10383
10551
  const styleHost = {
@@ -10468,6 +10636,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10468
10636
  "line-opacity": 0.7
10469
10637
  }
10470
10638
  });
10639
+ mapInstance.addSource(SELECTION_OVERLAY_SOURCE_ID, {
10640
+ type: "geojson",
10641
+ data: { type: "FeatureCollection", features: [] },
10642
+ maxzoom: 22
10643
+ });
10644
+ buildSelectionOverlayStack().forEach((spec) => mapInstance.addLayer(spec));
10471
10645
  if (tooltipElRef.current) {
10472
10646
  const prevCleanup = tooltipElRef.current._cleanup;
10473
10647
  try {
@@ -10586,8 +10760,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10586
10760
  const highlightFields = /* @__PURE__ */ new Set();
10587
10761
  if (((_a2 = visualConfig == null ? void 0 : visualConfig.size) == null ? void 0 : _a2.mode) === "field" && visualConfig.size.fieldName) highlightFields.add(visualConfig.size.fieldName);
10588
10762
  if (((_b2 = visualConfig == null ? void 0 : visualConfig.color) == null ? void 0 : _b2.mode) === "field" && visualConfig.color.fieldName) highlightFields.add(visualConfig.color.fieldName);
10589
- const excludeKeys = ["stroke", "stroke-width", "stroke-opacity", "fill", "fill-opacity", "pointRadius", "isSelected", "kind", "meta:type", "circleCenter", "circleRadius", "icon", "iconSize", "pointIcon", "pointIconSize", "fontSize", "fontColor", "fontWeight", "arrowSize", "label", "entityType"];
10590
- const displayProps = Object.entries(props).filter(([key, value]) => !excludeKeys.includes(key) && !key.startsWith("_") && !key.startsWith("isHidden") && !key.startsWith("isTrace") && !key.startsWith("isTimeline") && !key.startsWith("trace") && value != null && value !== "").slice(0, 5);
10763
+ const displayProps = Object.entries(props).filter(([key, value]) => !TOOLTIP_EXCLUDED_KEYS.includes(key) && !key.startsWith("_") && !key.startsWith("isHidden") && !key.startsWith("isTrace") && !key.startsWith("isTimeline") && !key.startsWith("trace") && value != null && value !== "").slice(0, 5);
10591
10764
  const name = props.name;
10592
10765
  let html = '<div class="text-sm space-y-0.5">';
10593
10766
  if (name) html += `<div class="font-medium">${name}</div>`;
@@ -11263,7 +11436,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11263
11436
  const clusterHit = clusterOverlayIds.length > 0 ? mapInstance.queryRenderedFeatures(e.point, { layers: clusterOverlayIds })[0] : void 0;
11264
11437
  if (!clusterHit) {
11265
11438
  if (selectedFeatureIdsRef.current.length > 0 && !isModifierKey) {
11266
- applySelectionState([]);
11439
+ applySelectionState$1([]);
11267
11440
  }
11268
11441
  return;
11269
11442
  }
@@ -11285,13 +11458,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11285
11458
  return;
11286
11459
  }
11287
11460
  const fid = String(featureId);
11288
- const currentSelection = selectedFeatureIdsRef.current;
11289
- const isAlreadySelected = currentSelection.includes(fid);
11461
+ const currentSelection2 = selectedFeatureIdsRef.current;
11462
+ const isAlreadySelected = currentSelection2.includes(fid);
11290
11463
  let nextIds;
11291
11464
  if (isModifierKey) {
11292
- nextIds = isAlreadySelected ? currentSelection.filter((id) => id !== fid) : [...currentSelection, fid];
11465
+ nextIds = isAlreadySelected ? currentSelection2.filter((id) => id !== fid) : [...currentSelection2, fid];
11293
11466
  } else {
11294
- nextIds = isAlreadySelected ? currentSelection.filter((id) => id !== fid) : [fid];
11467
+ nextIds = isAlreadySelected ? currentSelection2.filter((id) => id !== fid) : [fid];
11295
11468
  }
11296
11469
  isSelectingReadOnlyRef.current = true;
11297
11470
  if (drawInstance.getSelected().features.length > 0) {
@@ -11843,7 +12016,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11843
12016
  onFeatureDelete == null ? void 0 : onFeatureDelete(featureIds);
11844
12017
  },
11845
12018
  selectFeatures: (featureIds) => {
11846
- applySelectionState(featureIds, { focusProperties: true });
12019
+ applySelectionState$1(featureIds, { focusProperties: true });
11847
12020
  },
11848
12021
  getSelectedFeatures,
11849
12022
  setEditMode: (enabled) => {
@@ -12132,7 +12305,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
12132
12305
  setPersistedSelectionPolygon(null);
12133
12306
  setSelectionPoints([]);
12134
12307
  setSelectedFeatureIds([]);
12135
- applySelectionState([], { focusProperties: true });
12308
+ applySelectionState$1([], { focusProperties: true });
12136
12309
  },
12137
12310
  // Viewport and state getters
12138
12311
  getViewport: () => {
@@ -13120,6 +13293,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13120
13293
  if (!m.getLayer(id)) return;
13121
13294
  m.moveLayer(id, firstVisibleBasemapSymbol == null ? void 0 : firstVisibleBasemapSymbol.id);
13122
13295
  });
13296
+ if (!firstVisibleBasemapSymbol && m.getLayer(SELECTION_OVERLAY_LAYER_IDS.label)) {
13297
+ m.moveLayer(SELECTION_OVERLAY_LAYER_IDS.label);
13298
+ }
13123
13299
  } catch (e) {
13124
13300
  console.warn("[map-component] moveLabelsBeforeBasemapSymbols failed:", (e == null ? void 0 : e.message) ?? e);
13125
13301
  }
@@ -13674,24 +13850,91 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13674
13850
  react.useEffect(() => {
13675
13851
  enableDrawingRef.current = enableDrawing;
13676
13852
  }, [enableDrawing]);
13677
- const trySelectionFastPath = react.useCallback(() => {
13853
+ const overlayPaintContext = react.useCallback(() => {
13854
+ const base = overlayPaintContextRef.current;
13855
+ if (!base) return null;
13856
+ const sizeFieldRanges = new Map(base.sizeFieldRanges);
13857
+ const colorFieldRanges = new Map(base.colorFieldRanges);
13858
+ shardFieldRangesRef.current.forEach((ranges, layerId) => {
13859
+ if (ranges.size) sizeFieldRanges.set(layerId, ranges.size);
13860
+ if (ranges.color) colorFieldRanges.set(layerId, ranges.color);
13861
+ });
13862
+ return { ...base, timelineVisibleIds: timelineVisibleIdsRef.current, sizeFieldRanges, colorFieldRanges };
13863
+ }, []);
13864
+ const overlayFeatureCountRef = react.useRef(0);
13865
+ const overlayTimelineInputsRef = react.useRef(overlayTimelineInputs(EMPTY_ID_SET, null));
13866
+ const refreshSelectionOverlay = react.useCallback((m, ids) => {
13867
+ overlayTimelineInputsRef.current = overlayTimelineInputs(ids, timelineVisibleIdsRef.current);
13868
+ if (ids.size === 0 && overlayFeatureCountRef.current === 0) return;
13869
+ const overlay = m.getSource(SELECTION_OVERLAY_SOURCE_ID);
13870
+ if (!overlay) return;
13871
+ const ctx = ids.size > 0 ? overlayPaintContext() : null;
13872
+ const layers2 = layersRef.current;
13873
+ const layerById = new Map(layers2.map((l) => [l.id, l]));
13874
+ const data = buildSelectionOverlayData(ids, (id) => {
13875
+ if (!ctx) return [];
13876
+ const holders = locateFeatureHolders(id, readOnlyFeatures.current, locatorCacheRef.current);
13877
+ if (holders.length > 0) {
13878
+ return holders.filter((h) => {
13879
+ var _a;
13880
+ return ((_a = layerById.get(h.layerId)) == null ? void 0 : _a.visible) === true;
13881
+ }).map((h) => styleFeatureForPaint(h.feature, layerById.get(h.layerId), ctx, true).feature);
13882
+ }
13883
+ const feature = getFeatureById(id);
13884
+ if (!feature) return [];
13885
+ const layer = layers2.find((l) => !l.readOnly && l.featureIds.includes(id));
13886
+ return layer && !layer.visible ? [] : [styleFeatureForPaint(feature, layer, ctx, true).feature];
13887
+ });
13888
+ overlay.setData(data);
13889
+ overlayFeatureCountRef.current = data.features.length;
13890
+ }, [getFeatureById, overlayPaintContext]);
13891
+ const currentSelection = react.useCallback(() => {
13678
13892
  var _a;
13893
+ if (!(enableSelectionRef.current || enableDrawingRef.current)) return null;
13894
+ const next = /* @__PURE__ */ new Set();
13895
+ (((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => next.add(String(id)));
13896
+ selectedFeatureIdsRef.current.forEach((id) => next.add(String(id)));
13897
+ return next;
13898
+ }, []);
13899
+ const paintSelection = react.useCallback((m, overlay = true) => {
13900
+ const selection = currentSelection();
13901
+ const { set: set2, removed } = applySelectionState(
13902
+ appliedSelectionRef.current,
13903
+ selection ?? EMPTY_ID_SET,
13904
+ selection !== null,
13905
+ locateSelectionSources,
13906
+ featureStateHostFor(m)
13907
+ );
13908
+ const shown = selection ?? EMPTY_ID_SET;
13909
+ if (overlay) refreshSelectionOverlay(m, shown);
13910
+ return { set: set2, removed, overlay: overlay ? shown.size : 0 };
13911
+ }, [currentSelection, locateSelectionSources, refreshSelectionOverlay]);
13912
+ const applySelectionPaint = react.useCallback(() => {
13679
13913
  const m = map.current;
13680
13914
  if (!m) return true;
13681
- const source = m.getSource("custom-features");
13682
- const gate = enableSelectionRef.current || enableDrawingRef.current;
13683
- const next = /* @__PURE__ */ new Set();
13684
- if (gate) {
13685
- (((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => next.add(String(id)));
13686
- selectedFeatureIdsRef.current.forEach((id) => next.add(String(id)));
13687
- }
13688
- if (!applySelectionFastPath(selectionPaintCacheRef.current, next, source)) return false;
13689
- return forEachShardCache(
13690
- shardRegistryRef.current,
13691
- (cache2, shardSource) => applySelectionFastPath(cache2, next, shardSource)
13915
+ const start = performance.now();
13916
+ const painted = paintSelection(m);
13917
+ mapPerfLog("selection", "feature state applied", { ...painted, ms: Math.round(performance.now() - start) });
13918
+ return true;
13919
+ }, [paintSelection]);
13920
+ trySelectionFastPathRef.current = applySelectionPaint;
13921
+ const reconcileSelectionAfterPaint = react.useCallback((options) => {
13922
+ const m = map.current;
13923
+ if (!m) return;
13924
+ const { moved, pruned } = reconcileSelectionSources(
13925
+ appliedSelectionRef.current,
13926
+ locateSelectionSources,
13927
+ featureStateHostFor(m)
13692
13928
  );
13693
- }, []);
13694
- trySelectionFastPathRef.current = trySelectionFastPath;
13929
+ const applied = paintSelection(m, (options == null ? void 0 : options.overlay) ?? true);
13930
+ if (moved || pruned || applied.set || applied.removed) {
13931
+ mapPerfLog("selection", "reconciled after paint", { moved, pruned, ...applied });
13932
+ }
13933
+ }, [locateSelectionSources, paintSelection]);
13934
+ reconcileSelectionRef.current = reconcileSelectionAfterPaint;
13935
+ react.useEffect(() => {
13936
+ scheduleSync("selection");
13937
+ }, [enableSelection, enableDrawing, scheduleSync]);
13695
13938
  const tryTimelineFastPath = react.useCallback(() => {
13696
13939
  const m = map.current;
13697
13940
  if (!m) return true;
@@ -13705,13 +13948,17 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13705
13948
  const traceDiff = trace && paintCache ? buildTraceTimelineDiff(trace, paintCache, nextVisible) : null;
13706
13949
  const { applied, toggled } = applyTimelineFastPath(paintCache, nextVisible, source);
13707
13950
  if (!applied || !paintCache || !source) return false;
13708
- if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff, paintCache, source, traceSource))) return false;
13951
+ if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff, source, traceSource))) return false;
13709
13952
  if (!forEachShardCache(shardRegistryRef.current, (cache2, shardSource) => applyTimelineFastPath(cache2, nextVisible, shardSource).applied)) {
13710
13953
  return false;
13711
13954
  }
13712
13955
  const threshold = autoLabelConfig.enabled ? autoLabelConfig.threshold : 220;
13713
13956
  setVisibleFeatureCount(countVisibleFeatures(threshold));
13714
13957
  setLabelsSuppressed(false);
13958
+ const selection = currentSelection() ?? EMPTY_ID_SET;
13959
+ if (!sameOverlayTimelineInputs(overlayTimelineInputsRef.current, overlayTimelineInputs(selection, nextVisible))) {
13960
+ refreshSelectionOverlay(m, selection);
13961
+ }
13715
13962
  mapPerfLog("timeline", "fast path applied", {
13716
13963
  toggled,
13717
13964
  endpointsMoved: (traceDiff == null ? void 0 : traceDiff.pointUpdates.length) ?? 0,
@@ -13719,7 +13966,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13719
13966
  segmentsRemoved: (traceDiff == null ? void 0 : traceDiff.segmentRemove.length) ?? 0
13720
13967
  });
13721
13968
  return true;
13722
- }, [autoLabelConfig, countVisibleFeatures]);
13969
+ }, [autoLabelConfig, countVisibleFeatures, currentSelection, refreshSelectionOverlay]);
13723
13970
  tryTimelineFastPathRef.current = tryTimelineFastPath;
13724
13971
  const collectSelectionFeatureGroups = react.useCallback(() => {
13725
13972
  return collectVisibleFeatureGroups(
@@ -13835,7 +14082,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13835
14082
  axisAlignedRectangle: true
13836
14083
  });
13837
14084
  const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
13838
- applySelectionState(finalIds, { focusProperties: true });
14085
+ applySelectionState$1(finalIds, { focusProperties: true });
13839
14086
  }
13840
14087
  setIsSelectionToolActive(false);
13841
14088
  startPoint = null;
@@ -13858,7 +14105,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13858
14105
  } else {
13859
14106
  const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
13860
14107
  const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
13861
- applySelectionState(finalIds, { focusProperties: true });
14108
+ applySelectionState$1(finalIds, { focusProperties: true });
13862
14109
  }
13863
14110
  setIsSelectionToolActive(false);
13864
14111
  }
@@ -13892,7 +14139,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13892
14139
  } else {
13893
14140
  const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
13894
14141
  const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
13895
- applySelectionState(finalIds, { focusProperties: true });
14142
+ applySelectionState$1(finalIds, { focusProperties: true });
13896
14143
  }
13897
14144
  setIsSelectionToolActive(false);
13898
14145
  setSelectionPoints([]);
@@ -14008,7 +14255,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
14008
14255
  setSelectionPoints([]);
14009
14256
  mapInstance.dragPan.enable();
14010
14257
  canvas.style.cursor = "";
14011
- applySelectionState(mergedIds, { focusProperties: true });
14258
+ applySelectionState$1(mergedIds, { focusProperties: true });
14012
14259
  };
14013
14260
  canvas.addEventListener("mousedown", handleShiftMouseDown);
14014
14261
  window.addEventListener("mousemove", handleShiftMouseMove);
@@ -14021,7 +14268,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
14021
14268
  map.current.dragPan.enable();
14022
14269
  }
14023
14270
  };
14024
- }, [isMapLoaded, isSelectionToolActive, applySelectionState, collectSelectionFeatureGroups]);
14271
+ }, [isMapLoaded, isSelectionToolActive, applySelectionState$1, collectSelectionFeatureGroups]);
14025
14272
  react.useEffect(() => {
14026
14273
  if (!map.current || !isMapLoaded) return;
14027
14274
  const mapInstance = map.current;
@@ -17237,8 +17484,10 @@ exports.TIMEBAR_BOTTOM_OFFSET = TIMEBAR_BOTTOM_OFFSET;
17237
17484
  exports.TIMEBAR_HEIGHT = TIMEBAR_HEIGHT;
17238
17485
  exports.Timebar = Timebar;
17239
17486
  exports.TimebarToggle = TimebarToggle;
17487
+ exports.TimelineStoreContext = TimelineStoreContext;
17240
17488
  exports.cn = cn;
17241
17489
  exports.createClusterPieManager = createClusterPieManager;
17490
+ exports.createTimelineStore = createTimelineStore;
17242
17491
  exports.featureCollectionBlobPartsAsync = featureCollectionBlobPartsAsync;
17243
17492
  exports.getIconEmoji = getIconEmoji;
17244
17493
  exports.isFeatureInRange = isFeatureInRange;
@@ -17248,5 +17497,6 @@ exports.normalizeTemporalProperties = normalizeTemporalProperties;
17248
17497
  exports.parseKMLToGeoJSON = parseKMLToGeoJSON;
17249
17498
  exports.toast = useToast;
17250
17499
  exports.useTimelineStore = useTimelineStore;
17500
+ exports.useTimelineStoreApi = useTimelineStoreApi;
17251
17501
  exports.useToast = useToast;
17252
17502
  //# sourceMappingURL=index.cjs.map