@optimum-intelligence/opti-ui 0.7.3 → 0.7.5

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.
@@ -44,15 +44,22 @@ function useMapContext(part) {
44
44
  if (!ctx) throw new Error(`${part} must be used inside Map.Root`);
45
45
  return ctx;
46
46
  }
47
+ /** Glyph server for text labels (`Map.Points` `label`); OpenFreeMap's serves `Noto Sans Bold`. */
48
+ var DEFAULT_GLYPHS = "https://tiles.openfreemap.org/fonts/{fontstack}/{range}.pbf";
49
+ /** Font stack of `Map.Points` labels. Glyph servers without it make MapLibre draw the digits with a local font. */
50
+ var LABEL_FONT = ["Noto Sans Bold"];
47
51
  /**
48
52
  * Builds a MapLibre style from a raster tile URL template (`{z}`, `{x}`, `{y}`), for `MapBaseLayer.style`.
53
+ * The style gets a `glyphs` URL (OpenFreeMap's font server by default) so `Map.Points` labels can render;
54
+ * pass your own `glyphs` URL to use another font server.
49
55
  *
50
56
  * @example
51
57
  * const satellite = rasterStyle('https://tiles.example.com/{z}/{x}/{y}.jpg', '© Example');
52
58
  */
53
- function rasterStyle(tiles, attribution, tileSize = 256) {
59
+ function rasterStyle(tiles, attribution, tileSize = 256, glyphs = DEFAULT_GLYPHS) {
54
60
  return {
55
61
  version: 8,
62
+ glyphs,
56
63
  sources: { raster: {
57
64
  type: "raster",
58
65
  tiles: Array.isArray(tiles) ? tiles : [tiles],
@@ -79,24 +86,28 @@ function hasValidPositions(coords, min) {
79
86
  };
80
87
  return check(coords) && count >= min;
81
88
  }
82
- /** Grows `bounds` by every `[lng, lat]` pair nested in `coords`. */
83
- function extend(bounds, coords) {
84
- if (!Array.isArray(coords)) return bounds;
85
- if (typeof coords[0] === "number") {
86
- const [x, y] = coords;
87
- return bounds ? [
88
- Math.min(bounds[0], x),
89
- Math.min(bounds[1], y),
90
- Math.max(bounds[2], x),
91
- Math.max(bounds[3], y)
92
- ] : [
93
- x,
94
- y,
95
- x,
96
- y
97
- ];
98
- }
99
- return coords.reduce(extend, bounds);
89
+ /** `[w, s, e, n]` around every `[lng, lat]` pair nested in `coords`, or null when there is none. */
90
+ function boundsOf(coords) {
91
+ let w = Infinity, s = Infinity, e = -Infinity, n = -Infinity;
92
+ const visit = (value) => {
93
+ if (!Array.isArray(value)) return;
94
+ if (typeof value[0] !== "number") {
95
+ for (const child of value) visit(child);
96
+ return;
97
+ }
98
+ const [x, y] = value;
99
+ if (x < w) w = x;
100
+ if (x > e) e = x;
101
+ if (y < s) s = y;
102
+ if (y > n) n = y;
103
+ };
104
+ visit(coords);
105
+ return w <= e ? [
106
+ w,
107
+ s,
108
+ e,
109
+ n
110
+ ] : null;
100
111
  }
101
112
  var toneColors = {
102
113
  neutral: {
@@ -152,7 +163,7 @@ var dimmed = (hasSelection, dim) => hasSelection ? [
152
163
  * and keeps the `selected` feature state in sync (also after a style switch re-adds the source).
153
164
  */
154
165
  function useDataPart(partName, sourceId, options) {
155
- const $ = c(36);
166
+ const $ = c(62);
156
167
  const ctx = useMapContext(partName);
157
168
  const { items, selectedIds: t0, layerIds, coordinates, minPositions: t1, onItemClick, onItemHover } = options;
158
169
  let t2;
@@ -164,7 +175,6 @@ function useDataPart(partName, sourceId, options) {
164
175
  const selectedIds = t2;
165
176
  const minPositions = t1 === void 0 ? 1 : t1;
166
177
  const { register, setHandlers, map } = ctx;
167
- const selected = new Set(selectedIds);
168
178
  let t3;
169
179
  if ($[2] !== selectedIds) {
170
180
  t3 = selectedIds.join("\0");
@@ -173,83 +183,124 @@ function useDataPart(partName, sourceId, options) {
173
183
  } else t3 = $[3];
174
184
  const selectedKey = t3;
175
185
  let t4;
176
- if ($[4] !== coordinates || $[5] !== minPositions) {
177
- t4 = (item) => hasValidPositions(coordinates(item), minPositions);
178
- $[4] = coordinates;
179
- $[5] = minPositions;
180
- $[6] = t4;
181
- } else t4 = $[6];
182
- const valid = new Set(items.filter(t4));
183
- const invalidIds = items.filter((item_0) => !valid.has(item_0)).map(_temp).join(", ");
184
186
  let t5;
185
187
  let t6;
186
- if ($[7] !== invalidIds || $[8] !== partName) {
187
- t5 = () => {
188
+ if ($[4] !== coordinates || $[5] !== items || $[6] !== minPositions) {
189
+ let t7;
190
+ if ($[10] !== coordinates || $[11] !== minPositions) {
191
+ t7 = (item) => hasValidPositions(coordinates(item), minPositions);
192
+ $[10] = coordinates;
193
+ $[11] = minPositions;
194
+ $[12] = t7;
195
+ } else t7 = $[12];
196
+ const drawable = items.filter(t7);
197
+ const set = new Set(drawable);
198
+ t4 = set;
199
+ t5 = items.filter((item_0) => !set.has(item_0)).map(_temp).join(", ");
200
+ t6 = boundsOf(drawable.map(coordinates));
201
+ $[4] = coordinates;
202
+ $[5] = items;
203
+ $[6] = minPositions;
204
+ $[7] = t4;
205
+ $[8] = t5;
206
+ $[9] = t6;
207
+ } else {
208
+ t4 = $[7];
209
+ t5 = $[8];
210
+ t6 = $[9];
211
+ }
212
+ let t7;
213
+ if ($[13] !== t4 || $[14] !== t5 || $[15] !== t6) {
214
+ t7 = {
215
+ valid: t4,
216
+ invalidIds: t5,
217
+ bounds: t6
218
+ };
219
+ $[13] = t4;
220
+ $[14] = t5;
221
+ $[15] = t6;
222
+ $[16] = t7;
223
+ } else t7 = $[16];
224
+ const { valid, invalidIds, bounds } = t7;
225
+ let t8;
226
+ if ($[17] !== selectedKey) {
227
+ t8 = new Set(selectedKey ? selectedKey.split("\0") : []);
228
+ $[17] = selectedKey;
229
+ $[18] = t8;
230
+ } else t8 = $[18];
231
+ const selected = t8;
232
+ let t9;
233
+ if ($[19] !== coordinates || $[20] !== selected || $[21] !== valid) {
234
+ t9 = boundsOf([...valid].filter((item_2) => selected.has(item_2.id)).map(coordinates));
235
+ $[19] = coordinates;
236
+ $[20] = selected;
237
+ $[21] = valid;
238
+ $[22] = t9;
239
+ } else t9 = $[22];
240
+ const selectedBounds = t9;
241
+ let t10;
242
+ let t11;
243
+ if ($[23] !== invalidIds || $[24] !== partName) {
244
+ t10 = () => {
188
245
  if (invalidIds && process.env.NODE_ENV !== "production") console.warn(`${partName}: skipped items with invalid coordinates: ${invalidIds}`);
189
246
  };
190
- t6 = [partName, invalidIds];
191
- $[7] = invalidIds;
192
- $[8] = partName;
193
- $[9] = t5;
194
- $[10] = t6;
247
+ t11 = [partName, invalidIds];
248
+ $[23] = invalidIds;
249
+ $[24] = partName;
250
+ $[25] = t10;
251
+ $[26] = t11;
195
252
  } else {
196
- t5 = $[9];
197
- t6 = $[10];
198
- }
199
- React.useEffect(t5, t6);
200
- let bounds = null;
201
- let selectedBounds = null;
202
- for (const item_2 of valid) {
203
- bounds = extend(bounds, coordinates(item_2));
204
- if (selected.has(item_2.id)) selectedBounds = extend(selectedBounds, coordinates(item_2));
253
+ t10 = $[25];
254
+ t11 = $[26];
205
255
  }
256
+ React.useEffect(t10, t11);
206
257
  const boundsKey = `${bounds}|${selectedBounds}|${layerIds}`;
207
- let t7;
208
- if ($[11] !== bounds || $[12] !== layerIds || $[13] !== register || $[14] !== selectedBounds || $[15] !== sourceId) {
209
- t7 = () => {
258
+ let t12;
259
+ if ($[27] !== bounds || $[28] !== layerIds || $[29] !== register || $[30] !== selectedBounds || $[31] !== sourceId) {
260
+ t12 = () => {
210
261
  register(sourceId, {
211
262
  layerIds,
212
263
  bounds,
213
264
  selectedBounds
214
265
  });
215
266
  };
216
- $[11] = bounds;
217
- $[12] = layerIds;
218
- $[13] = register;
219
- $[14] = selectedBounds;
220
- $[15] = sourceId;
221
- $[16] = t7;
222
- } else t7 = $[16];
223
- let t8;
224
- if ($[17] !== boundsKey || $[18] !== register || $[19] !== sourceId) {
225
- t8 = [
267
+ $[27] = bounds;
268
+ $[28] = layerIds;
269
+ $[29] = register;
270
+ $[30] = selectedBounds;
271
+ $[31] = sourceId;
272
+ $[32] = t12;
273
+ } else t12 = $[32];
274
+ let t13;
275
+ if ($[33] !== boundsKey || $[34] !== register || $[35] !== sourceId) {
276
+ t13 = [
226
277
  register,
227
278
  sourceId,
228
279
  boundsKey
229
280
  ];
230
- $[17] = boundsKey;
231
- $[18] = register;
232
- $[19] = sourceId;
233
- $[20] = t8;
234
- } else t8 = $[20];
235
- React.useEffect(t7, t8);
236
- let t10;
237
- let t9;
238
- if ($[21] !== register || $[22] !== sourceId) {
239
- t9 = () => () => register(sourceId, null);
240
- t10 = [register, sourceId];
241
- $[21] = register;
242
- $[22] = sourceId;
243
- $[23] = t10;
244
- $[24] = t9;
281
+ $[33] = boundsKey;
282
+ $[34] = register;
283
+ $[35] = sourceId;
284
+ $[36] = t13;
285
+ } else t13 = $[36];
286
+ React.useEffect(t12, t13);
287
+ let t14;
288
+ let t15;
289
+ if ($[37] !== register || $[38] !== sourceId) {
290
+ t14 = () => () => register(sourceId, null);
291
+ t15 = [register, sourceId];
292
+ $[37] = register;
293
+ $[38] = sourceId;
294
+ $[39] = t14;
295
+ $[40] = t15;
245
296
  } else {
246
- t10 = $[23];
247
- t9 = $[24];
297
+ t14 = $[39];
298
+ t15 = $[40];
248
299
  }
249
- React.useEffect(t9, t10);
250
- let t11;
251
- if ($[25] !== items || $[26] !== onItemClick || $[27] !== onItemHover || $[28] !== setHandlers || $[29] !== sourceId) {
252
- t11 = () => {
300
+ React.useEffect(t14, t15);
301
+ let t16;
302
+ if ($[41] !== items || $[42] !== onItemClick || $[43] !== onItemHover || $[44] !== setHandlers || $[45] !== sourceId) {
303
+ t16 = () => {
253
304
  const byId = (id) => items.find((item_3) => item_3.id === id);
254
305
  setHandlers(sourceId, {
255
306
  onClick: (id_0, event) => {
@@ -259,73 +310,97 @@ function useDataPart(partName, sourceId, options) {
259
310
  onHover: (id_1, event_0) => onItemHover?.(id_1 == null ? null : byId(id_1) ?? null, event_0)
260
311
  });
261
312
  };
262
- $[25] = items;
263
- $[26] = onItemClick;
264
- $[27] = onItemHover;
265
- $[28] = setHandlers;
266
- $[29] = sourceId;
267
- $[30] = t11;
268
- } else t11 = $[30];
269
- React.useEffect(t11);
270
- let t12;
271
- let t13;
272
- if ($[31] !== setHandlers || $[32] !== sourceId) {
273
- t12 = () => () => setHandlers(sourceId, null);
274
- t13 = [setHandlers, sourceId];
275
- $[31] = setHandlers;
276
- $[32] = sourceId;
277
- $[33] = t12;
278
- $[34] = t13;
313
+ $[41] = items;
314
+ $[42] = onItemClick;
315
+ $[43] = onItemHover;
316
+ $[44] = setHandlers;
317
+ $[45] = sourceId;
318
+ $[46] = t16;
319
+ } else t16 = $[46];
320
+ React.useEffect(t16);
321
+ let t17;
322
+ let t18;
323
+ if ($[47] !== setHandlers || $[48] !== sourceId) {
324
+ t17 = () => () => setHandlers(sourceId, null);
325
+ t18 = [setHandlers, sourceId];
326
+ $[47] = setHandlers;
327
+ $[48] = sourceId;
328
+ $[49] = t17;
329
+ $[50] = t18;
279
330
  } else {
280
- t12 = $[33];
281
- t13 = $[34];
331
+ t17 = $[49];
332
+ t18 = $[50];
282
333
  }
283
- React.useEffect(t12, t13);
284
- let t14;
285
- if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
286
- t14 = /* @__PURE__ */ new Set();
287
- $[35] = t14;
288
- } else t14 = $[35];
289
- const applied = React.useRef(t14);
290
- React.useEffect(() => {
291
- const instance = map?.getMap();
292
- if (!instance) return;
293
- const drawn = new Set([...valid].map(_temp2));
294
- const target = new Set((selectedKey ? selectedKey.split("\0") : []).filter((id_2) => drawn.has(id_2)));
295
- const sync = () => {
296
- if (!instance.getSource(sourceId)) return;
297
- const prev = applied.current;
298
- for (const id_3 of prev) if (!target.has(id_3)) instance.setFeatureState({
299
- source: sourceId,
300
- id: id_3
301
- }, { selected: false });
302
- for (const id_4 of target) if (!prev.has(id_4)) instance.setFeatureState({
303
- source: sourceId,
304
- id: id_4
305
- }, { selected: true });
306
- applied.current = target;
307
- };
308
- sync();
309
- const onData = (e) => {
310
- if (e.sourceId !== sourceId || e.sourceDataType !== "metadata") return;
311
- applied.current = /* @__PURE__ */ new Set();
334
+ React.useEffect(t17, t18);
335
+ let t19;
336
+ if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
337
+ t19 = /* @__PURE__ */ new Set();
338
+ $[51] = t19;
339
+ } else t19 = $[51];
340
+ const applied = React.useRef(t19);
341
+ let t20;
342
+ let t21;
343
+ if ($[52] !== map || $[53] !== selectedKey || $[54] !== sourceId || $[55] !== valid) {
344
+ t20 = () => {
345
+ const instance = map?.getMap();
346
+ if (!instance) return;
347
+ const drawn = new Set([...valid].map(_temp2));
348
+ const target = new Set((selectedKey ? selectedKey.split("\0") : []).filter((id_2) => drawn.has(id_2)));
349
+ const sync = () => {
350
+ if (!instance.getSource(sourceId)) return;
351
+ const prev = applied.current;
352
+ for (const id_3 of prev) if (!target.has(id_3)) instance.setFeatureState({
353
+ source: sourceId,
354
+ id: id_3
355
+ }, { selected: false });
356
+ for (const id_4 of target) if (!prev.has(id_4)) instance.setFeatureState({
357
+ source: sourceId,
358
+ id: id_4
359
+ }, { selected: true });
360
+ applied.current = target;
361
+ };
312
362
  sync();
363
+ const onData = (e) => {
364
+ if (e.sourceId !== sourceId || e.sourceDataType !== "metadata") return;
365
+ applied.current = /* @__PURE__ */ new Set();
366
+ sync();
367
+ };
368
+ instance.on("sourcedata", onData);
369
+ return () => {
370
+ instance.off("sourcedata", onData);
371
+ };
313
372
  };
314
- instance.on("sourcedata", onData);
315
- return () => {
316
- instance.off("sourcedata", onData);
373
+ t21 = [
374
+ map,
375
+ sourceId,
376
+ valid,
377
+ selectedKey
378
+ ];
379
+ $[52] = map;
380
+ $[53] = selectedKey;
381
+ $[54] = sourceId;
382
+ $[55] = valid;
383
+ $[56] = t20;
384
+ $[57] = t21;
385
+ } else {
386
+ t20 = $[56];
387
+ t21 = $[57];
388
+ }
389
+ React.useEffect(t20, t21);
390
+ const t22 = selectedIds.length > 0;
391
+ let t23;
392
+ if ($[58] !== ctx.colors || $[59] !== t22 || $[60] !== valid) {
393
+ t23 = {
394
+ colors: ctx.colors,
395
+ hasSelection: t22,
396
+ valid
317
397
  };
318
- }, [
319
- map,
320
- sourceId,
321
- valid,
322
- selectedKey
323
- ]);
324
- return {
325
- colors: ctx.colors,
326
- hasSelection: selectedIds.length > 0,
327
- valid
328
- };
398
+ $[58] = ctx.colors;
399
+ $[59] = t22;
400
+ $[60] = valid;
401
+ $[61] = t23;
402
+ } else t23 = $[61];
403
+ return t23;
329
404
  }
330
405
  /** A source id that is safe in MapLibre layer ids. */
331
406
  function _temp2(item_5) {
@@ -521,11 +596,11 @@ function MapRoot(t0) {
521
596
  empty = entries.length > 0 && entries.every(_temp4);
522
597
  const corners = _temp5;
523
598
  const boundsKey = _temp7;
524
- dataKey = fit === "none" ? "" : boundsKey(extend(null, entries.map((t14) => {
599
+ dataKey = fit === "none" ? "" : boundsKey(boundsOf(entries.map((t14) => {
525
600
  const [, part_3] = t14;
526
601
  return corners(part_3.bounds);
527
602
  })));
528
- t12 = fit === "selected" ? boundsKey(extend(null, entries.map((t15) => {
603
+ t12 = fit === "selected" ? boundsKey(boundsOf(entries.map((t15) => {
529
604
  const [, part_4] = t15;
530
605
  return corners(part_4.selectedBounds);
531
606
  }))) : "";
@@ -1375,25 +1450,36 @@ function _temp11(item) {
1375
1450
  return item.geometry.coordinates;
1376
1451
  }
1377
1452
  /**
1378
- * Many simple points (sensors, stops, events) as one circle layer. For a few dozen styled pins with HTML
1379
- * content, use `Map.Marker` instead.
1453
+ * Many simple points (sensors, stops, events) as one circle layer. Items with a `label` get it drawn in
1454
+ * the circle by a symbol layer on the same source, so thousands of numbered stops stay fast. For a few
1455
+ * dozen styled pins with HTML content, use `Map.Marker` instead.
1380
1456
  *
1381
1457
  * @example
1382
1458
  * <Map.Points items={sensors.map((s) => ({ id: s.id, coordinates: s.position, tone: s.ok ? 'success' : 'danger' }))} />
1459
+ *
1460
+ * @example
1461
+ * // Stops numbered in visiting order, one colour per truck.
1462
+ * <Map.Points
1463
+ * items={trucks.flatMap((truck, t) =>
1464
+ * truck.stops.map((stop, i) => ({ id: stop.id, coordinates: stop.position, colorIndex: t, label: i + 1 })),
1465
+ * )}
1466
+ * />
1383
1467
  */
1384
1468
  function MapPoints(t0) {
1385
- const $ = c(34);
1469
+ const $ = c(43);
1386
1470
  const { items, selectedIds, onItemClick, onItemHover } = t0;
1387
1471
  const sourceId = usePartId("points");
1388
1472
  const circleId = `${sourceId}-circle`;
1473
+ const labelId = `${sourceId}-label`;
1389
1474
  let t1;
1390
- if ($[0] !== circleId) {
1391
- t1 = [circleId];
1475
+ if ($[0] !== circleId || $[1] !== labelId) {
1476
+ t1 = [circleId, labelId];
1392
1477
  $[0] = circleId;
1393
- $[1] = t1;
1394
- } else t1 = $[1];
1478
+ $[1] = labelId;
1479
+ $[2] = t1;
1480
+ } else t1 = $[2];
1395
1481
  let t2;
1396
- if ($[2] !== items || $[3] !== onItemClick || $[4] !== onItemHover || $[5] !== selectedIds || $[6] !== t1) {
1482
+ if ($[3] !== items || $[4] !== onItemClick || $[5] !== onItemHover || $[6] !== selectedIds || $[7] !== t1) {
1397
1483
  t2 = {
1398
1484
  items,
1399
1485
  selectedIds,
@@ -1402,119 +1488,178 @@ function MapPoints(t0) {
1402
1488
  onItemClick,
1403
1489
  onItemHover
1404
1490
  };
1405
- $[2] = items;
1406
- $[3] = onItemClick;
1407
- $[4] = onItemHover;
1408
- $[5] = selectedIds;
1409
- $[6] = t1;
1410
- $[7] = t2;
1411
- } else t2 = $[7];
1491
+ $[3] = items;
1492
+ $[4] = onItemClick;
1493
+ $[5] = onItemHover;
1494
+ $[6] = selectedIds;
1495
+ $[7] = t1;
1496
+ $[8] = t2;
1497
+ } else t2 = $[8];
1412
1498
  const { colors, hasSelection, valid } = useDataPart("Map.Points", sourceId, t2);
1499
+ let data;
1500
+ let opacity;
1413
1501
  let t3;
1414
- if ($[8] !== colors || $[9] !== items || $[10] !== valid) {
1502
+ if ($[9] !== colors || $[10] !== hasSelection || $[11] !== items || $[12] !== valid) {
1415
1503
  let t4;
1416
- if ($[12] !== colors || $[13] !== valid) {
1504
+ if ($[16] !== colors || $[17] !== valid) {
1417
1505
  t4 = (item_0, index) => valid.has(item_0) ? [{
1418
1506
  type: "Feature",
1419
1507
  properties: {
1420
1508
  id: item_0.id,
1421
- color: colors.color(item_0.color ?? (item_0.tone ? toneColors[item_0.tone].solid : seriesColor(item_0.colorIndex ?? index)))
1509
+ color: colors.color(item_0.color ?? (item_0.tone ? toneColors[item_0.tone].solid : seriesColor(item_0.colorIndex ?? index))),
1510
+ ...item_0.label != null && item_0.label !== "" && { label: String(item_0.label) }
1422
1511
  },
1423
1512
  geometry: {
1424
1513
  type: "Point",
1425
1514
  coordinates: item_0.coordinates
1426
1515
  }
1427
1516
  }] : [];
1428
- $[12] = colors;
1429
- $[13] = valid;
1430
- $[14] = t4;
1431
- } else t4 = $[14];
1432
- t3 = items.flatMap(t4);
1433
- $[8] = colors;
1434
- $[9] = items;
1435
- $[10] = valid;
1436
- $[11] = t3;
1437
- } else t3 = $[11];
1438
- let t4;
1439
- if ($[15] !== t3) {
1440
- t4 = {
1517
+ $[16] = colors;
1518
+ $[17] = valid;
1519
+ $[18] = t4;
1520
+ } else t4 = $[18];
1521
+ data = {
1441
1522
  type: "FeatureCollection",
1442
- features: t3
1523
+ features: items.flatMap(t4)
1443
1524
  };
1525
+ let t5;
1526
+ if ($[19] !== colors || $[20] !== hasSelection) {
1527
+ t5 = dimmed(hasSelection, colors.number("--oui-map-dim-opacity", .35));
1528
+ $[19] = colors;
1529
+ $[20] = hasSelection;
1530
+ $[21] = t5;
1531
+ } else t5 = $[21];
1532
+ opacity = t5;
1533
+ t3 = data.features.some(_temp13);
1534
+ $[9] = colors;
1535
+ $[10] = hasSelection;
1536
+ $[11] = items;
1537
+ $[12] = valid;
1538
+ $[13] = data;
1539
+ $[14] = opacity;
1444
1540
  $[15] = t3;
1445
- $[16] = t4;
1446
- } else t4 = $[16];
1447
- const data = t4;
1448
- let t5;
1449
- if ($[17] !== colors || $[18] !== hasSelection) {
1450
- t5 = dimmed(hasSelection, colors.number("--oui-map-dim-opacity", .35));
1451
- $[17] = colors;
1452
- $[18] = hasSelection;
1453
- $[19] = t5;
1454
- } else t5 = $[19];
1455
- const opacity = t5;
1456
- let t6;
1457
- let t7;
1458
- if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
1459
- t6 = ["get", "color"];
1460
- t7 = [
1541
+ } else {
1542
+ data = $[13];
1543
+ opacity = $[14];
1544
+ t3 = $[15];
1545
+ }
1546
+ const hasLabels = t3;
1547
+ let t4;
1548
+ if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
1549
+ t4 = [
1461
1550
  "case",
1462
1551
  ACTIVE,
1463
- 7,
1464
- 5
1552
+ 2,
1553
+ 0
1465
1554
  ];
1466
- $[20] = t6;
1467
- $[21] = t7;
1468
- } else {
1469
- t6 = $[20];
1470
- t7 = $[21];
1471
- }
1555
+ $[22] = t4;
1556
+ } else t4 = $[22];
1557
+ let t5;
1558
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
1559
+ t5 = ["has", "label"];
1560
+ $[23] = t5;
1561
+ } else t5 = $[23];
1562
+ let t6;
1563
+ if ($[24] === Symbol.for("react.memo_cache_sentinel")) {
1564
+ t6 = [
1565
+ "+",
1566
+ t4,
1567
+ [
1568
+ "case",
1569
+ t5,
1570
+ [
1571
+ "step",
1572
+ ["length", ["get", "label"]],
1573
+ 9,
1574
+ 3,
1575
+ 11
1576
+ ],
1577
+ 5
1578
+ ]
1579
+ ];
1580
+ $[24] = t6;
1581
+ } else t6 = $[24];
1582
+ const radius = t6;
1583
+ let t7;
1584
+ if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
1585
+ t7 = ["get", "color"];
1586
+ $[25] = t7;
1587
+ } else t7 = $[25];
1472
1588
  let t8;
1473
- if ($[22] !== colors) {
1589
+ if ($[26] !== colors) {
1474
1590
  t8 = colors.color("var(--oui-map-casing-color)");
1475
- $[22] = colors;
1476
- $[23] = t8;
1477
- } else t8 = $[23];
1591
+ $[26] = colors;
1592
+ $[27] = t8;
1593
+ } else t8 = $[27];
1478
1594
  let t9;
1479
- if ($[24] !== opacity || $[25] !== t8) {
1595
+ if ($[28] !== opacity || $[29] !== t8) {
1480
1596
  t9 = {
1481
- "circle-color": t6,
1482
- "circle-radius": t7,
1597
+ "circle-color": t7,
1598
+ "circle-radius": radius,
1483
1599
  "circle-stroke-color": t8,
1484
1600
  "circle-stroke-width": 1.5,
1485
1601
  "circle-opacity": opacity,
1486
1602
  "circle-stroke-opacity": opacity
1487
1603
  };
1488
- $[24] = opacity;
1489
- $[25] = t8;
1490
- $[26] = t9;
1491
- } else t9 = $[26];
1604
+ $[28] = opacity;
1605
+ $[29] = t8;
1606
+ $[30] = t9;
1607
+ } else t9 = $[30];
1492
1608
  let t10;
1493
- if ($[27] !== circleId || $[28] !== t9) {
1609
+ if ($[31] !== circleId || $[32] !== t9) {
1494
1610
  t10 = /* @__PURE__ */ jsx(Layer, {
1495
1611
  id: circleId,
1496
1612
  type: "circle",
1497
1613
  paint: t9
1498
1614
  });
1499
- $[27] = circleId;
1500
- $[28] = t9;
1501
- $[29] = t10;
1502
- } else t10 = $[29];
1615
+ $[31] = circleId;
1616
+ $[32] = t9;
1617
+ $[33] = t10;
1618
+ } else t10 = $[33];
1503
1619
  let t11;
1504
- if ($[30] !== data || $[31] !== sourceId || $[32] !== t10) {
1505
- t11 = /* @__PURE__ */ jsx(Source, {
1620
+ if ($[34] !== hasLabels || $[35] !== labelId || $[36] !== opacity) {
1621
+ t11 = hasLabels && /* @__PURE__ */ jsx(Layer, {
1622
+ id: labelId,
1623
+ type: "symbol",
1624
+ filter: ["has", "label"],
1625
+ layout: {
1626
+ "text-field": ["get", "label"],
1627
+ "text-font": LABEL_FONT,
1628
+ "text-size": 10,
1629
+ "text-allow-overlap": true,
1630
+ "text-ignore-placement": true
1631
+ },
1632
+ paint: {
1633
+ "text-color": "#ffffff",
1634
+ "text-halo-color": "rgba(0, 0, 0, 0.55)",
1635
+ "text-halo-width": 1,
1636
+ "text-opacity": opacity
1637
+ }
1638
+ });
1639
+ $[34] = hasLabels;
1640
+ $[35] = labelId;
1641
+ $[36] = opacity;
1642
+ $[37] = t11;
1643
+ } else t11 = $[37];
1644
+ let t12;
1645
+ if ($[38] !== data || $[39] !== sourceId || $[40] !== t10 || $[41] !== t11) {
1646
+ t12 = /* @__PURE__ */ jsxs(Source, {
1506
1647
  id: sourceId,
1507
1648
  type: "geojson",
1508
1649
  data,
1509
1650
  promoteId: "id",
1510
- children: t10
1651
+ children: [t10, t11]
1511
1652
  });
1512
- $[30] = data;
1513
- $[31] = sourceId;
1514
- $[32] = t10;
1515
- $[33] = t11;
1516
- } else t11 = $[33];
1517
- return t11;
1653
+ $[38] = data;
1654
+ $[39] = sourceId;
1655
+ $[40] = t10;
1656
+ $[41] = t11;
1657
+ $[42] = t12;
1658
+ } else t12 = $[42];
1659
+ return t12;
1660
+ }
1661
+ function _temp13(feature) {
1662
+ return "label" in feature.properties;
1518
1663
  }
1519
1664
  function _temp12(item) {
1520
1665
  return item.coordinates;
@@ -1859,7 +2004,7 @@ function MapLegend(t0) {
1859
2004
  const labels = React.use(MapContext)?.labels ?? defaultLabels;
1860
2005
  let t6;
1861
2006
  if ($[13] !== items) {
1862
- t6 = items.every(_temp13);
2007
+ t6 = items.every(_temp14);
1863
2008
  $[13] = items;
1864
2009
  $[14] = t6;
1865
2010
  } else t6 = $[14];
@@ -1888,7 +2033,7 @@ function MapLegend(t0) {
1888
2033
  t9 = onVisibilityChange && showAllToggle && /* @__PURE__ */ jsx("button", {
1889
2034
  type: "button",
1890
2035
  className: "oui-map-legend__toggle-all",
1891
- onClick: () => onVisibilityChange(items.map(_temp14), !allVisible),
2036
+ onClick: () => onVisibilityChange(items.map(_temp15), !allVisible),
1892
2037
  children: allVisible ? labels.hideAll : labels.showAll
1893
2038
  });
1894
2039
  $[21] = allVisible;
@@ -1987,10 +2132,10 @@ function MapLegend(t0) {
1987
2132
  } else t12 = $[49];
1988
2133
  return t12;
1989
2134
  }
1990
- function _temp14(item_0) {
2135
+ function _temp15(item_0) {
1991
2136
  return item_0.id;
1992
2137
  }
1993
- function _temp13(item) {
2138
+ function _temp14(item) {
1994
2139
  return item.visible !== false;
1995
2140
  }
1996
2141
  /**
@@ -2080,7 +2225,7 @@ function MapBaseLayerSwitch(t0) {
2080
2225
  }
2081
2226
  let t3;
2082
2227
  if ($[23] !== baseLayers) {
2083
- t3 = baseLayers.map(_temp15);
2228
+ t3 = baseLayers.map(_temp16);
2084
2229
  $[23] = baseLayers;
2085
2230
  $[24] = t3;
2086
2231
  } else t3 = $[24];
@@ -2124,7 +2269,7 @@ function MapBaseLayerSwitch(t0) {
2124
2269
  * </Map.Overlay>
2125
2270
  * </Map.Root>
2126
2271
  */
2127
- function _temp15(layer_0) {
2272
+ function _temp16(layer_0) {
2128
2273
  return {
2129
2274
  value: layer_0.id,
2130
2275
  label: layer_0.label