@vitessce/layer-controller 4.0.8 → 4.0.10

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.
@@ -8312,7 +8312,7 @@ var values = Object.values || function(obj) {
8312
8312
  return obj[k];
8313
8313
  });
8314
8314
  };
8315
- var defaultProps$P = {
8315
+ var defaultProps$Q = {
8316
8316
  component: "div",
8317
8317
  childFactory: function childFactory(child) {
8318
8318
  return child;
@@ -8439,7 +8439,7 @@ TransitionGroup.propTypes = {
8439
8439
  */
8440
8440
  childFactory: PropTypes.func
8441
8441
  };
8442
- TransitionGroup.defaultProps = defaultProps$P;
8442
+ TransitionGroup.defaultProps = defaultProps$Q;
8443
8443
  const UNINITIALIZED = {};
8444
8444
  function useLazyRef(init2, initArg) {
8445
8445
  const ref = React.useRef(UNINITIALIZED);
@@ -21409,7 +21409,8 @@ const ViewType = {
21409
21409
  TREEMAP: "treemap",
21410
21410
  SAMPLE_SET_PAIR_MANAGER: "sampleSetPairManager",
21411
21411
  FEATURE_STATS_TABLE: "featureStatsTable",
21412
- SINGLE_OBS_SET_SELECTOR: "singleObsSetSelector"
21412
+ SINGLE_OBS_SET_SELECTOR: "singleObsSetSelector",
21413
+ ANNOTATION_CONTROLLER: "annotationController"
21413
21414
  };
21414
21415
  const CoordinationType = {
21415
21416
  META_COORDINATION_SCOPES: "metaCoordinationScopes",
@@ -21556,7 +21557,15 @@ const CoordinationType = {
21556
21557
  FEATURE_POINT_FOLD_CHANGE_THRESHOLD: "featurePointFoldChangeThreshold",
21557
21558
  FEATURE_LABEL_FOLD_CHANGE_THRESHOLD: "featureLabelFoldChangeThreshold",
21558
21559
  // Treemap
21559
- HIERARCHY_LEVELS: "hierarchyLevels"
21560
+ HIERARCHY_LEVELS: "hierarchyLevels",
21561
+ // Annotation frames
21562
+ ANNOTATION_STORY: "annotationStory",
21563
+ ANNOTATION_FRAME_INDEX: "annotationFrameIndex",
21564
+ ANNOTATION_SHAPES: "annotationShapes",
21565
+ ANNOTATION_OVERLAY_VISIBLE: "annotationOverlayVisible",
21566
+ ANNOTATION_TRANSITION_DURATION: "annotationTransitionDuration",
21567
+ ANNOTATION_SEMANTIC_ZOOM: "annotationSemanticZoom",
21568
+ ANNOTATION_EDITABLE: "annotationEditable"
21560
21569
  };
21561
21570
  const ViewHelpMapping = {
21562
21571
  LAYER_CONTROLLER: "The spatial layer controller provides an interface for manipulating the visualization layers displayed in the spatial view."
@@ -21651,7 +21660,14 @@ const COMPONENT_COORDINATION_TYPES = {
21651
21660
  CoordinationType.EMBEDDING_CONTOURS_FILLED,
21652
21661
  CoordinationType.EMBEDDING_CONTOUR_PERCENTILES,
21653
21662
  CoordinationType.CONTOUR_COLOR_ENCODING,
21654
- CoordinationType.CONTOUR_COLOR
21663
+ CoordinationType.CONTOUR_COLOR,
21664
+ CoordinationType.ANNOTATION_STORY,
21665
+ CoordinationType.ANNOTATION_SHAPES,
21666
+ CoordinationType.ANNOTATION_FRAME_INDEX,
21667
+ CoordinationType.ANNOTATION_OVERLAY_VISIBLE,
21668
+ CoordinationType.ANNOTATION_TRANSITION_DURATION,
21669
+ CoordinationType.ANNOTATION_EDITABLE,
21670
+ CoordinationType.ANNOTATION_SEMANTIC_ZOOM
21655
21671
  ],
21656
21672
  [ViewType.DUAL_SCATTERPLOT]: [
21657
21673
  CoordinationType.DATASET,
@@ -21767,7 +21783,14 @@ const COMPONENT_COORDINATION_TYPES = {
21767
21783
  CoordinationType.ADDITIONAL_OBS_SETS,
21768
21784
  CoordinationType.MOLECULE_HIGHLIGHT,
21769
21785
  CoordinationType.TOOLTIPS_VISIBLE,
21770
- CoordinationType.PHOTOMETRIC_INTERPRETATION
21786
+ CoordinationType.PHOTOMETRIC_INTERPRETATION,
21787
+ CoordinationType.ANNOTATION_STORY,
21788
+ CoordinationType.ANNOTATION_SHAPES,
21789
+ CoordinationType.ANNOTATION_FRAME_INDEX,
21790
+ CoordinationType.ANNOTATION_OVERLAY_VISIBLE,
21791
+ CoordinationType.ANNOTATION_TRANSITION_DURATION,
21792
+ CoordinationType.ANNOTATION_EDITABLE,
21793
+ CoordinationType.ANNOTATION_SEMANTIC_ZOOM
21771
21794
  ],
21772
21795
  [ViewType.SPATIAL_BETA]: [
21773
21796
  CoordinationType.META_COORDINATION_SCOPES,
@@ -21845,7 +21868,27 @@ const COMPONENT_COORDINATION_TYPES = {
21845
21868
  CoordinationType.SPATIAL_CHANNEL_LABELS_ORIENTATION,
21846
21869
  CoordinationType.SPATIAL_CHANNEL_LABEL_SIZE,
21847
21870
  CoordinationType.SPATIAL_CHANNELS_SORT_ORDER,
21848
- CoordinationType.PHOTOMETRIC_INTERPRETATION
21871
+ CoordinationType.PHOTOMETRIC_INTERPRETATION,
21872
+ CoordinationType.ANNOTATION_STORY,
21873
+ CoordinationType.ANNOTATION_SHAPES,
21874
+ CoordinationType.ANNOTATION_FRAME_INDEX,
21875
+ CoordinationType.ANNOTATION_OVERLAY_VISIBLE,
21876
+ CoordinationType.ANNOTATION_TRANSITION_DURATION,
21877
+ CoordinationType.ANNOTATION_EDITABLE,
21878
+ CoordinationType.ANNOTATION_SEMANTIC_ZOOM
21879
+ ],
21880
+ [ViewType.ANNOTATION_CONTROLLER]: [
21881
+ CoordinationType.DATASET,
21882
+ CoordinationType.ANNOTATION_STORY,
21883
+ CoordinationType.ANNOTATION_FRAME_INDEX,
21884
+ CoordinationType.ANNOTATION_OVERLAY_VISIBLE,
21885
+ CoordinationType.ANNOTATION_TRANSITION_DURATION,
21886
+ CoordinationType.ANNOTATION_EDITABLE,
21887
+ CoordinationType.ANNOTATION_SEMANTIC_ZOOM
21888
+ // Note: the annotation controller also needs to read the coordination state
21889
+ // of all other views/coordination types via the full config.
21890
+ // Note: we get/set the CoordinationType.ANNOTATION_SHAPES from the full config,
21891
+ // as this info is view-specific rather than global to the story.
21849
21892
  ],
21850
21893
  [ViewType.HEATMAP]: [
21851
21894
  CoordinationType.DATASET,
@@ -24240,8 +24283,8 @@ class Vector extends MathArray {
24240
24283
  distanceSquared(mathArray) {
24241
24284
  let length2 = 0;
24242
24285
  for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
24243
- const dist = this[i2] - mathArray[i2];
24244
- length2 += dist * dist;
24286
+ const dist2 = this[i2] - mathArray[i2];
24287
+ length2 += dist2 * dist2;
24245
24288
  }
24246
24289
  return checkNumber(length2);
24247
24290
  }
@@ -24562,6 +24605,12 @@ function multiply$3(out, a2, b) {
24562
24605
  out[2] = a2[2] * b[2];
24563
24606
  return out;
24564
24607
  }
24608
+ function distance$3(a2, b) {
24609
+ var x = b[0] - a2[0];
24610
+ var y = b[1] - a2[1];
24611
+ var z = b[2] - a2[2];
24612
+ return Math.hypot(x, y, z);
24613
+ }
24565
24614
  function squaredLength$2(a2) {
24566
24615
  var x = a2[0];
24567
24616
  var y = a2[1];
@@ -24685,6 +24734,7 @@ function angle$2(a2, b) {
24685
24734
  }
24686
24735
  var sub = subtract;
24687
24736
  var mul = multiply$3;
24737
+ var dist = distance$3;
24688
24738
  var len = length$4;
24689
24739
  var sqrLen = squaredLength$2;
24690
24740
  (function() {
@@ -49816,7 +49866,7 @@ function noop$2() {
49816
49866
  const getCursor = ({
49817
49867
  isDragging
49818
49868
  }) => isDragging ? "grabbing" : "grab";
49819
- const defaultProps$O = {
49869
+ const defaultProps$P = {
49820
49870
  id: "",
49821
49871
  width: "100%",
49822
49872
  height: "100%",
@@ -49947,7 +49997,7 @@ class Deck {
49947
49997
  this._lastPointerDownInfo = pickedInfo.result[0] || pickedInfo.emptyInfo;
49948
49998
  });
49949
49999
  this.props = {
49950
- ...defaultProps$O,
50000
+ ...defaultProps$P,
49951
50001
  ...props
49952
50002
  };
49953
50003
  props = this.props;
@@ -50449,7 +50499,7 @@ class Deck {
50449
50499
  metrics.gpuMemory = memoryStats.get("GPU Memory").count;
50450
50500
  }
50451
50501
  }
50452
- _defineProperty(Deck, "defaultProps", defaultProps$O);
50502
+ _defineProperty(Deck, "defaultProps", defaultProps$P);
50453
50503
  _defineProperty(Deck, "VERSION", deckGlobal.VERSION);
50454
50504
  class ShaderAttribute {
50455
50505
  constructor(dataColumn, opts) {
@@ -53204,7 +53254,7 @@ const areViewportsEqual = memoize$1(({
53204
53254
  return oldViewport.equals(viewport);
53205
53255
  });
53206
53256
  let pickingColorCache = new Uint8ClampedArray(0);
53207
- const defaultProps$N = {
53257
+ const defaultProps$O = {
53208
53258
  data: {
53209
53259
  type: "data",
53210
53260
  value: EMPTY_ARRAY$1,
@@ -54079,7 +54129,7 @@ class Layer extends Component {
54079
54129
  this.setNeedsUpdate();
54080
54130
  }
54081
54131
  }
54082
- _defineProperty(Layer, "defaultProps", defaultProps$N);
54132
+ _defineProperty(Layer, "defaultProps", defaultProps$O);
54083
54133
  _defineProperty(Layer, "layerName", "Layer");
54084
54134
  const TRACE_RENDER_LAYERS = "compositeLayer.renderLayers";
54085
54135
  class CompositeLayer extends Layer {
@@ -55115,6 +55165,124 @@ const esm$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
55115
55165
  project32,
55116
55166
  shadow
55117
55167
  }, Symbol.toStringTag, { value: "Module" }));
55168
+ const dashShaders = {
55169
+ inject: {
55170
+ "vs:#decl": "\nattribute vec2 instanceDashArrays;\nattribute float instanceDashOffsets;\nvarying vec2 vDashArray;\nvarying float vDashOffset;\n",
55171
+ "vs:#main-end": "\nvDashArray = instanceDashArrays;\nvDashOffset = instanceDashOffsets / width.x;\n",
55172
+ "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",
55173
+ "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"
55174
+ }
55175
+ };
55176
+ const offsetShaders = {
55177
+ inject: {
55178
+ "vs:#decl": "\nattribute float instanceOffsets;\n",
55179
+ "vs:DECKGL_FILTER_SIZE": "\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n size *= offsetWidth;\n",
55180
+ "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",
55181
+ "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"
55182
+ }
55183
+ };
55184
+ const defaultProps$N = {
55185
+ getDashArray: {
55186
+ type: "accessor",
55187
+ value: [0, 0]
55188
+ },
55189
+ getOffset: {
55190
+ type: "accessor",
55191
+ value: 0
55192
+ },
55193
+ dashJustified: false,
55194
+ dashGapPickable: false
55195
+ };
55196
+ class PathStyleExtension extends LayerExtension {
55197
+ constructor({
55198
+ dash = false,
55199
+ offset: offset2 = false,
55200
+ highPrecisionDash = false
55201
+ } = {}) {
55202
+ super({
55203
+ dash: dash || highPrecisionDash,
55204
+ offset: offset2,
55205
+ highPrecisionDash
55206
+ });
55207
+ }
55208
+ isEnabled(layer) {
55209
+ return "pathTesselator" in layer.state;
55210
+ }
55211
+ getShaders(extension) {
55212
+ if (!extension.isEnabled(this)) {
55213
+ return null;
55214
+ }
55215
+ let result = {};
55216
+ if (extension.opts.dash) {
55217
+ result = mergeShaders(result, dashShaders);
55218
+ }
55219
+ if (extension.opts.offset) {
55220
+ result = mergeShaders(result, offsetShaders);
55221
+ }
55222
+ return result;
55223
+ }
55224
+ initializeState(context, extension) {
55225
+ const attributeManager = this.getAttributeManager();
55226
+ if (!attributeManager || !extension.isEnabled(this)) {
55227
+ return;
55228
+ }
55229
+ if (extension.opts.dash) {
55230
+ attributeManager.addInstanced({
55231
+ instanceDashArrays: {
55232
+ size: 2,
55233
+ accessor: "getDashArray"
55234
+ }
55235
+ });
55236
+ }
55237
+ if (extension.opts.highPrecisionDash) {
55238
+ attributeManager.addInstanced({
55239
+ instanceDashOffsets: {
55240
+ size: 1,
55241
+ accessor: "getPath",
55242
+ transform: extension.getDashOffsets.bind(this)
55243
+ }
55244
+ });
55245
+ }
55246
+ if (extension.opts.offset) {
55247
+ attributeManager.addInstanced({
55248
+ instanceOffsets: {
55249
+ size: 1,
55250
+ accessor: "getOffset"
55251
+ }
55252
+ });
55253
+ }
55254
+ }
55255
+ updateState(params, extension) {
55256
+ if (!extension.isEnabled(this)) {
55257
+ return;
55258
+ }
55259
+ const uniforms = {};
55260
+ if (extension.opts.dash) {
55261
+ uniforms.dashAlignMode = this.props.dashJustified ? 1 : 0;
55262
+ uniforms.dashGapPickable = Boolean(this.props.dashGapPickable);
55263
+ }
55264
+ this.state.model.setUniforms(uniforms);
55265
+ }
55266
+ getDashOffsets(path) {
55267
+ const result = [0];
55268
+ const positionSize = this.props.positionFormat === "XY" ? 2 : 3;
55269
+ const isNested2 = Array.isArray(path[0]);
55270
+ const geometrySize = isNested2 ? path.length : path.length / positionSize;
55271
+ let p;
55272
+ let prevP;
55273
+ for (let i2 = 0; i2 < geometrySize - 1; i2++) {
55274
+ p = isNested2 ? path[i2] : path.slice(i2 * positionSize, i2 * positionSize + positionSize);
55275
+ p = this.projectPosition(p);
55276
+ if (i2 > 0) {
55277
+ result[i2] = result[i2 - 1] + dist(prevP, p);
55278
+ }
55279
+ prevP = p;
55280
+ }
55281
+ return result;
55282
+ }
55283
+ }
55284
+ _defineProperty(PathStyleExtension, "defaultProps", defaultProps$N);
55285
+ _defineProperty(PathStyleExtension, "extensionName", "PathStyleExtension");
55118
55286
  const defaultProps$M = {
55119
55287
  clipBounds: [0, 0, 1, 1]
55120
55288
  };
@@ -111226,8 +111394,8 @@ function requireJs$b() {
111226
111394
  var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi12 / 2 + Math.PI / 4));
111227
111395
  var q = Math.abs(DeltaPsi) > 1e-11 ? DeltaPhi / DeltaPsi : Math.cos(phi12);
111228
111396
  var delta = Math.sqrt(DeltaPhi * DeltaPhi + q * q * DeltaLambda * DeltaLambda);
111229
- var dist = delta * R;
111230
- return dist;
111397
+ var dist2 = delta * R;
111398
+ return dist2;
111231
111399
  }
111232
111400
  js$a.default = rhumbDistance;
111233
111401
  return js$a;
@@ -111540,7 +111708,7 @@ function requireUtils$2() {
111540
111708
  var x;
111541
111709
  var y;
111542
111710
  var segmentIdx;
111543
- var dist;
111711
+ var dist2;
111544
111712
  if (coords.length > 1 && pointCoords.length) {
111545
111713
  var lineCoordinates;
111546
111714
  var pointCoordinate;
@@ -111557,17 +111725,17 @@ function requireUtils$2() {
111557
111725
  if (lineCoordinates[n2][0] !== lineCoordinates[n2 - 1][0]) {
111558
111726
  var slope = (lineCoordinates[n2][1] - lineCoordinates[n2 - 1][1]) / (lineCoordinates[n2][0] - lineCoordinates[n2 - 1][0]);
111559
111727
  var inverseSlope = lineCoordinates[n2][1] - slope * lineCoordinates[n2][0];
111560
- dist = Math.abs(slope * pointCoordinate[0] + inverseSlope - pointCoordinate[1]) / Math.sqrt(slope * slope + 1);
111561
- } else dist = Math.abs(pointCoordinate[0] - lineCoordinates[n2][0]);
111728
+ dist2 = Math.abs(slope * pointCoordinate[0] + inverseSlope - pointCoordinate[1]) / Math.sqrt(slope * slope + 1);
111729
+ } else dist2 = Math.abs(pointCoordinate[0] - lineCoordinates[n2][0]);
111562
111730
  var rl2 = Math.pow(lineCoordinates[n2][1] - lineCoordinates[n2 - 1][1], 2) + Math.pow(lineCoordinates[n2][0] - lineCoordinates[n2 - 1][0], 2);
111563
111731
  var ln2 = Math.pow(lineCoordinates[n2][1] - pointCoordinate[1], 2) + Math.pow(lineCoordinates[n2][0] - pointCoordinate[0], 2);
111564
111732
  var lnm12 = Math.pow(lineCoordinates[n2 - 1][1] - pointCoordinate[1], 2) + Math.pow(lineCoordinates[n2 - 1][0] - pointCoordinate[0], 2);
111565
- var dist2 = Math.pow(dist, 2);
111566
- var calcrl2 = ln2 - dist2 + lnm12 - dist2;
111733
+ var dist22 = Math.pow(dist2, 2);
111734
+ var calcrl2 = ln2 - dist22 + lnm12 - dist22;
111567
111735
  if (calcrl2 > rl2) {
111568
- dist = Math.sqrt(Math.min(ln2, lnm12));
111736
+ dist2 = Math.sqrt(Math.min(ln2, lnm12));
111569
111737
  }
111570
- if (minDist === null || minDist === void 0 || minDist > dist) {
111738
+ if (minDist === null || minDist === void 0 || minDist > dist2) {
111571
111739
  if (calcrl2 > rl2) {
111572
111740
  if (lnm12 < ln2) {
111573
111741
  to = 0;
@@ -111577,10 +111745,10 @@ function requireUtils$2() {
111577
111745
  to = 1;
111578
111746
  }
111579
111747
  } else {
111580
- to = Math.sqrt(lnm12 - dist2) / Math.sqrt(rl2);
111581
- from2 = Math.sqrt(ln2 - dist2) / Math.sqrt(rl2);
111748
+ to = Math.sqrt(lnm12 - dist22) / Math.sqrt(rl2);
111749
+ from2 = Math.sqrt(ln2 - dist22) / Math.sqrt(rl2);
111582
111750
  }
111583
- minDist = dist;
111751
+ minDist = dist2;
111584
111752
  segmentIdx = n2;
111585
111753
  }
111586
111754
  }
@@ -127838,22 +128006,22 @@ function addDecoder(cases, importFn) {
127838
128006
  }
127839
128007
  cases.forEach((c) => registry$1.set(c, importFn));
127840
128008
  }
127841
- addDecoder([void 0, 1], () => import("./raw-CZX8Hwty.js").then((m) => m.default));
127842
- addDecoder(5, () => import("./lzw-xJLWQ_ZD.js").then((m) => m.default));
128009
+ addDecoder([void 0, 1], () => import("./raw-C8diIxIM.js").then((m) => m.default));
128010
+ addDecoder(5, () => import("./lzw-Yu0h4Mbz.js").then((m) => m.default));
127843
128011
  addDecoder(6, () => {
127844
128012
  throw new Error("old style JPEG compression is not supported.");
127845
128013
  });
127846
- addDecoder(7, () => import("./jpeg-DyH-jI-T.js").then((m) => m.default));
127847
- addDecoder([8, 32946], () => import("./deflate-00LnY-B5.js").then((m) => m.default));
127848
- addDecoder(32773, () => import("./packbits-BDQiUrV1.js").then((m) => m.default));
128014
+ addDecoder(7, () => import("./jpeg-wF_G-80a.js").then((m) => m.default));
128015
+ addDecoder([8, 32946], () => import("./deflate-DeIPeSHQ.js").then((m) => m.default));
128016
+ addDecoder(32773, () => import("./packbits-DWEcy2Ta.js").then((m) => m.default));
127849
128017
  addDecoder(
127850
128018
  34887,
127851
- () => import("./lerc-BN4y1gvr.js").then(async (m) => {
128019
+ () => import("./lerc-CkBQzVHv.js").then(async (m) => {
127852
128020
  await m.zstd.init();
127853
128021
  return m;
127854
128022
  }).then((m) => m.default)
127855
128023
  );
127856
- addDecoder(50001, () => import("./webimage-DbDrNJFC.js").then((m) => m.default));
128024
+ addDecoder(50001, () => import("./webimage-DrxIJlKv.js").then((m) => m.default));
127857
128025
  function decodeRowAcc(row, stride) {
127858
128026
  let length2 = row.length - stride;
127859
128027
  let offset2 = 0;
@@ -131854,8 +132022,8 @@ function TreeDesc(dyn_tree, stat_desc) {
131854
132022
  this.max_code = 0;
131855
132023
  this.stat_desc = stat_desc;
131856
132024
  }
131857
- const d_code = (dist) => {
131858
- return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];
132025
+ const d_code = (dist2) => {
132026
+ return dist2 < 256 ? _dist_code[dist2] : _dist_code[256 + (dist2 >>> 7)];
131859
132027
  };
131860
132028
  const put_short = (s2, w2) => {
131861
132029
  s2.pending_buf[s2.pending++] = w2 & 255;
@@ -131989,7 +132157,7 @@ const tr_static_init = () => {
131989
132157
  let bits;
131990
132158
  let length2;
131991
132159
  let code;
131992
- let dist;
132160
+ let dist2;
131993
132161
  const bl_count = new Array(MAX_BITS + 1);
131994
132162
  length2 = 0;
131995
132163
  for (code = 0; code < LENGTH_CODES - 1; code++) {
@@ -131999,18 +132167,18 @@ const tr_static_init = () => {
131999
132167
  }
132000
132168
  }
132001
132169
  _length_code[length2 - 1] = code;
132002
- dist = 0;
132170
+ dist2 = 0;
132003
132171
  for (code = 0; code < 16; code++) {
132004
- base_dist[code] = dist;
132172
+ base_dist[code] = dist2;
132005
132173
  for (n2 = 0; n2 < 1 << extra_dbits[code]; n2++) {
132006
- _dist_code[dist++] = code;
132174
+ _dist_code[dist2++] = code;
132007
132175
  }
132008
132176
  }
132009
- dist >>= 7;
132177
+ dist2 >>= 7;
132010
132178
  for (; code < D_CODES; code++) {
132011
- base_dist[code] = dist << 7;
132179
+ base_dist[code] = dist2 << 7;
132012
132180
  for (n2 = 0; n2 < 1 << extra_dbits[code] - 7; n2++) {
132013
- _dist_code[256 + dist++] = code;
132181
+ _dist_code[256 + dist2++] = code;
132014
132182
  }
132015
132183
  }
132016
132184
  for (bits = 0; bits <= MAX_BITS; bits++) {
@@ -132101,17 +132269,17 @@ const pqdownheap = (s2, tree, k) => {
132101
132269
  s2.heap[k] = v;
132102
132270
  };
132103
132271
  const compress_block = (s2, ltree, dtree) => {
132104
- let dist;
132272
+ let dist2;
132105
132273
  let lc;
132106
132274
  let lx = 0;
132107
132275
  let code;
132108
132276
  let extra;
132109
132277
  if (s2.last_lit !== 0) {
132110
132278
  do {
132111
- dist = s2.pending_buf[s2.d_buf + lx * 2] << 8 | s2.pending_buf[s2.d_buf + lx * 2 + 1];
132279
+ dist2 = s2.pending_buf[s2.d_buf + lx * 2] << 8 | s2.pending_buf[s2.d_buf + lx * 2 + 1];
132112
132280
  lc = s2.pending_buf[s2.l_buf + lx];
132113
132281
  lx++;
132114
- if (dist === 0) {
132282
+ if (dist2 === 0) {
132115
132283
  send_code(s2, lc, ltree);
132116
132284
  } else {
132117
132285
  code = _length_code[lc];
@@ -132121,13 +132289,13 @@ const compress_block = (s2, ltree, dtree) => {
132121
132289
  lc -= base_length[code];
132122
132290
  send_bits(s2, lc, extra);
132123
132291
  }
132124
- dist--;
132125
- code = d_code(dist);
132292
+ dist2--;
132293
+ code = d_code(dist2);
132126
132294
  send_code(s2, code, dtree);
132127
132295
  extra = extra_dbits[code];
132128
132296
  if (extra !== 0) {
132129
- dist -= base_dist[code];
132130
- send_bits(s2, dist, extra);
132297
+ dist2 -= base_dist[code];
132298
+ send_bits(s2, dist2, extra);
132131
132299
  }
132132
132300
  }
132133
132301
  } while (lx < s2.last_lit);
@@ -132398,18 +132566,18 @@ const _tr_flush_block = (s2, buf, stored_len, last) => {
132398
132566
  bi_windup(s2);
132399
132567
  }
132400
132568
  };
132401
- const _tr_tally = (s2, dist, lc) => {
132402
- s2.pending_buf[s2.d_buf + s2.last_lit * 2] = dist >>> 8 & 255;
132403
- s2.pending_buf[s2.d_buf + s2.last_lit * 2 + 1] = dist & 255;
132569
+ const _tr_tally = (s2, dist2, lc) => {
132570
+ s2.pending_buf[s2.d_buf + s2.last_lit * 2] = dist2 >>> 8 & 255;
132571
+ s2.pending_buf[s2.d_buf + s2.last_lit * 2 + 1] = dist2 & 255;
132404
132572
  s2.pending_buf[s2.l_buf + s2.last_lit] = lc & 255;
132405
132573
  s2.last_lit++;
132406
- if (dist === 0) {
132574
+ if (dist2 === 0) {
132407
132575
  s2.dyn_ltree[lc * 2]++;
132408
132576
  } else {
132409
132577
  s2.matches++;
132410
- dist--;
132578
+ dist2--;
132411
132579
  s2.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]++;
132412
- s2.dyn_dtree[d_code(dist) * 2]++;
132580
+ s2.dyn_dtree[d_code(dist2) * 2]++;
132413
132581
  }
132414
132582
  return s2.last_lit === s2.lit_bufsize - 1;
132415
132583
  };
@@ -133914,7 +134082,7 @@ var inffast = function inflate_fast(strm, start) {
133914
134082
  let here;
133915
134083
  let op;
133916
134084
  let len2;
133917
- let dist;
134085
+ let dist2;
133918
134086
  let from2;
133919
134087
  let from_source;
133920
134088
  let input, output;
@@ -133980,7 +134148,7 @@ var inffast = function inflate_fast(strm, start) {
133980
134148
  bits -= op;
133981
134149
  op = here >>> 16 & 255;
133982
134150
  if (op & 16) {
133983
- dist = here & 65535;
134151
+ dist2 = here & 65535;
133984
134152
  op &= 15;
133985
134153
  if (bits < op) {
133986
134154
  hold += input[_in++] << bits;
@@ -133990,8 +134158,8 @@ var inffast = function inflate_fast(strm, start) {
133990
134158
  bits += 8;
133991
134159
  }
133992
134160
  }
133993
- dist += hold & (1 << op) - 1;
133994
- if (dist > dmax) {
134161
+ dist2 += hold & (1 << op) - 1;
134162
+ if (dist2 > dmax) {
133995
134163
  strm.msg = "invalid distance too far back";
133996
134164
  state.mode = BAD;
133997
134165
  break top;
@@ -133999,8 +134167,8 @@ var inffast = function inflate_fast(strm, start) {
133999
134167
  hold >>>= op;
134000
134168
  bits -= op;
134001
134169
  op = _out - beg;
134002
- if (dist > op) {
134003
- op = dist - op;
134170
+ if (dist2 > op) {
134171
+ op = dist2 - op;
134004
134172
  if (op > whave) {
134005
134173
  if (state.sane) {
134006
134174
  strm.msg = "invalid distance too far back";
@@ -134017,7 +134185,7 @@ var inffast = function inflate_fast(strm, start) {
134017
134185
  do {
134018
134186
  output[_out++] = s_window[from2++];
134019
134187
  } while (--op);
134020
- from2 = _out - dist;
134188
+ from2 = _out - dist2;
134021
134189
  from_source = output;
134022
134190
  }
134023
134191
  } else if (wnext < op) {
@@ -134035,7 +134203,7 @@ var inffast = function inflate_fast(strm, start) {
134035
134203
  do {
134036
134204
  output[_out++] = s_window[from2++];
134037
134205
  } while (--op);
134038
- from2 = _out - dist;
134206
+ from2 = _out - dist2;
134039
134207
  from_source = output;
134040
134208
  }
134041
134209
  }
@@ -134046,7 +134214,7 @@ var inffast = function inflate_fast(strm, start) {
134046
134214
  do {
134047
134215
  output[_out++] = s_window[from2++];
134048
134216
  } while (--op);
134049
- from2 = _out - dist;
134217
+ from2 = _out - dist2;
134050
134218
  from_source = output;
134051
134219
  }
134052
134220
  }
@@ -134063,7 +134231,7 @@ var inffast = function inflate_fast(strm, start) {
134063
134231
  }
134064
134232
  }
134065
134233
  } else {
134066
- from2 = _out - dist;
134234
+ from2 = _out - dist2;
134067
134235
  do {
134068
134236
  output[_out++] = output[from2++];
134069
134237
  output[_out++] = output[from2++];
@@ -134621,7 +134789,7 @@ const fixedtables = (state) => {
134621
134789
  state.distbits = 5;
134622
134790
  };
134623
134791
  const updatewindow = (strm, src, end, copy2) => {
134624
- let dist;
134792
+ let dist2;
134625
134793
  const state = strm.state;
134626
134794
  if (state.window === null) {
134627
134795
  state.wsize = 1 << state.wbits;
@@ -134634,23 +134802,23 @@ const updatewindow = (strm, src, end, copy2) => {
134634
134802
  state.wnext = 0;
134635
134803
  state.whave = state.wsize;
134636
134804
  } else {
134637
- dist = state.wsize - state.wnext;
134638
- if (dist > copy2) {
134639
- dist = copy2;
134805
+ dist2 = state.wsize - state.wnext;
134806
+ if (dist2 > copy2) {
134807
+ dist2 = copy2;
134640
134808
  }
134641
- state.window.set(src.subarray(end - copy2, end - copy2 + dist), state.wnext);
134642
- copy2 -= dist;
134809
+ state.window.set(src.subarray(end - copy2, end - copy2 + dist2), state.wnext);
134810
+ copy2 -= dist2;
134643
134811
  if (copy2) {
134644
134812
  state.window.set(src.subarray(end - copy2, end), 0);
134645
134813
  state.wnext = copy2;
134646
134814
  state.whave = state.wsize;
134647
134815
  } else {
134648
- state.wnext += dist;
134816
+ state.wnext += dist2;
134649
134817
  if (state.wnext === state.wsize) {
134650
134818
  state.wnext = 0;
134651
134819
  }
134652
134820
  if (state.whave < state.wsize) {
134653
- state.whave += dist;
134821
+ state.whave += dist2;
134654
134822
  }
134655
134823
  }
134656
134824
  }
@@ -138700,7 +138868,7 @@ function padColors({ colors, channelsVisible }) {
138700
138868
  ).reduce((acc, val) => acc.concat(val), []);
138701
138869
  return paddedColors;
138702
138870
  }
138703
- const defaultProps$3$1 = {
138871
+ const defaultProps$3$2 = {
138704
138872
  colors: { type: "array", value: null, compare: true },
138705
138873
  opacity: { type: "number", value: 1, compare: true },
138706
138874
  transparentColor: { type: "array", value: null, compare: true },
@@ -138717,9 +138885,9 @@ const ColorPaletteExtension = class extends LayerExtension {
138717
138885
  const {
138718
138886
  colors,
138719
138887
  channelsVisible,
138720
- opacity = defaultProps$3$1.opacity.value,
138721
- transparentColor = defaultProps$3$1.transparentColor.value,
138722
- useTransparentColor = defaultProps$3$1.useTransparentColor.value
138888
+ opacity = defaultProps$3$2.opacity.value,
138889
+ transparentColor = defaultProps$3$2.transparentColor.value,
138890
+ useTransparentColor = defaultProps$3$2.useTransparentColor.value
138723
138891
  } = this.props;
138724
138892
  const paddedColors = padColors({
138725
138893
  channelsVisible: channelsVisible || this.selections.map(() => true),
@@ -138735,7 +138903,7 @@ const ColorPaletteExtension = class extends LayerExtension {
138735
138903
  }
138736
138904
  };
138737
138905
  ColorPaletteExtension.extensionName = "ColorPaletteExtension";
138738
- ColorPaletteExtension.defaultProps = defaultProps$3$1;
138906
+ ColorPaletteExtension.defaultProps = defaultProps$3$2;
138739
138907
  const fs$4 = `// lens bounds for ellipse
138740
138908
  uniform float majorLensAxis;
138741
138909
  uniform float minorLensAxis;
@@ -140030,7 +140198,7 @@ const MultiscaleImageLayer = class extends CompositeLayer {
140030
140198
  };
140031
140199
  MultiscaleImageLayer.layerName = "MultiscaleImageLayer";
140032
140200
  MultiscaleImageLayer.defaultProps = defaultProps$4;
140033
- const defaultProps$3 = {
140201
+ const defaultProps$3$1 = {
140034
140202
  pickable: { type: "boolean", value: true, compare: true },
140035
140203
  loader: {
140036
140204
  type: "object",
@@ -140117,7 +140285,7 @@ const OverviewLayer = class extends CompositeLayer {
140117
140285
  }
140118
140286
  };
140119
140287
  OverviewLayer.layerName = "OverviewLayer";
140120
- OverviewLayer.defaultProps = defaultProps$3;
140288
+ OverviewLayer.defaultProps = defaultProps$3$1;
140121
140289
  function getPosition(boundingBox, position2, length2) {
140122
140290
  const viewWidth = boundingBox[2][0] - boundingBox[0][0];
140123
140291
  const viewHeight = boundingBox[2][1] - boundingBox[0][1];
@@ -141130,7 +141298,7 @@ function padWithDefault$1(arr, defaultValue2, padWidth) {
141130
141298
  }
141131
141299
  return newArr;
141132
141300
  }
141133
- const defaultProps$2 = {
141301
+ const defaultProps$3 = {
141134
141302
  hoveredCell: { type: "number", value: null, compare: true },
141135
141303
  // We do not want to deep-compare cellColorData,
141136
141304
  // as it is potentially a TypedArray with millions of elements.
@@ -141247,7 +141415,7 @@ let BitmaskLayer$1 = class BitmaskLayer extends XRLayer {
141247
141415
  }
141248
141416
  };
141249
141417
  BitmaskLayer$1.layerName = "BitmaskLayer";
141250
- BitmaskLayer$1.defaultProps = defaultProps$2;
141418
+ BitmaskLayer$1.defaultProps = defaultProps$3;
141251
141419
  const vs = `
141252
141420
  #define SHADER_NAME bitmask-layer-vertex-shader
141253
141421
 
@@ -141589,7 +141757,7 @@ function isEqualShallow(prevArr, nextArr) {
141589
141757
  }
141590
141758
  return prevArr === nextArr;
141591
141759
  }
141592
- const defaultProps$1 = {
141760
+ const defaultProps$2 = {
141593
141761
  channelStrokeWidths: { type: "array", value: null, compare: true },
141594
141762
  channelsFilled: { type: "array", value: null, compare: true },
141595
141763
  channelOpacities: { type: "array", value: null, compare: true },
@@ -141853,7 +142021,7 @@ class BitmaskLayer2 extends XRLayer {
141853
142021
  }
141854
142022
  }
141855
142023
  BitmaskLayer2.layerName = "BitmaskLayer";
141856
- BitmaskLayer2.defaultProps = defaultProps$1;
142024
+ BitmaskLayer2.defaultProps = defaultProps$2;
141857
142025
  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;
141858
142026
  function clone(configObject) {
141859
142027
  var div, convertBase, parseNumeric, P = 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 = {
@@ -144796,7 +144964,7 @@ function ringArea(coords) {
144796
144964
  return total * FACTOR;
144797
144965
  }
144798
144966
  const DEFAULT_THRESHOLD = 1;
144799
- const defaultProps = {
144967
+ const defaultProps$1 = {
144800
144968
  // for text
144801
144969
  obsSetPath: { type: "object" },
144802
144970
  sampleSetPath: { type: "object" },
@@ -144891,9 +145059,9 @@ class ContourLayerWithText extends ContourLayer {
144891
145059
  const circlePoint = point(circleCoord);
144892
145060
  polygonVertices.forEach((polyCoord) => {
144893
145061
  const polyPoint = point(polyCoord);
144894
- const dist = distance$1(circlePoint, polyPoint);
144895
- if (dist < minDist) {
144896
- minDist = dist;
145062
+ const dist2 = distance$1(circlePoint, polyPoint);
145063
+ if (dist2 < minDist) {
145064
+ minDist = dist2;
144897
145065
  minCirclePoint = circleCoord;
144898
145066
  minCirclePointI = circlePointI;
144899
145067
  minPolygonPoint = polyCoord;
@@ -144970,7 +145138,1077 @@ class ContourLayerWithText extends ContourLayer {
144970
145138
  }
144971
145139
  }
144972
145140
  ContourLayerWithText.layerName = "ContourLayerWithText";
144973
- ContourLayerWithText.defaultProps = defaultProps;
145141
+ ContourLayerWithText.defaultProps = defaultProps$1;
145142
+ const ARROW_SCREEN_PX = 14;
145143
+ const LABEL_FONT_FAMILY = '"Roboto", "Helvetica", "Arial", sans-serif';
145144
+ const LABEL_FONT_WEIGHT = "bold";
145145
+ const LABEL_FONT_SIZE = 14;
145146
+ const RATIO_CLUSTER = 0.1;
145147
+ const RATIO_DOT = 0.3;
145148
+ const RATIO_GEO_FADE = 0.55;
145149
+ const RATIO_TIPS = 0.7;
145150
+ const RATIO_LABEL = 0.55;
145151
+ const RATIO_LABEL_FULL = 0.75;
145152
+ function textBgColor(strokeColor) {
145153
+ const [r2, g2, b] = strokeColor;
145154
+ const lum = (0.299 * r2 + 0.587 * g2 + 0.114 * b) / 255;
145155
+ return lum > 0.45 ? [20, 20, 20, 210] : [245, 245, 245, 210];
145156
+ }
145157
+ function parseDashArray(strokeDashArray) {
145158
+ if (!strokeDashArray || strokeDashArray === "none")
145159
+ return null;
145160
+ const nums = strokeDashArray.trim().split(/\s+/).map(Number).filter((n2) => !Number.isNaN(n2) && n2 >= 0);
145161
+ return nums.length >= 2 ? [nums[0], nums[1]] : null;
145162
+ }
145163
+ function computeEllipsePolygon(cx, cy, rx, ry, numSegments = 64) {
145164
+ const pts = [];
145165
+ for (let i2 = 0; i2 < numSegments; i2++) {
145166
+ const angle2 = 2 * Math.PI * i2 / numSegments;
145167
+ pts.push([cx + rx * Math.cos(angle2), cy + ry * Math.sin(angle2)]);
145168
+ }
145169
+ return pts;
145170
+ }
145171
+ function createPreviewLayer(inProgress, hoverCoord, strokeColor = [255, 255, 0]) {
145172
+ if (!inProgress || inProgress.vertices.length === 0)
145173
+ return null;
145174
+ const { type, vertices } = inProgress;
145175
+ const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN };
145176
+ const previewColor = [...strokeColor, 160];
145177
+ const cursor2 = hoverCoord ?? vertices[vertices.length - 1];
145178
+ if (type === "rectangle" && vertices.length === 1) {
145179
+ const [ax, ay] = vertices[0];
145180
+ const [bx, by] = cursor2;
145181
+ const path = [[ax, ay], [bx, ay], [bx, by], [ax, by], [ax, ay]];
145182
+ return new PathLayer({
145183
+ ...base,
145184
+ id: "annotation-preview-rectangle",
145185
+ data: [{ path }],
145186
+ getPath: (d) => d.path,
145187
+ getColor: previewColor,
145188
+ getWidth: 1,
145189
+ widthUnits: "pixels",
145190
+ extensions: [new PathStyleExtension({ dash: true })],
145191
+ getDashArray: [8, 4]
145192
+ });
145193
+ }
145194
+ if (type === "line" && vertices.length === 1) {
145195
+ const path = [vertices[0], cursor2];
145196
+ return new PathLayer({
145197
+ ...base,
145198
+ id: "annotation-preview-line",
145199
+ data: [{ path }],
145200
+ getPath: (d) => d.path,
145201
+ getColor: previewColor,
145202
+ getWidth: 1,
145203
+ widthUnits: "pixels",
145204
+ extensions: [new PathStyleExtension({ dash: true })],
145205
+ getDashArray: [8, 4]
145206
+ });
145207
+ }
145208
+ if (type === "ellipse" && vertices.length === 1) {
145209
+ const [cx, cy] = vertices[0];
145210
+ const [ex, ey] = cursor2;
145211
+ const rx = Math.abs(ex - cx);
145212
+ const ry = Math.abs(ey - cy);
145213
+ if (rx < 1 && ry < 1)
145214
+ return null;
145215
+ const pts = computeEllipsePolygon(cx, cy, Math.max(rx, 1), Math.max(ry, 1));
145216
+ const path = [...pts, pts[0]];
145217
+ return new PathLayer({
145218
+ ...base,
145219
+ id: "annotation-preview-ellipse",
145220
+ data: [{ path }],
145221
+ getPath: (d) => d.path,
145222
+ getColor: previewColor,
145223
+ getWidth: 1,
145224
+ widthUnits: "pixels",
145225
+ extensions: [new PathStyleExtension({ dash: true })],
145226
+ getDashArray: [8, 4]
145227
+ });
145228
+ }
145229
+ if ((type === "polygon" || type === "polyline") && vertices.length >= 1) {
145230
+ const path = [...vertices, cursor2];
145231
+ if (type === "polygon" && vertices.length >= 2)
145232
+ path.push(vertices[0]);
145233
+ return new PathLayer({
145234
+ ...base,
145235
+ id: `annotation-preview-${type}`,
145236
+ data: [{ path }],
145237
+ getPath: (d) => d.path,
145238
+ getColor: previewColor,
145239
+ getWidth: 1,
145240
+ widthUnits: "pixels",
145241
+ jointRounded: true,
145242
+ capRounded: true,
145243
+ extensions: [new PathStyleExtension({ dash: true })],
145244
+ getDashArray: [8, 4]
145245
+ });
145246
+ }
145247
+ return null;
145248
+ }
145249
+ function computeTickCap(tipX, tipY, dirX, dirY, dataSize) {
145250
+ const len2 = Math.sqrt(dirX * dirX + dirY * dirY);
145251
+ if (len2 === 0)
145252
+ return null;
145253
+ const ux = dirX / len2;
145254
+ const uy = dirY / len2;
145255
+ const px = -uy;
145256
+ const py = ux;
145257
+ const half = dataSize * 0.55;
145258
+ return [
145259
+ [tipX + px * half, tipY + py * half],
145260
+ [tipX - px * half, tipY - py * half]
145261
+ ];
145262
+ }
145263
+ function computeArrowhead(tipX, tipY, dirX, dirY, dataSize) {
145264
+ const len2 = Math.sqrt(dirX * dirX + dirY * dirY);
145265
+ if (len2 === 0)
145266
+ return null;
145267
+ const ux = dirX / len2;
145268
+ const uy = dirY / len2;
145269
+ const px = -uy;
145270
+ const py = ux;
145271
+ const halfBase = dataSize * 0.4;
145272
+ const bx = tipX - ux * dataSize;
145273
+ const by = tipY - uy * dataSize;
145274
+ return [
145275
+ [tipX, tipY],
145276
+ [bx + px * halfBase, by + py * halfBase],
145277
+ [bx - px * halfBase, by - py * halfBase]
145278
+ ];
145279
+ }
145280
+ function fmtCommas(n2) {
145281
+ return Math.round(n2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
145282
+ }
145283
+ function getMeasurementLabel(shape2, physicalPixelSize, viewType = ViewType.SPATIAL) {
145284
+ const pps = physicalPixelSize;
145285
+ const px = pps?.x ?? 1;
145286
+ const py = pps?.y ?? 1;
145287
+ const unit = pps ? pps.unit ?? "" : null;
145288
+ const hasPhys = !!pps;
145289
+ const isEmbedding = viewType === ViewType.SCATTERPLOT;
145290
+ const fmtDist = (d) => {
145291
+ if (hasPhys)
145292
+ return `${d.toFixed(2)} ${unit}`;
145293
+ if (isEmbedding)
145294
+ return d.toFixed(2);
145295
+ return `${fmtCommas(d)} px`;
145296
+ };
145297
+ const fmtArea = (a2) => {
145298
+ if (hasPhys)
145299
+ return `${a2.toFixed(2)} ${unit}²`;
145300
+ if (isEmbedding)
145301
+ return a2.toFixed(2);
145302
+ return `${fmtCommas(a2)} px²`;
145303
+ };
145304
+ if (shape2.type === "line") {
145305
+ const dx = (shape2.x2 ?? 0) - (shape2.x1 ?? 0);
145306
+ const dy = (shape2.y2 ?? 0) - (shape2.y1 ?? 0);
145307
+ const dist2 = hasPhys ? Math.sqrt((dx * px) ** 2 + (dy * py) ** 2) : Math.sqrt(dx * dx + dy * dy);
145308
+ return fmtDist(dist2);
145309
+ }
145310
+ if (shape2.type === "rectangle") {
145311
+ return fmtArea(hasPhys ? Math.abs(shape2.width ?? 0) * px * Math.abs(shape2.height ?? 0) * py : Math.abs((shape2.width ?? 0) * (shape2.height ?? 0)));
145312
+ }
145313
+ if (shape2.type === "ellipse") {
145314
+ const rx = Math.abs(shape2.radiusX ?? 0);
145315
+ const ry = Math.abs(shape2.radiusY ?? 0);
145316
+ return fmtArea(hasPhys ? Math.PI * rx * px * ry * py : Math.PI * rx * ry);
145317
+ }
145318
+ if (shape2.type === "polygon" && shape2.points?.length >= 3) {
145319
+ const pts = shape2.points;
145320
+ let shoelace = 0;
145321
+ for (let i2 = 0; i2 < pts.length; i2++) {
145322
+ const [ax, ay] = pts[i2];
145323
+ const [bx, by] = pts[(i2 + 1) % pts.length];
145324
+ shoelace += (hasPhys ? ax * px : ax) * (hasPhys ? by * py : by) - (hasPhys ? bx * px : bx) * (hasPhys ? ay * py : ay);
145325
+ }
145326
+ return fmtArea(Math.abs(shoelace / 2));
145327
+ }
145328
+ if (shape2.type === "polyline" && shape2.points?.length >= 2) {
145329
+ let total = 0;
145330
+ for (let i2 = 0; i2 < shape2.points.length - 1; i2++) {
145331
+ const [ax, ay] = shape2.points[i2];
145332
+ const [bx, by] = shape2.points[i2 + 1];
145333
+ total += hasPhys ? Math.sqrt(((bx - ax) * px) ** 2 + ((by - ay) * py) ** 2) : Math.sqrt((bx - ax) ** 2 + (by - ay) ** 2);
145334
+ }
145335
+ return fmtDist(total);
145336
+ }
145337
+ return null;
145338
+ }
145339
+ function pickBelowPerp(ux, uy) {
145340
+ const rp = [uy, -ux];
145341
+ const lp = [-uy, ux];
145342
+ return rp[1] > lp[1] || rp[1] === lp[1] && rp[0] > lp[0] ? rp : lp;
145343
+ }
145344
+ function readableAngle(deg) {
145345
+ let a2 = deg;
145346
+ if (a2 > 90)
145347
+ a2 -= 180;
145348
+ if (a2 < -90)
145349
+ a2 += 180;
145350
+ return a2;
145351
+ }
145352
+ function getShapeCentroid(shape2) {
145353
+ if (shape2.type === "rectangle") {
145354
+ return [(shape2.x ?? 0) + (shape2.width ?? 0) / 2, (shape2.y ?? 0) + (shape2.height ?? 0) / 2];
145355
+ }
145356
+ if (shape2.type === "line") {
145357
+ return [((shape2.x1 ?? 0) + (shape2.x2 ?? 0)) / 2, ((shape2.y1 ?? 0) + (shape2.y2 ?? 0)) / 2];
145358
+ }
145359
+ if (shape2.type === "ellipse") {
145360
+ return [shape2.x1 ?? 0, shape2.y1 ?? 0];
145361
+ }
145362
+ if ((shape2.type === "polygon" || shape2.type === "polyline") && shape2.points?.length >= 1) {
145363
+ const mx = shape2.points.reduce((s2, p) => s2 + p[0], 0) / shape2.points.length;
145364
+ const my = shape2.points.reduce((s2, p) => s2 + p[1], 0) / shape2.points.length;
145365
+ return [mx, my];
145366
+ }
145367
+ return [0, 0];
145368
+ }
145369
+ function computeClusters(shapeList, zoom, cellPx = 50) {
145370
+ const cellSize = cellPx / 2 ** Math.floor(zoom);
145371
+ const cells = /* @__PURE__ */ new Map();
145372
+ shapeList.forEach(({ shape: shape2 }) => {
145373
+ const [cx, cy] = getShapeCentroid(shape2);
145374
+ const key = `${Math.floor(cx / cellSize)},${Math.floor(cy / cellSize)}`;
145375
+ if (!cells.has(key)) {
145376
+ cells.set(key, { sumX: 0, sumY: 0, count: 0, color: shape2.strokeColor ?? [255, 255, 255] });
145377
+ }
145378
+ const c = cells.get(key);
145379
+ c.sumX += cx;
145380
+ c.sumY += cy;
145381
+ c.count++;
145382
+ });
145383
+ return Array.from(cells.values()).map((c) => ({
145384
+ position: [c.sumX / c.count, c.sumY / c.count, 0],
145385
+ count: c.count,
145386
+ color: c.color
145387
+ }));
145388
+ }
145389
+ function createAnnotationLayers(shapes = [], zoom = 0, selectedShapeUid = null, physicalPixelSize = null, authoredZoom = null, semanticZoom = true, viewType = ViewType.SPATIAL) {
145390
+ const selectionLayers = [];
145391
+ if (selectedShapeUid) {
145392
+ const sel = shapes.find((s2) => s2.uid === selectedShapeUid);
145393
+ if (sel) {
145394
+ const { uid: sUid, type: sType, strokeWidth: sStrokeWidth = 3 } = sel;
145395
+ const haloColor = [255, 220, 50, 70];
145396
+ const haloWidth = Math.max(sStrokeWidth + 8, 10);
145397
+ const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN };
145398
+ if (sType === "rectangle") {
145399
+ const { x, y, width: width2, height: height2 } = sel;
145400
+ selectionLayers.push(new PathLayer({
145401
+ ...base,
145402
+ id: `annotation-select-${sUid}`,
145403
+ data: [{
145404
+ path: [
145405
+ [x, y],
145406
+ [x + width2, y],
145407
+ [x + width2, y + height2],
145408
+ [x, y + height2],
145409
+ [x, y]
145410
+ ]
145411
+ }],
145412
+ getPath: (d) => d.path,
145413
+ getColor: haloColor,
145414
+ getWidth: haloWidth,
145415
+ widthUnits: "pixels",
145416
+ jointRounded: true,
145417
+ capRounded: true
145418
+ }));
145419
+ }
145420
+ if (sType === "line") {
145421
+ const { x1: x12, y1: y12, x2, y2 } = sel;
145422
+ selectionLayers.push(new PathLayer({
145423
+ ...base,
145424
+ id: `annotation-select-${sUid}`,
145425
+ data: [{ path: [[x12, y12], [x2, y2]] }],
145426
+ getPath: (d) => d.path,
145427
+ getColor: haloColor,
145428
+ getWidth: haloWidth,
145429
+ widthUnits: "pixels",
145430
+ capRounded: true
145431
+ }));
145432
+ }
145433
+ if (sType === "ellipse") {
145434
+ const polygon2 = computeEllipsePolygon(sel.x1, sel.y1, sel.radiusX, sel.radiusY);
145435
+ selectionLayers.push(new PathLayer({
145436
+ ...base,
145437
+ id: `annotation-select-${sUid}`,
145438
+ data: [{ path: [...polygon2, polygon2[0]] }],
145439
+ getPath: (d) => d.path,
145440
+ getColor: haloColor,
145441
+ getWidth: haloWidth,
145442
+ widthUnits: "pixels",
145443
+ jointRounded: true
145444
+ }));
145445
+ }
145446
+ if (sType === "polygon" && sel.points?.length >= 3) {
145447
+ selectionLayers.push(new PathLayer({
145448
+ ...base,
145449
+ id: `annotation-select-${sUid}`,
145450
+ data: [{ path: [...sel.points, sel.points[0]] }],
145451
+ getPath: (d) => d.path,
145452
+ getColor: haloColor,
145453
+ getWidth: haloWidth,
145454
+ widthUnits: "pixels",
145455
+ jointRounded: true
145456
+ }));
145457
+ }
145458
+ if (sType === "polyline" && sel.points?.length >= 2) {
145459
+ selectionLayers.push(new PathLayer({
145460
+ ...base,
145461
+ id: `annotation-select-${sUid}`,
145462
+ data: [{ path: sel.points }],
145463
+ getPath: (d) => d.path,
145464
+ getColor: haloColor,
145465
+ getWidth: haloWidth,
145466
+ widthUnits: "pixels",
145467
+ jointRounded: true,
145468
+ capRounded: true
145469
+ }));
145470
+ }
145471
+ }
145472
+ }
145473
+ const layers = [];
145474
+ const dotShapes = [];
145475
+ const clusterDotShapes = [];
145476
+ shapes.forEach((shape2, i2) => {
145477
+ const { uid: uid2, type, strokeColor = [255, 255, 255], strokeWidth = 3, strokeDashArray } = shape2;
145478
+ const isSelected = uid2 === selectedShapeUid;
145479
+ let shapeOpacity = 1;
145480
+ let tipsOpacity = 1;
145481
+ let labelOpacity = 0;
145482
+ if (isSelected || !semanticZoom || authoredZoom === null) {
145483
+ tipsOpacity = 1;
145484
+ labelOpacity = 1;
145485
+ } else {
145486
+ const zoomRatio = 2 ** (zoom - authoredZoom);
145487
+ if (zoomRatio < RATIO_CLUSTER) {
145488
+ clusterDotShapes.push({ shape: shape2 });
145489
+ return;
145490
+ }
145491
+ if (zoomRatio < RATIO_DOT) {
145492
+ dotShapes.push({ shape: shape2, alpha: 200 });
145493
+ return;
145494
+ }
145495
+ if (zoomRatio < RATIO_GEO_FADE) {
145496
+ const t = (zoomRatio - RATIO_DOT) / (RATIO_GEO_FADE - RATIO_DOT);
145497
+ shapeOpacity = t;
145498
+ dotShapes.push({ shape: shape2, alpha: Math.round((1 - t) * 200) });
145499
+ }
145500
+ tipsOpacity = zoomRatio >= RATIO_TIPS ? shapeOpacity : Math.max(0, (zoomRatio - RATIO_GEO_FADE) / (RATIO_TIPS - RATIO_GEO_FADE) * shapeOpacity);
145501
+ if (zoomRatio >= RATIO_LABEL_FULL) {
145502
+ labelOpacity = shapeOpacity;
145503
+ } else if (zoomRatio >= RATIO_LABEL) {
145504
+ labelOpacity = (zoomRatio - RATIO_LABEL) / (RATIO_LABEL_FULL - RATIO_LABEL) * shapeOpacity;
145505
+ }
145506
+ }
145507
+ const arrowDataSize = Math.max(ARROW_SCREEN_PX, strokeWidth * 4) / 2 ** zoom;
145508
+ const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: shapeOpacity };
145509
+ const tipsBase = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: tipsOpacity };
145510
+ const labelBase = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: labelOpacity };
145511
+ const labelBgProps = shape2.labelBackground ? {
145512
+ background: true,
145513
+ getBackgroundColor: textBgColor(strokeColor),
145514
+ backgroundPadding: [3, 1, 3, 2]
145515
+ } : {};
145516
+ const labelProps = { ...labelBgProps };
145517
+ const dashArray = parseDashArray(strokeDashArray);
145518
+ const dashExt = [new PathStyleExtension({ dash: true })];
145519
+ const getDash = dashArray ?? [0, 0];
145520
+ if (type === "rectangle") {
145521
+ const { x, y, width: width2, height: height2, fillColor = strokeColor, fillOpacity = 0 } = shape2;
145522
+ const filled = fillOpacity > 0;
145523
+ const rectPolygon = [[x, y], [x + width2, y], [x + width2, y + height2], [x, y + height2]];
145524
+ layers.push(new PolygonLayer({
145525
+ ...base,
145526
+ id: `annotation-rect-${uid2}-${i2}`,
145527
+ data: [{ polygon: rectPolygon }],
145528
+ getPolygon: (d) => d.polygon,
145529
+ filled,
145530
+ stroked: true,
145531
+ getFillColor: filled ? [...fillColor, Math.round(fillOpacity * 255)] : [0, 0, 0, 0],
145532
+ getLineColor: strokeColor,
145533
+ getLineWidth: strokeWidth,
145534
+ lineWidthUnits: "pixels",
145535
+ ...dashArray ? {
145536
+ extensions: [new PathStyleExtension({ dash: true })],
145537
+ getDashArray: dashArray
145538
+ } : {}
145539
+ }));
145540
+ if (shape2.text && labelOpacity > 0) {
145541
+ layers.push(new TextLayer({
145542
+ ...labelBase,
145543
+ ...labelProps,
145544
+ id: `annotation-rect-text-${uid2}-${i2}`,
145545
+ data: [{ position: [x, y], text: shape2.text }],
145546
+ getPosition: (d) => d.position,
145547
+ getText: (d) => d.text,
145548
+ getColor: strokeColor,
145549
+ getSize: LABEL_FONT_SIZE,
145550
+ sizeUnits: "pixels",
145551
+ fontFamily: LABEL_FONT_FAMILY,
145552
+ fontWeight: LABEL_FONT_WEIGHT,
145553
+ getPixelOffset: [3, -7],
145554
+ getTextAnchor: "start",
145555
+ getAlignmentBaseline: "bottom"
145556
+ }));
145557
+ }
145558
+ }
145559
+ if (type === "line") {
145560
+ const { x1: x12, y1: y12, x2, y2, markerStart, markerEnd } = shape2;
145561
+ const dx = x2 - x12;
145562
+ const dy = y2 - y12;
145563
+ const len2 = Math.sqrt(dx * dx + dy * dy);
145564
+ const ux = len2 > 0 ? dx / len2 : 0;
145565
+ const uy = len2 > 0 ? dy / len2 : 0;
145566
+ const srcX = markerStart === "Arrow" ? x12 + ux * arrowDataSize : x12;
145567
+ const srcY = markerStart === "Arrow" ? y12 + uy * arrowDataSize : y12;
145568
+ const tgtX = markerEnd === "Arrow" ? x2 - ux * arrowDataSize : x2;
145569
+ const tgtY = markerEnd === "Arrow" ? y2 - uy * arrowDataSize : y2;
145570
+ layers.push(new PathLayer({
145571
+ ...base,
145572
+ id: `annotation-line-${uid2}-${i2}`,
145573
+ extensions: [new PathStyleExtension({ dash: true })],
145574
+ getDashArray: dashArray ?? [0, 0],
145575
+ data: [{ path: [[srcX, srcY], [tgtX, tgtY]] }],
145576
+ getPath: (d) => d.path,
145577
+ getColor: strokeColor,
145578
+ getWidth: strokeWidth,
145579
+ widthUnits: "pixels",
145580
+ capRounded: true
145581
+ }));
145582
+ if (markerEnd === "Arrow" && tipsOpacity > 0) {
145583
+ const head = computeArrowhead(x2, y2, x2 - x12, y2 - y12, arrowDataSize);
145584
+ if (head) {
145585
+ layers.push(new PolygonLayer({
145586
+ ...tipsBase,
145587
+ id: `annotation-end-arrow-${uid2}-${i2}`,
145588
+ data: [{ polygon: head }],
145589
+ getPolygon: (d) => d.polygon,
145590
+ filled: true,
145591
+ stroked: false,
145592
+ getFillColor: strokeColor
145593
+ }));
145594
+ }
145595
+ }
145596
+ if (markerStart === "Arrow" && tipsOpacity > 0) {
145597
+ const head = computeArrowhead(x12, y12, x12 - x2, y12 - y2, arrowDataSize);
145598
+ if (head) {
145599
+ layers.push(new PolygonLayer({
145600
+ ...tipsBase,
145601
+ id: `annotation-start-arrow-${uid2}-${i2}`,
145602
+ data: [{ polygon: head }],
145603
+ getPolygon: (d) => d.polygon,
145604
+ filled: true,
145605
+ stroked: false,
145606
+ getFillColor: strokeColor
145607
+ }));
145608
+ }
145609
+ }
145610
+ if (markerEnd === "Tick" && tipsOpacity > 0) {
145611
+ const tick = computeTickCap(x2, y2, x2 - x12, y2 - y12, arrowDataSize);
145612
+ if (tick) {
145613
+ layers.push(new PathLayer({
145614
+ ...tipsBase,
145615
+ id: `annotation-end-tick-${uid2}-${i2}`,
145616
+ data: [{ path: tick }],
145617
+ getPath: (d) => d.path,
145618
+ getColor: strokeColor,
145619
+ getWidth: strokeWidth,
145620
+ widthUnits: "pixels",
145621
+ capRounded: true
145622
+ }));
145623
+ }
145624
+ }
145625
+ if (markerStart === "Tick" && tipsOpacity > 0) {
145626
+ const tick = computeTickCap(x12, y12, x12 - x2, y12 - y2, arrowDataSize);
145627
+ if (tick) {
145628
+ layers.push(new PathLayer({
145629
+ ...tipsBase,
145630
+ id: `annotation-start-tick-${uid2}-${i2}`,
145631
+ data: [{ path: tick }],
145632
+ getPath: (d) => d.path,
145633
+ getColor: strokeColor,
145634
+ getWidth: strokeWidth,
145635
+ widthUnits: "pixels",
145636
+ capRounded: true
145637
+ }));
145638
+ }
145639
+ }
145640
+ if (shape2.text) {
145641
+ const pos = shape2.textPosition ?? "start";
145642
+ let textX;
145643
+ let textY;
145644
+ if (pos === "start") {
145645
+ textX = x12;
145646
+ textY = y12;
145647
+ } else if (pos === "end") {
145648
+ textX = x2;
145649
+ textY = y2;
145650
+ } else {
145651
+ textX = (x12 + x2) / 2;
145652
+ textY = (y12 + y2) / 2;
145653
+ }
145654
+ let pixelOffset = [0, 0];
145655
+ let textAnchor = "middle";
145656
+ let alignmentBaseline = "center";
145657
+ if (pos !== "middle") {
145658
+ const dxT = x2 - x12;
145659
+ const dyT = y2 - y12;
145660
+ const lenT = Math.sqrt(dxT * dxT + dyT * dyT);
145661
+ if (lenT > 0) {
145662
+ const uxT = dxT / lenT;
145663
+ const uyT = dyT / lenT;
145664
+ const sign2 = pos === "start" ? -1 : 1;
145665
+ const bufferPx = shape2.textBufferPx ?? 8;
145666
+ const offsetX = sign2 * uxT * bufferPx;
145667
+ const offsetY = sign2 * uyT * bufferPx;
145668
+ pixelOffset = [offsetX, offsetY];
145669
+ const absX = Math.abs(offsetX);
145670
+ const absY = Math.abs(offsetY);
145671
+ if (absX >= absY) {
145672
+ textAnchor = offsetX > 0 ? "start" : "end";
145673
+ }
145674
+ if (absY >= absX) {
145675
+ alignmentBaseline = offsetY > 0 ? "top" : "bottom";
145676
+ }
145677
+ }
145678
+ } else if (len2 > 0) {
145679
+ const belowPerp = pickBelowPerp(ux, uy);
145680
+ const bufferPx = shape2.textBufferPx ?? 14;
145681
+ pixelOffset = [-belowPerp[0] * bufferPx, -belowPerp[1] * bufferPx];
145682
+ textAnchor = "middle";
145683
+ alignmentBaseline = "center";
145684
+ }
145685
+ const middleAngle = pos === "middle" && len2 > 0 ? -readableAngle(Math.atan2(dy, dx) * 180 / Math.PI) : null;
145686
+ if (labelOpacity <= 0)
145687
+ return;
145688
+ layers.push(new TextLayer({
145689
+ ...labelBase,
145690
+ ...labelProps,
145691
+ id: `annotation-line-text-${uid2}-${i2}`,
145692
+ data: [{ position: [textX, textY], text: shape2.text }],
145693
+ getPosition: (d) => d.position,
145694
+ getText: (d) => d.text,
145695
+ getColor: strokeColor,
145696
+ getSize: LABEL_FONT_SIZE,
145697
+ sizeUnits: "pixels",
145698
+ fontFamily: LABEL_FONT_FAMILY,
145699
+ fontWeight: LABEL_FONT_WEIGHT,
145700
+ getPixelOffset: pixelOffset,
145701
+ getTextAnchor: textAnchor,
145702
+ getAlignmentBaseline: alignmentBaseline,
145703
+ ...middleAngle !== null && { getAngle: middleAngle }
145704
+ }));
145705
+ }
145706
+ }
145707
+ if (type === "ellipse") {
145708
+ const { x1: x12, y1: y12, radiusX, radiusY, fillColor = strokeColor, fillOpacity = 0 } = shape2;
145709
+ const polygon2 = computeEllipsePolygon(x12, y12, radiusX, radiusY);
145710
+ const filled = fillOpacity > 0;
145711
+ layers.push(new PolygonLayer({
145712
+ ...base,
145713
+ id: `annotation-ellipse-${uid2}-${i2}`,
145714
+ data: [{ polygon: polygon2 }],
145715
+ getPolygon: (d) => d.polygon,
145716
+ filled,
145717
+ stroked: true,
145718
+ getFillColor: filled ? [...fillColor, Math.round(fillOpacity * 255)] : [0, 0, 0, 0],
145719
+ getLineColor: strokeColor,
145720
+ getLineWidth: strokeWidth,
145721
+ lineWidthUnits: "pixels",
145722
+ ...dashArray ? {
145723
+ extensions: [new PathStyleExtension({ dash: true })],
145724
+ getDashArray: dashArray
145725
+ } : {}
145726
+ }));
145727
+ if (shape2.text && labelOpacity > 0) {
145728
+ layers.push(new TextLayer({
145729
+ ...labelBase,
145730
+ ...labelProps,
145731
+ id: `annotation-ellipse-text-${uid2}-${i2}`,
145732
+ data: [{ position: [x12, y12 - radiusY], text: shape2.text }],
145733
+ getPosition: (d) => d.position,
145734
+ getText: (d) => d.text,
145735
+ getColor: strokeColor,
145736
+ getSize: LABEL_FONT_SIZE,
145737
+ sizeUnits: "pixels",
145738
+ fontFamily: LABEL_FONT_FAMILY,
145739
+ fontWeight: LABEL_FONT_WEIGHT,
145740
+ getPixelOffset: [0, -4],
145741
+ getTextAnchor: "middle",
145742
+ getAlignmentBaseline: "bottom"
145743
+ }));
145744
+ }
145745
+ }
145746
+ if (type === "polygon") {
145747
+ const { points, fillColor = strokeColor, fillOpacity = 0 } = shape2;
145748
+ if (!points || points.length < 3)
145749
+ return;
145750
+ const closedPath = [...points, points[0]];
145751
+ if (fillOpacity > 0) {
145752
+ layers.push(new PolygonLayer({
145753
+ ...base,
145754
+ id: `annotation-polygon-fill-${uid2}-${i2}`,
145755
+ data: [{ polygon: points }],
145756
+ getPolygon: (d) => d.polygon,
145757
+ stroked: false,
145758
+ filled: true,
145759
+ getFillColor: [...fillColor, Math.round(fillOpacity * 255)]
145760
+ }));
145761
+ }
145762
+ layers.push(new PathLayer({
145763
+ ...base,
145764
+ id: `annotation-polygon-${uid2}-${i2}`,
145765
+ extensions: dashExt,
145766
+ getDashArray: getDash,
145767
+ data: [{ path: closedPath }],
145768
+ getPath: (d) => d.path,
145769
+ getColor: strokeColor,
145770
+ getWidth: strokeWidth,
145771
+ widthUnits: "pixels",
145772
+ jointRounded: true
145773
+ }));
145774
+ if (shape2.text && labelOpacity > 0) {
145775
+ const minX = Math.min(...points.map((p) => p[0]));
145776
+ const maxX = Math.max(...points.map((p) => p[0]));
145777
+ const minY = Math.min(...points.map((p) => p[1]));
145778
+ const topCenterX = (minX + maxX) / 2;
145779
+ layers.push(new TextLayer({
145780
+ ...labelBase,
145781
+ ...labelProps,
145782
+ id: `annotation-polygon-text-${uid2}-${i2}`,
145783
+ data: [{ position: [topCenterX, minY], text: shape2.text }],
145784
+ getPosition: (d) => d.position,
145785
+ getText: (d) => d.text,
145786
+ getColor: strokeColor,
145787
+ getSize: LABEL_FONT_SIZE,
145788
+ sizeUnits: "pixels",
145789
+ fontFamily: LABEL_FONT_FAMILY,
145790
+ fontWeight: LABEL_FONT_WEIGHT,
145791
+ getPixelOffset: [0, -4],
145792
+ getTextAnchor: "middle",
145793
+ getAlignmentBaseline: "bottom"
145794
+ }));
145795
+ }
145796
+ }
145797
+ if (type === "polyline") {
145798
+ const { points, markerStart, markerEnd } = shape2;
145799
+ if (!points || points.length < 2)
145800
+ return;
145801
+ let pathPoints = points;
145802
+ if (markerStart === "Arrow") {
145803
+ const [x02, y02] = points[0];
145804
+ const [x12, y12] = points[1];
145805
+ const dx = x02 - x12;
145806
+ const dy = y02 - y12;
145807
+ const len2 = Math.sqrt(dx * dx + dy * dy);
145808
+ if (len2 > 0) {
145809
+ const ux = dx / len2;
145810
+ const uy = dy / len2;
145811
+ pathPoints = [[x02 - ux * arrowDataSize, y02 - uy * arrowDataSize], ...pathPoints.slice(1)];
145812
+ }
145813
+ }
145814
+ if (markerEnd === "Arrow") {
145815
+ const last = pathPoints[pathPoints.length - 1];
145816
+ const prev2 = pathPoints[pathPoints.length - 2];
145817
+ const dx = last[0] - prev2[0];
145818
+ const dy = last[1] - prev2[1];
145819
+ const len2 = Math.sqrt(dx * dx + dy * dy);
145820
+ if (len2 > 0) {
145821
+ const ux = dx / len2;
145822
+ const uy = dy / len2;
145823
+ const shortened = [last[0] - ux * arrowDataSize, last[1] - uy * arrowDataSize];
145824
+ pathPoints = [...pathPoints.slice(0, -1), shortened];
145825
+ }
145826
+ }
145827
+ layers.push(new PathLayer({
145828
+ ...base,
145829
+ id: `annotation-polyline-${uid2}-${i2}`,
145830
+ extensions: dashExt,
145831
+ getDashArray: getDash,
145832
+ data: [{ path: pathPoints }],
145833
+ getPath: (d) => d.path,
145834
+ getColor: strokeColor,
145835
+ getWidth: strokeWidth,
145836
+ widthUnits: "pixels",
145837
+ jointRounded: true,
145838
+ capRounded: true
145839
+ }));
145840
+ if (markerStart === "Arrow" && tipsOpacity > 0) {
145841
+ const [x02, y02] = points[0];
145842
+ const [x12, y12] = points[1];
145843
+ const head = computeArrowhead(x02, y02, x02 - x12, y02 - y12, arrowDataSize);
145844
+ if (head) {
145845
+ layers.push(new PolygonLayer({
145846
+ ...tipsBase,
145847
+ id: `annotation-polyline-start-arrow-${uid2}-${i2}`,
145848
+ data: [{ polygon: head }],
145849
+ getPolygon: (d) => d.polygon,
145850
+ filled: true,
145851
+ stroked: false,
145852
+ getFillColor: strokeColor
145853
+ }));
145854
+ }
145855
+ }
145856
+ if (markerEnd === "Arrow" && tipsOpacity > 0) {
145857
+ const last = points[points.length - 1];
145858
+ const prev2 = points[points.length - 2];
145859
+ const dxArrow = last[0] - prev2[0];
145860
+ const dyArrow = last[1] - prev2[1];
145861
+ const head = computeArrowhead(last[0], last[1], dxArrow, dyArrow, arrowDataSize);
145862
+ if (head) {
145863
+ layers.push(new PolygonLayer({
145864
+ ...tipsBase,
145865
+ id: `annotation-polyline-end-arrow-${uid2}-${i2}`,
145866
+ data: [{ polygon: head }],
145867
+ getPolygon: (d) => d.polygon,
145868
+ filled: true,
145869
+ stroked: false,
145870
+ getFillColor: strokeColor
145871
+ }));
145872
+ }
145873
+ }
145874
+ if (markerStart === "Tick" && tipsOpacity > 0) {
145875
+ const [x02, y02] = points[0];
145876
+ const [x12, y12] = points[1];
145877
+ const tick = computeTickCap(x02, y02, x02 - x12, y02 - y12, arrowDataSize);
145878
+ if (tick) {
145879
+ layers.push(new PathLayer({
145880
+ ...tipsBase,
145881
+ id: `annotation-polyline-start-tick-${uid2}-${i2}`,
145882
+ data: [{ path: tick }],
145883
+ getPath: (d) => d.path,
145884
+ getColor: strokeColor,
145885
+ getWidth: strokeWidth,
145886
+ widthUnits: "pixels",
145887
+ capRounded: true
145888
+ }));
145889
+ }
145890
+ }
145891
+ if (markerEnd === "Tick" && tipsOpacity > 0) {
145892
+ const last = points[points.length - 1];
145893
+ const prev2 = points[points.length - 2];
145894
+ const dxTick = last[0] - prev2[0];
145895
+ const dyTick = last[1] - prev2[1];
145896
+ const tick = computeTickCap(last[0], last[1], dxTick, dyTick, arrowDataSize);
145897
+ if (tick) {
145898
+ layers.push(new PathLayer({
145899
+ ...tipsBase,
145900
+ id: `annotation-polyline-end-tick-${uid2}-${i2}`,
145901
+ data: [{ path: tick }],
145902
+ getPath: (d) => d.path,
145903
+ getColor: strokeColor,
145904
+ getWidth: strokeWidth,
145905
+ widthUnits: "pixels",
145906
+ capRounded: true
145907
+ }));
145908
+ }
145909
+ }
145910
+ if (shape2.text) {
145911
+ const pos = shape2.textPosition ?? "start";
145912
+ const bufferPx = shape2.textBufferPx ?? 8;
145913
+ let textPt;
145914
+ let dirX;
145915
+ let dirY;
145916
+ if (pos === "end") {
145917
+ const last = points[points.length - 1];
145918
+ const prev2 = points[points.length - 2];
145919
+ textPt = last;
145920
+ dirX = last[0] - prev2[0];
145921
+ dirY = last[1] - prev2[1];
145922
+ } else if (pos === "middle") {
145923
+ const mx = points.reduce((s2, p) => s2 + p[0], 0) / points.length;
145924
+ const my = points.reduce((s2, p) => s2 + p[1], 0) / points.length;
145925
+ textPt = [mx, my];
145926
+ dirX = 0;
145927
+ dirY = 0;
145928
+ } else {
145929
+ [textPt] = points;
145930
+ dirX = points[0][0] - points[1][0];
145931
+ dirY = points[0][1] - points[1][1];
145932
+ }
145933
+ const [textX, textY] = textPt;
145934
+ const lenT = Math.sqrt(dirX * dirX + dirY * dirY);
145935
+ let polylinePixelOffset = [0, 0];
145936
+ let polylineTextAnchor = "middle";
145937
+ let polylineAlignmentBaseline = pos === "middle" ? "center" : "bottom";
145938
+ if (lenT > 0) {
145939
+ const uxT = dirX / lenT;
145940
+ const uyT = dirY / lenT;
145941
+ const offX = uxT * bufferPx;
145942
+ const offY = uyT * bufferPx;
145943
+ polylinePixelOffset = [offX, offY];
145944
+ if (Math.abs(offX) >= Math.abs(offY)) {
145945
+ polylineTextAnchor = offX > 0 ? "start" : "end";
145946
+ }
145947
+ if (Math.abs(offY) >= Math.abs(offX)) {
145948
+ polylineAlignmentBaseline = offY > 0 ? "top" : "bottom";
145949
+ }
145950
+ }
145951
+ if (labelOpacity <= 0)
145952
+ return;
145953
+ layers.push(new TextLayer({
145954
+ ...labelBase,
145955
+ ...labelProps,
145956
+ id: `annotation-polyline-text-${uid2}-${i2}`,
145957
+ data: [{ position: [textX, textY], text: shape2.text }],
145958
+ getPosition: (d) => d.position,
145959
+ getText: (d) => d.text,
145960
+ getColor: strokeColor,
145961
+ getSize: LABEL_FONT_SIZE,
145962
+ sizeUnits: "pixels",
145963
+ fontFamily: LABEL_FONT_FAMILY,
145964
+ fontWeight: LABEL_FONT_WEIGHT,
145965
+ getPixelOffset: polylinePixelOffset,
145966
+ getTextAnchor: polylineTextAnchor,
145967
+ getAlignmentBaseline: polylineAlignmentBaseline
145968
+ }));
145969
+ }
145970
+ }
145971
+ });
145972
+ if (dotShapes.length > 0) {
145973
+ layers.push(new ScatterplotLayer({
145974
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
145975
+ id: "annotation-dots",
145976
+ data: dotShapes.map(({ shape: s2, alpha: alpha2 }) => ({
145977
+ position: getShapeCentroid(s2),
145978
+ color: [...s2.strokeColor ?? [255, 255, 255], alpha2]
145979
+ })),
145980
+ getPosition: (d) => d.position,
145981
+ getFillColor: (d) => d.color,
145982
+ getRadius: 4,
145983
+ radiusUnits: "pixels",
145984
+ filled: true,
145985
+ stroked: false
145986
+ }));
145987
+ }
145988
+ if (clusterDotShapes.length > 0) {
145989
+ const clusters = computeClusters(clusterDotShapes, zoom);
145990
+ layers.push(new ScatterplotLayer({
145991
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
145992
+ id: "annotation-clusters",
145993
+ data: clusters,
145994
+ getPosition: (d) => d.position,
145995
+ getFillColor: (d) => [...d.color, 180],
145996
+ getRadius: (d) => Math.max(6, 4 + Math.sqrt(d.count) * 2),
145997
+ radiusUnits: "pixels",
145998
+ filled: true,
145999
+ stroked: true,
146000
+ getLineColor: (d) => [...d.color, 220],
146001
+ lineWidthMinPixels: 1.5
146002
+ }));
146003
+ const multiClusters = clusters.filter((c) => c.count > 1);
146004
+ if (multiClusters.length > 0) {
146005
+ layers.push(new TextLayer({
146006
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
146007
+ id: "annotation-cluster-counts",
146008
+ data: multiClusters,
146009
+ getPosition: (d) => d.position,
146010
+ getText: (d) => String(d.count),
146011
+ getColor: [255, 255, 255],
146012
+ getSize: 10,
146013
+ sizeUnits: "pixels",
146014
+ fontWeight: "bold",
146015
+ getTextAnchor: "middle",
146016
+ getAlignmentBaseline: "center"
146017
+ }));
146018
+ }
146019
+ }
146020
+ const measureLayers = [];
146021
+ shapes.forEach((shape2) => {
146022
+ if (!shape2.showMeasure)
146023
+ return;
146024
+ const mIsSelected = shape2.uid === selectedShapeUid;
146025
+ const label = getMeasurementLabel(shape2, physicalPixelSize, viewType);
146026
+ if (!label)
146027
+ return;
146028
+ const color2 = shape2.strokeColor ?? [255, 255, 255];
146029
+ let mShapeOpacity = 1;
146030
+ let mLabelFactor = 0;
146031
+ if (mIsSelected || !semanticZoom || authoredZoom === null) {
146032
+ mLabelFactor = 1;
146033
+ } else {
146034
+ const mZoomRatio = 2 ** (zoom - authoredZoom);
146035
+ if (mZoomRatio < RATIO_DOT)
146036
+ return;
146037
+ if (mZoomRatio < RATIO_GEO_FADE) {
146038
+ mShapeOpacity = (mZoomRatio - RATIO_DOT) / (RATIO_GEO_FADE - RATIO_DOT);
146039
+ }
146040
+ if (mZoomRatio >= RATIO_LABEL_FULL) {
146041
+ mLabelFactor = 1;
146042
+ } else if (mZoomRatio >= RATIO_LABEL) {
146043
+ mLabelFactor = (mZoomRatio - RATIO_LABEL) / (RATIO_LABEL_FULL - RATIO_LABEL);
146044
+ }
146045
+ }
146046
+ const measureOpacity = mShapeOpacity * mLabelFactor;
146047
+ if (measureOpacity <= 0)
146048
+ return;
146049
+ const base = {
146050
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
146051
+ opacity: measureOpacity,
146052
+ getText: (d) => d.text,
146053
+ getPosition: (d) => d.position,
146054
+ getColor: color2,
146055
+ getSize: 13,
146056
+ sizeUnits: "pixels",
146057
+ fontFamily: LABEL_FONT_FAMILY,
146058
+ fontWeight: "bold",
146059
+ // 'auto' builds the font atlas from the actual rendered characters (e.g. µ, ²)
146060
+ // instead of deck.gl's default ASCII-only atlas.
146061
+ characterSet: "auto",
146062
+ ...shape2.measureBackground ? {
146063
+ background: true,
146064
+ getBackgroundColor: textBgColor(color2),
146065
+ backgroundPadding: [3, 1, 3, 2]
146066
+ } : {}
146067
+ };
146068
+ if (shape2.type === "line") {
146069
+ const mx = ((shape2.x1 ?? 0) + (shape2.x2 ?? 0)) / 2;
146070
+ const my = ((shape2.y1 ?? 0) + (shape2.y2 ?? 0)) / 2;
146071
+ const dx = (shape2.x2 ?? 0) - (shape2.x1 ?? 0);
146072
+ const dy = (shape2.y2 ?? 0) - (shape2.y1 ?? 0);
146073
+ const len2 = Math.sqrt(dx * dx + dy * dy);
146074
+ if (len2 === 0)
146075
+ return;
146076
+ const perp = pickBelowPerp(dx / len2, dy / len2);
146077
+ const angle2 = readableAngle(Math.atan2(dy, dx) * 180 / Math.PI);
146078
+ measureLayers.push(new TextLayer({
146079
+ ...base,
146080
+ id: `annotation-measure-${shape2.uid}`,
146081
+ data: [{ position: [mx, my], text: label }],
146082
+ getAngle: -angle2,
146083
+ getTextAnchor: "middle",
146084
+ getAlignmentBaseline: "center",
146085
+ getPixelOffset: [perp[0] * 16, perp[1] * 16]
146086
+ }));
146087
+ } else if (shape2.type === "polyline" && shape2.points?.length >= 2) {
146088
+ const pts = shape2.points;
146089
+ const mi = Math.floor((pts.length - 1) / 2);
146090
+ const [ax, ay] = pts[mi];
146091
+ const [bx, by] = pts[mi + 1];
146092
+ const dx = bx - ax;
146093
+ const dy = by - ay;
146094
+ const len2 = Math.sqrt(dx * dx + dy * dy);
146095
+ if (len2 === 0)
146096
+ return;
146097
+ const perp = pickBelowPerp(dx / len2, dy / len2);
146098
+ const angle2 = readableAngle(Math.atan2(dy, dx) * 180 / Math.PI);
146099
+ measureLayers.push(new TextLayer({
146100
+ ...base,
146101
+ id: `annotation-measure-${shape2.uid}`,
146102
+ data: [{ position: [(ax + bx) / 2, (ay + by) / 2], text: label }],
146103
+ getAngle: -angle2,
146104
+ getTextAnchor: "middle",
146105
+ getAlignmentBaseline: "center",
146106
+ getPixelOffset: [perp[0] * 16, perp[1] * 16]
146107
+ }));
146108
+ } else if (shape2.type === "rectangle") {
146109
+ const x02 = shape2.x ?? 0;
146110
+ const y02 = shape2.y ?? 0;
146111
+ const w2 = shape2.width ?? 0;
146112
+ const h = shape2.height ?? 0;
146113
+ const rx = x02 + (w2 >= 0 ? w2 : 0);
146114
+ const ry = y02 + (h >= 0 ? h : 0);
146115
+ measureLayers.push(new TextLayer({
146116
+ ...base,
146117
+ id: `annotation-measure-${shape2.uid}`,
146118
+ data: [{ position: [rx, ry], text: label }],
146119
+ getTextAnchor: "end",
146120
+ getAlignmentBaseline: "bottom",
146121
+ getPixelOffset: [-6, -6]
146122
+ }));
146123
+ } else if (shape2.type === "ellipse") {
146124
+ const cx = shape2.x1 ?? 0;
146125
+ const cy = shape2.y1 ?? 0;
146126
+ const ry = Math.abs(shape2.radiusY ?? 0);
146127
+ measureLayers.push(new TextLayer({
146128
+ ...base,
146129
+ id: `annotation-measure-${shape2.uid}`,
146130
+ data: [{ position: [cx, cy + ry], text: label }],
146131
+ getTextAnchor: "middle",
146132
+ getAlignmentBaseline: "top",
146133
+ getPixelOffset: [0, 8]
146134
+ }));
146135
+ } else if (shape2.type === "polygon" && shape2.points?.length >= 3) {
146136
+ const xs = shape2.points.map((p) => p[0]);
146137
+ const ys = shape2.points.map((p) => p[1]);
146138
+ const cx = (Math.min(...xs) + Math.max(...xs)) / 2;
146139
+ const maxY = Math.max(...ys);
146140
+ measureLayers.push(new TextLayer({
146141
+ ...base,
146142
+ id: `annotation-measure-${shape2.uid}`,
146143
+ data: [{ position: [cx, maxY], text: label }],
146144
+ getTextAnchor: "middle",
146145
+ getAlignmentBaseline: "top",
146146
+ getPixelOffset: [0, 8]
146147
+ }));
146148
+ }
146149
+ });
146150
+ return [...selectionLayers, ...layers, ...measureLayers];
146151
+ }
146152
+ const defaultProps = {
146153
+ // Array of annotation shape objects (see annotationShapeObj in @vitessce/schemas).
146154
+ data: { type: "object", value: [], compare: true },
146155
+ // UID of the shape to highlight with a selection halo.
146156
+ selectedShapeUid: { type: "string", value: null },
146157
+ // { x, y, unit } used to format measurement labels in physical units.
146158
+ physicalPixelSize: { type: "object", value: null, compare: true },
146159
+ // The zoom level at which the shapes were authored (reference for semantic zoom).
146160
+ authoredZoom: { type: "number", value: null },
146161
+ // Whether to apply semantic zoom (level-of-detail) based on authoredZoom.
146162
+ semanticZoom: { type: "boolean", value: true },
146163
+ // The view type in which the layer is rendered (affects measurement label formatting).
146164
+ viewType: { type: "string", value: ViewType.SPATIAL },
146165
+ // In-progress shape being drawn, as { type, vertices }.
146166
+ inProgressShape: { type: "object", value: null, compare: true },
146167
+ // Current mouse position (in data coordinates) while drawing.
146168
+ hoverCoord: { type: "array", value: null, compare: true },
146169
+ // Stroke color [r, g, b] of the in-progress shape preview.
146170
+ previewStrokeColor: { type: "color", value: [255, 255, 0] }
146171
+ };
146172
+ class AnnotationLayer extends CompositeLayer {
146173
+ // The semantic zoom and arrowhead sizes depend on the current zoom level,
146174
+ // so the sublayers must also be re-rendered when the viewport changes.
146175
+ // eslint-disable-next-line class-methods-use-this
146176
+ shouldUpdateState({ changeFlags }) {
146177
+ return changeFlags.propsOrDataChanged || changeFlags.viewportChanged;
146178
+ }
146179
+ /**
146180
+ * Prefix the sublayer ID with this layer's ID (so that multiple
146181
+ * AnnotationLayers can co-exist), and combine this layer's
146182
+ * opacity with the per-shape opacity of the sublayer.
146183
+ * Note: we avoid getSubLayerProps here, since it would
146184
+ * overwrite the sublayer extensions (e.g., PathStyleExtension)
146185
+ * and opacity values.
146186
+ * @param {object} layer A DeckGL layer instance.
146187
+ * @returns {object} The cloned layer instance.
146188
+ */
146189
+ wrapSubLayer(layer) {
146190
+ const { id, opacity, pickable, visible } = this.props;
146191
+ return layer.clone({
146192
+ id: `${id}-${layer.id}`,
146193
+ opacity: layer.props.opacity * opacity,
146194
+ pickable,
146195
+ visible
146196
+ });
146197
+ }
146198
+ renderLayers() {
146199
+ const { data, selectedShapeUid, physicalPixelSize, authoredZoom, semanticZoom, viewType, inProgressShape, hoverCoord, previewStrokeColor } = this.props;
146200
+ const zoom = this.context.viewport?.zoom ?? 0;
146201
+ const visibleShapes = (data ?? []).filter((shape2) => shape2.visible !== false);
146202
+ const annotationLayers = createAnnotationLayers(visibleShapes, zoom, selectedShapeUid, physicalPixelSize, authoredZoom, semanticZoom, viewType);
146203
+ const previewLayer = createPreviewLayer(inProgressShape, hoverCoord, previewStrokeColor.slice(0, 3));
146204
+ return [
146205
+ ...annotationLayers,
146206
+ ...previewLayer ? [previewLayer] : []
146207
+ ].map((layer) => this.wrapSubLayer(layer));
146208
+ }
146209
+ }
146210
+ AnnotationLayer.layerName = "AnnotationLayer";
146211
+ AnnotationLayer.defaultProps = defaultProps;
144974
146212
  const toRgbUIString = (on, arr, theme) => {
144975
146213
  const color2 = on || theme !== "dark" && arr?.every((i2) => i2 === 255) ? [220, 220, 220] : arr;
144976
146214
  return `rgb(${color2})`;
@@ -144988,8 +146226,8 @@ async function getSingleSelectionStats2D({ loader, selection }) {
144988
146226
  const filteredSelection = filterSelection(loader, selection);
144989
146227
  const raster = await data.getRaster({ selection: filteredSelection });
144990
146228
  const selectionStats = getChannelStats(raster.data);
144991
- const { domain, contrastLimits: slider } = selectionStats;
144992
- return { domain, slider };
146229
+ const { domain, contrastLimits: slider, q1, q3 } = selectionStats;
146230
+ return { domain, slider, q1, q3 };
144993
146231
  }
144994
146232
  async function getSingleSelectionStats3D({ loader, selection }) {
144995
146233
  const lowResSource = loader[loader.length - 1];
@@ -145016,7 +146254,9 @@ async function getSingleSelectionStats3D({ loader, selection }) {
145016
146254
  slider: [
145017
146255
  Math.min(stats0.contrastLimits[0], statsMid.contrastLimits[0], statsTop.contrastLimits[0]),
145018
146256
  Math.max(stats0.contrastLimits[1], statsMid.contrastLimits[1], statsTop.contrastLimits[1])
145019
- ]
146257
+ ],
146258
+ q1: Math.min(stats0.q1[0], statsMid.q1[0], statsTop.q1[0]),
146259
+ q3: Math.max(stats0.q3[1], statsMid.q3[1], statsTop.q3[1])
145020
146260
  };
145021
146261
  }
145022
146262
  const getSingleSelectionStats = async ({ loader, selection, use3d }) => {
@@ -145027,7 +146267,9 @@ const getMultiSelectionStats = async ({ loader, selections, use3d }) => {
145027
146267
  const stats = await Promise.all(selections.map((selection) => getSingleSelectionStats({ loader, selection, use3d })));
145028
146268
  const domains = stats.map((stat) => stat.domain);
145029
146269
  const sliders = stats.map((stat) => stat.slider);
145030
- return { domains, sliders };
146270
+ const q1s = stats.map((stat) => stat.q1);
146271
+ const q3s = stats.map((stat) => stat.q3);
146272
+ return { domains, sliders, q1s, q3s };
145031
146273
  };
145032
146274
  function getPhysicalSizeScalingMatrix(loader) {
145033
146275
  const { x, y, z } = loader?.meta?.physicalSizes ?? {};