@vitessce/json 4.0.7 → 4.0.9

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.
@@ -94,7 +94,9 @@ const ViewType$1 = {
94
94
  DUAL_SCATTERPLOT: "dualScatterplot",
95
95
  TREEMAP: "treemap",
96
96
  SAMPLE_SET_PAIR_MANAGER: "sampleSetPairManager",
97
- FEATURE_STATS_TABLE: "featureStatsTable"
97
+ FEATURE_STATS_TABLE: "featureStatsTable",
98
+ SINGLE_OBS_SET_SELECTOR: "singleObsSetSelector",
99
+ ANNOTATION_CONTROLLER: "annotationController"
98
100
  };
99
101
  const DataType$2 = {
100
102
  OBS_LABELS: "obsLabels",
@@ -115,7 +117,8 @@ const DataType$2 = {
115
117
  COMPARISON_METADATA: "comparisonMetadata",
116
118
  FEATURE_STATS: "featureStats",
117
119
  FEATURE_SET_STATS: "featureSetStats",
118
- OBS_SET_STATS: "obsSetStats"
120
+ OBS_SET_STATS: "obsSetStats",
121
+ ANNOTATION_STORY: "annotationStory"
119
122
  };
120
123
  const FileType$1 = {
121
124
  // Joint file types
@@ -137,6 +140,7 @@ const FileType$1 = {
137
140
  OBS_SETS_CSV: "obsSets.csv",
138
141
  OBS_SETS_JSON: "obsSets.json",
139
142
  SAMPLE_SETS_CSV: "sampleSets.csv",
143
+ ANNOTATION_STORY_JSON: "annotationStory.json",
140
144
  // OME-Zarr
141
145
  IMAGE_OME_ZARR: "image.ome-zarr",
142
146
  OBS_SEGMENTATIONS_OME_ZARR: "obsSegmentations.ome-zarr",
@@ -421,7 +425,15 @@ const CoordinationType$1 = {
421
425
  FEATURE_POINT_FOLD_CHANGE_THRESHOLD: "featurePointFoldChangeThreshold",
422
426
  FEATURE_LABEL_FOLD_CHANGE_THRESHOLD: "featureLabelFoldChangeThreshold",
423
427
  // Treemap
424
- HIERARCHY_LEVELS: "hierarchyLevels"
428
+ HIERARCHY_LEVELS: "hierarchyLevels",
429
+ // Annotation frames
430
+ ANNOTATION_STORY: "annotationStory",
431
+ ANNOTATION_FRAME_INDEX: "annotationFrameIndex",
432
+ ANNOTATION_SHAPES: "annotationShapes",
433
+ ANNOTATION_OVERLAY_VISIBLE: "annotationOverlayVisible",
434
+ ANNOTATION_TRANSITION_DURATION: "annotationTransitionDuration",
435
+ ANNOTATION_SEMANTIC_ZOOM: "annotationSemanticZoom",
436
+ ANNOTATION_EDITABLE: "annotationEditable"
425
437
  };
426
438
  ({
427
439
  // For new file types
@@ -437,6 +449,7 @@ const CoordinationType$1 = {
437
449
  [FileType$1.OBS_SEGMENTATIONS_JSON]: DataType$2.OBS_SEGMENTATIONS,
438
450
  [FileType$1.OBS_SETS_CSV]: DataType$2.OBS_SETS,
439
451
  [FileType$1.OBS_SETS_JSON]: DataType$2.OBS_SETS,
452
+ [FileType$1.ANNOTATION_STORY_JSON]: DataType$2.ANNOTATION_STORY,
440
453
  [FileType$1.IMAGE_OME_ZARR]: DataType$2.IMAGE,
441
454
  [FileType$1.OBS_SEGMENTATIONS_OME_ZARR]: DataType$2.OBS_SEGMENTATIONS,
442
455
  [FileType$1.OBS_FEATURE_MATRIX_ANNDATA_ZARR]: DataType$2.OBS_FEATURE_MATRIX,
@@ -559,7 +572,8 @@ const CoordinationType$1 = {
559
572
  [DataType$2.OBS_SET_STATS]: [
560
573
  CoordinationType$1.OBS_TYPE
561
574
  // TODO: should sampleType, obsSetSelection, and/or sampleSetSelection be used here?
562
- ]
575
+ ],
576
+ [DataType$2.ANNOTATION_STORY]: []
563
577
  });
564
578
  ({
565
579
  // For AnnData:
@@ -692,7 +706,9 @@ const CoordinationType$1 = {
692
706
  CoordinationType$1.SPATIAL_TARGET_Z,
693
707
  CoordinationType$1.SPATIAL_AXIS_FIXED,
694
708
  CoordinationType$1.SPATIAL_ORBIT_AXIS,
695
- CoordinationType$1.FEATURE_AGGREGATION_STRATEGY
709
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
710
+ // Annotation shapes are specific to a view's coordinate system.
711
+ CoordinationType$1.ANNOTATION_SHAPES
696
712
  ];
697
713
  ({
698
714
  [ViewType$1.NEUROGLANCER]: [
@@ -784,7 +800,14 @@ const CoordinationType$1 = {
784
800
  CoordinationType$1.EMBEDDING_CONTOURS_FILLED,
785
801
  CoordinationType$1.EMBEDDING_CONTOUR_PERCENTILES,
786
802
  CoordinationType$1.CONTOUR_COLOR_ENCODING,
787
- CoordinationType$1.CONTOUR_COLOR
803
+ CoordinationType$1.CONTOUR_COLOR,
804
+ CoordinationType$1.ANNOTATION_STORY,
805
+ CoordinationType$1.ANNOTATION_SHAPES,
806
+ CoordinationType$1.ANNOTATION_FRAME_INDEX,
807
+ CoordinationType$1.ANNOTATION_OVERLAY_VISIBLE,
808
+ CoordinationType$1.ANNOTATION_TRANSITION_DURATION,
809
+ CoordinationType$1.ANNOTATION_EDITABLE,
810
+ CoordinationType$1.ANNOTATION_SEMANTIC_ZOOM
788
811
  ],
789
812
  [ViewType$1.DUAL_SCATTERPLOT]: [
790
813
  CoordinationType$1.DATASET,
@@ -900,7 +923,14 @@ const CoordinationType$1 = {
900
923
  CoordinationType$1.ADDITIONAL_OBS_SETS,
901
924
  CoordinationType$1.MOLECULE_HIGHLIGHT,
902
925
  CoordinationType$1.TOOLTIPS_VISIBLE,
903
- CoordinationType$1.PHOTOMETRIC_INTERPRETATION
926
+ CoordinationType$1.PHOTOMETRIC_INTERPRETATION,
927
+ CoordinationType$1.ANNOTATION_STORY,
928
+ CoordinationType$1.ANNOTATION_SHAPES,
929
+ CoordinationType$1.ANNOTATION_FRAME_INDEX,
930
+ CoordinationType$1.ANNOTATION_OVERLAY_VISIBLE,
931
+ CoordinationType$1.ANNOTATION_TRANSITION_DURATION,
932
+ CoordinationType$1.ANNOTATION_EDITABLE,
933
+ CoordinationType$1.ANNOTATION_SEMANTIC_ZOOM
904
934
  ],
905
935
  [ViewType$1.SPATIAL_BETA]: [
906
936
  CoordinationType$1.META_COORDINATION_SCOPES,
@@ -978,7 +1008,27 @@ const CoordinationType$1 = {
978
1008
  CoordinationType$1.SPATIAL_CHANNEL_LABELS_ORIENTATION,
979
1009
  CoordinationType$1.SPATIAL_CHANNEL_LABEL_SIZE,
980
1010
  CoordinationType$1.SPATIAL_CHANNELS_SORT_ORDER,
981
- CoordinationType$1.PHOTOMETRIC_INTERPRETATION
1011
+ CoordinationType$1.PHOTOMETRIC_INTERPRETATION,
1012
+ CoordinationType$1.ANNOTATION_STORY,
1013
+ CoordinationType$1.ANNOTATION_SHAPES,
1014
+ CoordinationType$1.ANNOTATION_FRAME_INDEX,
1015
+ CoordinationType$1.ANNOTATION_OVERLAY_VISIBLE,
1016
+ CoordinationType$1.ANNOTATION_TRANSITION_DURATION,
1017
+ CoordinationType$1.ANNOTATION_EDITABLE,
1018
+ CoordinationType$1.ANNOTATION_SEMANTIC_ZOOM
1019
+ ],
1020
+ [ViewType$1.ANNOTATION_CONTROLLER]: [
1021
+ CoordinationType$1.DATASET,
1022
+ CoordinationType$1.ANNOTATION_STORY,
1023
+ CoordinationType$1.ANNOTATION_FRAME_INDEX,
1024
+ CoordinationType$1.ANNOTATION_OVERLAY_VISIBLE,
1025
+ CoordinationType$1.ANNOTATION_TRANSITION_DURATION,
1026
+ CoordinationType$1.ANNOTATION_EDITABLE,
1027
+ CoordinationType$1.ANNOTATION_SEMANTIC_ZOOM
1028
+ // Note: the annotation controller also needs to read the coordination state
1029
+ // of all other views/coordination types via the full config.
1030
+ // Note: we get/set the CoordinationType.ANNOTATION_SHAPES from the full config,
1031
+ // as this info is view-specific rather than global to the story.
982
1032
  ],
983
1033
  [ViewType$1.HEATMAP]: [
984
1034
  CoordinationType$1.DATASET,
@@ -1288,6 +1338,11 @@ const CoordinationType$1 = {
1288
1338
  CoordinationType$1.FEATURE_POINT_FOLD_CHANGE_THRESHOLD,
1289
1339
  CoordinationType$1.FEATURE_LABEL_FOLD_CHANGE_THRESHOLD
1290
1340
  ],
1341
+ [ViewType$1.SINGLE_OBS_SET_SELECTOR]: [
1342
+ CoordinationType$1.OBS_TYPE,
1343
+ CoordinationType$1.OBS_SET_COLOR,
1344
+ CoordinationType$1.OBS_SET_SELECTION
1345
+ ],
1291
1346
  [ViewType$1.OBS_SET_COMPOSITION_BAR_PLOT]: [
1292
1347
  CoordinationType$1.DATASET,
1293
1348
  CoordinationType$1.OBS_TYPE,
@@ -6122,7 +6177,7 @@ const latestFileDefSchema = z.object({
6122
6177
  options: fileOptionsSchema.optional(),
6123
6178
  requestInit: requestInit.optional(),
6124
6179
  // New: file def can have coordinationValues.
6125
- coordinationValues: z.record(z.string()).optional()
6180
+ coordinationValues: z.record(z.any()).optional()
6126
6181
  });
6127
6182
  const datasetsSchema1_0_13 = z.array(z.object({
6128
6183
  uid: z.string(),
@@ -6153,7 +6208,8 @@ const configSchema1_0_16 = configSchema1_0_13.extend({
6153
6208
  h: z.number().int().optional(),
6154
6209
  // Updates coordinationScopes and coordinationScopesBy
6155
6210
  coordinationScopes: componentCoordinationScopes.optional(),
6156
- coordinationScopesBy: componentCoordinationScopesBy.optional()
6211
+ coordinationScopesBy: componentCoordinationScopesBy.optional(),
6212
+ coordinationValues: z.record(z.any()).optional()
6157
6213
  }))
6158
6214
  });
6159
6215
  const configSchema1_0_17 = configSchema1_0_16.extend({
@@ -10286,6 +10342,124 @@ z.object({
10286
10342
  radius: z.number(),
10287
10343
  opacity: z.number()
10288
10344
  });
10345
+ const shapeBaseObj = z.object({
10346
+ uid: z.string(),
10347
+ text: z.string().optional(),
10348
+ strokeColor: z.array(z.number()).length(3).optional(),
10349
+ strokeWidth: z.number().optional(),
10350
+ // SVG-style dash pattern, e.g. "10 5" or "10 20 30 10". "none" or omitted = solid.
10351
+ strokeDashArray: z.string().optional(),
10352
+ visible: z.boolean().optional()
10353
+ // TODO: define unit modes for x and y axes
10354
+ // ("pixels" vs "normalized" vs "physical" etc.)
10355
+ // TODO: a coordinate system identifier (e.g., "DeckGL" for now,
10356
+ // but a coordinate system from OME-NGFF/SpatialData eventually?)
10357
+ });
10358
+ const rectangleShapeObj = shapeBaseObj.extend({
10359
+ type: z.literal("rectangle"),
10360
+ // OME-XML field names verbatim (upper-left origin)
10361
+ x: z.number(),
10362
+ y: z.number(),
10363
+ width: z.number(),
10364
+ height: z.number(),
10365
+ fillColor: z.array(z.number()).length(3).optional(),
10366
+ fillOpacity: z.number().optional()
10367
+ });
10368
+ const lineShapeObj = shapeBaseObj.extend({
10369
+ type: z.literal("line"),
10370
+ // OME-XML field names verbatim
10371
+ x1: z.number(),
10372
+ y1: z.number(),
10373
+ x2: z.number(),
10374
+ y2: z.number(),
10375
+ markerStart: z.enum(["Arrow", "Tick"]).nullable().optional(),
10376
+ markerEnd: z.enum(["Arrow", "Tick"]).nullable().optional(),
10377
+ textPosition: z.enum(["start", "middle", "end"]).optional(),
10378
+ textBufferPx: z.number().optional()
10379
+ });
10380
+ const ellipseShapeObj = shapeBaseObj.extend({
10381
+ type: z.literal("ellipse"),
10382
+ // OME-XML field names verbatim (centre point + radii)
10383
+ x1: z.number(),
10384
+ y1: z.number(),
10385
+ radiusX: z.number(),
10386
+ radiusY: z.number(),
10387
+ fillColor: z.array(z.number()).length(3).optional(),
10388
+ fillOpacity: z.number().optional()
10389
+ });
10390
+ const polygonShapeObj = shapeBaseObj.extend({
10391
+ type: z.literal("polygon"),
10392
+ // OME-XML: array of [x, y] coordinate pairs, closed automatically
10393
+ points: z.array(z.tuple([z.number(), z.number()])),
10394
+ fillColor: z.array(z.number()).length(3).optional(),
10395
+ fillOpacity: z.number().optional()
10396
+ });
10397
+ const polylineShapeObj = shapeBaseObj.extend({
10398
+ type: z.literal("polyline"),
10399
+ // OME-XML: array of [x, y] coordinate pairs, open (not closed)
10400
+ points: z.array(z.tuple([z.number(), z.number()])),
10401
+ markerStart: z.enum(["Arrow", "Tick"]).nullable().optional(),
10402
+ markerEnd: z.enum(["Arrow", "Tick"]).nullable().optional()
10403
+ });
10404
+ const annotationShapeObj = z.discriminatedUnion("type", [
10405
+ rectangleShapeObj,
10406
+ lineShapeObj,
10407
+ ellipseShapeObj,
10408
+ polygonShapeObj,
10409
+ polylineShapeObj
10410
+ ]);
10411
+ z.array(annotationShapeObj);
10412
+ const annotationFrameObj = z.object({
10413
+ uid: z.string(),
10414
+ title: z.string().optional(),
10415
+ description: z.string().optional(),
10416
+ descriptionType: z.enum(["text", "markdown"]).optional(),
10417
+ // A frame can define per-view: coordinationValues
10418
+ // (if the view's state should not be coordinated with other views)
10419
+ // or per-view coordinationScopes/coordinationScopesBy
10420
+ // (if at this frame, the view should be coordinated with other views).
10421
+ // We can also define a frame-level coordination space,
10422
+ // which will be merged with the global coordination space.
10423
+ // TODO: datasets
10424
+ // TODO: coordinationSpace
10425
+ layout: z.array(
10426
+ // Note: for now, we will infer view objects which have a uid
10427
+ // that is present in the global layout, and do NOT have x/y/w/h defined,
10428
+ // to mean that in this frame, the layout and set of views is unchanged
10429
+ // from the global layout.
10430
+ // This will allow each frame to omit the full list of views from the layout,
10431
+ // and only specify the views whose coordination state is changing in this frame.
10432
+ // If a frame includes a view with a uid that is not present
10433
+ // in the global layout, then that view will be added to the layout at this frame.
10434
+ // This frame should also define x/y/w/h for all views,
10435
+ // since it will otherwise be ambiguous how to layout the updated set of views
10436
+ // for this frame.
10437
+ z.object({
10438
+ // The view UID. If this view uid is not present in the global layout,
10439
+ // it will be added to the layout at this frame,
10440
+ // and will need to have its coordination values initialized to their defaults
10441
+ // for any that were not fully specified.
10442
+ uid: z.string(),
10443
+ coordinationValues: z.record(
10444
+ z.string(),
10445
+ // The coordination type name, e.g. "embeddingType"
10446
+ z.any()
10447
+ ).optional()
10448
+ // TODO: support coordinationScopes/coordinationScopesBy for per-view coordination
10449
+ // at this frame.
10450
+ // TODO: view x/y/w/h once we support view layout changes per-frame.
10451
+ })
10452
+ ).optional()
10453
+ });
10454
+ const annotationStoryObj = z.object({
10455
+ // TODO: schema version for the story schema?
10456
+ // Same as current Vitessce schema version?
10457
+ uid: z.string(),
10458
+ title: z.string().optional(),
10459
+ description: z.string().optional(),
10460
+ descriptionType: z.enum(["text", "markdown"]).optional(),
10461
+ frames: z.array(annotationFrameObj)
10462
+ });
10289
10463
  const coordSchema = z.array(z.number()).length(2);
10290
10464
  const cellsSchema = z.record(
10291
10465
  z.object({
@@ -14070,11 +14244,11 @@ function requireConcaveman() {
14070
14244
  while (node2) {
14071
14245
  for (var i2 = 0; i2 < node2.children.length; i2++) {
14072
14246
  var child = node2.children[i2];
14073
- var dist = node2.leaf ? sqSegDist(child, b, c) : sqSegBoxDist(b, c, child);
14074
- if (dist > maxDist) continue;
14247
+ var dist2 = node2.leaf ? sqSegDist(child, b, c) : sqSegBoxDist(b, c, child);
14248
+ if (dist2 > maxDist) continue;
14075
14249
  queue.push({
14076
14250
  node: child,
14077
- dist
14251
+ dist: dist2
14078
14252
  });
14079
14253
  }
14080
14254
  while (queue.length && !queue.peek().node.children) {
@@ -15553,6 +15727,24 @@ class ObsSetsJsonLoader extends JsonLoader {
15553
15727
  }, url, coordinationValues));
15554
15728
  }
15555
15729
  }
15730
+ class AnnotationStoryJsonLoader extends JsonLoader {
15731
+ constructor(dataSource, params) {
15732
+ super(dataSource, params);
15733
+ this.schema = annotationStoryObj;
15734
+ }
15735
+ async load() {
15736
+ if (this.cachedResult) {
15737
+ return this.cachedResult;
15738
+ }
15739
+ const payload = await super.load();
15740
+ const { data: annotationStory, url } = payload;
15741
+ const coordinationValues = {
15742
+ annotationStory
15743
+ };
15744
+ this.cachedResult = new LoaderResult({ annotationStory }, url, coordinationValues);
15745
+ return this.cachedResult;
15746
+ }
15747
+ }
15556
15748
  class CellsJsonAsObsEmbeddingLoader extends JsonLoader {
15557
15749
  constructor(dataSource, params) {
15558
15750
  super(dataSource, params);
@@ -16215,8 +16407,8 @@ class Vector extends MathArray {
16215
16407
  distanceSquared(mathArray) {
16216
16408
  let length2 = 0;
16217
16409
  for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
16218
- const dist = this[i2] - mathArray[i2];
16219
- length2 += dist * dist;
16410
+ const dist2 = this[i2] - mathArray[i2];
16411
+ length2 += dist2 * dist2;
16220
16412
  }
16221
16413
  return checkNumber(length2);
16222
16414
  }
@@ -16537,6 +16729,12 @@ function multiply$4(out, a2, b) {
16537
16729
  out[2] = a2[2] * b[2];
16538
16730
  return out;
16539
16731
  }
16732
+ function distance$3(a2, b) {
16733
+ var x = b[0] - a2[0];
16734
+ var y = b[1] - a2[1];
16735
+ var z2 = b[2] - a2[2];
16736
+ return Math.hypot(x, y, z2);
16737
+ }
16540
16738
  function squaredLength$2(a2) {
16541
16739
  var x = a2[0];
16542
16740
  var y = a2[1];
@@ -16660,6 +16858,7 @@ function angle$2(a2, b) {
16660
16858
  }
16661
16859
  var sub$1 = subtract$1;
16662
16860
  var mul$1 = multiply$4;
16861
+ var dist = distance$3;
16663
16862
  var len = length$4;
16664
16863
  var sqrLen = squaredLength$2;
16665
16864
  (function() {
@@ -56642,7 +56841,7 @@ function noop$2() {
56642
56841
  const getCursor = ({
56643
56842
  isDragging
56644
56843
  }) => isDragging ? "grabbing" : "grab";
56645
- const defaultProps$O = {
56844
+ const defaultProps$P = {
56646
56845
  id: "",
56647
56846
  width: "100%",
56648
56847
  height: "100%",
@@ -56773,7 +56972,7 @@ class Deck {
56773
56972
  this._lastPointerDownInfo = pickedInfo.result[0] || pickedInfo.emptyInfo;
56774
56973
  });
56775
56974
  this.props = {
56776
- ...defaultProps$O,
56975
+ ...defaultProps$P,
56777
56976
  ...props
56778
56977
  };
56779
56978
  props = this.props;
@@ -57275,7 +57474,7 @@ class Deck {
57275
57474
  metrics.gpuMemory = memoryStats.get("GPU Memory").count;
57276
57475
  }
57277
57476
  }
57278
- _defineProperty(Deck, "defaultProps", defaultProps$O);
57477
+ _defineProperty(Deck, "defaultProps", defaultProps$P);
57279
57478
  _defineProperty(Deck, "VERSION", deckGlobal.VERSION);
57280
57479
  class ShaderAttribute {
57281
57480
  constructor(dataColumn, opts) {
@@ -60030,7 +60229,7 @@ const areViewportsEqual = memoize$1(({
60030
60229
  return oldViewport.equals(viewport);
60031
60230
  });
60032
60231
  let pickingColorCache = new Uint8ClampedArray(0);
60033
- const defaultProps$N = {
60232
+ const defaultProps$O = {
60034
60233
  data: {
60035
60234
  type: "data",
60036
60235
  value: EMPTY_ARRAY$1,
@@ -60905,7 +61104,7 @@ class Layer extends Component {
60905
61104
  this.setNeedsUpdate();
60906
61105
  }
60907
61106
  }
60908
- _defineProperty(Layer, "defaultProps", defaultProps$N);
61107
+ _defineProperty(Layer, "defaultProps", defaultProps$O);
60909
61108
  _defineProperty(Layer, "layerName", "Layer");
60910
61109
  const TRACE_RENDER_LAYERS = "compositeLayer.renderLayers";
60911
61110
  class CompositeLayer extends Layer {
@@ -61941,6 +62140,124 @@ const esm$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
61941
62140
  project32,
61942
62141
  shadow
61943
62142
  }, Symbol.toStringTag, { value: "Module" }));
62143
+ const dashShaders = {
62144
+ inject: {
62145
+ "vs:#decl": "\nattribute vec2 instanceDashArrays;\nattribute float instanceDashOffsets;\nvarying vec2 vDashArray;\nvarying float vDashOffset;\n",
62146
+ "vs:#main-end": "\nvDashArray = instanceDashArrays;\nvDashOffset = instanceDashOffsets / width.x;\n",
62147
+ "fs:#decl": "\nuniform float dashAlignMode;\nuniform float capType;\nuniform bool dashGapPickable;\nvarying vec2 vDashArray;\nvarying float vDashOffset;\n\nfloat round(float x) {\n return floor(x + 0.5);\n}\n",
62148
+ "fs:#main-start": "\n float solidLength = vDashArray.x;\n float gapLength = vDashArray.y;\n float unitLength = solidLength + gapLength;\n\n float offset;\n\n if (unitLength > 0.0) {\n if (dashAlignMode == 0.0) {\n offset = vDashOffset;\n } else {\n unitLength = vPathLength / round(vPathLength / unitLength);\n offset = solidLength / 2.0;\n }\n\n float unitOffset = mod(clamp(vPathPosition.y, 0.0, vPathLength) + offset, unitLength);\n\n if (gapLength > 0.0 && unitOffset > solidLength) {\n if (capType <= 0.5) {\n if (!(dashGapPickable && picking_uActive)) {\n discard;\n }\n } else {\n // caps are rounded, test the distance to solid ends\n float distToEnd = length(vec2(\n min(unitOffset - solidLength, unitLength - unitOffset),\n vPathPosition.x\n ));\n if (distToEnd > 1.0) {\n if (!(dashGapPickable && picking_uActive)) {\n discard;\n }\n }\n }\n }\n }\n"
62149
+ }
62150
+ };
62151
+ const offsetShaders = {
62152
+ inject: {
62153
+ "vs:#decl": "\nattribute float instanceOffsets;\n",
62154
+ "vs:DECKGL_FILTER_SIZE": "\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n size *= offsetWidth;\n",
62155
+ "vCornerOffset = offsetVec;": "\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n vec2 offsetCenter = -instanceOffsets * (isCap ? perp : miterVec * miterSize) * 2.0;\n vCornerOffset = vCornerOffset * offsetWidth - offsetCenter;\n",
62156
+ "fs:#main-start": "\n float isInside;\n isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);\n if (isInside == 0.0) {\n discard;\n }\n"
62157
+ }
62158
+ };
62159
+ const defaultProps$N = {
62160
+ getDashArray: {
62161
+ type: "accessor",
62162
+ value: [0, 0]
62163
+ },
62164
+ getOffset: {
62165
+ type: "accessor",
62166
+ value: 0
62167
+ },
62168
+ dashJustified: false,
62169
+ dashGapPickable: false
62170
+ };
62171
+ class PathStyleExtension extends LayerExtension {
62172
+ constructor({
62173
+ dash = false,
62174
+ offset = false,
62175
+ highPrecisionDash = false
62176
+ } = {}) {
62177
+ super({
62178
+ dash: dash || highPrecisionDash,
62179
+ offset,
62180
+ highPrecisionDash
62181
+ });
62182
+ }
62183
+ isEnabled(layer) {
62184
+ return "pathTesselator" in layer.state;
62185
+ }
62186
+ getShaders(extension) {
62187
+ if (!extension.isEnabled(this)) {
62188
+ return null;
62189
+ }
62190
+ let result = {};
62191
+ if (extension.opts.dash) {
62192
+ result = mergeShaders(result, dashShaders);
62193
+ }
62194
+ if (extension.opts.offset) {
62195
+ result = mergeShaders(result, offsetShaders);
62196
+ }
62197
+ return result;
62198
+ }
62199
+ initializeState(context, extension) {
62200
+ const attributeManager = this.getAttributeManager();
62201
+ if (!attributeManager || !extension.isEnabled(this)) {
62202
+ return;
62203
+ }
62204
+ if (extension.opts.dash) {
62205
+ attributeManager.addInstanced({
62206
+ instanceDashArrays: {
62207
+ size: 2,
62208
+ accessor: "getDashArray"
62209
+ }
62210
+ });
62211
+ }
62212
+ if (extension.opts.highPrecisionDash) {
62213
+ attributeManager.addInstanced({
62214
+ instanceDashOffsets: {
62215
+ size: 1,
62216
+ accessor: "getPath",
62217
+ transform: extension.getDashOffsets.bind(this)
62218
+ }
62219
+ });
62220
+ }
62221
+ if (extension.opts.offset) {
62222
+ attributeManager.addInstanced({
62223
+ instanceOffsets: {
62224
+ size: 1,
62225
+ accessor: "getOffset"
62226
+ }
62227
+ });
62228
+ }
62229
+ }
62230
+ updateState(params, extension) {
62231
+ if (!extension.isEnabled(this)) {
62232
+ return;
62233
+ }
62234
+ const uniforms = {};
62235
+ if (extension.opts.dash) {
62236
+ uniforms.dashAlignMode = this.props.dashJustified ? 1 : 0;
62237
+ uniforms.dashGapPickable = Boolean(this.props.dashGapPickable);
62238
+ }
62239
+ this.state.model.setUniforms(uniforms);
62240
+ }
62241
+ getDashOffsets(path) {
62242
+ const result = [0];
62243
+ const positionSize = this.props.positionFormat === "XY" ? 2 : 3;
62244
+ const isNested2 = Array.isArray(path[0]);
62245
+ const geometrySize = isNested2 ? path.length : path.length / positionSize;
62246
+ let p;
62247
+ let prevP;
62248
+ for (let i2 = 0; i2 < geometrySize - 1; i2++) {
62249
+ p = isNested2 ? path[i2] : path.slice(i2 * positionSize, i2 * positionSize + positionSize);
62250
+ p = this.projectPosition(p);
62251
+ if (i2 > 0) {
62252
+ result[i2] = result[i2 - 1] + dist(prevP, p);
62253
+ }
62254
+ prevP = p;
62255
+ }
62256
+ return result;
62257
+ }
62258
+ }
62259
+ _defineProperty(PathStyleExtension, "defaultProps", defaultProps$N);
62260
+ _defineProperty(PathStyleExtension, "extensionName", "PathStyleExtension");
61944
62261
  const defaultProps$M = {
61945
62262
  clipBounds: [0, 0, 1, 1]
61946
62263
  };
@@ -117646,8 +117963,8 @@ function requireJs$b() {
117646
117963
  var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi12 / 2 + Math.PI / 4));
117647
117964
  var q = Math.abs(DeltaPsi) > 1e-11 ? DeltaPhi / DeltaPsi : Math.cos(phi12);
117648
117965
  var delta = Math.sqrt(DeltaPhi * DeltaPhi + q * q * DeltaLambda * DeltaLambda);
117649
- var dist = delta * R;
117650
- return dist;
117966
+ var dist2 = delta * R;
117967
+ return dist2;
117651
117968
  }
117652
117969
  js$a.default = rhumbDistance;
117653
117970
  return js$a;
@@ -117960,7 +118277,7 @@ function requireUtils$2() {
117960
118277
  var x;
117961
118278
  var y;
117962
118279
  var segmentIdx;
117963
- var dist;
118280
+ var dist2;
117964
118281
  if (coords.length > 1 && pointCoords.length) {
117965
118282
  var lineCoordinates;
117966
118283
  var pointCoordinate;
@@ -117977,17 +118294,17 @@ function requireUtils$2() {
117977
118294
  if (lineCoordinates[n3][0] !== lineCoordinates[n3 - 1][0]) {
117978
118295
  var slope = (lineCoordinates[n3][1] - lineCoordinates[n3 - 1][1]) / (lineCoordinates[n3][0] - lineCoordinates[n3 - 1][0]);
117979
118296
  var inverseSlope = lineCoordinates[n3][1] - slope * lineCoordinates[n3][0];
117980
- dist = Math.abs(slope * pointCoordinate[0] + inverseSlope - pointCoordinate[1]) / Math.sqrt(slope * slope + 1);
117981
- } else dist = Math.abs(pointCoordinate[0] - lineCoordinates[n3][0]);
118297
+ dist2 = Math.abs(slope * pointCoordinate[0] + inverseSlope - pointCoordinate[1]) / Math.sqrt(slope * slope + 1);
118298
+ } else dist2 = Math.abs(pointCoordinate[0] - lineCoordinates[n3][0]);
117982
118299
  var rl2 = Math.pow(lineCoordinates[n3][1] - lineCoordinates[n3 - 1][1], 2) + Math.pow(lineCoordinates[n3][0] - lineCoordinates[n3 - 1][0], 2);
117983
118300
  var ln2 = Math.pow(lineCoordinates[n3][1] - pointCoordinate[1], 2) + Math.pow(lineCoordinates[n3][0] - pointCoordinate[0], 2);
117984
118301
  var lnm12 = Math.pow(lineCoordinates[n3 - 1][1] - pointCoordinate[1], 2) + Math.pow(lineCoordinates[n3 - 1][0] - pointCoordinate[0], 2);
117985
- var dist2 = Math.pow(dist, 2);
117986
- var calcrl2 = ln2 - dist2 + lnm12 - dist2;
118302
+ var dist22 = Math.pow(dist2, 2);
118303
+ var calcrl2 = ln2 - dist22 + lnm12 - dist22;
117987
118304
  if (calcrl2 > rl2) {
117988
- dist = Math.sqrt(Math.min(ln2, lnm12));
118305
+ dist2 = Math.sqrt(Math.min(ln2, lnm12));
117989
118306
  }
117990
- if (minDist === null || minDist === void 0 || minDist > dist) {
118307
+ if (minDist === null || minDist === void 0 || minDist > dist2) {
117991
118308
  if (calcrl2 > rl2) {
117992
118309
  if (lnm12 < ln2) {
117993
118310
  to = 0;
@@ -117997,10 +118314,10 @@ function requireUtils$2() {
117997
118314
  to = 1;
117998
118315
  }
117999
118316
  } else {
118000
- to = Math.sqrt(lnm12 - dist2) / Math.sqrt(rl2);
118001
- from = Math.sqrt(ln2 - dist2) / Math.sqrt(rl2);
118317
+ to = Math.sqrt(lnm12 - dist22) / Math.sqrt(rl2);
118318
+ from = Math.sqrt(ln2 - dist22) / Math.sqrt(rl2);
118002
118319
  }
118003
- minDist = dist;
118320
+ minDist = dist2;
118004
118321
  segmentIdx = n3;
118005
118322
  }
118006
118323
  }
@@ -134939,22 +135256,22 @@ async function getDecoder(fileDirectory) {
134939
135256
  const Decoder = await importFn();
134940
135257
  return new Decoder(fileDirectory);
134941
135258
  }
134942
- addDecoder([void 0, 1], () => import("./raw-BgXNT663.js").then((m) => m.default));
134943
- addDecoder(5, () => import("./lzw-CD9kTc69.js").then((m) => m.default));
135259
+ addDecoder([void 0, 1], () => import("./raw-DrKGleEE.js").then((m) => m.default));
135260
+ addDecoder(5, () => import("./lzw-Cn4MHMg0.js").then((m) => m.default));
134944
135261
  addDecoder(6, () => {
134945
135262
  throw new Error("old style JPEG compression is not supported.");
134946
135263
  });
134947
- addDecoder(7, () => import("./jpeg-gwkCEYa9.js").then((m) => m.default));
134948
- addDecoder([8, 32946], () => import("./deflate-ESHkuhOQ.js").then((m) => m.default));
134949
- addDecoder(32773, () => import("./packbits-vQncyXH1.js").then((m) => m.default));
135264
+ addDecoder(7, () => import("./jpeg-DYOBxHhT.js").then((m) => m.default));
135265
+ addDecoder([8, 32946], () => import("./deflate-B9yQXNA5.js").then((m) => m.default));
135266
+ addDecoder(32773, () => import("./packbits-3K31MqMe.js").then((m) => m.default));
134950
135267
  addDecoder(
134951
135268
  34887,
134952
- () => import("./lerc-LHTQh1pB.js").then(async (m) => {
135269
+ () => import("./lerc-CXBCb2wB.js").then(async (m) => {
134953
135270
  await m.zstd.init();
134954
135271
  return m;
134955
135272
  }).then((m) => m.default)
134956
135273
  );
134957
- addDecoder(50001, () => import("./webimage-DMF58_l5.js").then((m) => m.default));
135274
+ addDecoder(50001, () => import("./webimage-MBv_oDxF.js").then((m) => m.default));
134958
135275
  function copyNewSize(array, width, height, samplesPerPixel = 1) {
134959
135276
  return new (Object.getPrototypeOf(array)).constructor(width * height * samplesPerPixel);
134960
135277
  }
@@ -138007,8 +138324,8 @@ function TreeDesc(dyn_tree, stat_desc) {
138007
138324
  this.max_code = 0;
138008
138325
  this.stat_desc = stat_desc;
138009
138326
  }
138010
- const d_code = (dist) => {
138011
- return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];
138327
+ const d_code = (dist2) => {
138328
+ return dist2 < 256 ? _dist_code[dist2] : _dist_code[256 + (dist2 >>> 7)];
138012
138329
  };
138013
138330
  const put_short = (s2, w2) => {
138014
138331
  s2.pending_buf[s2.pending++] = w2 & 255;
@@ -138142,7 +138459,7 @@ const tr_static_init = () => {
138142
138459
  let bits;
138143
138460
  let length2;
138144
138461
  let code;
138145
- let dist;
138462
+ let dist2;
138146
138463
  const bl_count = new Array(MAX_BITS + 1);
138147
138464
  length2 = 0;
138148
138465
  for (code = 0; code < LENGTH_CODES - 1; code++) {
@@ -138152,18 +138469,18 @@ const tr_static_init = () => {
138152
138469
  }
138153
138470
  }
138154
138471
  _length_code[length2 - 1] = code;
138155
- dist = 0;
138472
+ dist2 = 0;
138156
138473
  for (code = 0; code < 16; code++) {
138157
- base_dist[code] = dist;
138474
+ base_dist[code] = dist2;
138158
138475
  for (n3 = 0; n3 < 1 << extra_dbits[code]; n3++) {
138159
- _dist_code[dist++] = code;
138476
+ _dist_code[dist2++] = code;
138160
138477
  }
138161
138478
  }
138162
- dist >>= 7;
138479
+ dist2 >>= 7;
138163
138480
  for (; code < D_CODES; code++) {
138164
- base_dist[code] = dist << 7;
138481
+ base_dist[code] = dist2 << 7;
138165
138482
  for (n3 = 0; n3 < 1 << extra_dbits[code] - 7; n3++) {
138166
- _dist_code[256 + dist++] = code;
138483
+ _dist_code[256 + dist2++] = code;
138167
138484
  }
138168
138485
  }
138169
138486
  for (bits = 0; bits <= MAX_BITS; bits++) {
@@ -138254,17 +138571,17 @@ const pqdownheap = (s2, tree, k) => {
138254
138571
  s2.heap[k] = v;
138255
138572
  };
138256
138573
  const compress_block = (s2, ltree, dtree) => {
138257
- let dist;
138574
+ let dist2;
138258
138575
  let lc;
138259
138576
  let lx = 0;
138260
138577
  let code;
138261
138578
  let extra;
138262
138579
  if (s2.last_lit !== 0) {
138263
138580
  do {
138264
- dist = s2.pending_buf[s2.d_buf + lx * 2] << 8 | s2.pending_buf[s2.d_buf + lx * 2 + 1];
138581
+ dist2 = s2.pending_buf[s2.d_buf + lx * 2] << 8 | s2.pending_buf[s2.d_buf + lx * 2 + 1];
138265
138582
  lc = s2.pending_buf[s2.l_buf + lx];
138266
138583
  lx++;
138267
- if (dist === 0) {
138584
+ if (dist2 === 0) {
138268
138585
  send_code(s2, lc, ltree);
138269
138586
  } else {
138270
138587
  code = _length_code[lc];
@@ -138274,13 +138591,13 @@ const compress_block = (s2, ltree, dtree) => {
138274
138591
  lc -= base_length[code];
138275
138592
  send_bits(s2, lc, extra);
138276
138593
  }
138277
- dist--;
138278
- code = d_code(dist);
138594
+ dist2--;
138595
+ code = d_code(dist2);
138279
138596
  send_code(s2, code, dtree);
138280
138597
  extra = extra_dbits[code];
138281
138598
  if (extra !== 0) {
138282
- dist -= base_dist[code];
138283
- send_bits(s2, dist, extra);
138599
+ dist2 -= base_dist[code];
138600
+ send_bits(s2, dist2, extra);
138284
138601
  }
138285
138602
  }
138286
138603
  } while (lx < s2.last_lit);
@@ -138551,18 +138868,18 @@ const _tr_flush_block = (s2, buf, stored_len, last) => {
138551
138868
  bi_windup(s2);
138552
138869
  }
138553
138870
  };
138554
- const _tr_tally = (s2, dist, lc) => {
138555
- s2.pending_buf[s2.d_buf + s2.last_lit * 2] = dist >>> 8 & 255;
138556
- s2.pending_buf[s2.d_buf + s2.last_lit * 2 + 1] = dist & 255;
138871
+ const _tr_tally = (s2, dist2, lc) => {
138872
+ s2.pending_buf[s2.d_buf + s2.last_lit * 2] = dist2 >>> 8 & 255;
138873
+ s2.pending_buf[s2.d_buf + s2.last_lit * 2 + 1] = dist2 & 255;
138557
138874
  s2.pending_buf[s2.l_buf + s2.last_lit] = lc & 255;
138558
138875
  s2.last_lit++;
138559
- if (dist === 0) {
138876
+ if (dist2 === 0) {
138560
138877
  s2.dyn_ltree[lc * 2]++;
138561
138878
  } else {
138562
138879
  s2.matches++;
138563
- dist--;
138880
+ dist2--;
138564
138881
  s2.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]++;
138565
- s2.dyn_dtree[d_code(dist) * 2]++;
138882
+ s2.dyn_dtree[d_code(dist2) * 2]++;
138566
138883
  }
138567
138884
  return s2.last_lit === s2.lit_bufsize - 1;
138568
138885
  };
@@ -140067,7 +140384,7 @@ var inffast = function inflate_fast(strm, start) {
140067
140384
  let here;
140068
140385
  let op;
140069
140386
  let len2;
140070
- let dist;
140387
+ let dist2;
140071
140388
  let from;
140072
140389
  let from_source;
140073
140390
  let input, output;
@@ -140133,7 +140450,7 @@ var inffast = function inflate_fast(strm, start) {
140133
140450
  bits -= op;
140134
140451
  op = here >>> 16 & 255;
140135
140452
  if (op & 16) {
140136
- dist = here & 65535;
140453
+ dist2 = here & 65535;
140137
140454
  op &= 15;
140138
140455
  if (bits < op) {
140139
140456
  hold += input[_in++] << bits;
@@ -140143,8 +140460,8 @@ var inffast = function inflate_fast(strm, start) {
140143
140460
  bits += 8;
140144
140461
  }
140145
140462
  }
140146
- dist += hold & (1 << op) - 1;
140147
- if (dist > dmax) {
140463
+ dist2 += hold & (1 << op) - 1;
140464
+ if (dist2 > dmax) {
140148
140465
  strm.msg = "invalid distance too far back";
140149
140466
  state.mode = BAD;
140150
140467
  break top;
@@ -140152,8 +140469,8 @@ var inffast = function inflate_fast(strm, start) {
140152
140469
  hold >>>= op;
140153
140470
  bits -= op;
140154
140471
  op = _out - beg;
140155
- if (dist > op) {
140156
- op = dist - op;
140472
+ if (dist2 > op) {
140473
+ op = dist2 - op;
140157
140474
  if (op > whave) {
140158
140475
  if (state.sane) {
140159
140476
  strm.msg = "invalid distance too far back";
@@ -140170,7 +140487,7 @@ var inffast = function inflate_fast(strm, start) {
140170
140487
  do {
140171
140488
  output[_out++] = s_window[from++];
140172
140489
  } while (--op);
140173
- from = _out - dist;
140490
+ from = _out - dist2;
140174
140491
  from_source = output;
140175
140492
  }
140176
140493
  } else if (wnext < op) {
@@ -140188,7 +140505,7 @@ var inffast = function inflate_fast(strm, start) {
140188
140505
  do {
140189
140506
  output[_out++] = s_window[from++];
140190
140507
  } while (--op);
140191
- from = _out - dist;
140508
+ from = _out - dist2;
140192
140509
  from_source = output;
140193
140510
  }
140194
140511
  }
@@ -140199,7 +140516,7 @@ var inffast = function inflate_fast(strm, start) {
140199
140516
  do {
140200
140517
  output[_out++] = s_window[from++];
140201
140518
  } while (--op);
140202
- from = _out - dist;
140519
+ from = _out - dist2;
140203
140520
  from_source = output;
140204
140521
  }
140205
140522
  }
@@ -140216,7 +140533,7 @@ var inffast = function inflate_fast(strm, start) {
140216
140533
  }
140217
140534
  }
140218
140535
  } else {
140219
- from = _out - dist;
140536
+ from = _out - dist2;
140220
140537
  do {
140221
140538
  output[_out++] = output[from++];
140222
140539
  output[_out++] = output[from++];
@@ -140774,7 +141091,7 @@ const fixedtables = (state) => {
140774
141091
  state.distbits = 5;
140775
141092
  };
140776
141093
  const updatewindow = (strm, src, end, copy2) => {
140777
- let dist;
141094
+ let dist2;
140778
141095
  const state = strm.state;
140779
141096
  if (state.window === null) {
140780
141097
  state.wsize = 1 << state.wbits;
@@ -140787,23 +141104,23 @@ const updatewindow = (strm, src, end, copy2) => {
140787
141104
  state.wnext = 0;
140788
141105
  state.whave = state.wsize;
140789
141106
  } else {
140790
- dist = state.wsize - state.wnext;
140791
- if (dist > copy2) {
140792
- dist = copy2;
141107
+ dist2 = state.wsize - state.wnext;
141108
+ if (dist2 > copy2) {
141109
+ dist2 = copy2;
140793
141110
  }
140794
- state.window.set(src.subarray(end - copy2, end - copy2 + dist), state.wnext);
140795
- copy2 -= dist;
141111
+ state.window.set(src.subarray(end - copy2, end - copy2 + dist2), state.wnext);
141112
+ copy2 -= dist2;
140796
141113
  if (copy2) {
140797
141114
  state.window.set(src.subarray(end - copy2, end), 0);
140798
141115
  state.wnext = copy2;
140799
141116
  state.whave = state.wsize;
140800
141117
  } else {
140801
- state.wnext += dist;
141118
+ state.wnext += dist2;
140802
141119
  if (state.wnext === state.wsize) {
140803
141120
  state.wnext = 0;
140804
141121
  }
140805
141122
  if (state.whave < state.wsize) {
140806
- state.whave += dist;
141123
+ state.whave += dist2;
140807
141124
  }
140808
141125
  }
140809
141126
  }
@@ -145444,7 +145761,7 @@ function padColors({ colors, channelsVisible }) {
145444
145761
  ).reduce((acc, val) => acc.concat(val), []);
145445
145762
  return paddedColors;
145446
145763
  }
145447
- const defaultProps$3$1 = {
145764
+ const defaultProps$3$2 = {
145448
145765
  colors: { type: "array", value: null, compare: true },
145449
145766
  opacity: { type: "number", value: 1, compare: true },
145450
145767
  transparentColor: { type: "array", value: null, compare: true },
@@ -145461,9 +145778,9 @@ const ColorPaletteExtension = class extends LayerExtension {
145461
145778
  const {
145462
145779
  colors,
145463
145780
  channelsVisible,
145464
- opacity = defaultProps$3$1.opacity.value,
145465
- transparentColor = defaultProps$3$1.transparentColor.value,
145466
- useTransparentColor = defaultProps$3$1.useTransparentColor.value
145781
+ opacity = defaultProps$3$2.opacity.value,
145782
+ transparentColor = defaultProps$3$2.transparentColor.value,
145783
+ useTransparentColor = defaultProps$3$2.useTransparentColor.value
145467
145784
  } = this.props;
145468
145785
  const paddedColors = padColors({
145469
145786
  channelsVisible: channelsVisible || this.selections.map(() => true),
@@ -145479,7 +145796,7 @@ const ColorPaletteExtension = class extends LayerExtension {
145479
145796
  }
145480
145797
  };
145481
145798
  ColorPaletteExtension.extensionName = "ColorPaletteExtension";
145482
- ColorPaletteExtension.defaultProps = defaultProps$3$1;
145799
+ ColorPaletteExtension.defaultProps = defaultProps$3$2;
145483
145800
  const fs$4 = `// lens bounds for ellipse
145484
145801
  uniform float majorLensAxis;
145485
145802
  uniform float minorLensAxis;
@@ -146774,7 +147091,7 @@ const MultiscaleImageLayer = class extends CompositeLayer {
146774
147091
  };
146775
147092
  MultiscaleImageLayer.layerName = "MultiscaleImageLayer";
146776
147093
  MultiscaleImageLayer.defaultProps = defaultProps$4;
146777
- const defaultProps$3 = {
147094
+ const defaultProps$3$1 = {
146778
147095
  pickable: { type: "boolean", value: true, compare: true },
146779
147096
  loader: {
146780
147097
  type: "object",
@@ -146861,7 +147178,7 @@ const OverviewLayer = class extends CompositeLayer {
146861
147178
  }
146862
147179
  };
146863
147180
  OverviewLayer.layerName = "OverviewLayer";
146864
- OverviewLayer.defaultProps = defaultProps$3;
147181
+ OverviewLayer.defaultProps = defaultProps$3$1;
146865
147182
  function getPosition(boundingBox, position, length2) {
146866
147183
  const viewWidth = boundingBox[2][0] - boundingBox[0][0];
146867
147184
  const viewHeight = boundingBox[2][1] - boundingBox[0][1];
@@ -147849,7 +148166,7 @@ function padWithDefault$1(arr, defaultValue2, padWidth) {
147849
148166
  }
147850
148167
  return newArr;
147851
148168
  }
147852
- const defaultProps$2 = {
148169
+ const defaultProps$3 = {
147853
148170
  hoveredCell: { type: "number", value: null, compare: true },
147854
148171
  // We do not want to deep-compare cellColorData,
147855
148172
  // as it is potentially a TypedArray with millions of elements.
@@ -147966,7 +148283,7 @@ let BitmaskLayer$1 = class BitmaskLayer extends XRLayer {
147966
148283
  }
147967
148284
  };
147968
148285
  BitmaskLayer$1.layerName = "BitmaskLayer";
147969
- BitmaskLayer$1.defaultProps = defaultProps$2;
148286
+ BitmaskLayer$1.defaultProps = defaultProps$3;
147970
148287
  const vs = `
147971
148288
  #define SHADER_NAME bitmask-layer-vertex-shader
147972
148289
 
@@ -148308,7 +148625,7 @@ function isEqualShallow(prevArr, nextArr) {
148308
148625
  }
148309
148626
  return prevArr === nextArr;
148310
148627
  }
148311
- const defaultProps$1 = {
148628
+ const defaultProps$2 = {
148312
148629
  channelStrokeWidths: { type: "array", value: null, compare: true },
148313
148630
  channelsFilled: { type: "array", value: null, compare: true },
148314
148631
  channelOpacities: { type: "array", value: null, compare: true },
@@ -148572,7 +148889,7 @@ class BitmaskLayer2 extends XRLayer {
148572
148889
  }
148573
148890
  }
148574
148891
  BitmaskLayer2.layerName = "BitmaskLayer";
148575
- BitmaskLayer2.defaultProps = defaultProps$1;
148892
+ BitmaskLayer2.defaultProps = defaultProps$2;
148576
148893
  var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, mathceil = Math.ceil, mathfloor = Math.floor, bignumberError = "[BigNumber Error] ", tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ", BASE = 1e14, LOG_BASE = 14, MAX_SAFE_INTEGER = 9007199254740991, POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], SQRT_BASE = 1e7, MAX = 1e9;
148577
148894
  function clone(configObject) {
148578
148895
  var div2, convertBase2, parseNumeric, P2 = BigNumber2.prototype = { constructor: BigNumber2, toString: null, valueOf: null }, ONE = new BigNumber2(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
@@ -151515,7 +151832,7 @@ function ringArea(coords) {
151515
151832
  return total * FACTOR;
151516
151833
  }
151517
151834
  const DEFAULT_THRESHOLD = 1;
151518
- const defaultProps = {
151835
+ const defaultProps$1 = {
151519
151836
  // for text
151520
151837
  obsSetPath: { type: "object" },
151521
151838
  sampleSetPath: { type: "object" },
@@ -151610,9 +151927,9 @@ class ContourLayerWithText extends ContourLayer {
151610
151927
  const circlePoint = point(circleCoord);
151611
151928
  polygonVertices.forEach((polyCoord) => {
151612
151929
  const polyPoint = point(polyCoord);
151613
- const dist = distance$1(circlePoint, polyPoint);
151614
- if (dist < minDist) {
151615
- minDist = dist;
151930
+ const dist2 = distance$1(circlePoint, polyPoint);
151931
+ if (dist2 < minDist) {
151932
+ minDist = dist2;
151616
151933
  minCirclePoint = circleCoord;
151617
151934
  minCirclePointI = circlePointI;
151618
151935
  minPolygonPoint = polyCoord;
@@ -151689,7 +152006,1077 @@ class ContourLayerWithText extends ContourLayer {
151689
152006
  }
151690
152007
  }
151691
152008
  ContourLayerWithText.layerName = "ContourLayerWithText";
151692
- ContourLayerWithText.defaultProps = defaultProps;
152009
+ ContourLayerWithText.defaultProps = defaultProps$1;
152010
+ const ARROW_SCREEN_PX = 14;
152011
+ const LABEL_FONT_FAMILY = '"Roboto", "Helvetica", "Arial", sans-serif';
152012
+ const LABEL_FONT_WEIGHT = "bold";
152013
+ const LABEL_FONT_SIZE = 14;
152014
+ const RATIO_CLUSTER = 0.1;
152015
+ const RATIO_DOT = 0.3;
152016
+ const RATIO_GEO_FADE = 0.55;
152017
+ const RATIO_TIPS = 0.7;
152018
+ const RATIO_LABEL = 0.55;
152019
+ const RATIO_LABEL_FULL = 0.75;
152020
+ function textBgColor(strokeColor) {
152021
+ const [r2, g2, b] = strokeColor;
152022
+ const lum = (0.299 * r2 + 0.587 * g2 + 0.114 * b) / 255;
152023
+ return lum > 0.45 ? [20, 20, 20, 210] : [245, 245, 245, 210];
152024
+ }
152025
+ function parseDashArray(strokeDashArray) {
152026
+ if (!strokeDashArray || strokeDashArray === "none")
152027
+ return null;
152028
+ const nums = strokeDashArray.trim().split(/\s+/).map(Number).filter((n3) => !Number.isNaN(n3) && n3 >= 0);
152029
+ return nums.length >= 2 ? [nums[0], nums[1]] : null;
152030
+ }
152031
+ function computeEllipsePolygon(cx, cy, rx, ry, numSegments = 64) {
152032
+ const pts = [];
152033
+ for (let i2 = 0; i2 < numSegments; i2++) {
152034
+ const angle2 = 2 * Math.PI * i2 / numSegments;
152035
+ pts.push([cx + rx * Math.cos(angle2), cy + ry * Math.sin(angle2)]);
152036
+ }
152037
+ return pts;
152038
+ }
152039
+ function createPreviewLayer(inProgress, hoverCoord, strokeColor = [255, 255, 0]) {
152040
+ if (!inProgress || inProgress.vertices.length === 0)
152041
+ return null;
152042
+ const { type, vertices } = inProgress;
152043
+ const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN };
152044
+ const previewColor = [...strokeColor, 160];
152045
+ const cursor = hoverCoord ?? vertices[vertices.length - 1];
152046
+ if (type === "rectangle" && vertices.length === 1) {
152047
+ const [ax, ay] = vertices[0];
152048
+ const [bx, by] = cursor;
152049
+ const path = [[ax, ay], [bx, ay], [bx, by], [ax, by], [ax, ay]];
152050
+ return new PathLayer({
152051
+ ...base,
152052
+ id: "annotation-preview-rectangle",
152053
+ data: [{ path }],
152054
+ getPath: (d) => d.path,
152055
+ getColor: previewColor,
152056
+ getWidth: 1,
152057
+ widthUnits: "pixels",
152058
+ extensions: [new PathStyleExtension({ dash: true })],
152059
+ getDashArray: [8, 4]
152060
+ });
152061
+ }
152062
+ if (type === "line" && vertices.length === 1) {
152063
+ const path = [vertices[0], cursor];
152064
+ return new PathLayer({
152065
+ ...base,
152066
+ id: "annotation-preview-line",
152067
+ data: [{ path }],
152068
+ getPath: (d) => d.path,
152069
+ getColor: previewColor,
152070
+ getWidth: 1,
152071
+ widthUnits: "pixels",
152072
+ extensions: [new PathStyleExtension({ dash: true })],
152073
+ getDashArray: [8, 4]
152074
+ });
152075
+ }
152076
+ if (type === "ellipse" && vertices.length === 1) {
152077
+ const [cx, cy] = vertices[0];
152078
+ const [ex, ey] = cursor;
152079
+ const rx = Math.abs(ex - cx);
152080
+ const ry = Math.abs(ey - cy);
152081
+ if (rx < 1 && ry < 1)
152082
+ return null;
152083
+ const pts = computeEllipsePolygon(cx, cy, Math.max(rx, 1), Math.max(ry, 1));
152084
+ const path = [...pts, pts[0]];
152085
+ return new PathLayer({
152086
+ ...base,
152087
+ id: "annotation-preview-ellipse",
152088
+ data: [{ path }],
152089
+ getPath: (d) => d.path,
152090
+ getColor: previewColor,
152091
+ getWidth: 1,
152092
+ widthUnits: "pixels",
152093
+ extensions: [new PathStyleExtension({ dash: true })],
152094
+ getDashArray: [8, 4]
152095
+ });
152096
+ }
152097
+ if ((type === "polygon" || type === "polyline") && vertices.length >= 1) {
152098
+ const path = [...vertices, cursor];
152099
+ if (type === "polygon" && vertices.length >= 2)
152100
+ path.push(vertices[0]);
152101
+ return new PathLayer({
152102
+ ...base,
152103
+ id: `annotation-preview-${type}`,
152104
+ data: [{ path }],
152105
+ getPath: (d) => d.path,
152106
+ getColor: previewColor,
152107
+ getWidth: 1,
152108
+ widthUnits: "pixels",
152109
+ jointRounded: true,
152110
+ capRounded: true,
152111
+ extensions: [new PathStyleExtension({ dash: true })],
152112
+ getDashArray: [8, 4]
152113
+ });
152114
+ }
152115
+ return null;
152116
+ }
152117
+ function computeTickCap(tipX, tipY, dirX, dirY, dataSize) {
152118
+ const len2 = Math.sqrt(dirX * dirX + dirY * dirY);
152119
+ if (len2 === 0)
152120
+ return null;
152121
+ const ux = dirX / len2;
152122
+ const uy = dirY / len2;
152123
+ const px = -uy;
152124
+ const py = ux;
152125
+ const half = dataSize * 0.55;
152126
+ return [
152127
+ [tipX + px * half, tipY + py * half],
152128
+ [tipX - px * half, tipY - py * half]
152129
+ ];
152130
+ }
152131
+ function computeArrowhead(tipX, tipY, dirX, dirY, dataSize) {
152132
+ const len2 = Math.sqrt(dirX * dirX + dirY * dirY);
152133
+ if (len2 === 0)
152134
+ return null;
152135
+ const ux = dirX / len2;
152136
+ const uy = dirY / len2;
152137
+ const px = -uy;
152138
+ const py = ux;
152139
+ const halfBase = dataSize * 0.4;
152140
+ const bx = tipX - ux * dataSize;
152141
+ const by = tipY - uy * dataSize;
152142
+ return [
152143
+ [tipX, tipY],
152144
+ [bx + px * halfBase, by + py * halfBase],
152145
+ [bx - px * halfBase, by - py * halfBase]
152146
+ ];
152147
+ }
152148
+ function fmtCommas(n3) {
152149
+ return Math.round(n3).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
152150
+ }
152151
+ function getMeasurementLabel(shape, physicalPixelSize, viewType = ViewType$1.SPATIAL) {
152152
+ const pps = physicalPixelSize;
152153
+ const px = pps?.x ?? 1;
152154
+ const py = pps?.y ?? 1;
152155
+ const unit2 = pps ? pps.unit ?? "" : null;
152156
+ const hasPhys = !!pps;
152157
+ const isEmbedding = viewType === ViewType$1.SCATTERPLOT;
152158
+ const fmtDist = (d) => {
152159
+ if (hasPhys)
152160
+ return `${d.toFixed(2)} ${unit2}`;
152161
+ if (isEmbedding)
152162
+ return d.toFixed(2);
152163
+ return `${fmtCommas(d)} px`;
152164
+ };
152165
+ const fmtArea = (a2) => {
152166
+ if (hasPhys)
152167
+ return `${a2.toFixed(2)} ${unit2}²`;
152168
+ if (isEmbedding)
152169
+ return a2.toFixed(2);
152170
+ return `${fmtCommas(a2)} px²`;
152171
+ };
152172
+ if (shape.type === "line") {
152173
+ const dx = (shape.x2 ?? 0) - (shape.x1 ?? 0);
152174
+ const dy = (shape.y2 ?? 0) - (shape.y1 ?? 0);
152175
+ const dist2 = hasPhys ? Math.sqrt((dx * px) ** 2 + (dy * py) ** 2) : Math.sqrt(dx * dx + dy * dy);
152176
+ return fmtDist(dist2);
152177
+ }
152178
+ if (shape.type === "rectangle") {
152179
+ return fmtArea(hasPhys ? Math.abs(shape.width ?? 0) * px * Math.abs(shape.height ?? 0) * py : Math.abs((shape.width ?? 0) * (shape.height ?? 0)));
152180
+ }
152181
+ if (shape.type === "ellipse") {
152182
+ const rx = Math.abs(shape.radiusX ?? 0);
152183
+ const ry = Math.abs(shape.radiusY ?? 0);
152184
+ return fmtArea(hasPhys ? Math.PI * rx * px * ry * py : Math.PI * rx * ry);
152185
+ }
152186
+ if (shape.type === "polygon" && shape.points?.length >= 3) {
152187
+ const pts = shape.points;
152188
+ let shoelace = 0;
152189
+ for (let i2 = 0; i2 < pts.length; i2++) {
152190
+ const [ax, ay] = pts[i2];
152191
+ const [bx, by] = pts[(i2 + 1) % pts.length];
152192
+ shoelace += (hasPhys ? ax * px : ax) * (hasPhys ? by * py : by) - (hasPhys ? bx * px : bx) * (hasPhys ? ay * py : ay);
152193
+ }
152194
+ return fmtArea(Math.abs(shoelace / 2));
152195
+ }
152196
+ if (shape.type === "polyline" && shape.points?.length >= 2) {
152197
+ let total = 0;
152198
+ for (let i2 = 0; i2 < shape.points.length - 1; i2++) {
152199
+ const [ax, ay] = shape.points[i2];
152200
+ const [bx, by] = shape.points[i2 + 1];
152201
+ total += hasPhys ? Math.sqrt(((bx - ax) * px) ** 2 + ((by - ay) * py) ** 2) : Math.sqrt((bx - ax) ** 2 + (by - ay) ** 2);
152202
+ }
152203
+ return fmtDist(total);
152204
+ }
152205
+ return null;
152206
+ }
152207
+ function pickBelowPerp(ux, uy) {
152208
+ const rp = [uy, -ux];
152209
+ const lp = [-uy, ux];
152210
+ return rp[1] > lp[1] || rp[1] === lp[1] && rp[0] > lp[0] ? rp : lp;
152211
+ }
152212
+ function readableAngle(deg) {
152213
+ let a2 = deg;
152214
+ if (a2 > 90)
152215
+ a2 -= 180;
152216
+ if (a2 < -90)
152217
+ a2 += 180;
152218
+ return a2;
152219
+ }
152220
+ function getShapeCentroid(shape) {
152221
+ if (shape.type === "rectangle") {
152222
+ return [(shape.x ?? 0) + (shape.width ?? 0) / 2, (shape.y ?? 0) + (shape.height ?? 0) / 2];
152223
+ }
152224
+ if (shape.type === "line") {
152225
+ return [((shape.x1 ?? 0) + (shape.x2 ?? 0)) / 2, ((shape.y1 ?? 0) + (shape.y2 ?? 0)) / 2];
152226
+ }
152227
+ if (shape.type === "ellipse") {
152228
+ return [shape.x1 ?? 0, shape.y1 ?? 0];
152229
+ }
152230
+ if ((shape.type === "polygon" || shape.type === "polyline") && shape.points?.length >= 1) {
152231
+ const mx = shape.points.reduce((s2, p) => s2 + p[0], 0) / shape.points.length;
152232
+ const my = shape.points.reduce((s2, p) => s2 + p[1], 0) / shape.points.length;
152233
+ return [mx, my];
152234
+ }
152235
+ return [0, 0];
152236
+ }
152237
+ function computeClusters(shapeList, zoom, cellPx = 50) {
152238
+ const cellSize = cellPx / 2 ** Math.floor(zoom);
152239
+ const cells = /* @__PURE__ */ new Map();
152240
+ shapeList.forEach(({ shape }) => {
152241
+ const [cx, cy] = getShapeCentroid(shape);
152242
+ const key = `${Math.floor(cx / cellSize)},${Math.floor(cy / cellSize)}`;
152243
+ if (!cells.has(key)) {
152244
+ cells.set(key, { sumX: 0, sumY: 0, count: 0, color: shape.strokeColor ?? [255, 255, 255] });
152245
+ }
152246
+ const c = cells.get(key);
152247
+ c.sumX += cx;
152248
+ c.sumY += cy;
152249
+ c.count++;
152250
+ });
152251
+ return Array.from(cells.values()).map((c) => ({
152252
+ position: [c.sumX / c.count, c.sumY / c.count, 0],
152253
+ count: c.count,
152254
+ color: c.color
152255
+ }));
152256
+ }
152257
+ function createAnnotationLayers(shapes = [], zoom = 0, selectedShapeUid = null, physicalPixelSize = null, authoredZoom = null, semanticZoom = true, viewType = ViewType$1.SPATIAL) {
152258
+ const selectionLayers = [];
152259
+ if (selectedShapeUid) {
152260
+ const sel = shapes.find((s2) => s2.uid === selectedShapeUid);
152261
+ if (sel) {
152262
+ const { uid: sUid, type: sType, strokeWidth: sStrokeWidth = 3 } = sel;
152263
+ const haloColor = [255, 220, 50, 70];
152264
+ const haloWidth = Math.max(sStrokeWidth + 8, 10);
152265
+ const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN };
152266
+ if (sType === "rectangle") {
152267
+ const { x, y, width, height } = sel;
152268
+ selectionLayers.push(new PathLayer({
152269
+ ...base,
152270
+ id: `annotation-select-${sUid}`,
152271
+ data: [{
152272
+ path: [
152273
+ [x, y],
152274
+ [x + width, y],
152275
+ [x + width, y + height],
152276
+ [x, y + height],
152277
+ [x, y]
152278
+ ]
152279
+ }],
152280
+ getPath: (d) => d.path,
152281
+ getColor: haloColor,
152282
+ getWidth: haloWidth,
152283
+ widthUnits: "pixels",
152284
+ jointRounded: true,
152285
+ capRounded: true
152286
+ }));
152287
+ }
152288
+ if (sType === "line") {
152289
+ const { x1: x12, y1: y12, x2, y2 } = sel;
152290
+ selectionLayers.push(new PathLayer({
152291
+ ...base,
152292
+ id: `annotation-select-${sUid}`,
152293
+ data: [{ path: [[x12, y12], [x2, y2]] }],
152294
+ getPath: (d) => d.path,
152295
+ getColor: haloColor,
152296
+ getWidth: haloWidth,
152297
+ widthUnits: "pixels",
152298
+ capRounded: true
152299
+ }));
152300
+ }
152301
+ if (sType === "ellipse") {
152302
+ const polygon2 = computeEllipsePolygon(sel.x1, sel.y1, sel.radiusX, sel.radiusY);
152303
+ selectionLayers.push(new PathLayer({
152304
+ ...base,
152305
+ id: `annotation-select-${sUid}`,
152306
+ data: [{ path: [...polygon2, polygon2[0]] }],
152307
+ getPath: (d) => d.path,
152308
+ getColor: haloColor,
152309
+ getWidth: haloWidth,
152310
+ widthUnits: "pixels",
152311
+ jointRounded: true
152312
+ }));
152313
+ }
152314
+ if (sType === "polygon" && sel.points?.length >= 3) {
152315
+ selectionLayers.push(new PathLayer({
152316
+ ...base,
152317
+ id: `annotation-select-${sUid}`,
152318
+ data: [{ path: [...sel.points, sel.points[0]] }],
152319
+ getPath: (d) => d.path,
152320
+ getColor: haloColor,
152321
+ getWidth: haloWidth,
152322
+ widthUnits: "pixels",
152323
+ jointRounded: true
152324
+ }));
152325
+ }
152326
+ if (sType === "polyline" && sel.points?.length >= 2) {
152327
+ selectionLayers.push(new PathLayer({
152328
+ ...base,
152329
+ id: `annotation-select-${sUid}`,
152330
+ data: [{ path: sel.points }],
152331
+ getPath: (d) => d.path,
152332
+ getColor: haloColor,
152333
+ getWidth: haloWidth,
152334
+ widthUnits: "pixels",
152335
+ jointRounded: true,
152336
+ capRounded: true
152337
+ }));
152338
+ }
152339
+ }
152340
+ }
152341
+ const layers = [];
152342
+ const dotShapes = [];
152343
+ const clusterDotShapes = [];
152344
+ shapes.forEach((shape, i2) => {
152345
+ const { uid: uid2, type, strokeColor = [255, 255, 255], strokeWidth = 3, strokeDashArray } = shape;
152346
+ const isSelected = uid2 === selectedShapeUid;
152347
+ let shapeOpacity = 1;
152348
+ let tipsOpacity = 1;
152349
+ let labelOpacity = 0;
152350
+ if (isSelected || !semanticZoom || authoredZoom === null) {
152351
+ tipsOpacity = 1;
152352
+ labelOpacity = 1;
152353
+ } else {
152354
+ const zoomRatio = 2 ** (zoom - authoredZoom);
152355
+ if (zoomRatio < RATIO_CLUSTER) {
152356
+ clusterDotShapes.push({ shape });
152357
+ return;
152358
+ }
152359
+ if (zoomRatio < RATIO_DOT) {
152360
+ dotShapes.push({ shape, alpha: 200 });
152361
+ return;
152362
+ }
152363
+ if (zoomRatio < RATIO_GEO_FADE) {
152364
+ const t = (zoomRatio - RATIO_DOT) / (RATIO_GEO_FADE - RATIO_DOT);
152365
+ shapeOpacity = t;
152366
+ dotShapes.push({ shape, alpha: Math.round((1 - t) * 200) });
152367
+ }
152368
+ tipsOpacity = zoomRatio >= RATIO_TIPS ? shapeOpacity : Math.max(0, (zoomRatio - RATIO_GEO_FADE) / (RATIO_TIPS - RATIO_GEO_FADE) * shapeOpacity);
152369
+ if (zoomRatio >= RATIO_LABEL_FULL) {
152370
+ labelOpacity = shapeOpacity;
152371
+ } else if (zoomRatio >= RATIO_LABEL) {
152372
+ labelOpacity = (zoomRatio - RATIO_LABEL) / (RATIO_LABEL_FULL - RATIO_LABEL) * shapeOpacity;
152373
+ }
152374
+ }
152375
+ const arrowDataSize = Math.max(ARROW_SCREEN_PX, strokeWidth * 4) / 2 ** zoom;
152376
+ const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: shapeOpacity };
152377
+ const tipsBase = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: tipsOpacity };
152378
+ const labelBase = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: labelOpacity };
152379
+ const labelBgProps = shape.labelBackground ? {
152380
+ background: true,
152381
+ getBackgroundColor: textBgColor(strokeColor),
152382
+ backgroundPadding: [3, 1, 3, 2]
152383
+ } : {};
152384
+ const labelProps = { ...labelBgProps };
152385
+ const dashArray = parseDashArray(strokeDashArray);
152386
+ const dashExt = [new PathStyleExtension({ dash: true })];
152387
+ const getDash = dashArray ?? [0, 0];
152388
+ if (type === "rectangle") {
152389
+ const { x, y, width, height, fillColor = strokeColor, fillOpacity = 0 } = shape;
152390
+ const filled = fillOpacity > 0;
152391
+ const rectPolygon = [[x, y], [x + width, y], [x + width, y + height], [x, y + height]];
152392
+ layers.push(new PolygonLayer({
152393
+ ...base,
152394
+ id: `annotation-rect-${uid2}-${i2}`,
152395
+ data: [{ polygon: rectPolygon }],
152396
+ getPolygon: (d) => d.polygon,
152397
+ filled,
152398
+ stroked: true,
152399
+ getFillColor: filled ? [...fillColor, Math.round(fillOpacity * 255)] : [0, 0, 0, 0],
152400
+ getLineColor: strokeColor,
152401
+ getLineWidth: strokeWidth,
152402
+ lineWidthUnits: "pixels",
152403
+ ...dashArray ? {
152404
+ extensions: [new PathStyleExtension({ dash: true })],
152405
+ getDashArray: dashArray
152406
+ } : {}
152407
+ }));
152408
+ if (shape.text && labelOpacity > 0) {
152409
+ layers.push(new TextLayer({
152410
+ ...labelBase,
152411
+ ...labelProps,
152412
+ id: `annotation-rect-text-${uid2}-${i2}`,
152413
+ data: [{ position: [x, y], text: shape.text }],
152414
+ getPosition: (d) => d.position,
152415
+ getText: (d) => d.text,
152416
+ getColor: strokeColor,
152417
+ getSize: LABEL_FONT_SIZE,
152418
+ sizeUnits: "pixels",
152419
+ fontFamily: LABEL_FONT_FAMILY,
152420
+ fontWeight: LABEL_FONT_WEIGHT,
152421
+ getPixelOffset: [3, -7],
152422
+ getTextAnchor: "start",
152423
+ getAlignmentBaseline: "bottom"
152424
+ }));
152425
+ }
152426
+ }
152427
+ if (type === "line") {
152428
+ const { x1: x12, y1: y12, x2, y2, markerStart, markerEnd } = shape;
152429
+ const dx = x2 - x12;
152430
+ const dy = y2 - y12;
152431
+ const len2 = Math.sqrt(dx * dx + dy * dy);
152432
+ const ux = len2 > 0 ? dx / len2 : 0;
152433
+ const uy = len2 > 0 ? dy / len2 : 0;
152434
+ const srcX = markerStart === "Arrow" ? x12 + ux * arrowDataSize : x12;
152435
+ const srcY = markerStart === "Arrow" ? y12 + uy * arrowDataSize : y12;
152436
+ const tgtX = markerEnd === "Arrow" ? x2 - ux * arrowDataSize : x2;
152437
+ const tgtY = markerEnd === "Arrow" ? y2 - uy * arrowDataSize : y2;
152438
+ layers.push(new PathLayer({
152439
+ ...base,
152440
+ id: `annotation-line-${uid2}-${i2}`,
152441
+ extensions: [new PathStyleExtension({ dash: true })],
152442
+ getDashArray: dashArray ?? [0, 0],
152443
+ data: [{ path: [[srcX, srcY], [tgtX, tgtY]] }],
152444
+ getPath: (d) => d.path,
152445
+ getColor: strokeColor,
152446
+ getWidth: strokeWidth,
152447
+ widthUnits: "pixels",
152448
+ capRounded: true
152449
+ }));
152450
+ if (markerEnd === "Arrow" && tipsOpacity > 0) {
152451
+ const head = computeArrowhead(x2, y2, x2 - x12, y2 - y12, arrowDataSize);
152452
+ if (head) {
152453
+ layers.push(new PolygonLayer({
152454
+ ...tipsBase,
152455
+ id: `annotation-end-arrow-${uid2}-${i2}`,
152456
+ data: [{ polygon: head }],
152457
+ getPolygon: (d) => d.polygon,
152458
+ filled: true,
152459
+ stroked: false,
152460
+ getFillColor: strokeColor
152461
+ }));
152462
+ }
152463
+ }
152464
+ if (markerStart === "Arrow" && tipsOpacity > 0) {
152465
+ const head = computeArrowhead(x12, y12, x12 - x2, y12 - y2, arrowDataSize);
152466
+ if (head) {
152467
+ layers.push(new PolygonLayer({
152468
+ ...tipsBase,
152469
+ id: `annotation-start-arrow-${uid2}-${i2}`,
152470
+ data: [{ polygon: head }],
152471
+ getPolygon: (d) => d.polygon,
152472
+ filled: true,
152473
+ stroked: false,
152474
+ getFillColor: strokeColor
152475
+ }));
152476
+ }
152477
+ }
152478
+ if (markerEnd === "Tick" && tipsOpacity > 0) {
152479
+ const tick = computeTickCap(x2, y2, x2 - x12, y2 - y12, arrowDataSize);
152480
+ if (tick) {
152481
+ layers.push(new PathLayer({
152482
+ ...tipsBase,
152483
+ id: `annotation-end-tick-${uid2}-${i2}`,
152484
+ data: [{ path: tick }],
152485
+ getPath: (d) => d.path,
152486
+ getColor: strokeColor,
152487
+ getWidth: strokeWidth,
152488
+ widthUnits: "pixels",
152489
+ capRounded: true
152490
+ }));
152491
+ }
152492
+ }
152493
+ if (markerStart === "Tick" && tipsOpacity > 0) {
152494
+ const tick = computeTickCap(x12, y12, x12 - x2, y12 - y2, arrowDataSize);
152495
+ if (tick) {
152496
+ layers.push(new PathLayer({
152497
+ ...tipsBase,
152498
+ id: `annotation-start-tick-${uid2}-${i2}`,
152499
+ data: [{ path: tick }],
152500
+ getPath: (d) => d.path,
152501
+ getColor: strokeColor,
152502
+ getWidth: strokeWidth,
152503
+ widthUnits: "pixels",
152504
+ capRounded: true
152505
+ }));
152506
+ }
152507
+ }
152508
+ if (shape.text) {
152509
+ const pos = shape.textPosition ?? "start";
152510
+ let textX;
152511
+ let textY;
152512
+ if (pos === "start") {
152513
+ textX = x12;
152514
+ textY = y12;
152515
+ } else if (pos === "end") {
152516
+ textX = x2;
152517
+ textY = y2;
152518
+ } else {
152519
+ textX = (x12 + x2) / 2;
152520
+ textY = (y12 + y2) / 2;
152521
+ }
152522
+ let pixelOffset = [0, 0];
152523
+ let textAnchor = "middle";
152524
+ let alignmentBaseline = "center";
152525
+ if (pos !== "middle") {
152526
+ const dxT = x2 - x12;
152527
+ const dyT = y2 - y12;
152528
+ const lenT = Math.sqrt(dxT * dxT + dyT * dyT);
152529
+ if (lenT > 0) {
152530
+ const uxT = dxT / lenT;
152531
+ const uyT = dyT / lenT;
152532
+ const sign2 = pos === "start" ? -1 : 1;
152533
+ const bufferPx = shape.textBufferPx ?? 8;
152534
+ const offsetX = sign2 * uxT * bufferPx;
152535
+ const offsetY = sign2 * uyT * bufferPx;
152536
+ pixelOffset = [offsetX, offsetY];
152537
+ const absX = Math.abs(offsetX);
152538
+ const absY = Math.abs(offsetY);
152539
+ if (absX >= absY) {
152540
+ textAnchor = offsetX > 0 ? "start" : "end";
152541
+ }
152542
+ if (absY >= absX) {
152543
+ alignmentBaseline = offsetY > 0 ? "top" : "bottom";
152544
+ }
152545
+ }
152546
+ } else if (len2 > 0) {
152547
+ const belowPerp = pickBelowPerp(ux, uy);
152548
+ const bufferPx = shape.textBufferPx ?? 14;
152549
+ pixelOffset = [-belowPerp[0] * bufferPx, -belowPerp[1] * bufferPx];
152550
+ textAnchor = "middle";
152551
+ alignmentBaseline = "center";
152552
+ }
152553
+ const middleAngle = pos === "middle" && len2 > 0 ? -readableAngle(Math.atan2(dy, dx) * 180 / Math.PI) : null;
152554
+ if (labelOpacity <= 0)
152555
+ return;
152556
+ layers.push(new TextLayer({
152557
+ ...labelBase,
152558
+ ...labelProps,
152559
+ id: `annotation-line-text-${uid2}-${i2}`,
152560
+ data: [{ position: [textX, textY], text: shape.text }],
152561
+ getPosition: (d) => d.position,
152562
+ getText: (d) => d.text,
152563
+ getColor: strokeColor,
152564
+ getSize: LABEL_FONT_SIZE,
152565
+ sizeUnits: "pixels",
152566
+ fontFamily: LABEL_FONT_FAMILY,
152567
+ fontWeight: LABEL_FONT_WEIGHT,
152568
+ getPixelOffset: pixelOffset,
152569
+ getTextAnchor: textAnchor,
152570
+ getAlignmentBaseline: alignmentBaseline,
152571
+ ...middleAngle !== null && { getAngle: middleAngle }
152572
+ }));
152573
+ }
152574
+ }
152575
+ if (type === "ellipse") {
152576
+ const { x1: x12, y1: y12, radiusX, radiusY, fillColor = strokeColor, fillOpacity = 0 } = shape;
152577
+ const polygon2 = computeEllipsePolygon(x12, y12, radiusX, radiusY);
152578
+ const filled = fillOpacity > 0;
152579
+ layers.push(new PolygonLayer({
152580
+ ...base,
152581
+ id: `annotation-ellipse-${uid2}-${i2}`,
152582
+ data: [{ polygon: polygon2 }],
152583
+ getPolygon: (d) => d.polygon,
152584
+ filled,
152585
+ stroked: true,
152586
+ getFillColor: filled ? [...fillColor, Math.round(fillOpacity * 255)] : [0, 0, 0, 0],
152587
+ getLineColor: strokeColor,
152588
+ getLineWidth: strokeWidth,
152589
+ lineWidthUnits: "pixels",
152590
+ ...dashArray ? {
152591
+ extensions: [new PathStyleExtension({ dash: true })],
152592
+ getDashArray: dashArray
152593
+ } : {}
152594
+ }));
152595
+ if (shape.text && labelOpacity > 0) {
152596
+ layers.push(new TextLayer({
152597
+ ...labelBase,
152598
+ ...labelProps,
152599
+ id: `annotation-ellipse-text-${uid2}-${i2}`,
152600
+ data: [{ position: [x12, y12 - radiusY], text: shape.text }],
152601
+ getPosition: (d) => d.position,
152602
+ getText: (d) => d.text,
152603
+ getColor: strokeColor,
152604
+ getSize: LABEL_FONT_SIZE,
152605
+ sizeUnits: "pixels",
152606
+ fontFamily: LABEL_FONT_FAMILY,
152607
+ fontWeight: LABEL_FONT_WEIGHT,
152608
+ getPixelOffset: [0, -4],
152609
+ getTextAnchor: "middle",
152610
+ getAlignmentBaseline: "bottom"
152611
+ }));
152612
+ }
152613
+ }
152614
+ if (type === "polygon") {
152615
+ const { points, fillColor = strokeColor, fillOpacity = 0 } = shape;
152616
+ if (!points || points.length < 3)
152617
+ return;
152618
+ const closedPath = [...points, points[0]];
152619
+ if (fillOpacity > 0) {
152620
+ layers.push(new PolygonLayer({
152621
+ ...base,
152622
+ id: `annotation-polygon-fill-${uid2}-${i2}`,
152623
+ data: [{ polygon: points }],
152624
+ getPolygon: (d) => d.polygon,
152625
+ stroked: false,
152626
+ filled: true,
152627
+ getFillColor: [...fillColor, Math.round(fillOpacity * 255)]
152628
+ }));
152629
+ }
152630
+ layers.push(new PathLayer({
152631
+ ...base,
152632
+ id: `annotation-polygon-${uid2}-${i2}`,
152633
+ extensions: dashExt,
152634
+ getDashArray: getDash,
152635
+ data: [{ path: closedPath }],
152636
+ getPath: (d) => d.path,
152637
+ getColor: strokeColor,
152638
+ getWidth: strokeWidth,
152639
+ widthUnits: "pixels",
152640
+ jointRounded: true
152641
+ }));
152642
+ if (shape.text && labelOpacity > 0) {
152643
+ const minX = Math.min(...points.map((p) => p[0]));
152644
+ const maxX = Math.max(...points.map((p) => p[0]));
152645
+ const minY = Math.min(...points.map((p) => p[1]));
152646
+ const topCenterX = (minX + maxX) / 2;
152647
+ layers.push(new TextLayer({
152648
+ ...labelBase,
152649
+ ...labelProps,
152650
+ id: `annotation-polygon-text-${uid2}-${i2}`,
152651
+ data: [{ position: [topCenterX, minY], text: shape.text }],
152652
+ getPosition: (d) => d.position,
152653
+ getText: (d) => d.text,
152654
+ getColor: strokeColor,
152655
+ getSize: LABEL_FONT_SIZE,
152656
+ sizeUnits: "pixels",
152657
+ fontFamily: LABEL_FONT_FAMILY,
152658
+ fontWeight: LABEL_FONT_WEIGHT,
152659
+ getPixelOffset: [0, -4],
152660
+ getTextAnchor: "middle",
152661
+ getAlignmentBaseline: "bottom"
152662
+ }));
152663
+ }
152664
+ }
152665
+ if (type === "polyline") {
152666
+ const { points, markerStart, markerEnd } = shape;
152667
+ if (!points || points.length < 2)
152668
+ return;
152669
+ let pathPoints = points;
152670
+ if (markerStart === "Arrow") {
152671
+ const [x02, y02] = points[0];
152672
+ const [x12, y12] = points[1];
152673
+ const dx = x02 - x12;
152674
+ const dy = y02 - y12;
152675
+ const len2 = Math.sqrt(dx * dx + dy * dy);
152676
+ if (len2 > 0) {
152677
+ const ux = dx / len2;
152678
+ const uy = dy / len2;
152679
+ pathPoints = [[x02 - ux * arrowDataSize, y02 - uy * arrowDataSize], ...pathPoints.slice(1)];
152680
+ }
152681
+ }
152682
+ if (markerEnd === "Arrow") {
152683
+ const last = pathPoints[pathPoints.length - 1];
152684
+ const prev = pathPoints[pathPoints.length - 2];
152685
+ const dx = last[0] - prev[0];
152686
+ const dy = last[1] - prev[1];
152687
+ const len2 = Math.sqrt(dx * dx + dy * dy);
152688
+ if (len2 > 0) {
152689
+ const ux = dx / len2;
152690
+ const uy = dy / len2;
152691
+ const shortened = [last[0] - ux * arrowDataSize, last[1] - uy * arrowDataSize];
152692
+ pathPoints = [...pathPoints.slice(0, -1), shortened];
152693
+ }
152694
+ }
152695
+ layers.push(new PathLayer({
152696
+ ...base,
152697
+ id: `annotation-polyline-${uid2}-${i2}`,
152698
+ extensions: dashExt,
152699
+ getDashArray: getDash,
152700
+ data: [{ path: pathPoints }],
152701
+ getPath: (d) => d.path,
152702
+ getColor: strokeColor,
152703
+ getWidth: strokeWidth,
152704
+ widthUnits: "pixels",
152705
+ jointRounded: true,
152706
+ capRounded: true
152707
+ }));
152708
+ if (markerStart === "Arrow" && tipsOpacity > 0) {
152709
+ const [x02, y02] = points[0];
152710
+ const [x12, y12] = points[1];
152711
+ const head = computeArrowhead(x02, y02, x02 - x12, y02 - y12, arrowDataSize);
152712
+ if (head) {
152713
+ layers.push(new PolygonLayer({
152714
+ ...tipsBase,
152715
+ id: `annotation-polyline-start-arrow-${uid2}-${i2}`,
152716
+ data: [{ polygon: head }],
152717
+ getPolygon: (d) => d.polygon,
152718
+ filled: true,
152719
+ stroked: false,
152720
+ getFillColor: strokeColor
152721
+ }));
152722
+ }
152723
+ }
152724
+ if (markerEnd === "Arrow" && tipsOpacity > 0) {
152725
+ const last = points[points.length - 1];
152726
+ const prev = points[points.length - 2];
152727
+ const dxArrow = last[0] - prev[0];
152728
+ const dyArrow = last[1] - prev[1];
152729
+ const head = computeArrowhead(last[0], last[1], dxArrow, dyArrow, arrowDataSize);
152730
+ if (head) {
152731
+ layers.push(new PolygonLayer({
152732
+ ...tipsBase,
152733
+ id: `annotation-polyline-end-arrow-${uid2}-${i2}`,
152734
+ data: [{ polygon: head }],
152735
+ getPolygon: (d) => d.polygon,
152736
+ filled: true,
152737
+ stroked: false,
152738
+ getFillColor: strokeColor
152739
+ }));
152740
+ }
152741
+ }
152742
+ if (markerStart === "Tick" && tipsOpacity > 0) {
152743
+ const [x02, y02] = points[0];
152744
+ const [x12, y12] = points[1];
152745
+ const tick = computeTickCap(x02, y02, x02 - x12, y02 - y12, arrowDataSize);
152746
+ if (tick) {
152747
+ layers.push(new PathLayer({
152748
+ ...tipsBase,
152749
+ id: `annotation-polyline-start-tick-${uid2}-${i2}`,
152750
+ data: [{ path: tick }],
152751
+ getPath: (d) => d.path,
152752
+ getColor: strokeColor,
152753
+ getWidth: strokeWidth,
152754
+ widthUnits: "pixels",
152755
+ capRounded: true
152756
+ }));
152757
+ }
152758
+ }
152759
+ if (markerEnd === "Tick" && tipsOpacity > 0) {
152760
+ const last = points[points.length - 1];
152761
+ const prev = points[points.length - 2];
152762
+ const dxTick = last[0] - prev[0];
152763
+ const dyTick = last[1] - prev[1];
152764
+ const tick = computeTickCap(last[0], last[1], dxTick, dyTick, arrowDataSize);
152765
+ if (tick) {
152766
+ layers.push(new PathLayer({
152767
+ ...tipsBase,
152768
+ id: `annotation-polyline-end-tick-${uid2}-${i2}`,
152769
+ data: [{ path: tick }],
152770
+ getPath: (d) => d.path,
152771
+ getColor: strokeColor,
152772
+ getWidth: strokeWidth,
152773
+ widthUnits: "pixels",
152774
+ capRounded: true
152775
+ }));
152776
+ }
152777
+ }
152778
+ if (shape.text) {
152779
+ const pos = shape.textPosition ?? "start";
152780
+ const bufferPx = shape.textBufferPx ?? 8;
152781
+ let textPt;
152782
+ let dirX;
152783
+ let dirY;
152784
+ if (pos === "end") {
152785
+ const last = points[points.length - 1];
152786
+ const prev = points[points.length - 2];
152787
+ textPt = last;
152788
+ dirX = last[0] - prev[0];
152789
+ dirY = last[1] - prev[1];
152790
+ } else if (pos === "middle") {
152791
+ const mx = points.reduce((s2, p) => s2 + p[0], 0) / points.length;
152792
+ const my = points.reduce((s2, p) => s2 + p[1], 0) / points.length;
152793
+ textPt = [mx, my];
152794
+ dirX = 0;
152795
+ dirY = 0;
152796
+ } else {
152797
+ [textPt] = points;
152798
+ dirX = points[0][0] - points[1][0];
152799
+ dirY = points[0][1] - points[1][1];
152800
+ }
152801
+ const [textX, textY] = textPt;
152802
+ const lenT = Math.sqrt(dirX * dirX + dirY * dirY);
152803
+ let polylinePixelOffset = [0, 0];
152804
+ let polylineTextAnchor = "middle";
152805
+ let polylineAlignmentBaseline = pos === "middle" ? "center" : "bottom";
152806
+ if (lenT > 0) {
152807
+ const uxT = dirX / lenT;
152808
+ const uyT = dirY / lenT;
152809
+ const offX = uxT * bufferPx;
152810
+ const offY = uyT * bufferPx;
152811
+ polylinePixelOffset = [offX, offY];
152812
+ if (Math.abs(offX) >= Math.abs(offY)) {
152813
+ polylineTextAnchor = offX > 0 ? "start" : "end";
152814
+ }
152815
+ if (Math.abs(offY) >= Math.abs(offX)) {
152816
+ polylineAlignmentBaseline = offY > 0 ? "top" : "bottom";
152817
+ }
152818
+ }
152819
+ if (labelOpacity <= 0)
152820
+ return;
152821
+ layers.push(new TextLayer({
152822
+ ...labelBase,
152823
+ ...labelProps,
152824
+ id: `annotation-polyline-text-${uid2}-${i2}`,
152825
+ data: [{ position: [textX, textY], text: shape.text }],
152826
+ getPosition: (d) => d.position,
152827
+ getText: (d) => d.text,
152828
+ getColor: strokeColor,
152829
+ getSize: LABEL_FONT_SIZE,
152830
+ sizeUnits: "pixels",
152831
+ fontFamily: LABEL_FONT_FAMILY,
152832
+ fontWeight: LABEL_FONT_WEIGHT,
152833
+ getPixelOffset: polylinePixelOffset,
152834
+ getTextAnchor: polylineTextAnchor,
152835
+ getAlignmentBaseline: polylineAlignmentBaseline
152836
+ }));
152837
+ }
152838
+ }
152839
+ });
152840
+ if (dotShapes.length > 0) {
152841
+ layers.push(new ScatterplotLayer({
152842
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
152843
+ id: "annotation-dots",
152844
+ data: dotShapes.map(({ shape: s2, alpha: alpha2 }) => ({
152845
+ position: getShapeCentroid(s2),
152846
+ color: [...s2.strokeColor ?? [255, 255, 255], alpha2]
152847
+ })),
152848
+ getPosition: (d) => d.position,
152849
+ getFillColor: (d) => d.color,
152850
+ getRadius: 4,
152851
+ radiusUnits: "pixels",
152852
+ filled: true,
152853
+ stroked: false
152854
+ }));
152855
+ }
152856
+ if (clusterDotShapes.length > 0) {
152857
+ const clusters = computeClusters(clusterDotShapes, zoom);
152858
+ layers.push(new ScatterplotLayer({
152859
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
152860
+ id: "annotation-clusters",
152861
+ data: clusters,
152862
+ getPosition: (d) => d.position,
152863
+ getFillColor: (d) => [...d.color, 180],
152864
+ getRadius: (d) => Math.max(6, 4 + Math.sqrt(d.count) * 2),
152865
+ radiusUnits: "pixels",
152866
+ filled: true,
152867
+ stroked: true,
152868
+ getLineColor: (d) => [...d.color, 220],
152869
+ lineWidthMinPixels: 1.5
152870
+ }));
152871
+ const multiClusters = clusters.filter((c) => c.count > 1);
152872
+ if (multiClusters.length > 0) {
152873
+ layers.push(new TextLayer({
152874
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
152875
+ id: "annotation-cluster-counts",
152876
+ data: multiClusters,
152877
+ getPosition: (d) => d.position,
152878
+ getText: (d) => String(d.count),
152879
+ getColor: [255, 255, 255],
152880
+ getSize: 10,
152881
+ sizeUnits: "pixels",
152882
+ fontWeight: "bold",
152883
+ getTextAnchor: "middle",
152884
+ getAlignmentBaseline: "center"
152885
+ }));
152886
+ }
152887
+ }
152888
+ const measureLayers = [];
152889
+ shapes.forEach((shape) => {
152890
+ if (!shape.showMeasure)
152891
+ return;
152892
+ const mIsSelected = shape.uid === selectedShapeUid;
152893
+ const label = getMeasurementLabel(shape, physicalPixelSize, viewType);
152894
+ if (!label)
152895
+ return;
152896
+ const color = shape.strokeColor ?? [255, 255, 255];
152897
+ let mShapeOpacity = 1;
152898
+ let mLabelFactor = 0;
152899
+ if (mIsSelected || !semanticZoom || authoredZoom === null) {
152900
+ mLabelFactor = 1;
152901
+ } else {
152902
+ const mZoomRatio = 2 ** (zoom - authoredZoom);
152903
+ if (mZoomRatio < RATIO_DOT)
152904
+ return;
152905
+ if (mZoomRatio < RATIO_GEO_FADE) {
152906
+ mShapeOpacity = (mZoomRatio - RATIO_DOT) / (RATIO_GEO_FADE - RATIO_DOT);
152907
+ }
152908
+ if (mZoomRatio >= RATIO_LABEL_FULL) {
152909
+ mLabelFactor = 1;
152910
+ } else if (mZoomRatio >= RATIO_LABEL) {
152911
+ mLabelFactor = (mZoomRatio - RATIO_LABEL) / (RATIO_LABEL_FULL - RATIO_LABEL);
152912
+ }
152913
+ }
152914
+ const measureOpacity = mShapeOpacity * mLabelFactor;
152915
+ if (measureOpacity <= 0)
152916
+ return;
152917
+ const base = {
152918
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
152919
+ opacity: measureOpacity,
152920
+ getText: (d) => d.text,
152921
+ getPosition: (d) => d.position,
152922
+ getColor: color,
152923
+ getSize: 13,
152924
+ sizeUnits: "pixels",
152925
+ fontFamily: LABEL_FONT_FAMILY,
152926
+ fontWeight: "bold",
152927
+ // 'auto' builds the font atlas from the actual rendered characters (e.g. µ, ²)
152928
+ // instead of deck.gl's default ASCII-only atlas.
152929
+ characterSet: "auto",
152930
+ ...shape.measureBackground ? {
152931
+ background: true,
152932
+ getBackgroundColor: textBgColor(color),
152933
+ backgroundPadding: [3, 1, 3, 2]
152934
+ } : {}
152935
+ };
152936
+ if (shape.type === "line") {
152937
+ const mx = ((shape.x1 ?? 0) + (shape.x2 ?? 0)) / 2;
152938
+ const my = ((shape.y1 ?? 0) + (shape.y2 ?? 0)) / 2;
152939
+ const dx = (shape.x2 ?? 0) - (shape.x1 ?? 0);
152940
+ const dy = (shape.y2 ?? 0) - (shape.y1 ?? 0);
152941
+ const len2 = Math.sqrt(dx * dx + dy * dy);
152942
+ if (len2 === 0)
152943
+ return;
152944
+ const perp = pickBelowPerp(dx / len2, dy / len2);
152945
+ const angle2 = readableAngle(Math.atan2(dy, dx) * 180 / Math.PI);
152946
+ measureLayers.push(new TextLayer({
152947
+ ...base,
152948
+ id: `annotation-measure-${shape.uid}`,
152949
+ data: [{ position: [mx, my], text: label }],
152950
+ getAngle: -angle2,
152951
+ getTextAnchor: "middle",
152952
+ getAlignmentBaseline: "center",
152953
+ getPixelOffset: [perp[0] * 16, perp[1] * 16]
152954
+ }));
152955
+ } else if (shape.type === "polyline" && shape.points?.length >= 2) {
152956
+ const pts = shape.points;
152957
+ const mi = Math.floor((pts.length - 1) / 2);
152958
+ const [ax, ay] = pts[mi];
152959
+ const [bx, by] = pts[mi + 1];
152960
+ const dx = bx - ax;
152961
+ const dy = by - ay;
152962
+ const len2 = Math.sqrt(dx * dx + dy * dy);
152963
+ if (len2 === 0)
152964
+ return;
152965
+ const perp = pickBelowPerp(dx / len2, dy / len2);
152966
+ const angle2 = readableAngle(Math.atan2(dy, dx) * 180 / Math.PI);
152967
+ measureLayers.push(new TextLayer({
152968
+ ...base,
152969
+ id: `annotation-measure-${shape.uid}`,
152970
+ data: [{ position: [(ax + bx) / 2, (ay + by) / 2], text: label }],
152971
+ getAngle: -angle2,
152972
+ getTextAnchor: "middle",
152973
+ getAlignmentBaseline: "center",
152974
+ getPixelOffset: [perp[0] * 16, perp[1] * 16]
152975
+ }));
152976
+ } else if (shape.type === "rectangle") {
152977
+ const x02 = shape.x ?? 0;
152978
+ const y02 = shape.y ?? 0;
152979
+ const w2 = shape.width ?? 0;
152980
+ const h = shape.height ?? 0;
152981
+ const rx = x02 + (w2 >= 0 ? w2 : 0);
152982
+ const ry = y02 + (h >= 0 ? h : 0);
152983
+ measureLayers.push(new TextLayer({
152984
+ ...base,
152985
+ id: `annotation-measure-${shape.uid}`,
152986
+ data: [{ position: [rx, ry], text: label }],
152987
+ getTextAnchor: "end",
152988
+ getAlignmentBaseline: "bottom",
152989
+ getPixelOffset: [-6, -6]
152990
+ }));
152991
+ } else if (shape.type === "ellipse") {
152992
+ const cx = shape.x1 ?? 0;
152993
+ const cy = shape.y1 ?? 0;
152994
+ const ry = Math.abs(shape.radiusY ?? 0);
152995
+ measureLayers.push(new TextLayer({
152996
+ ...base,
152997
+ id: `annotation-measure-${shape.uid}`,
152998
+ data: [{ position: [cx, cy + ry], text: label }],
152999
+ getTextAnchor: "middle",
153000
+ getAlignmentBaseline: "top",
153001
+ getPixelOffset: [0, 8]
153002
+ }));
153003
+ } else if (shape.type === "polygon" && shape.points?.length >= 3) {
153004
+ const xs = shape.points.map((p) => p[0]);
153005
+ const ys = shape.points.map((p) => p[1]);
153006
+ const cx = (Math.min(...xs) + Math.max(...xs)) / 2;
153007
+ const maxY = Math.max(...ys);
153008
+ measureLayers.push(new TextLayer({
153009
+ ...base,
153010
+ id: `annotation-measure-${shape.uid}`,
153011
+ data: [{ position: [cx, maxY], text: label }],
153012
+ getTextAnchor: "middle",
153013
+ getAlignmentBaseline: "top",
153014
+ getPixelOffset: [0, 8]
153015
+ }));
153016
+ }
153017
+ });
153018
+ return [...selectionLayers, ...layers, ...measureLayers];
153019
+ }
153020
+ const defaultProps = {
153021
+ // Array of annotation shape objects (see annotationShapeObj in @vitessce/schemas).
153022
+ data: { type: "object", value: [], compare: true },
153023
+ // UID of the shape to highlight with a selection halo.
153024
+ selectedShapeUid: { type: "string", value: null },
153025
+ // { x, y, unit } used to format measurement labels in physical units.
153026
+ physicalPixelSize: { type: "object", value: null, compare: true },
153027
+ // The zoom level at which the shapes were authored (reference for semantic zoom).
153028
+ authoredZoom: { type: "number", value: null },
153029
+ // Whether to apply semantic zoom (level-of-detail) based on authoredZoom.
153030
+ semanticZoom: { type: "boolean", value: true },
153031
+ // The view type in which the layer is rendered (affects measurement label formatting).
153032
+ viewType: { type: "string", value: ViewType$1.SPATIAL },
153033
+ // In-progress shape being drawn, as { type, vertices }.
153034
+ inProgressShape: { type: "object", value: null, compare: true },
153035
+ // Current mouse position (in data coordinates) while drawing.
153036
+ hoverCoord: { type: "array", value: null, compare: true },
153037
+ // Stroke color [r, g, b] of the in-progress shape preview.
153038
+ previewStrokeColor: { type: "color", value: [255, 255, 0] }
153039
+ };
153040
+ class AnnotationLayer extends CompositeLayer {
153041
+ // The semantic zoom and arrowhead sizes depend on the current zoom level,
153042
+ // so the sublayers must also be re-rendered when the viewport changes.
153043
+ // eslint-disable-next-line class-methods-use-this
153044
+ shouldUpdateState({ changeFlags }) {
153045
+ return changeFlags.propsOrDataChanged || changeFlags.viewportChanged;
153046
+ }
153047
+ /**
153048
+ * Prefix the sublayer ID with this layer's ID (so that multiple
153049
+ * AnnotationLayers can co-exist), and combine this layer's
153050
+ * opacity with the per-shape opacity of the sublayer.
153051
+ * Note: we avoid getSubLayerProps here, since it would
153052
+ * overwrite the sublayer extensions (e.g., PathStyleExtension)
153053
+ * and opacity values.
153054
+ * @param {object} layer A DeckGL layer instance.
153055
+ * @returns {object} The cloned layer instance.
153056
+ */
153057
+ wrapSubLayer(layer) {
153058
+ const { id, opacity, pickable, visible } = this.props;
153059
+ return layer.clone({
153060
+ id: `${id}-${layer.id}`,
153061
+ opacity: layer.props.opacity * opacity,
153062
+ pickable,
153063
+ visible
153064
+ });
153065
+ }
153066
+ renderLayers() {
153067
+ const { data, selectedShapeUid, physicalPixelSize, authoredZoom, semanticZoom, viewType, inProgressShape, hoverCoord, previewStrokeColor } = this.props;
153068
+ const zoom = this.context.viewport?.zoom ?? 0;
153069
+ const visibleShapes = (data ?? []).filter((shape) => shape.visible !== false);
153070
+ const annotationLayers = createAnnotationLayers(visibleShapes, zoom, selectedShapeUid, physicalPixelSize, authoredZoom, semanticZoom, viewType);
153071
+ const previewLayer = createPreviewLayer(inProgressShape, hoverCoord, previewStrokeColor.slice(0, 3));
153072
+ return [
153073
+ ...annotationLayers,
153074
+ ...previewLayer ? [previewLayer] : []
153075
+ ].map((layer) => this.wrapSubLayer(layer));
153076
+ }
153077
+ }
153078
+ AnnotationLayer.layerName = "AnnotationLayer";
153079
+ AnnotationLayer.defaultProps = defaultProps;
151693
153080
  function filterSelection(loader, selection) {
151694
153081
  if (!selection) {
151695
153082
  return selection;
@@ -151703,8 +153090,8 @@ async function getSingleSelectionStats2D({ loader, selection }) {
151703
153090
  const filteredSelection = filterSelection(loader, selection);
151704
153091
  const raster = await data.getRaster({ selection: filteredSelection });
151705
153092
  const selectionStats = getChannelStats(raster.data);
151706
- const { domain, contrastLimits: slider } = selectionStats;
151707
- return { domain, slider };
153093
+ const { domain, contrastLimits: slider, q1, q3 } = selectionStats;
153094
+ return { domain, slider, q1, q3 };
151708
153095
  }
151709
153096
  const getSingleSelectionStats = async ({ loader, selection, use3d }) => {
151710
153097
  const getStats = getSingleSelectionStats2D;
@@ -151714,7 +153101,9 @@ const getMultiSelectionStats = async ({ loader, selections, use3d }) => {
151714
153101
  const stats = await Promise.all(selections.map((selection) => getSingleSelectionStats({ loader, selection, use3d })));
151715
153102
  const domains = stats.map((stat) => stat.domain);
151716
153103
  const sliders = stats.map((stat) => stat.slider);
151717
- return { domains, sliders };
153104
+ const q1s = stats.map((stat) => stat.q1);
153105
+ const q3s = stats.map((stat) => stat.q3);
153106
+ return { domains, sliders, q1s, q3s };
151718
153107
  };
151719
153108
  function getSourceFromLoader(loader, level) {
151720
153109
  const { data } = loader;
@@ -152338,6 +153727,7 @@ class RasterJsonAsObsSegmentationsLoader extends RasterLoader {
152338
153727
  }
152339
153728
  }
152340
153729
  export {
153730
+ AnnotationStoryJsonLoader as A,
152341
153731
  BaseDecoder as B,
152342
153732
  CellsJsonAsObsEmbeddingLoader as C,
152343
153733
  GenesJsonAsObsFeatureMatrixLoader as G,