@octostar/map-component 0.2.22 → 0.3.1

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 (43) hide show
  1. package/dist/index.cjs +656 -382
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.mjs +656 -382
  4. package/dist/index.mjs.map +1 -1
  5. package/dist/types/components/drawing-toolbar.d.ts +4 -6
  6. package/dist/types/components/drawing-toolbar.d.ts.map +1 -1
  7. package/dist/types/components/layers-panel.d.ts +1 -1
  8. package/dist/types/components/layers-panel.d.ts.map +1 -1
  9. package/dist/types/components/map-editor-canvas.d.ts.map +1 -1
  10. package/dist/types/index.d.ts +1 -1
  11. package/dist/types/index.d.ts.map +1 -1
  12. package/dist/types/lib/basemap-list.d.ts +15 -6
  13. package/dist/types/lib/basemap-list.d.ts.map +1 -1
  14. package/dist/types/lib/custom-layer-stack.d.ts +20 -7
  15. package/dist/types/lib/custom-layer-stack.d.ts.map +1 -1
  16. package/dist/types/lib/label-pinning.d.ts +10 -2
  17. package/dist/types/lib/label-pinning.d.ts.map +1 -1
  18. package/dist/types/lib/map-editor-api.d.ts +80 -47
  19. package/dist/types/lib/map-editor-api.d.ts.map +1 -1
  20. package/dist/types/lib/map-endpoints.d.ts +71 -0
  21. package/dist/types/lib/map-endpoints.d.ts.map +1 -0
  22. package/dist/types/lib/paint-feature.d.ts +11 -11
  23. package/dist/types/lib/paint-feature.d.ts.map +1 -1
  24. package/dist/types/lib/selection-diff.d.ts +9 -34
  25. package/dist/types/lib/selection-diff.d.ts.map +1 -1
  26. package/dist/types/lib/selection-overlay.d.ts +53 -0
  27. package/dist/types/lib/selection-overlay.d.ts.map +1 -0
  28. package/dist/types/lib/selection-paint.d.ts +23 -0
  29. package/dist/types/lib/selection-paint.d.ts.map +1 -0
  30. package/dist/types/lib/selection-state.d.ts +60 -0
  31. package/dist/types/lib/selection-state.d.ts.map +1 -0
  32. package/dist/types/lib/shard-fingerprint.d.ts +6 -7
  33. package/dist/types/lib/shard-fingerprint.d.ts.map +1 -1
  34. package/dist/types/lib/shard-locator.d.ts +53 -0
  35. package/dist/types/lib/shard-locator.d.ts.map +1 -0
  36. package/dist/types/lib/shard-pipeline.d.ts.map +1 -1
  37. package/dist/types/lib/shard-registry.d.ts +5 -4
  38. package/dist/types/lib/shard-registry.d.ts.map +1 -1
  39. package/dist/types/lib/trace-timeline.d.ts +3 -6
  40. package/dist/types/lib/trace-timeline.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/vite-plugin.d.mts +2 -0
  43. package/vite-plugin.mjs +42 -8
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
  }
@@ -2657,6 +2553,148 @@ function useToast() {
2657
2553
  };
2658
2554
  return { toast };
2659
2555
  }
2556
+ const DEFAULT_ENDPOINTS = {
2557
+ streetsStyle: "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",
2558
+ darkStyle: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
2559
+ satelliteTiles: ["https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"],
2560
+ satelliteAttribution: "Esri, Maxar, Earthstar Geographics",
2561
+ terrainTiles: ["https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"],
2562
+ geocodingUrl: "https://nominatim.openstreetmap.org/search",
2563
+ glyphsUrl: "/fonts/{fontstack}/{range}.pbf"
2564
+ };
2565
+ const BUILT_IN_NAMES = {
2566
+ streets: "Streets",
2567
+ satellite: "Satellite",
2568
+ dark: "Dark"
2569
+ };
2570
+ const isOff = (value) => value === false || value === null;
2571
+ const nonEmpty = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
2572
+ const nonEmptyTiles = (tiles) => Array.isArray(tiles) ? tiles.filter((tile) => nonEmpty(tile) !== void 0) : [];
2573
+ function resolveVectorStyle(endpoint, defaultStyle) {
2574
+ if (isOff(endpoint)) return null;
2575
+ if (endpoint === void 0) return { style: defaultStyle };
2576
+ const style = nonEmpty(endpoint.style);
2577
+ return style ? { style, name: endpoint.name } : null;
2578
+ }
2579
+ function resolveGeocoder(endpoint) {
2580
+ if (isOff(endpoint)) return null;
2581
+ if (endpoint === void 0) return { url: DEFAULT_ENDPOINTS.geocodingUrl };
2582
+ if ("provider" in endpoint) return typeof endpoint.provider === "function" ? { provider: endpoint.provider } : null;
2583
+ const url = nonEmpty(endpoint.url);
2584
+ return url ? { url } : null;
2585
+ }
2586
+ function resolveEndpoints(endpoints) {
2587
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2588
+ const e = endpoints ?? {};
2589
+ const streets = resolveVectorStyle(e.streets, DEFAULT_ENDPOINTS.streetsStyle);
2590
+ const dark = resolveVectorStyle(e.dark, DEFAULT_ENDPOINTS.darkStyle);
2591
+ let satellite = null;
2592
+ let satelliteName;
2593
+ if (!isOff(e.satellite)) {
2594
+ const tiles = e.satellite === void 0 ? [...DEFAULT_ENDPOINTS.satelliteTiles] : nonEmptyTiles(e.satellite.tiles);
2595
+ if (tiles.length > 0) {
2596
+ satellite = {
2597
+ tiles,
2598
+ tileSize: ((_a = e.satellite) == null ? void 0 : _a.tileSize) ?? 256,
2599
+ minzoom: ((_b = e.satellite) == null ? void 0 : _b.minzoom) ?? 0,
2600
+ maxzoom: ((_c = e.satellite) == null ? void 0 : _c.maxzoom) ?? 22,
2601
+ attribution: e.satellite === void 0 ? DEFAULT_ENDPOINTS.satelliteAttribution : e.satellite.attribution ?? ""
2602
+ };
2603
+ satelliteName = (_d = e.satellite) == null ? void 0 : _d.name;
2604
+ }
2605
+ }
2606
+ let terrain = null;
2607
+ if (!isOff(e.terrain)) {
2608
+ const tiles = e.terrain === void 0 ? [...DEFAULT_ENDPOINTS.terrainTiles] : nonEmptyTiles(e.terrain.tiles);
2609
+ if (tiles.length > 0) {
2610
+ terrain = {
2611
+ tiles,
2612
+ encoding: ((_e = e.terrain) == null ? void 0 : _e.encoding) ?? "terrarium",
2613
+ tileSize: ((_f = e.terrain) == null ? void 0 : _f.tileSize) ?? 256,
2614
+ minzoom: ((_g = e.terrain) == null ? void 0 : _g.minzoom) ?? 0,
2615
+ maxzoom: ((_h = e.terrain) == null ? void 0 : _h.maxzoom) ?? 15,
2616
+ attribution: ((_i = e.terrain) == null ? void 0 : _i.attribution) ?? ""
2617
+ };
2618
+ }
2619
+ }
2620
+ const glyphs = e.glyphs;
2621
+ const adoptStyleGlyphs = glyphs === "from-style";
2622
+ const glyphsUrl = typeof glyphs === "object" && glyphs !== null && nonEmpty(glyphs.url) || DEFAULT_ENDPOINTS.glyphsUrl;
2623
+ const builtInBasemaps = [];
2624
+ if (streets) builtInBasemaps.push({ id: "streets", name: streets.name ?? BUILT_IN_NAMES.streets });
2625
+ if (satellite) builtInBasemaps.push({ id: "satellite", name: satelliteName ?? BUILT_IN_NAMES.satellite });
2626
+ if (dark) builtInBasemaps.push({ id: "dark", name: dark.name ?? BUILT_IN_NAMES.dark });
2627
+ return {
2628
+ vectorStyles: {
2629
+ ...streets ? { streets: streets.style } : {},
2630
+ ...dark ? { dark: dark.style } : {}
2631
+ },
2632
+ satellite,
2633
+ terrain,
2634
+ glyphsUrl,
2635
+ adoptStyleGlyphs,
2636
+ builtInBasemaps
2637
+ };
2638
+ }
2639
+ function builtInStyleUrl(resolved, id) {
2640
+ if (id === "streets") return resolved.vectorStyles.streets;
2641
+ if (id === "dark") return resolved.vectorStyles.dark;
2642
+ return void 0;
2643
+ }
2644
+ function isBuiltInBasemapEnabled(resolved, id) {
2645
+ return resolved.builtInBasemaps.some((basemap) => basemap.id === id);
2646
+ }
2647
+ const BUILT_IN_IDS = ["streets", "satellite", "dark"];
2648
+ function initialBasemapId(resolved, requested) {
2649
+ var _a;
2650
+ if (!BUILT_IN_IDS.includes(requested) || isBuiltInBasemapEnabled(resolved, requested)) return requested;
2651
+ return ((_a = resolved.builtInBasemaps[0]) == null ? void 0 : _a.id) ?? requested;
2652
+ }
2653
+ function createBaseStyle(resolved) {
2654
+ const sources = {};
2655
+ const layers = [
2656
+ { id: "background", type: "background", paint: { "background-color": "#f0f0f0" } }
2657
+ ];
2658
+ if (resolved.satellite) {
2659
+ sources["satellite-tiles"] = {
2660
+ type: "raster",
2661
+ tiles: resolved.satellite.tiles,
2662
+ tileSize: resolved.satellite.tileSize,
2663
+ minzoom: resolved.satellite.minzoom,
2664
+ maxzoom: resolved.satellite.maxzoom,
2665
+ attribution: resolved.satellite.attribution
2666
+ };
2667
+ layers.push({
2668
+ id: "satellite-layer",
2669
+ type: "raster",
2670
+ source: "satellite-tiles",
2671
+ minzoom: 0,
2672
+ maxzoom: 22,
2673
+ layout: { visibility: "none" }
2674
+ });
2675
+ }
2676
+ if (resolved.terrain) {
2677
+ sources["terrain-dem"] = {
2678
+ type: "raster-dem",
2679
+ tiles: resolved.terrain.tiles,
2680
+ tileSize: resolved.terrain.tileSize,
2681
+ minzoom: resolved.terrain.minzoom,
2682
+ maxzoom: resolved.terrain.maxzoom,
2683
+ encoding: resolved.terrain.encoding,
2684
+ attribution: resolved.terrain.attribution
2685
+ };
2686
+ }
2687
+ return { version: 8, sources, layers, glyphs: resolved.glyphsUrl };
2688
+ }
2689
+ async function geocodeAddress(geocoder, query, fetchImpl = fetch) {
2690
+ if ("provider" in geocoder) return geocoder.provider(query);
2691
+ const response = await fetchImpl(`${geocoder.url}?format=json&q=${encodeURIComponent(query)}&limit=1`);
2692
+ if (!response.ok) throw new Error("Search failed");
2693
+ const results = await response.json();
2694
+ if (!Array.isArray(results) || results.length === 0) return null;
2695
+ const { lon, lat, display_name } = results[0];
2696
+ return { lon: parseFloat(lon), lat: parseFloat(lat), displayName: display_name };
2697
+ }
2660
2698
  function ToolButton({ mode, activeMode, onModeChange, icon, label, shortcut, disabled, showShortcutHint = true }) {
2661
2699
  const isActive = activeMode === mode;
2662
2700
  const handleClick = () => {
@@ -2734,8 +2772,7 @@ function DrawingToolbar({
2734
2772
  onClearFilter,
2735
2773
  onFilterActiveChange,
2736
2774
  onSearchEngineRequest,
2737
- geocodingUrl = "https://nominatim.openstreetmap.org/search",
2738
- geocoderProvider,
2775
+ geocoder,
2739
2776
  showShortcutHints = true,
2740
2777
  expandSelectionTools = false,
2741
2778
  showFilterTool = false,
@@ -2749,6 +2786,7 @@ function DrawingToolbar({
2749
2786
  const [goToLng, setGoToLng] = react.useState("");
2750
2787
  const [goToAddress, setGoToAddress] = react.useState("");
2751
2788
  const [isSearching, setIsSearching] = react.useState(false);
2789
+ const resolvedGeocoder = react.useMemo(() => resolveGeocoder(geocoder), [geocoder]);
2752
2790
  const [filterActive, setFilterActive] = react.useState(false);
2753
2791
  const [isCompact, setIsCompact] = react.useState(false);
2754
2792
  const [featureSearchOpen, setFeatureSearchOpen] = react.useState(false);
@@ -2881,27 +2919,10 @@ function DrawingToolbar({
2881
2919
  setGoToLng("");
2882
2920
  };
2883
2921
  const handleAddressSearch = async () => {
2884
- if (!goToAddress.trim()) return;
2922
+ if (!resolvedGeocoder || !goToAddress.trim()) return;
2885
2923
  setIsSearching(true);
2886
2924
  try {
2887
- let result = null;
2888
- if (geocoderProvider) {
2889
- result = await geocoderProvider(goToAddress.trim());
2890
- } else {
2891
- const response = await fetch(
2892
- `${geocodingUrl}?format=json&q=${encodeURIComponent(goToAddress)}&limit=1`
2893
- );
2894
- if (!response.ok) throw new Error("Search failed");
2895
- const results = await response.json();
2896
- if (results.length > 0) {
2897
- const { lon, lat, display_name } = results[0];
2898
- result = {
2899
- lon: parseFloat(lon),
2900
- lat: parseFloat(lat),
2901
- displayName: display_name
2902
- };
2903
- }
2904
- }
2925
+ const result = await geocodeAddress(resolvedGeocoder, goToAddress.trim());
2905
2926
  if (!result) {
2906
2927
  toast({
2907
2928
  title: "Location not found",
@@ -3672,41 +3693,43 @@ function DrawingToolbar({
3672
3693
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Navigation, { className: "w-3 h-3 text-muted-foreground" }),
3673
3694
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] font-semibold uppercase tracking-wider text-muted-foreground", children: "Navigate To" })
3674
3695
  ] }),
3675
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
3676
- /* @__PURE__ */ jsxRuntime.jsx(
3677
- antd.Input,
3678
- {
3679
- placeholder: "Search address...",
3680
- value: goToAddress,
3681
- onChange: (e) => setGoToAddress(e.target.value),
3682
- onKeyDown: (e) => {
3683
- if (e.key === "Enter") handleAddressSearch();
3684
- },
3685
- disabled: isSearching,
3686
- size: "small",
3687
- prefix: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { className: "w-3.5 h-3.5 opacity-50" }),
3688
- allowClear: true,
3689
- "data-testid": "input-goto-address"
3690
- }
3691
- ),
3692
- /* @__PURE__ */ jsxRuntime.jsx(
3693
- antd.Button,
3694
- {
3695
- type: "primary",
3696
- size: "small",
3697
- onClick: handleAddressSearch,
3698
- disabled: isSearching || !goToAddress.trim(),
3699
- className: "shrink-0",
3700
- "data-testid": "button-search-address",
3701
- icon: isSearching ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "w-4 h-4 animate-spin" }) : void 0,
3702
- children: isSearching ? "" : "Go"
3703
- }
3704
- )
3705
- ] }),
3706
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
3707
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 h-px bg-border" }),
3708
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground shrink-0", children: "or coordinates" }),
3709
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 h-px bg-border" })
3696
+ resolvedGeocoder && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3697
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2", children: [
3698
+ /* @__PURE__ */ jsxRuntime.jsx(
3699
+ antd.Input,
3700
+ {
3701
+ placeholder: "Search address...",
3702
+ value: goToAddress,
3703
+ onChange: (e) => setGoToAddress(e.target.value),
3704
+ onKeyDown: (e) => {
3705
+ if (e.key === "Enter") handleAddressSearch();
3706
+ },
3707
+ disabled: isSearching,
3708
+ size: "small",
3709
+ prefix: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { className: "w-3.5 h-3.5 opacity-50" }),
3710
+ allowClear: true,
3711
+ "data-testid": "input-goto-address"
3712
+ }
3713
+ ),
3714
+ /* @__PURE__ */ jsxRuntime.jsx(
3715
+ antd.Button,
3716
+ {
3717
+ type: "primary",
3718
+ size: "small",
3719
+ onClick: handleAddressSearch,
3720
+ disabled: isSearching || !goToAddress.trim(),
3721
+ className: "shrink-0",
3722
+ "data-testid": "button-search-address",
3723
+ icon: isSearching ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "w-4 h-4 animate-spin" }) : void 0,
3724
+ children: isSearching ? "" : "Go"
3725
+ }
3726
+ )
3727
+ ] }),
3728
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
3729
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 h-px bg-border" }),
3730
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-muted-foreground shrink-0", children: "or coordinates" }),
3731
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 h-px bg-border" })
3732
+ ] })
3710
3733
  ] }),
3711
3734
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 items-end", children: [
3712
3735
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
@@ -3767,16 +3790,21 @@ function DrawingToolbar({
3767
3790
  );
3768
3791
  }
3769
3792
  const BUILT_IN_BASEMAP_IDS = ["streets", "satellite", "dark"];
3770
- const BUILT_IN_NAMES = {
3771
- streets: "Streets",
3772
- satellite: "Satellite",
3773
- dark: "Dark"
3774
- };
3775
- function resolveBasemapChoices(order, customBasemaps) {
3793
+ const isBuiltInId = (id) => BUILT_IN_BASEMAP_IDS.includes(id);
3794
+ function customBasemapsWithoutBuiltIns(customBasemaps) {
3795
+ if (!customBasemaps) return void 0;
3796
+ const ignored = Object.keys(customBasemaps).filter(isBuiltInId);
3797
+ if (ignored.length === 0) return customBasemaps;
3798
+ console.warn(
3799
+ `[map-component] customBasemaps entries for built-in ids are ignored (${ignored.join(", ")}); configure them through the endpoints prop.`
3800
+ );
3801
+ return Object.fromEntries(Object.entries(customBasemaps).filter(([id]) => !isBuiltInId(id)));
3802
+ }
3803
+ function resolveBasemapChoices(order, customBasemaps, builtIns) {
3776
3804
  const describe = (id) => {
3777
- if (BUILT_IN_BASEMAP_IDS.includes(id)) {
3778
- return { id, name: BUILT_IN_NAMES[id] ?? id, builtIn: true };
3779
- }
3805
+ const builtIn = builtIns.find((entry) => entry.id === id);
3806
+ if (builtIn) return { id, name: builtIn.name, builtIn: true };
3807
+ if (isBuiltInId(id)) return void 0;
3780
3808
  const custom = customBasemaps == null ? void 0 : customBasemaps[id];
3781
3809
  if (!custom) return void 0;
3782
3810
  return { id, name: custom.name || id, builtIn: false };
@@ -3784,13 +3812,8 @@ function resolveBasemapChoices(order, customBasemaps) {
3784
3812
  if (order) {
3785
3813
  return order.map(describe).filter((choice) => !!choice);
3786
3814
  }
3787
- const customIds = Object.keys(customBasemaps ?? {}).filter(
3788
- (id) => !BUILT_IN_BASEMAP_IDS.includes(id)
3789
- );
3790
- return [
3791
- ...BUILT_IN_BASEMAP_IDS.map((id) => describe(id)),
3792
- ...customIds.map(describe).filter((choice) => !!choice)
3793
- ];
3815
+ const customIds = Object.keys(customBasemaps ?? {}).filter((id) => !isBuiltInId(id));
3816
+ return [...builtIns.map((entry) => entry.id), ...customIds].map(describe).filter((choice) => !!choice);
3794
3817
  }
3795
3818
  const PRESET_COLORS$1 = [
3796
3819
  "#3b82f6",
@@ -5392,10 +5415,10 @@ const RECORD_EXCLUDE_KEYS = /* @__PURE__ */ new Set([
5392
5415
  // NOTE: 'description' intentionally NOT excluded — we surface it as a regular
5393
5416
  // property row instead of giving it its own labelled section.
5394
5417
  ]);
5395
- function buildKeyExclusionPredicate(set) {
5396
- 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()));
5397
5420
  return (key) => {
5398
- if (set.has(key)) return true;
5421
+ if (set2.has(key)) return true;
5399
5422
  const normalized = key.toLowerCase().replace(/^[^a-z0-9_-]+/, "");
5400
5423
  return lowered.has(normalized);
5401
5424
  };
@@ -6949,7 +6972,7 @@ function computeHistogramBins(features, minDate, maxDate, binCount = 50) {
6949
6972
  });
6950
6973
  return bins;
6951
6974
  }
6952
- const timelineStoreInitializer = (set, get) => ({
6975
+ const timelineStoreInitializer = (set2, get) => ({
6953
6976
  isEnabled: false,
6954
6977
  hasTemporalData: false,
6955
6978
  temporalFeatures: [],
@@ -6964,13 +6987,13 @@ const timelineStoreInitializer = (set, get) => ({
6964
6987
  setEnabled: (enabled) => {
6965
6988
  if (enabled) {
6966
6989
  const state = get();
6967
- set({
6990
+ set2({
6968
6991
  isEnabled: true,
6969
6992
  rangeStart: state.globalMinDate,
6970
6993
  rangeEnd: state.globalMaxDate
6971
6994
  });
6972
6995
  } else {
6973
- set({ isEnabled: false, isPlaying: false });
6996
+ set2({ isEnabled: false, isPlaying: false });
6974
6997
  }
6975
6998
  },
6976
6999
  setTemporalFeatures: (features, untimedIds) => {
@@ -6979,7 +7002,7 @@ const timelineStoreInitializer = (set, get) => ({
6979
7002
  const state = get();
6980
7003
  if (timedFeatures.length === 0) {
6981
7004
  if (!state.hasTemporalData && state.temporalFeatures.length === 0) return;
6982
- set({
7005
+ set2({
6983
7006
  hasTemporalData: false,
6984
7007
  temporalFeatures: [],
6985
7008
  untimedFeatureIds: untimedIds,
@@ -7006,7 +7029,7 @@ const timelineStoreInitializer = (set, get) => ({
7006
7029
  const sameUntimed = state.untimedFeatureIds.length === untimedIds.length && untimedIds.every((id, i) => id === state.untimedFeatureIds[i]);
7007
7030
  if (sameFeatureIds && sameDates && sameUntimed && state.hasTemporalData) return;
7008
7031
  const histogramBins = minDate && maxDate ? computeHistogramBins(timedFeatures, minDate, maxDate) : [];
7009
- set({
7032
+ set2({
7010
7033
  hasTemporalData: true,
7011
7034
  temporalFeatures: timedFeatures,
7012
7035
  untimedFeatureIds: untimedIds,
@@ -7017,9 +7040,9 @@ const timelineStoreInitializer = (set, get) => ({
7017
7040
  histogramBins
7018
7041
  });
7019
7042
  },
7020
- setRange: (start, end) => set({ rangeStart: start, rangeEnd: end }),
7021
- setPlaying: (playing) => set({ isPlaying: playing }),
7022
- setPlaybackSpeed: (speed) => set({ playbackSpeed: speed }),
7043
+ setRange: (start, end) => set2({ rangeStart: start, rangeEnd: end }),
7044
+ setPlaying: (playing) => set2({ isPlaying: playing }),
7045
+ setPlaybackSpeed: (speed) => set2({ playbackSpeed: speed }),
7023
7046
  advancePlayhead: () => {
7024
7047
  const state = get();
7025
7048
  if (!state.globalMinDate || !state.globalMaxDate || !state.rangeStart) {
@@ -7030,20 +7053,20 @@ const timelineStoreInitializer = (set, get) => ({
7030
7053
  const newStart = new Date(state.rangeStart.getTime() + stepSize);
7031
7054
  const newEnd = state.rangeEnd ? new Date(state.rangeEnd.getTime() + stepSize) : null;
7032
7055
  if (newStart >= state.globalMaxDate) {
7033
- set({
7056
+ set2({
7034
7057
  isPlaying: false,
7035
7058
  rangeStart: state.globalMinDate,
7036
7059
  rangeEnd: state.globalMaxDate
7037
7060
  });
7038
7061
  return false;
7039
7062
  }
7040
- set({
7063
+ set2({
7041
7064
  rangeStart: newStart,
7042
7065
  rangeEnd: newEnd && newEnd <= state.globalMaxDate ? newEnd : state.globalMaxDate
7043
7066
  });
7044
7067
  return true;
7045
7068
  },
7046
- reset: () => set({
7069
+ reset: () => set2({
7047
7070
  isEnabled: false,
7048
7071
  hasTemporalData: false,
7049
7072
  temporalFeatures: [],
@@ -7821,6 +7844,129 @@ function createRafCoalescer(run, scheduler = rafScheduler) {
7821
7844
  }
7822
7845
  };
7823
7846
  }
7847
+ const EMPTY = /* @__PURE__ */ new Set();
7848
+ function isLive(host, entry) {
7849
+ return host.source(entry.sourceId) === entry.handle;
7850
+ }
7851
+ function remove(host, entry, id) {
7852
+ if (!isLive(host, entry)) return false;
7853
+ host.removeFeatureState(entry.sourceId, id);
7854
+ return true;
7855
+ }
7856
+ function set(host, sourceId, id) {
7857
+ const handle = host.source(sourceId);
7858
+ if (!handle) return null;
7859
+ host.setFeatureState(sourceId, id, SELECTED_STATE);
7860
+ return { sourceId, handle };
7861
+ }
7862
+ function setAll(host, sourceIds, id) {
7863
+ const done = [];
7864
+ sourceIds.forEach((sourceId) => {
7865
+ const entry = set(host, sourceId, id);
7866
+ if (entry) done.push(entry);
7867
+ });
7868
+ return done;
7869
+ }
7870
+ function place(applied, id, sources, host) {
7871
+ const done = setAll(host, sources, id);
7872
+ if (done.length > 0) applied.set(id, done);
7873
+ return done.length;
7874
+ }
7875
+ function applySelectionState(applied, next, gate, locate, host) {
7876
+ const target = gate ? next : EMPTY;
7877
+ let setCount = 0;
7878
+ let removed = 0;
7879
+ const gone = [];
7880
+ applied.forEach((_sources, id) => {
7881
+ if (!target.has(id)) gone.push(id);
7882
+ });
7883
+ gone.forEach((id) => {
7884
+ (applied.get(id) ?? []).forEach((entry) => {
7885
+ if (remove(host, entry, id)) removed++;
7886
+ });
7887
+ applied.delete(id);
7888
+ });
7889
+ target.forEach((id) => {
7890
+ if (applied.has(id)) return;
7891
+ setCount += place(applied, id, locate(id), host);
7892
+ });
7893
+ return { set: setCount, removed };
7894
+ }
7895
+ function reconcileSelectionSources(applied, locate, host) {
7896
+ let moved = 0;
7897
+ let pruned = 0;
7898
+ const changes = [];
7899
+ applied.forEach((have, id) => {
7900
+ const want = locate(id);
7901
+ const live = have.filter((entry) => isLive(host, entry));
7902
+ const same = want.length > 0 && live.length === have.length && want.every((sourceId) => live.some((entry) => entry.sourceId === sourceId));
7903
+ if (!same) changes.push({ id, have, live, want });
7904
+ });
7905
+ changes.forEach(({ id, have, live, want }) => {
7906
+ if (want.length === 0) {
7907
+ have.forEach((entry) => remove(host, entry, id));
7908
+ applied.delete(id);
7909
+ pruned++;
7910
+ return;
7911
+ }
7912
+ const missing = want.filter((sourceId) => !live.some((entry) => entry.sourceId === sourceId));
7913
+ const gained = setAll(host, missing, id);
7914
+ const now = [...live, ...gained];
7915
+ if (now.length > 0) applied.set(id, now);
7916
+ else applied.delete(id);
7917
+ if (gained.length > 0) moved++;
7918
+ });
7919
+ return { moved, pruned };
7920
+ }
7921
+ function createLocatorCache() {
7922
+ return /* @__PURE__ */ new WeakMap();
7923
+ }
7924
+ function indexOfIds(features, cache2) {
7925
+ const cached = cache2.get(features);
7926
+ if (cached) return cached;
7927
+ const index = { first: /* @__PURE__ */ new Map(), repeats: /* @__PURE__ */ new Map() };
7928
+ for (let i = 0; i < features.length; i++) {
7929
+ const id = features[i].id;
7930
+ if (id === void 0 || id === null) continue;
7931
+ const key = String(id);
7932
+ if (!index.first.has(key)) index.first.set(key, i);
7933
+ else {
7934
+ const more = index.repeats.get(key);
7935
+ if (more) more.push(i);
7936
+ else index.repeats.set(key, [i]);
7937
+ }
7938
+ }
7939
+ cache2.set(features, index);
7940
+ return index;
7941
+ }
7942
+ function forEachIndex(index, id, visit) {
7943
+ var _a;
7944
+ const at = index.first.get(id);
7945
+ if (at === void 0) return;
7946
+ visit(at);
7947
+ (_a = index.repeats.get(id)) == null ? void 0 : _a.forEach(visit);
7948
+ }
7949
+ function locateFeatureHolders(id, readOnly, cache2) {
7950
+ const holders = [];
7951
+ readOnly.forEach((features, layerId) => {
7952
+ forEachIndex(indexOfIds(features, cache2), id, (at) => holders.push({ layerId, feature: features[at] }));
7953
+ });
7954
+ return holders;
7955
+ }
7956
+ function locateFeatureSources(id, inputs, cache2) {
7957
+ const sources = [];
7958
+ const add = (sourceId) => {
7959
+ if (!sources.includes(sourceId)) sources.push(sourceId);
7960
+ };
7961
+ inputs.readOnly.forEach((features, layerId) => {
7962
+ const sharded = inputs.shardedLayerIds.has(layerId);
7963
+ forEachIndex(indexOfIds(features, cache2), id, (at) => {
7964
+ add(sharded ? shardSourceId(layerId, Math.floor(at / inputs.shardSize)) : SHARED_SOURCE_ID);
7965
+ });
7966
+ });
7967
+ if (sources.length === 0) add(SHARED_SOURCE_ID);
7968
+ return sources;
7969
+ }
7824
7970
  function deepClone(value) {
7825
7971
  try {
7826
7972
  return structuredClone(value);
@@ -8083,6 +8229,93 @@ function hitTestSelection(featureGroups, selectionPolygon, options) {
8083
8229
  mapPerfLog("hit-test", "selection gesture", { visited, total, selected: selectedIds.length });
8084
8230
  return selectedIds;
8085
8231
  }
8232
+ const SELECTION_OVERLAY_SOURCE_ID = "selection-overlay";
8233
+ const SELECTION_OVERLAY_LAYER_IDS = {
8234
+ iconRing: "selection-overlay-icon-ring",
8235
+ line: "selection-overlay-line",
8236
+ polygon: "selection-overlay-polygon",
8237
+ label: "selection-overlay-label"
8238
+ };
8239
+ function buildSelectionOverlayStack() {
8240
+ const source = SELECTION_OVERLAY_SOURCE_ID;
8241
+ return [
8242
+ {
8243
+ id: SELECTION_OVERLAY_LAYER_IDS.iconRing,
8244
+ type: "circle",
8245
+ source,
8246
+ filter: ["all", ["==", "$type", "Point"], ["!=", "icon", ""], ["!=", "isHiddenByHeatmap", 1]],
8247
+ paint: {
8248
+ "circle-color": "transparent",
8249
+ "circle-radius": ["/", ["coalesce", ["get", "iconSize"], 24], 1.6],
8250
+ "circle-stroke-color": SELECTION_COLOR,
8251
+ "circle-stroke-width": 3,
8252
+ "circle-stroke-opacity": 1
8253
+ }
8254
+ },
8255
+ {
8256
+ id: SELECTION_OVERLAY_LAYER_IDS.line,
8257
+ type: "line",
8258
+ source,
8259
+ filter: ["==", "$type", "LineString"],
8260
+ paint: {
8261
+ "line-color": SELECTION_COLOR,
8262
+ "line-width": ["+", ["get", "stroke-width"], 4],
8263
+ "line-dasharray": [4, 2]
8264
+ }
8265
+ },
8266
+ {
8267
+ id: SELECTION_OVERLAY_LAYER_IDS.polygon,
8268
+ type: "line",
8269
+ source,
8270
+ filter: ["==", "$type", "Polygon"],
8271
+ paint: {
8272
+ "line-color": SELECTION_COLOR,
8273
+ "line-width": 4,
8274
+ "line-dasharray": [4, 2]
8275
+ }
8276
+ },
8277
+ {
8278
+ id: SELECTION_OVERLAY_LAYER_IDS.label,
8279
+ type: "symbol",
8280
+ source,
8281
+ layout: {
8282
+ ...buildCustomLabelLayout(),
8283
+ // Never hidden by the auto-label density cap, which only flips the
8284
+ // unpinned base layer: with base labels off, the selected ones stay.
8285
+ visibility: "visible",
8286
+ // Full collision; topmost, so placed first (see the module comment):
8287
+ // selected labels thin among themselves and win against every other.
8288
+ "text-allow-overlap": false,
8289
+ "text-ignore-placement": false,
8290
+ "text-optional": true,
8291
+ // Same ranking as the base layers, so which selected label wins a
8292
+ // crowded spot is stable across repaints.
8293
+ "symbol-sort-key": ["coalesce", ["get", "_labelPriority"], 100]
8294
+ },
8295
+ paint: buildCustomLabelPaint()
8296
+ }
8297
+ ];
8298
+ }
8299
+ function overlayTimelineInputs(ids, visible) {
8300
+ const hidden = /* @__PURE__ */ new Set();
8301
+ if (visible !== null) ids.forEach((id) => {
8302
+ if (!visible.has(id)) hidden.add(id);
8303
+ });
8304
+ return { ids, hidden };
8305
+ }
8306
+ function sameIds(a, b) {
8307
+ return a.size === b.size && Array.from(a).every((id) => b.has(id));
8308
+ }
8309
+ function sameOverlayTimelineInputs(a, b) {
8310
+ return sameIds(a.ids, b.ids) && sameIds(a.hidden, b.hidden);
8311
+ }
8312
+ function buildSelectionOverlayData(ids, styleFor) {
8313
+ const features = [];
8314
+ ids.forEach((id) => {
8315
+ styleFor(id).forEach((feature) => features.push(feature));
8316
+ });
8317
+ return { type: "FeatureCollection", features };
8318
+ }
8086
8319
  function renderedFeatureId(f) {
8087
8320
  var _a;
8088
8321
  const fromProps = (_a = f.properties) == null ? void 0 : _a.id;
@@ -8612,6 +8845,8 @@ function ClusterPieManager(props) {
8612
8845
  return null;
8613
8846
  }
8614
8847
  const EMPTY_ID_SET = /* @__PURE__ */ new Set();
8848
+ const EMPTY_SOURCES = [];
8849
+ 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"];
8615
8850
  const EMPTY_LABEL_MAP = /* @__PURE__ */ new Map();
8616
8851
  function renderEmojiToCanvas(emoji, size = EMOJI_CANVAS_SIZE) {
8617
8852
  const ratio = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
@@ -8812,53 +9047,16 @@ function extract3DFlightPaths(features) {
8812
9047
  return paths;
8813
9048
  }
8814
9049
  const CAP_NOTICE_INTERVAL_MS = 5e3;
8815
- const DEFAULT_LOCAL_GLYPHS_URL = "/fonts/{fontstack}/{range}.pbf";
8816
9050
  function basemapInsertAnchor(map) {
8817
9051
  if (map.getLayer("satellite-layer")) return "satellite-layer";
8818
9052
  if (map.getLayer("custom-polygon-fill")) return "custom-polygon-fill";
8819
9053
  return void 0;
8820
9054
  }
8821
- function createBaseStyle(options) {
8822
- const sources = {};
8823
- const layers = [
8824
- {
8825
- id: "background",
8826
- type: "background",
8827
- paint: {
8828
- "background-color": "#f0f0f0"
8829
- }
8830
- }
8831
- ];
8832
- if (options.enableSatellite !== false) {
8833
- sources["satellite-tiles"] = {
8834
- type: "raster",
8835
- tiles: ["https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"],
8836
- tileSize: 256,
8837
- attribution: "Esri, Maxar, Earthstar Geographics"
8838
- };
8839
- layers.push({
8840
- id: "satellite-layer",
8841
- type: "raster",
8842
- source: "satellite-tiles",
8843
- minzoom: 0,
8844
- maxzoom: 22,
8845
- layout: { visibility: "none" }
8846
- });
8847
- }
8848
- if (options.enableTerrain !== false) {
8849
- sources["terrain-dem"] = {
8850
- type: "raster-dem",
8851
- tiles: ["https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"],
8852
- tileSize: 256,
8853
- maxzoom: 15,
8854
- encoding: "terrarium"
8855
- };
8856
- }
9055
+ function featureStateHostFor(m) {
8857
9056
  return {
8858
- version: 8,
8859
- sources,
8860
- layers,
8861
- glyphs: options.glyphsUrl || DEFAULT_LOCAL_GLYPHS_URL
9057
+ setFeatureState: (source, id, state) => m.setFeatureState({ source, id }, state),
9058
+ removeFeatureState: (source, id) => m.removeFeatureState({ source, id }),
9059
+ source: (source) => m.getSource(source)
8862
9060
  };
8863
9061
  }
8864
9062
  const BASEMAP_LAYER_PREFIXES = {
@@ -8866,10 +9064,6 @@ const BASEMAP_LAYER_PREFIXES = {
8866
9064
  satellite: "satellite-",
8867
9065
  dark: "dark-"
8868
9066
  };
8869
- const EXTERNAL_STYLE_URLS = {
8870
- streets: "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",
8871
- dark: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"
8872
- };
8873
9067
  const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8874
9068
  className,
8875
9069
  enableDrawing = true,
@@ -8889,8 +9083,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8889
9083
  showDebugSidebar = false,
8890
9084
  initialCenter = [-74.006, 40.7128],
8891
9085
  initialZoom = 12,
8892
- baseMapStyle = "streets",
8893
- customBasemaps,
9086
+ baseMapStyle: requestedBaseMapStyle = "streets",
9087
+ endpoints,
9088
+ customBasemaps: customBasemapsProp,
8894
9089
  basemapOrder,
8895
9090
  initialDrawingMode,
8896
9091
  onFeatureSelect,
@@ -8907,8 +9102,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8907
9102
  onClearFilter,
8908
9103
  showGoToButton = false,
8909
9104
  onDropPoint,
8910
- geocodingUrl,
8911
- geocoderProvider,
8912
9105
  onSearchEngineRequest,
8913
9106
  onWorkspaceLoad,
8914
9107
  onWorkspaceSave,
@@ -8923,12 +9116,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8923
9116
  featureSaveProvider,
8924
9117
  featureRefreshProvider,
8925
9118
  tooltipProvider,
8926
- glyphsUrl,
8927
9119
  filterGeometry,
8928
- enableSatellite = true,
8929
- enableTerrain = true,
8930
- enableDark = true,
8931
- enable3D = true,
8932
9120
  hideBasemapSwitcher = false,
8933
9121
  externalPersistence = false,
8934
9122
  enableKeyboardShortcuts = true,
@@ -8949,6 +9137,18 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8949
9137
  onEntityContextMenu
8950
9138
  }, ref) {
8951
9139
  const mapContainer = react.useRef(null);
9140
+ const [resolvedEndpoints] = react.useState(() => resolveEndpoints(endpoints));
9141
+ const [baseMapStyle] = react.useState(() => {
9142
+ if (!resolvedEndpoints.vectorStyles.streets) {
9143
+ console.warn("[map-component] streets is turned off in endpoints.");
9144
+ }
9145
+ const id = initialBasemapId(resolvedEndpoints, requestedBaseMapStyle);
9146
+ if (id !== requestedBaseMapStyle) {
9147
+ console.warn(`[map-component] basemap "${requestedBaseMapStyle}" is turned off in endpoints; opening on "${id}".`);
9148
+ }
9149
+ return id;
9150
+ });
9151
+ const customBasemaps = react.useMemo(() => customBasemapsWithoutBuiltIns(customBasemapsProp), [customBasemapsProp]);
8952
9152
  const map = react.useRef(null);
8953
9153
  const draw = react.useRef(null);
8954
9154
  const fileInputRef = react.useRef(null);
@@ -8965,19 +9165,19 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
8965
9165
  const readOnlyFeatures = react.useRef(/* @__PURE__ */ new Map());
8966
9166
  const layerTemporalCacheRef = react.useRef(/* @__PURE__ */ new Map());
8967
9167
  const timelineUpdateTimerRef = react.useRef(null);
8968
- const loadedBasemaps = react.useRef(new Set(enableSatellite ? ["satellite"] : []));
8969
- const basemapLayerIds = react.useRef(new Map(enableSatellite ? [["satellite", ["satellite-layer"]]] : []));
9168
+ const loadedBasemaps = react.useRef(new Set(resolvedEndpoints.satellite ? ["satellite"] : []));
9169
+ const basemapLayerIds = react.useRef(new Map(resolvedEndpoints.satellite ? [["satellite", ["satellite-layer"]]] : []));
8970
9170
  const availableBasemaps = react.useMemo(() => {
8971
9171
  const iconFor = (id) => {
8972
9172
  var _a;
8973
9173
  return ((_a = MAP_STYLES.find((style) => style.id === id)) == null ? void 0 : _a.icon) ?? lucideReact.Map;
8974
9174
  };
8975
- return resolveBasemapChoices(basemapOrder, customBasemaps).map((choice) => ({
9175
+ return resolveBasemapChoices(basemapOrder, customBasemaps, resolvedEndpoints.builtInBasemaps).map((choice) => ({
8976
9176
  id: choice.id,
8977
9177
  name: choice.name,
8978
9178
  icon: iconFor(choice.id)
8979
9179
  }));
8980
- }, [basemapOrder, customBasemaps]);
9180
+ }, [basemapOrder, customBasemaps, resolvedEndpoints]);
8981
9181
  const loadingBasemaps = react.useRef(/* @__PURE__ */ new Set());
8982
9182
  const customBasemapRegistry = react.useRef(/* @__PURE__ */ new Map());
8983
9183
  const clusterPieManagers = react.useRef(/* @__PURE__ */ new Map());
@@ -9208,6 +9408,19 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9208
9408
  }
9209
9409
  return getReadOnlyFeatureById(id);
9210
9410
  }, [getReadOnlyFeatureById]);
9411
+ const appliedSelectionRef = react.useRef(/* @__PURE__ */ new Map());
9412
+ const locatorCacheRef = react.useRef(createLocatorCache());
9413
+ const shardedLayerIdsRef = react.useRef(EMPTY_ID_SET);
9414
+ const overlayPaintContextRef = react.useRef(null);
9415
+ const shardFieldRangesRef = react.useRef(/* @__PURE__ */ new Map());
9416
+ const locateSelectionSources = react.useCallback((id) => {
9417
+ if (getFeatureById(id) === null) return EMPTY_SOURCES;
9418
+ return locateFeatureSources(
9419
+ id,
9420
+ { readOnly: readOnlyFeatures.current, shardedLayerIds: shardedLayerIdsRef.current, shardSize: shardSizeRef.current },
9421
+ locatorCacheRef.current
9422
+ );
9423
+ }, [getFeatureById]);
9211
9424
  const canDeleteSelected = react.useMemo(() => {
9212
9425
  if (selectedFeatureIds.length === 0) return false;
9213
9426
  return selectedFeatureIds.some((id) => {
@@ -9229,7 +9442,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9229
9442
  return true;
9230
9443
  });
9231
9444
  }, [selectedFeatureIds, hiddenDrawingTools, getFeatureById]);
9232
- const applySelectionState = react.useCallback((nextIds, options) => {
9445
+ const applySelectionState$1 = react.useCallback((nextIds, options) => {
9233
9446
  if (!isMapLoaded || !draw.current) {
9234
9447
  setSelectedFeatureIds(nextIds);
9235
9448
  if (options == null ? void 0 : options.focusProperties) setShowProperties(nextIds.length > 0);
@@ -9300,6 +9513,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9300
9513
  });
9301
9514
  const trySelectionFastPathRef = react.useRef(null);
9302
9515
  const tryTimelineFastPathRef = react.useRef(null);
9516
+ const reconcileSelectionRef = react.useRef(null);
9303
9517
  const syncCoalescerRef = react.useRef(null);
9304
9518
  if (syncCoalescerRef.current === null) {
9305
9519
  syncCoalescerRef.current = createRafCoalescer((reasons) => {
@@ -9500,7 +9714,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9500
9714
  }
9501
9715
  }, []);
9502
9716
  const syncFeaturesToCustomLayers = react.useCallback(() => {
9503
- var _a, _b;
9717
+ var _a, _b, _c;
9504
9718
  if (!map.current) return;
9505
9719
  if (isSyncingRef.current) return;
9506
9720
  isSyncingRef.current = true;
@@ -9509,11 +9723,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9509
9723
  const source = map.current.getSource("custom-features");
9510
9724
  if (!source) return;
9511
9725
  const drawFeatures = draw.current ? draw.current.getAll() : { type: "FeatureCollection", features: [] };
9512
- const drawSelectedIds = draw.current ? draw.current.getSelectedIds() : [];
9513
- const componentSelectedIds = selectedFeatureIdsRef.current;
9514
- const selectedIdSet = /* @__PURE__ */ new Set();
9515
- drawSelectedIds.forEach((id) => selectedIdSet.add(String(id)));
9516
- componentSelectedIds.forEach((id) => selectedIdSet.add(String(id)));
9517
9726
  const visibleSet = timelineVisibleIdsRef.current;
9518
9727
  const currentLayers = layersRef.current;
9519
9728
  const isLayerVisible = (layer) => {
@@ -9525,6 +9734,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9525
9734
  const count = ((_a2 = readOnlyFeatures.current.get(layer.id)) == null ? void 0 : _a2.length) ?? 0;
9526
9735
  if (isShardEligible(layer, count, shardSizeRef.current)) shardedLayerIds.add(layer.id);
9527
9736
  });
9737
+ shardedLayerIdsRef.current = shardedLayerIds;
9528
9738
  const allFeatures = [...drawFeatures.features];
9529
9739
  readOnlyFeatures.current.forEach((features, layerId) => {
9530
9740
  if (shardedLayerIds.has(layerId)) return;
@@ -9609,8 +9819,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9609
9819
  const paintCache = createSelectionPaintCache();
9610
9820
  const paintContext = {
9611
9821
  timelineVisibleIds: visibleSet,
9612
- selectedIds: selectedIdSet,
9613
- selectionEnabled: enableSelectionRef.current || enableDrawingRef.current,
9614
9822
  sizeFieldRanges,
9615
9823
  colorFieldRanges,
9616
9824
  tracePointIds,
@@ -9624,21 +9832,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9624
9832
  features: allFeatures.map((f, i) => {
9625
9833
  const styled = styleFeatureForPaint(f, featureToLayer.get(String(f.id)), paintContext, i >= drawFeatureCount);
9626
9834
  const p = styled.paint;
9627
- recordPaintedFeature(
9628
- paintCache,
9629
- p.featureId,
9630
- p.basePriority,
9631
- p.selected,
9632
- p.visibleStrokeOpacity,
9633
- p.visibleFillOpacity,
9634
- p.timelineHidden
9635
- );
9835
+ recordPaintedFeature(paintCache, p.featureId, p.visibleStrokeOpacity, p.visibleFillOpacity, p.timelineHidden);
9636
9836
  if (styled.tracePaint) tracePointPaint.set(p.featureId, styled.tracePaint);
9637
9837
  return styled.feature;
9638
9838
  })
9639
9839
  };
9640
9840
  source.setData(sourceData);
9641
9841
  selectionPaintCacheRef.current = paintCache;
9842
+ overlayPaintContextRef.current = paintContext;
9843
+ (_a = reconcileSelectionRef.current) == null ? void 0 : _a.call(reconcileSelectionRef);
9642
9844
  const traceSource = map.current.getSource("trace-features");
9643
9845
  if (traceSource) traceSource.setData({ type: "FeatureCollection", features: traceSegments });
9644
9846
  tracePaintCacheRef.current = traceSource && paintedTraceGroups.length > 0 ? { groups: paintedTraceGroups, pointPaint: tracePointPaint } : null;
@@ -9652,7 +9854,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9652
9854
  sawArrowFeature = true;
9653
9855
  if (f.geometry.type === "LineString") arrowLines.push(f);
9654
9856
  });
9655
- const shardArrows = ((_a = shardRegistryRef.current) == null ? void 0 : _a.arrowLines((id) => {
9857
+ const shardArrows = ((_b = shardRegistryRef.current) == null ? void 0 : _b.arrowLines((id) => {
9656
9858
  var _a2;
9657
9859
  return ((_a2 = currentLayers.find((l) => l.id === id)) == null ? void 0 : _a2.visible) === true;
9658
9860
  })) ?? [];
@@ -9672,7 +9874,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9672
9874
  setVisibleFeatureCount(countVisibleFeatures(threshold));
9673
9875
  setLabelsSuppressed(false);
9674
9876
  }
9675
- (_b = applyShardedLayersRef.current) == null ? void 0 : _b.call(applyShardedLayersRef);
9877
+ (_c = applyShardedLayersRef.current) == null ? void 0 : _c.call(applyShardedLayersRef);
9676
9878
  const requestedBy = fullSyncCallersRef.current.splice(0);
9677
9879
  let shardedFeatures = 0;
9678
9880
  shardedLayerIds.forEach((id) => {
@@ -9769,21 +9971,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9769
9971
  if (!m || !registry) return;
9770
9972
  const currentLayers = layersRef.current;
9771
9973
  const shardSize2 = shardSizeRef.current;
9772
- const selectionEnabled = enableSelectionRef.current || enableDrawingRef.current;
9773
- const currentSelectedIds = () => {
9774
- var _a;
9775
- const ids = /* @__PURE__ */ new Set();
9776
- if (selectionEnabled) {
9777
- (((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => ids.add(String(id)));
9778
- selectedFeatureIdsRef.current.forEach((id) => ids.add(String(id)));
9779
- }
9780
- return ids;
9781
- };
9782
9974
  currentLayers.forEach((layer) => {
9783
9975
  var _a;
9784
9976
  const features = readOnlyFeatures.current.get(layer.id) ?? [];
9785
9977
  if (!isShardEligible(layer, features.length, shardSize2)) {
9786
9978
  registry.remove(layer.id);
9979
+ shardFieldRangesRef.current.delete(layer.id);
9787
9980
  setLayerImporting(layer.id, false);
9788
9981
  return;
9789
9982
  }
@@ -9793,10 +9986,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9793
9986
  setLayerImporting(layer.id, false);
9794
9987
  return;
9795
9988
  }
9796
- const fingerprint = buildShardFingerprint(layer, features, selectionEnabled, shardSize2);
9989
+ const fingerprint = buildShardFingerprint(layer, features, shardSize2);
9797
9990
  const expectedShards = shardRanges(features.length, shardSize2).length;
9798
9991
  if (shardFingerprintsEqual(state.fingerprint, fingerprint) && state.stacks.length === expectedShards) {
9799
- if (reconcileShardCaches(registry, state.layerId, expectedShards, currentSelectedIds(), timelineVisibleIdsRef.current)) {
9992
+ if (reconcileShardCaches(registry, state.layerId, expectedShards, timelineVisibleIdsRef.current)) {
9800
9993
  setLayerImporting(layer.id, false);
9801
9994
  mapPerfLog("shards", "pass skipped (fingerprint)", { layerId: layer.id, shards: expectedShards });
9802
9995
  return;
@@ -9816,10 +10009,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9816
10009
  const ranges = layerFieldRanges(layer.visualConfig, (visit) => {
9817
10010
  for (let i = 0; i < features.length; i++) visit(features[i].properties);
9818
10011
  });
10012
+ shardFieldRangesRef.current.set(layer.id, ranges);
9819
10013
  const sizeFieldRanges = /* @__PURE__ */ new Map();
9820
10014
  const colorFieldRanges = /* @__PURE__ */ new Map();
9821
10015
  if (ranges.size) sizeFieldRanges.set(layer.id, ranges.size);
9822
10016
  if (ranges.color) colorFieldRanges.set(layer.id, ranges.color);
10017
+ let overlayRestyled = false;
9823
10018
  void runShardPass({
9824
10019
  layer,
9825
10020
  features,
@@ -9830,8 +10025,6 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9830
10025
  contextForShard: () => {
9831
10026
  return {
9832
10027
  timelineVisibleIds: timelineVisibleIdsRef.current,
9833
- selectedIds: currentSelectedIds(),
9834
- selectionEnabled,
9835
10028
  sizeFieldRanges,
9836
10029
  colorFieldRanges,
9837
10030
  // Trace-enabled layers are never sharded, so these are empty by construction.
@@ -9842,7 +10035,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
9842
10035
  };
9843
10036
  },
9844
10037
  onShardPainted: (index, cache2) => {
10038
+ var _a2;
9845
10039
  state.caches[index] = cache2;
10040
+ (_a2 = reconcileSelectionRef.current) == null ? void 0 : _a2.call(reconcileSelectionRef, { overlay: !overlayRestyled });
10041
+ overlayRestyled = true;
9846
10042
  },
9847
10043
  onProgress: (painted) => progress == null ? void 0 : progress.update(painted)
9848
10044
  }).then((result) => {
@@ -10033,7 +10229,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10033
10229
  });
10034
10230
  const registry = shardRegistryRef.current;
10035
10231
  registry == null ? void 0 : registry.trackedLayerIds().forEach((layerId) => {
10036
- if (!liveLayerIds.has(layerId)) registry.remove(layerId);
10232
+ if (!liveLayerIds.has(layerId)) {
10233
+ registry.remove(layerId);
10234
+ shardFieldRangesRef.current.delete(layerId);
10235
+ }
10037
10236
  });
10038
10237
  Object.keys((style == null ? void 0 : style.sources) ?? {}).forEach((sid) => {
10039
10238
  const parsed = parseShardSourceId(sid);
@@ -10156,15 +10355,15 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10156
10355
  coalesceKey,
10157
10356
  undo: () => {
10158
10357
  applyHistoryState(featureIds, layerIds, beforeF, beforeL);
10159
- applySelectionState(beforeSelectedIds, { focusProperties: false });
10358
+ applySelectionState$1(beforeSelectedIds, { focusProperties: false });
10160
10359
  },
10161
10360
  redo: () => {
10162
10361
  applyHistoryState(featureIds, layerIds, afterF, afterL);
10163
- applySelectionState(afterSelectedIds, { focusProperties: false });
10362
+ applySelectionState$1(afterSelectedIds, { focusProperties: false });
10164
10363
  }
10165
10364
  };
10166
10365
  },
10167
- [applyHistoryState, applySelectionState]
10366
+ [applyHistoryState, applySelectionState$1]
10168
10367
  );
10169
10368
  const finalizeCapture = react.useCallback(() => {
10170
10369
  const pending = pendingCaptureRef.current;
@@ -10220,11 +10419,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10220
10419
  if (!mapContainer.current || map.current) return;
10221
10420
  let removeDrawGateListeners;
10222
10421
  try {
10223
- const baseStyle = createBaseStyle({
10224
- glyphsUrl,
10225
- enableSatellite,
10226
- enableTerrain
10227
- });
10422
+ const baseStyle = createBaseStyle(resolvedEndpoints);
10228
10423
  const mapInstance = new maplibregl.Map({
10229
10424
  container: mapContainer.current,
10230
10425
  style: baseStyle,
@@ -10292,11 +10487,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10292
10487
  var _a, _b;
10293
10488
  map.current = mapInstance;
10294
10489
  draw.current = drawInstance;
10295
- mapInstance.addSource("custom-features", {
10296
- type: "geojson",
10297
- data: { type: "FeatureCollection", features: [] },
10298
- maxzoom: 22
10299
- });
10490
+ mapInstance.addSource(SHARED_SOURCE_ID, customSourceSpec());
10300
10491
  const sharedStack = buildCustomLayerStack(SHARED_SOURCE_ID, CUSTOM_LAYER_ROLES, { labelsVisible: false });
10301
10492
  sharedStack.forEach((spec) => mapInstance.addLayer(spec));
10302
10493
  const styleHost = {
@@ -10387,6 +10578,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10387
10578
  "line-opacity": 0.7
10388
10579
  }
10389
10580
  });
10581
+ mapInstance.addSource(SELECTION_OVERLAY_SOURCE_ID, {
10582
+ type: "geojson",
10583
+ data: { type: "FeatureCollection", features: [] },
10584
+ maxzoom: 22
10585
+ });
10586
+ buildSelectionOverlayStack().forEach((spec) => mapInstance.addLayer(spec));
10390
10587
  if (tooltipElRef.current) {
10391
10588
  const prevCleanup = tooltipElRef.current._cleanup;
10392
10589
  try {
@@ -10505,8 +10702,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10505
10702
  const highlightFields = /* @__PURE__ */ new Set();
10506
10703
  if (((_a2 = visualConfig == null ? void 0 : visualConfig.size) == null ? void 0 : _a2.mode) === "field" && visualConfig.size.fieldName) highlightFields.add(visualConfig.size.fieldName);
10507
10704
  if (((_b2 = visualConfig == null ? void 0 : visualConfig.color) == null ? void 0 : _b2.mode) === "field" && visualConfig.color.fieldName) highlightFields.add(visualConfig.color.fieldName);
10508
- 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"];
10509
- 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);
10705
+ 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);
10510
10706
  const name = props.name;
10511
10707
  let html = '<div class="text-sm space-y-0.5">';
10512
10708
  if (name) html += `<div class="font-medium">${name}</div>`;
@@ -10797,7 +10993,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10797
10993
  onMapLoad == null ? void 0 : onMapLoad(mapInstance);
10798
10994
  if (baseMapStyle !== "satellite") {
10799
10995
  const customDef = customBasemaps == null ? void 0 : customBasemaps[baseMapStyle];
10800
- const styleUrl = (customDef == null ? void 0 : customDef.type) === "vector" && typeof customDef.style === "string" ? customDef.style : EXTERNAL_STYLE_URLS[baseMapStyle];
10996
+ const styleUrl = (customDef == null ? void 0 : customDef.type) === "vector" && typeof customDef.style === "string" ? customDef.style : builtInStyleUrl(resolvedEndpoints, baseMapStyle);
10801
10997
  if (styleUrl) {
10802
10998
  const prefix = BASEMAP_LAYER_PREFIXES[baseMapStyle] || `${baseMapStyle}-`;
10803
10999
  fetch(styleUrl).then((res) => res.json()).then((externalStyle) => {
@@ -10811,8 +11007,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10811
11007
  return url;
10812
11008
  }
10813
11009
  };
10814
- const usingLocalGlyphs = !glyphsUrl || glyphsUrl === DEFAULT_LOCAL_GLYPHS_URL;
10815
- if (externalStyle.glyphs && !usingLocalGlyphs) {
11010
+ if (externalStyle.glyphs && resolvedEndpoints.adoptStyleGlyphs) {
10816
11011
  mapInstance.setGlyphs(resolveUrl(externalStyle.glyphs));
10817
11012
  }
10818
11013
  if (externalStyle.sprite) {
@@ -11183,7 +11378,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11183
11378
  const clusterHit = clusterOverlayIds.length > 0 ? mapInstance.queryRenderedFeatures(e.point, { layers: clusterOverlayIds })[0] : void 0;
11184
11379
  if (!clusterHit) {
11185
11380
  if (selectedFeatureIdsRef.current.length > 0 && !isModifierKey) {
11186
- applySelectionState([]);
11381
+ applySelectionState$1([]);
11187
11382
  }
11188
11383
  return;
11189
11384
  }
@@ -11205,13 +11400,13 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11205
11400
  return;
11206
11401
  }
11207
11402
  const fid = String(featureId);
11208
- const currentSelection = selectedFeatureIdsRef.current;
11209
- const isAlreadySelected = currentSelection.includes(fid);
11403
+ const currentSelection2 = selectedFeatureIdsRef.current;
11404
+ const isAlreadySelected = currentSelection2.includes(fid);
11210
11405
  let nextIds;
11211
11406
  if (isModifierKey) {
11212
- nextIds = isAlreadySelected ? currentSelection.filter((id) => id !== fid) : [...currentSelection, fid];
11407
+ nextIds = isAlreadySelected ? currentSelection2.filter((id) => id !== fid) : [...currentSelection2, fid];
11213
11408
  } else {
11214
- nextIds = isAlreadySelected ? currentSelection.filter((id) => id !== fid) : [fid];
11409
+ nextIds = isAlreadySelected ? currentSelection2.filter((id) => id !== fid) : [fid];
11215
11410
  }
11216
11411
  isSelectingReadOnlyRef.current = true;
11217
11412
  if (drawInstance.getSelected().features.length > 0) {
@@ -11763,7 +11958,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11763
11958
  onFeatureDelete == null ? void 0 : onFeatureDelete(featureIds);
11764
11959
  },
11765
11960
  selectFeatures: (featureIds) => {
11766
- applySelectionState(featureIds, { focusProperties: true });
11961
+ applySelectionState$1(featureIds, { focusProperties: true });
11767
11962
  },
11768
11963
  getSelectedFeatures,
11769
11964
  setEditMode: (enabled) => {
@@ -11869,6 +12064,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11869
12064
  // Basemap management methods
11870
12065
  registerBasemap: (id, definition) => {
11871
12066
  if (!map.current) return;
12067
+ if (BUILT_IN_BASEMAP_IDS.includes(id)) {
12068
+ console.warn(`[map-component] registerBasemap("${id}") ignored: built-in basemaps are configured through the endpoints prop.`);
12069
+ return;
12070
+ }
11872
12071
  customBasemapRegistry.current.set(id, definition);
11873
12072
  if (definition.type === "raster") {
11874
12073
  const sourceId = `custom-basemap-${id}`;
@@ -11895,8 +12094,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11895
12094
  },
11896
12095
  unregisterBasemap: (id) => {
11897
12096
  if (!map.current) return false;
11898
- const builtIn = ["streets", "satellite", "dark"];
11899
- if (builtIn.includes(id)) return false;
12097
+ if (BUILT_IN_BASEMAP_IDS.includes(id)) return false;
11900
12098
  customBasemapRegistry.current.delete(id);
11901
12099
  const layerIds = basemapLayerIds.current.get(id) || [];
11902
12100
  for (const layerId of layerIds) {
@@ -11920,7 +12118,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
11920
12118
  return currentMapStyle;
11921
12119
  },
11922
12120
  listBasemaps: () => {
11923
- const builtIn = ["streets", "satellite", "dark"];
12121
+ const builtIn = resolvedEndpoints.builtInBasemaps.map((basemap) => basemap.id);
11924
12122
  const custom = Array.from(customBasemapRegistry.current.keys());
11925
12123
  return [...builtIn, ...custom];
11926
12124
  },
@@ -12049,7 +12247,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
12049
12247
  setPersistedSelectionPolygon(null);
12050
12248
  setSelectionPoints([]);
12051
12249
  setSelectedFeatureIds([]);
12052
- applySelectionState([], { focusProperties: true });
12250
+ applySelectionState$1([], { focusProperties: true });
12053
12251
  },
12054
12252
  // Viewport and state getters
12055
12253
  getViewport: () => {
@@ -13037,6 +13235,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13037
13235
  if (!m.getLayer(id)) return;
13038
13236
  m.moveLayer(id, firstVisibleBasemapSymbol == null ? void 0 : firstVisibleBasemapSymbol.id);
13039
13237
  });
13238
+ if (!firstVisibleBasemapSymbol && m.getLayer(SELECTION_OVERLAY_LAYER_IDS.label)) {
13239
+ m.moveLayer(SELECTION_OVERLAY_LAYER_IDS.label);
13240
+ }
13040
13241
  } catch (e) {
13041
13242
  console.warn("[map-component] moveLabelsBeforeBasemapSymbols failed:", (e == null ? void 0 : e.message) ?? e);
13042
13243
  }
@@ -13046,7 +13247,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13046
13247
  if (!map.current) return [];
13047
13248
  const mapInstance = map.current;
13048
13249
  const prefix = BASEMAP_LAYER_PREFIXES[styleName] || `${styleName}-`;
13049
- const styleUrl = overrideStyleUrl || EXTERNAL_STYLE_URLS[styleName];
13250
+ const styleUrl = overrideStyleUrl || builtInStyleUrl(resolvedEndpoints, styleName);
13050
13251
  if (!styleUrl) {
13051
13252
  console.warn(`No external style URL for: ${styleName}`);
13052
13253
  return [];
@@ -13063,8 +13264,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13063
13264
  return url;
13064
13265
  }
13065
13266
  };
13066
- const usingLocalGlyphs = !glyphsUrl || glyphsUrl === DEFAULT_LOCAL_GLYPHS_URL;
13067
- if (externalStyle.glyphs && !usingLocalGlyphs) {
13267
+ if (externalStyle.glyphs && resolvedEndpoints.adoptStyleGlyphs) {
13068
13268
  mapInstance.setGlyphs(resolveUrl(externalStyle.glyphs));
13069
13269
  }
13070
13270
  if (externalStyle.sprite) {
@@ -13111,7 +13311,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13111
13311
  console.error(`Failed to load basemap style ${styleName}:`, e);
13112
13312
  return [];
13113
13313
  }
13114
- }, [moveLabelsBeforeBasemapSymbols]);
13314
+ }, [moveLabelsBeforeBasemapSymbols, resolvedEndpoints]);
13115
13315
  const setBasemapVisibility = react.useCallback((styleName, visible) => {
13116
13316
  if (!map.current) return;
13117
13317
  const mapInstance = map.current;
@@ -13125,6 +13325,10 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13125
13325
  const handleMapStyleChange = react.useCallback(async (style) => {
13126
13326
  if (!map.current) return;
13127
13327
  const mapInstance = map.current;
13328
+ if (BUILT_IN_BASEMAP_IDS.includes(style) && !isBuiltInBasemapEnabled(resolvedEndpoints, style)) {
13329
+ console.warn(`[map-component] basemap "${style}" is turned off in endpoints; ignoring the switch.`);
13330
+ return;
13331
+ }
13128
13332
  basemapLayerIds.current.forEach((_, basemapName) => {
13129
13333
  setBasemapVisibility(basemapName, false);
13130
13334
  });
@@ -13170,7 +13374,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13170
13374
  setBasemapVisibility(style, true);
13171
13375
  setCurrentMapStyle(style);
13172
13376
  moveLabelsBeforeBasemapSymbols();
13173
- }, [loadBasemapStyle, setBasemapVisibility, moveLabelsBeforeBasemapSymbols]);
13377
+ }, [loadBasemapStyle, setBasemapVisibility, moveLabelsBeforeBasemapSymbols, resolvedEndpoints]);
13174
13378
  handleMapStyleChangeRef.current = handleMapStyleChange;
13175
13379
  const handleUpdateTraceConfig = react.useCallback((layerId, config) => {
13176
13380
  saveStateForUndo("trace config", { coalesceKey: `traceConfig:${layerId}` });
@@ -13520,7 +13724,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13520
13724
  }, [isEditMode]);
13521
13725
  const handleToggle3DTerrain = react.useCallback(() => {
13522
13726
  if (!map.current) return;
13523
- if (!enableTerrain || !enable3D) {
13727
+ if (!resolvedEndpoints.terrain) {
13524
13728
  toast({
13525
13729
  title: "3D Terrain Unavailable",
13526
13730
  description: "Terrain features are disabled for this configuration.",
@@ -13565,7 +13769,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13565
13769
  mapInstance.setLayoutProperty("terrain-hillshade", "visibility", "none");
13566
13770
  }
13567
13771
  }
13568
- }, [is3DTerrainEnabled, enableTerrain, enable3D, toast]);
13772
+ }, [is3DTerrainEnabled, resolvedEndpoints, toast]);
13569
13773
  const handleSelectionModeChange = react.useCallback((mode) => {
13570
13774
  setSelectionMode(mode);
13571
13775
  setSelectionPoints([]);
@@ -13588,24 +13792,91 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13588
13792
  react.useEffect(() => {
13589
13793
  enableDrawingRef.current = enableDrawing;
13590
13794
  }, [enableDrawing]);
13591
- const trySelectionFastPath = react.useCallback(() => {
13795
+ const overlayPaintContext = react.useCallback(() => {
13796
+ const base = overlayPaintContextRef.current;
13797
+ if (!base) return null;
13798
+ const sizeFieldRanges = new Map(base.sizeFieldRanges);
13799
+ const colorFieldRanges = new Map(base.colorFieldRanges);
13800
+ shardFieldRangesRef.current.forEach((ranges, layerId) => {
13801
+ if (ranges.size) sizeFieldRanges.set(layerId, ranges.size);
13802
+ if (ranges.color) colorFieldRanges.set(layerId, ranges.color);
13803
+ });
13804
+ return { ...base, timelineVisibleIds: timelineVisibleIdsRef.current, sizeFieldRanges, colorFieldRanges };
13805
+ }, []);
13806
+ const overlayFeatureCountRef = react.useRef(0);
13807
+ const overlayTimelineInputsRef = react.useRef(overlayTimelineInputs(EMPTY_ID_SET, null));
13808
+ const refreshSelectionOverlay = react.useCallback((m, ids) => {
13809
+ overlayTimelineInputsRef.current = overlayTimelineInputs(ids, timelineVisibleIdsRef.current);
13810
+ if (ids.size === 0 && overlayFeatureCountRef.current === 0) return;
13811
+ const overlay = m.getSource(SELECTION_OVERLAY_SOURCE_ID);
13812
+ if (!overlay) return;
13813
+ const ctx = ids.size > 0 ? overlayPaintContext() : null;
13814
+ const layers2 = layersRef.current;
13815
+ const layerById = new Map(layers2.map((l) => [l.id, l]));
13816
+ const data = buildSelectionOverlayData(ids, (id) => {
13817
+ if (!ctx) return [];
13818
+ const holders = locateFeatureHolders(id, readOnlyFeatures.current, locatorCacheRef.current);
13819
+ if (holders.length > 0) {
13820
+ return holders.filter((h) => {
13821
+ var _a;
13822
+ return ((_a = layerById.get(h.layerId)) == null ? void 0 : _a.visible) === true;
13823
+ }).map((h) => styleFeatureForPaint(h.feature, layerById.get(h.layerId), ctx, true).feature);
13824
+ }
13825
+ const feature = getFeatureById(id);
13826
+ if (!feature) return [];
13827
+ const layer = layers2.find((l) => !l.readOnly && l.featureIds.includes(id));
13828
+ return layer && !layer.visible ? [] : [styleFeatureForPaint(feature, layer, ctx, true).feature];
13829
+ });
13830
+ overlay.setData(data);
13831
+ overlayFeatureCountRef.current = data.features.length;
13832
+ }, [getFeatureById, overlayPaintContext]);
13833
+ const currentSelection = react.useCallback(() => {
13592
13834
  var _a;
13835
+ if (!(enableSelectionRef.current || enableDrawingRef.current)) return null;
13836
+ const next = /* @__PURE__ */ new Set();
13837
+ (((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => next.add(String(id)));
13838
+ selectedFeatureIdsRef.current.forEach((id) => next.add(String(id)));
13839
+ return next;
13840
+ }, []);
13841
+ const paintSelection = react.useCallback((m, overlay = true) => {
13842
+ const selection = currentSelection();
13843
+ const { set: set2, removed } = applySelectionState(
13844
+ appliedSelectionRef.current,
13845
+ selection ?? EMPTY_ID_SET,
13846
+ selection !== null,
13847
+ locateSelectionSources,
13848
+ featureStateHostFor(m)
13849
+ );
13850
+ const shown = selection ?? EMPTY_ID_SET;
13851
+ if (overlay) refreshSelectionOverlay(m, shown);
13852
+ return { set: set2, removed, overlay: overlay ? shown.size : 0 };
13853
+ }, [currentSelection, locateSelectionSources, refreshSelectionOverlay]);
13854
+ const applySelectionPaint = react.useCallback(() => {
13593
13855
  const m = map.current;
13594
13856
  if (!m) return true;
13595
- const source = m.getSource("custom-features");
13596
- const gate = enableSelectionRef.current || enableDrawingRef.current;
13597
- const next = /* @__PURE__ */ new Set();
13598
- if (gate) {
13599
- (((_a = draw.current) == null ? void 0 : _a.getSelectedIds()) ?? []).forEach((id) => next.add(String(id)));
13600
- selectedFeatureIdsRef.current.forEach((id) => next.add(String(id)));
13601
- }
13602
- if (!applySelectionFastPath(selectionPaintCacheRef.current, next, source)) return false;
13603
- return forEachShardCache(
13604
- shardRegistryRef.current,
13605
- (cache2, shardSource) => applySelectionFastPath(cache2, next, shardSource)
13857
+ const start = performance.now();
13858
+ const painted = paintSelection(m);
13859
+ mapPerfLog("selection", "feature state applied", { ...painted, ms: Math.round(performance.now() - start) });
13860
+ return true;
13861
+ }, [paintSelection]);
13862
+ trySelectionFastPathRef.current = applySelectionPaint;
13863
+ const reconcileSelectionAfterPaint = react.useCallback((options) => {
13864
+ const m = map.current;
13865
+ if (!m) return;
13866
+ const { moved, pruned } = reconcileSelectionSources(
13867
+ appliedSelectionRef.current,
13868
+ locateSelectionSources,
13869
+ featureStateHostFor(m)
13606
13870
  );
13607
- }, []);
13608
- trySelectionFastPathRef.current = trySelectionFastPath;
13871
+ const applied = paintSelection(m, (options == null ? void 0 : options.overlay) ?? true);
13872
+ if (moved || pruned || applied.set || applied.removed) {
13873
+ mapPerfLog("selection", "reconciled after paint", { moved, pruned, ...applied });
13874
+ }
13875
+ }, [locateSelectionSources, paintSelection]);
13876
+ reconcileSelectionRef.current = reconcileSelectionAfterPaint;
13877
+ react.useEffect(() => {
13878
+ scheduleSync("selection");
13879
+ }, [enableSelection, enableDrawing, scheduleSync]);
13609
13880
  const tryTimelineFastPath = react.useCallback(() => {
13610
13881
  const m = map.current;
13611
13882
  if (!m) return true;
@@ -13619,13 +13890,17 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13619
13890
  const traceDiff = trace && paintCache ? buildTraceTimelineDiff(trace, paintCache, nextVisible) : null;
13620
13891
  const { applied, toggled } = applyTimelineFastPath(paintCache, nextVisible, source);
13621
13892
  if (!applied || !paintCache || !source) return false;
13622
- if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff, paintCache, source, traceSource))) return false;
13893
+ if (traceDiff && (!traceSource || !applyTraceTimelineDiff(traceDiff, source, traceSource))) return false;
13623
13894
  if (!forEachShardCache(shardRegistryRef.current, (cache2, shardSource) => applyTimelineFastPath(cache2, nextVisible, shardSource).applied)) {
13624
13895
  return false;
13625
13896
  }
13626
13897
  const threshold = autoLabelConfig.enabled ? autoLabelConfig.threshold : 220;
13627
13898
  setVisibleFeatureCount(countVisibleFeatures(threshold));
13628
13899
  setLabelsSuppressed(false);
13900
+ const selection = currentSelection() ?? EMPTY_ID_SET;
13901
+ if (!sameOverlayTimelineInputs(overlayTimelineInputsRef.current, overlayTimelineInputs(selection, nextVisible))) {
13902
+ refreshSelectionOverlay(m, selection);
13903
+ }
13629
13904
  mapPerfLog("timeline", "fast path applied", {
13630
13905
  toggled,
13631
13906
  endpointsMoved: (traceDiff == null ? void 0 : traceDiff.pointUpdates.length) ?? 0,
@@ -13633,7 +13908,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13633
13908
  segmentsRemoved: (traceDiff == null ? void 0 : traceDiff.segmentRemove.length) ?? 0
13634
13909
  });
13635
13910
  return true;
13636
- }, [autoLabelConfig, countVisibleFeatures]);
13911
+ }, [autoLabelConfig, countVisibleFeatures, currentSelection, refreshSelectionOverlay]);
13637
13912
  tryTimelineFastPathRef.current = tryTimelineFastPath;
13638
13913
  const collectSelectionFeatureGroups = react.useCallback(() => {
13639
13914
  return collectVisibleFeatureGroups(
@@ -13749,7 +14024,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13749
14024
  axisAlignedRectangle: true
13750
14025
  });
13751
14026
  const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
13752
- applySelectionState(finalIds, { focusProperties: true });
14027
+ applySelectionState$1(finalIds, { focusProperties: true });
13753
14028
  }
13754
14029
  setIsSelectionToolActive(false);
13755
14030
  startPoint = null;
@@ -13772,7 +14047,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13772
14047
  } else {
13773
14048
  const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
13774
14049
  const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
13775
- applySelectionState(finalIds, { focusProperties: true });
14050
+ applySelectionState$1(finalIds, { focusProperties: true });
13776
14051
  }
13777
14052
  setIsSelectionToolActive(false);
13778
14053
  }
@@ -13806,7 +14081,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13806
14081
  } else {
13807
14082
  const selectedIds = hitTestSelection(collectSelectionFeatureGroups(), selectionPolygon);
13808
14083
  const finalIds = e.shiftKey ? Array.from(/* @__PURE__ */ new Set([...selectedFeatureIdsRef.current, ...selectedIds])) : selectedIds;
13809
- applySelectionState(finalIds, { focusProperties: true });
14084
+ applySelectionState$1(finalIds, { focusProperties: true });
13810
14085
  }
13811
14086
  setIsSelectionToolActive(false);
13812
14087
  setSelectionPoints([]);
@@ -13922,7 +14197,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13922
14197
  setSelectionPoints([]);
13923
14198
  mapInstance.dragPan.enable();
13924
14199
  canvas.style.cursor = "";
13925
- applySelectionState(mergedIds, { focusProperties: true });
14200
+ applySelectionState$1(mergedIds, { focusProperties: true });
13926
14201
  };
13927
14202
  canvas.addEventListener("mousedown", handleShiftMouseDown);
13928
14203
  window.addEventListener("mousemove", handleShiftMouseMove);
@@ -13935,7 +14210,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
13935
14210
  map.current.dragPan.enable();
13936
14211
  }
13937
14212
  };
13938
- }, [isMapLoaded, isSelectionToolActive, applySelectionState, collectSelectionFeatureGroups]);
14213
+ }, [isMapLoaded, isSelectionToolActive, applySelectionState$1, collectSelectionFeatureGroups]);
13939
14214
  react.useEffect(() => {
13940
14215
  if (!map.current || !isMapLoaded) return;
13941
14216
  const mapInstance = map.current;
@@ -15889,8 +16164,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
15889
16164
  showGoToButton,
15890
16165
  onFitToFeatures: handleFitToFeatures,
15891
16166
  onDropPoint,
15892
- geocodingUrl,
15893
- geocoderProvider,
16167
+ geocoder: endpoints == null ? void 0 : endpoints.geocoder,
15894
16168
  onSearchEngineRequest: onSearchEngineRequest ? handleSearchAndAddToNewLayer : void 0,
15895
16169
  getAllFeatures,
15896
16170
  onFlyToFeature: (feature) => {
@@ -16010,9 +16284,9 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
16010
16284
  onToggle3DTerrain: handleToggle3DTerrain,
16011
16285
  onUpdateAltitudeDisplayMode: handleUpdateAltitudeDisplayMode,
16012
16286
  availableBasemaps,
16013
- hideSatellite: !enableSatellite,
16014
- hideDark: !enableDark,
16015
- hideTerrain: !enableTerrain,
16287
+ hideSatellite: !resolvedEndpoints.satellite,
16288
+ hideDark: !resolvedEndpoints.vectorStyles.dark,
16289
+ hideTerrain: !resolvedEndpoints.terrain,
16016
16290
  hideBasemapSwitcher,
16017
16291
  externalPersistence,
16018
16292
  customGlobalMenuItems,