@vitessce/ome-tiff 4.0.8 → 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.
@@ -11089,8 +11089,8 @@ class Vector extends MathArray {
11089
11089
  distanceSquared(mathArray) {
11090
11090
  let length2 = 0;
11091
11091
  for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
11092
- const dist = this[i2] - mathArray[i2];
11093
- length2 += dist * dist;
11092
+ const dist2 = this[i2] - mathArray[i2];
11093
+ length2 += dist2 * dist2;
11094
11094
  }
11095
11095
  return checkNumber(length2);
11096
11096
  }
@@ -11411,6 +11411,12 @@ function multiply$4(out, a2, b) {
11411
11411
  out[2] = a2[2] * b[2];
11412
11412
  return out;
11413
11413
  }
11414
+ function distance$3(a2, b) {
11415
+ var x = b[0] - a2[0];
11416
+ var y = b[1] - a2[1];
11417
+ var z = b[2] - a2[2];
11418
+ return Math.hypot(x, y, z);
11419
+ }
11414
11420
  function squaredLength$2(a2) {
11415
11421
  var x = a2[0];
11416
11422
  var y = a2[1];
@@ -11534,6 +11540,7 @@ function angle$2(a2, b) {
11534
11540
  }
11535
11541
  var sub$1 = subtract$1;
11536
11542
  var mul$1 = multiply$4;
11543
+ var dist = distance$3;
11537
11544
  var len = length$4;
11538
11545
  var sqrLen = squaredLength$2;
11539
11546
  (function() {
@@ -26037,7 +26044,7 @@ function noop$2() {
26037
26044
  const getCursor = ({
26038
26045
  isDragging
26039
26046
  }) => isDragging ? "grabbing" : "grab";
26040
- const defaultProps$O = {
26047
+ const defaultProps$P = {
26041
26048
  id: "",
26042
26049
  width: "100%",
26043
26050
  height: "100%",
@@ -26168,7 +26175,7 @@ class Deck {
26168
26175
  this._lastPointerDownInfo = pickedInfo.result[0] || pickedInfo.emptyInfo;
26169
26176
  });
26170
26177
  this.props = {
26171
- ...defaultProps$O,
26178
+ ...defaultProps$P,
26172
26179
  ...props
26173
26180
  };
26174
26181
  props = this.props;
@@ -26670,7 +26677,7 @@ class Deck {
26670
26677
  metrics.gpuMemory = memoryStats.get("GPU Memory").count;
26671
26678
  }
26672
26679
  }
26673
- _defineProperty(Deck, "defaultProps", defaultProps$O);
26680
+ _defineProperty(Deck, "defaultProps", defaultProps$P);
26674
26681
  _defineProperty(Deck, "VERSION", deckGlobal.VERSION);
26675
26682
  class ShaderAttribute {
26676
26683
  constructor(dataColumn, opts) {
@@ -29425,7 +29432,7 @@ const areViewportsEqual = memoize$2(({
29425
29432
  return oldViewport.equals(viewport);
29426
29433
  });
29427
29434
  let pickingColorCache = new Uint8ClampedArray(0);
29428
- const defaultProps$N = {
29435
+ const defaultProps$O = {
29429
29436
  data: {
29430
29437
  type: "data",
29431
29438
  value: EMPTY_ARRAY$1,
@@ -30300,7 +30307,7 @@ class Layer extends Component {
30300
30307
  this.setNeedsUpdate();
30301
30308
  }
30302
30309
  }
30303
- _defineProperty(Layer, "defaultProps", defaultProps$N);
30310
+ _defineProperty(Layer, "defaultProps", defaultProps$O);
30304
30311
  _defineProperty(Layer, "layerName", "Layer");
30305
30312
  const TRACE_RENDER_LAYERS = "compositeLayer.renderLayers";
30306
30313
  class CompositeLayer extends Layer {
@@ -31336,6 +31343,124 @@ const esm$5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
31336
31343
  project32,
31337
31344
  shadow
31338
31345
  }, Symbol.toStringTag, { value: "Module" }));
31346
+ const dashShaders = {
31347
+ inject: {
31348
+ "vs:#decl": "\nattribute vec2 instanceDashArrays;\nattribute float instanceDashOffsets;\nvarying vec2 vDashArray;\nvarying float vDashOffset;\n",
31349
+ "vs:#main-end": "\nvDashArray = instanceDashArrays;\nvDashOffset = instanceDashOffsets / width.x;\n",
31350
+ "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",
31351
+ "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"
31352
+ }
31353
+ };
31354
+ const offsetShaders = {
31355
+ inject: {
31356
+ "vs:#decl": "\nattribute float instanceOffsets;\n",
31357
+ "vs:DECKGL_FILTER_SIZE": "\n float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;\n size *= offsetWidth;\n",
31358
+ "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",
31359
+ "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"
31360
+ }
31361
+ };
31362
+ const defaultProps$N = {
31363
+ getDashArray: {
31364
+ type: "accessor",
31365
+ value: [0, 0]
31366
+ },
31367
+ getOffset: {
31368
+ type: "accessor",
31369
+ value: 0
31370
+ },
31371
+ dashJustified: false,
31372
+ dashGapPickable: false
31373
+ };
31374
+ class PathStyleExtension extends LayerExtension {
31375
+ constructor({
31376
+ dash = false,
31377
+ offset = false,
31378
+ highPrecisionDash = false
31379
+ } = {}) {
31380
+ super({
31381
+ dash: dash || highPrecisionDash,
31382
+ offset,
31383
+ highPrecisionDash
31384
+ });
31385
+ }
31386
+ isEnabled(layer) {
31387
+ return "pathTesselator" in layer.state;
31388
+ }
31389
+ getShaders(extension) {
31390
+ if (!extension.isEnabled(this)) {
31391
+ return null;
31392
+ }
31393
+ let result = {};
31394
+ if (extension.opts.dash) {
31395
+ result = mergeShaders(result, dashShaders);
31396
+ }
31397
+ if (extension.opts.offset) {
31398
+ result = mergeShaders(result, offsetShaders);
31399
+ }
31400
+ return result;
31401
+ }
31402
+ initializeState(context, extension) {
31403
+ const attributeManager = this.getAttributeManager();
31404
+ if (!attributeManager || !extension.isEnabled(this)) {
31405
+ return;
31406
+ }
31407
+ if (extension.opts.dash) {
31408
+ attributeManager.addInstanced({
31409
+ instanceDashArrays: {
31410
+ size: 2,
31411
+ accessor: "getDashArray"
31412
+ }
31413
+ });
31414
+ }
31415
+ if (extension.opts.highPrecisionDash) {
31416
+ attributeManager.addInstanced({
31417
+ instanceDashOffsets: {
31418
+ size: 1,
31419
+ accessor: "getPath",
31420
+ transform: extension.getDashOffsets.bind(this)
31421
+ }
31422
+ });
31423
+ }
31424
+ if (extension.opts.offset) {
31425
+ attributeManager.addInstanced({
31426
+ instanceOffsets: {
31427
+ size: 1,
31428
+ accessor: "getOffset"
31429
+ }
31430
+ });
31431
+ }
31432
+ }
31433
+ updateState(params, extension) {
31434
+ if (!extension.isEnabled(this)) {
31435
+ return;
31436
+ }
31437
+ const uniforms = {};
31438
+ if (extension.opts.dash) {
31439
+ uniforms.dashAlignMode = this.props.dashJustified ? 1 : 0;
31440
+ uniforms.dashGapPickable = Boolean(this.props.dashGapPickable);
31441
+ }
31442
+ this.state.model.setUniforms(uniforms);
31443
+ }
31444
+ getDashOffsets(path) {
31445
+ const result = [0];
31446
+ const positionSize = this.props.positionFormat === "XY" ? 2 : 3;
31447
+ const isNested2 = Array.isArray(path[0]);
31448
+ const geometrySize = isNested2 ? path.length : path.length / positionSize;
31449
+ let p;
31450
+ let prevP;
31451
+ for (let i2 = 0; i2 < geometrySize - 1; i2++) {
31452
+ p = isNested2 ? path[i2] : path.slice(i2 * positionSize, i2 * positionSize + positionSize);
31453
+ p = this.projectPosition(p);
31454
+ if (i2 > 0) {
31455
+ result[i2] = result[i2 - 1] + dist(prevP, p);
31456
+ }
31457
+ prevP = p;
31458
+ }
31459
+ return result;
31460
+ }
31461
+ }
31462
+ _defineProperty(PathStyleExtension, "defaultProps", defaultProps$N);
31463
+ _defineProperty(PathStyleExtension, "extensionName", "PathStyleExtension");
31339
31464
  const defaultProps$M = {
31340
31465
  clipBounds: [0, 0, 1, 1]
31341
31466
  };
@@ -87450,8 +87575,8 @@ function requireJs$b() {
87450
87575
  var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi12 / 2 + Math.PI / 4));
87451
87576
  var q = Math.abs(DeltaPsi) > 1e-11 ? DeltaPhi / DeltaPsi : Math.cos(phi12);
87452
87577
  var delta = Math.sqrt(DeltaPhi * DeltaPhi + q * q * DeltaLambda * DeltaLambda);
87453
- var dist = delta * R;
87454
- return dist;
87578
+ var dist2 = delta * R;
87579
+ return dist2;
87455
87580
  }
87456
87581
  js$a.default = rhumbDistance;
87457
87582
  return js$a;
@@ -87764,7 +87889,7 @@ function requireUtils$2() {
87764
87889
  var x;
87765
87890
  var y;
87766
87891
  var segmentIdx;
87767
- var dist;
87892
+ var dist2;
87768
87893
  if (coords.length > 1 && pointCoords.length) {
87769
87894
  var lineCoordinates;
87770
87895
  var pointCoordinate;
@@ -87781,17 +87906,17 @@ function requireUtils$2() {
87781
87906
  if (lineCoordinates[n3][0] !== lineCoordinates[n3 - 1][0]) {
87782
87907
  var slope = (lineCoordinates[n3][1] - lineCoordinates[n3 - 1][1]) / (lineCoordinates[n3][0] - lineCoordinates[n3 - 1][0]);
87783
87908
  var inverseSlope = lineCoordinates[n3][1] - slope * lineCoordinates[n3][0];
87784
- dist = Math.abs(slope * pointCoordinate[0] + inverseSlope - pointCoordinate[1]) / Math.sqrt(slope * slope + 1);
87785
- } else dist = Math.abs(pointCoordinate[0] - lineCoordinates[n3][0]);
87909
+ dist2 = Math.abs(slope * pointCoordinate[0] + inverseSlope - pointCoordinate[1]) / Math.sqrt(slope * slope + 1);
87910
+ } else dist2 = Math.abs(pointCoordinate[0] - lineCoordinates[n3][0]);
87786
87911
  var rl2 = Math.pow(lineCoordinates[n3][1] - lineCoordinates[n3 - 1][1], 2) + Math.pow(lineCoordinates[n3][0] - lineCoordinates[n3 - 1][0], 2);
87787
87912
  var ln2 = Math.pow(lineCoordinates[n3][1] - pointCoordinate[1], 2) + Math.pow(lineCoordinates[n3][0] - pointCoordinate[0], 2);
87788
87913
  var lnm12 = Math.pow(lineCoordinates[n3 - 1][1] - pointCoordinate[1], 2) + Math.pow(lineCoordinates[n3 - 1][0] - pointCoordinate[0], 2);
87789
- var dist2 = Math.pow(dist, 2);
87790
- var calcrl2 = ln2 - dist2 + lnm12 - dist2;
87914
+ var dist22 = Math.pow(dist2, 2);
87915
+ var calcrl2 = ln2 - dist22 + lnm12 - dist22;
87791
87916
  if (calcrl2 > rl2) {
87792
- dist = Math.sqrt(Math.min(ln2, lnm12));
87917
+ dist2 = Math.sqrt(Math.min(ln2, lnm12));
87793
87918
  }
87794
- if (minDist === null || minDist === void 0 || minDist > dist) {
87919
+ if (minDist === null || minDist === void 0 || minDist > dist2) {
87795
87920
  if (calcrl2 > rl2) {
87796
87921
  if (lnm12 < ln2) {
87797
87922
  to = 0;
@@ -87801,10 +87926,10 @@ function requireUtils$2() {
87801
87926
  to = 1;
87802
87927
  }
87803
87928
  } else {
87804
- to = Math.sqrt(lnm12 - dist2) / Math.sqrt(rl2);
87805
- from = Math.sqrt(ln2 - dist2) / Math.sqrt(rl2);
87929
+ to = Math.sqrt(lnm12 - dist22) / Math.sqrt(rl2);
87930
+ from = Math.sqrt(ln2 - dist22) / Math.sqrt(rl2);
87806
87931
  }
87807
- minDist = dist;
87932
+ minDist = dist2;
87808
87933
  segmentIdx = n3;
87809
87934
  }
87810
87935
  }
@@ -104781,22 +104906,22 @@ async function getDecoder(fileDirectory) {
104781
104906
  const Decoder = await importFn();
104782
104907
  return new Decoder(fileDirectory);
104783
104908
  }
104784
- addDecoder([void 0, 1], () => import("./raw-ZDPY7q_j.js").then((m) => m.default));
104785
- addDecoder(5, () => import("./lzw-DOmBhfF8.js").then((m) => m.default));
104909
+ addDecoder([void 0, 1], () => import("./raw-tUqt587l.js").then((m) => m.default));
104910
+ addDecoder(5, () => import("./lzw-Dz4Jq-yH.js").then((m) => m.default));
104786
104911
  addDecoder(6, () => {
104787
104912
  throw new Error("old style JPEG compression is not supported.");
104788
104913
  });
104789
- addDecoder(7, () => import("./jpeg-Bp1i56Ab.js").then((m) => m.default));
104790
- addDecoder([8, 32946], () => import("./deflate-np6gHRbh.js").then((m) => m.default));
104791
- addDecoder(32773, () => import("./packbits-Day8SQEk.js").then((m) => m.default));
104914
+ addDecoder(7, () => import("./jpeg-CHgZKG82.js").then((m) => m.default));
104915
+ addDecoder([8, 32946], () => import("./deflate-CYQTYSCB.js").then((m) => m.default));
104916
+ addDecoder(32773, () => import("./packbits-CHn2islS.js").then((m) => m.default));
104792
104917
  addDecoder(
104793
104918
  34887,
104794
- () => import("./lerc-3WJW9dLU.js").then(async (m) => {
104919
+ () => import("./lerc-DVjQP6R8.js").then(async (m) => {
104795
104920
  await m.zstd.init();
104796
104921
  return m;
104797
104922
  }).then((m) => m.default)
104798
104923
  );
104799
- addDecoder(50001, () => import("./webimage-DjGAt__8.js").then((m) => m.default));
104924
+ addDecoder(50001, () => import("./webimage-DVCltRg_.js").then((m) => m.default));
104800
104925
  function copyNewSize(array, width, height, samplesPerPixel = 1) {
104801
104926
  return new (Object.getPrototypeOf(array)).constructor(width * height * samplesPerPixel);
104802
104927
  }
@@ -111435,8 +111560,8 @@ function TreeDesc(dyn_tree, stat_desc) {
111435
111560
  this.max_code = 0;
111436
111561
  this.stat_desc = stat_desc;
111437
111562
  }
111438
- const d_code = (dist) => {
111439
- return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];
111563
+ const d_code = (dist2) => {
111564
+ return dist2 < 256 ? _dist_code[dist2] : _dist_code[256 + (dist2 >>> 7)];
111440
111565
  };
111441
111566
  const put_short = (s2, w2) => {
111442
111567
  s2.pending_buf[s2.pending++] = w2 & 255;
@@ -111570,7 +111695,7 @@ const tr_static_init = () => {
111570
111695
  let bits;
111571
111696
  let length2;
111572
111697
  let code;
111573
- let dist;
111698
+ let dist2;
111574
111699
  const bl_count = new Array(MAX_BITS + 1);
111575
111700
  length2 = 0;
111576
111701
  for (code = 0; code < LENGTH_CODES - 1; code++) {
@@ -111580,18 +111705,18 @@ const tr_static_init = () => {
111580
111705
  }
111581
111706
  }
111582
111707
  _length_code[length2 - 1] = code;
111583
- dist = 0;
111708
+ dist2 = 0;
111584
111709
  for (code = 0; code < 16; code++) {
111585
- base_dist[code] = dist;
111710
+ base_dist[code] = dist2;
111586
111711
  for (n3 = 0; n3 < 1 << extra_dbits[code]; n3++) {
111587
- _dist_code[dist++] = code;
111712
+ _dist_code[dist2++] = code;
111588
111713
  }
111589
111714
  }
111590
- dist >>= 7;
111715
+ dist2 >>= 7;
111591
111716
  for (; code < D_CODES; code++) {
111592
- base_dist[code] = dist << 7;
111717
+ base_dist[code] = dist2 << 7;
111593
111718
  for (n3 = 0; n3 < 1 << extra_dbits[code] - 7; n3++) {
111594
- _dist_code[256 + dist++] = code;
111719
+ _dist_code[256 + dist2++] = code;
111595
111720
  }
111596
111721
  }
111597
111722
  for (bits = 0; bits <= MAX_BITS; bits++) {
@@ -111682,17 +111807,17 @@ const pqdownheap = (s2, tree, k) => {
111682
111807
  s2.heap[k] = v;
111683
111808
  };
111684
111809
  const compress_block = (s2, ltree, dtree) => {
111685
- let dist;
111810
+ let dist2;
111686
111811
  let lc;
111687
111812
  let lx = 0;
111688
111813
  let code;
111689
111814
  let extra;
111690
111815
  if (s2.last_lit !== 0) {
111691
111816
  do {
111692
- dist = s2.pending_buf[s2.d_buf + lx * 2] << 8 | s2.pending_buf[s2.d_buf + lx * 2 + 1];
111817
+ dist2 = s2.pending_buf[s2.d_buf + lx * 2] << 8 | s2.pending_buf[s2.d_buf + lx * 2 + 1];
111693
111818
  lc = s2.pending_buf[s2.l_buf + lx];
111694
111819
  lx++;
111695
- if (dist === 0) {
111820
+ if (dist2 === 0) {
111696
111821
  send_code(s2, lc, ltree);
111697
111822
  } else {
111698
111823
  code = _length_code[lc];
@@ -111702,13 +111827,13 @@ const compress_block = (s2, ltree, dtree) => {
111702
111827
  lc -= base_length[code];
111703
111828
  send_bits(s2, lc, extra);
111704
111829
  }
111705
- dist--;
111706
- code = d_code(dist);
111830
+ dist2--;
111831
+ code = d_code(dist2);
111707
111832
  send_code(s2, code, dtree);
111708
111833
  extra = extra_dbits[code];
111709
111834
  if (extra !== 0) {
111710
- dist -= base_dist[code];
111711
- send_bits(s2, dist, extra);
111835
+ dist2 -= base_dist[code];
111836
+ send_bits(s2, dist2, extra);
111712
111837
  }
111713
111838
  }
111714
111839
  } while (lx < s2.last_lit);
@@ -111979,18 +112104,18 @@ const _tr_flush_block = (s2, buf, stored_len, last) => {
111979
112104
  bi_windup(s2);
111980
112105
  }
111981
112106
  };
111982
- const _tr_tally = (s2, dist, lc) => {
111983
- s2.pending_buf[s2.d_buf + s2.last_lit * 2] = dist >>> 8 & 255;
111984
- s2.pending_buf[s2.d_buf + s2.last_lit * 2 + 1] = dist & 255;
112107
+ const _tr_tally = (s2, dist2, lc) => {
112108
+ s2.pending_buf[s2.d_buf + s2.last_lit * 2] = dist2 >>> 8 & 255;
112109
+ s2.pending_buf[s2.d_buf + s2.last_lit * 2 + 1] = dist2 & 255;
111985
112110
  s2.pending_buf[s2.l_buf + s2.last_lit] = lc & 255;
111986
112111
  s2.last_lit++;
111987
- if (dist === 0) {
112112
+ if (dist2 === 0) {
111988
112113
  s2.dyn_ltree[lc * 2]++;
111989
112114
  } else {
111990
112115
  s2.matches++;
111991
- dist--;
112116
+ dist2--;
111992
112117
  s2.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]++;
111993
- s2.dyn_dtree[d_code(dist) * 2]++;
112118
+ s2.dyn_dtree[d_code(dist2) * 2]++;
111994
112119
  }
111995
112120
  return s2.last_lit === s2.lit_bufsize - 1;
111996
112121
  };
@@ -113495,7 +113620,7 @@ var inffast = function inflate_fast(strm, start) {
113495
113620
  let here;
113496
113621
  let op;
113497
113622
  let len2;
113498
- let dist;
113623
+ let dist2;
113499
113624
  let from;
113500
113625
  let from_source;
113501
113626
  let input, output;
@@ -113561,7 +113686,7 @@ var inffast = function inflate_fast(strm, start) {
113561
113686
  bits -= op;
113562
113687
  op = here >>> 16 & 255;
113563
113688
  if (op & 16) {
113564
- dist = here & 65535;
113689
+ dist2 = here & 65535;
113565
113690
  op &= 15;
113566
113691
  if (bits < op) {
113567
113692
  hold += input[_in++] << bits;
@@ -113571,8 +113696,8 @@ var inffast = function inflate_fast(strm, start) {
113571
113696
  bits += 8;
113572
113697
  }
113573
113698
  }
113574
- dist += hold & (1 << op) - 1;
113575
- if (dist > dmax) {
113699
+ dist2 += hold & (1 << op) - 1;
113700
+ if (dist2 > dmax) {
113576
113701
  strm.msg = "invalid distance too far back";
113577
113702
  state.mode = BAD;
113578
113703
  break top;
@@ -113580,8 +113705,8 @@ var inffast = function inflate_fast(strm, start) {
113580
113705
  hold >>>= op;
113581
113706
  bits -= op;
113582
113707
  op = _out - beg;
113583
- if (dist > op) {
113584
- op = dist - op;
113708
+ if (dist2 > op) {
113709
+ op = dist2 - op;
113585
113710
  if (op > whave) {
113586
113711
  if (state.sane) {
113587
113712
  strm.msg = "invalid distance too far back";
@@ -113598,7 +113723,7 @@ var inffast = function inflate_fast(strm, start) {
113598
113723
  do {
113599
113724
  output[_out++] = s_window[from++];
113600
113725
  } while (--op);
113601
- from = _out - dist;
113726
+ from = _out - dist2;
113602
113727
  from_source = output;
113603
113728
  }
113604
113729
  } else if (wnext < op) {
@@ -113616,7 +113741,7 @@ var inffast = function inflate_fast(strm, start) {
113616
113741
  do {
113617
113742
  output[_out++] = s_window[from++];
113618
113743
  } while (--op);
113619
- from = _out - dist;
113744
+ from = _out - dist2;
113620
113745
  from_source = output;
113621
113746
  }
113622
113747
  }
@@ -113627,7 +113752,7 @@ var inffast = function inflate_fast(strm, start) {
113627
113752
  do {
113628
113753
  output[_out++] = s_window[from++];
113629
113754
  } while (--op);
113630
- from = _out - dist;
113755
+ from = _out - dist2;
113631
113756
  from_source = output;
113632
113757
  }
113633
113758
  }
@@ -113644,7 +113769,7 @@ var inffast = function inflate_fast(strm, start) {
113644
113769
  }
113645
113770
  }
113646
113771
  } else {
113647
- from = _out - dist;
113772
+ from = _out - dist2;
113648
113773
  do {
113649
113774
  output[_out++] = output[from++];
113650
113775
  output[_out++] = output[from++];
@@ -114202,7 +114327,7 @@ const fixedtables = (state) => {
114202
114327
  state.distbits = 5;
114203
114328
  };
114204
114329
  const updatewindow = (strm, src, end, copy2) => {
114205
- let dist;
114330
+ let dist2;
114206
114331
  const state = strm.state;
114207
114332
  if (state.window === null) {
114208
114333
  state.wsize = 1 << state.wbits;
@@ -114215,23 +114340,23 @@ const updatewindow = (strm, src, end, copy2) => {
114215
114340
  state.wnext = 0;
114216
114341
  state.whave = state.wsize;
114217
114342
  } else {
114218
- dist = state.wsize - state.wnext;
114219
- if (dist > copy2) {
114220
- dist = copy2;
114343
+ dist2 = state.wsize - state.wnext;
114344
+ if (dist2 > copy2) {
114345
+ dist2 = copy2;
114221
114346
  }
114222
- state.window.set(src.subarray(end - copy2, end - copy2 + dist), state.wnext);
114223
- copy2 -= dist;
114347
+ state.window.set(src.subarray(end - copy2, end - copy2 + dist2), state.wnext);
114348
+ copy2 -= dist2;
114224
114349
  if (copy2) {
114225
114350
  state.window.set(src.subarray(end - copy2, end), 0);
114226
114351
  state.wnext = copy2;
114227
114352
  state.whave = state.wsize;
114228
114353
  } else {
114229
- state.wnext += dist;
114354
+ state.wnext += dist2;
114230
114355
  if (state.wnext === state.wsize) {
114231
114356
  state.wnext = 0;
114232
114357
  }
114233
114358
  if (state.whave < state.wsize) {
114234
- state.whave += dist;
114359
+ state.whave += dist2;
114235
114360
  }
114236
114361
  }
114237
114362
  }
@@ -118746,7 +118871,7 @@ function padColors({ colors, channelsVisible }) {
118746
118871
  ).reduce((acc, val) => acc.concat(val), []);
118747
118872
  return paddedColors;
118748
118873
  }
118749
- const defaultProps$3$1 = {
118874
+ const defaultProps$3$2 = {
118750
118875
  colors: { type: "array", value: null, compare: true },
118751
118876
  opacity: { type: "number", value: 1, compare: true },
118752
118877
  transparentColor: { type: "array", value: null, compare: true },
@@ -118763,9 +118888,9 @@ const ColorPaletteExtension = class extends LayerExtension {
118763
118888
  const {
118764
118889
  colors,
118765
118890
  channelsVisible,
118766
- opacity = defaultProps$3$1.opacity.value,
118767
- transparentColor = defaultProps$3$1.transparentColor.value,
118768
- useTransparentColor = defaultProps$3$1.useTransparentColor.value
118891
+ opacity = defaultProps$3$2.opacity.value,
118892
+ transparentColor = defaultProps$3$2.transparentColor.value,
118893
+ useTransparentColor = defaultProps$3$2.useTransparentColor.value
118769
118894
  } = this.props;
118770
118895
  const paddedColors = padColors({
118771
118896
  channelsVisible: channelsVisible || this.selections.map(() => true),
@@ -118781,7 +118906,7 @@ const ColorPaletteExtension = class extends LayerExtension {
118781
118906
  }
118782
118907
  };
118783
118908
  ColorPaletteExtension.extensionName = "ColorPaletteExtension";
118784
- ColorPaletteExtension.defaultProps = defaultProps$3$1;
118909
+ ColorPaletteExtension.defaultProps = defaultProps$3$2;
118785
118910
  const fs$4 = `// lens bounds for ellipse
118786
118911
  uniform float majorLensAxis;
118787
118912
  uniform float minorLensAxis;
@@ -120076,7 +120201,7 @@ const MultiscaleImageLayer = class extends CompositeLayer {
120076
120201
  };
120077
120202
  MultiscaleImageLayer.layerName = "MultiscaleImageLayer";
120078
120203
  MultiscaleImageLayer.defaultProps = defaultProps$4;
120079
- const defaultProps$3 = {
120204
+ const defaultProps$3$1 = {
120080
120205
  pickable: { type: "boolean", value: true, compare: true },
120081
120206
  loader: {
120082
120207
  type: "object",
@@ -120163,7 +120288,7 @@ const OverviewLayer = class extends CompositeLayer {
120163
120288
  }
120164
120289
  };
120165
120290
  OverviewLayer.layerName = "OverviewLayer";
120166
- OverviewLayer.defaultProps = defaultProps$3;
120291
+ OverviewLayer.defaultProps = defaultProps$3$1;
120167
120292
  function getPosition(boundingBox, position, length2) {
120168
120293
  const viewWidth = boundingBox[2][0] - boundingBox[0][0];
120169
120294
  const viewHeight = boundingBox[2][1] - boundingBox[0][1];
@@ -121151,7 +121276,7 @@ function padWithDefault$1(arr, defaultValue2, padWidth) {
121151
121276
  }
121152
121277
  return newArr;
121153
121278
  }
121154
- const defaultProps$2 = {
121279
+ const defaultProps$3 = {
121155
121280
  hoveredCell: { type: "number", value: null, compare: true },
121156
121281
  // We do not want to deep-compare cellColorData,
121157
121282
  // as it is potentially a TypedArray with millions of elements.
@@ -121268,7 +121393,7 @@ let BitmaskLayer$1 = class BitmaskLayer extends XRLayer {
121268
121393
  }
121269
121394
  };
121270
121395
  BitmaskLayer$1.layerName = "BitmaskLayer";
121271
- BitmaskLayer$1.defaultProps = defaultProps$2;
121396
+ BitmaskLayer$1.defaultProps = defaultProps$3;
121272
121397
  var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
121273
121398
  var freeSelf = typeof self == "object" && self && self.Object === Object && self;
121274
121399
  var root = freeGlobal || freeSelf || Function("return this")();
@@ -122685,7 +122810,7 @@ function isEqualShallow(prevArr, nextArr) {
122685
122810
  }
122686
122811
  return prevArr === nextArr;
122687
122812
  }
122688
- const defaultProps$1 = {
122813
+ const defaultProps$2 = {
122689
122814
  channelStrokeWidths: { type: "array", value: null, compare: true },
122690
122815
  channelsFilled: { type: "array", value: null, compare: true },
122691
122816
  channelOpacities: { type: "array", value: null, compare: true },
@@ -122949,7 +123074,7 @@ class BitmaskLayer2 extends XRLayer {
122949
123074
  }
122950
123075
  }
122951
123076
  BitmaskLayer2.layerName = "BitmaskLayer";
122952
- BitmaskLayer2.defaultProps = defaultProps$1;
123077
+ BitmaskLayer2.defaultProps = defaultProps$2;
122953
123078
  var isNumeric$1 = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, mathceil = Math.ceil, mathfloor$1 = Math.floor, bignumberError = "[BigNumber Error] ", tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ", BASE$1 = 1e14, LOG_BASE$1 = 14, MAX_SAFE_INTEGER$1 = 9007199254740991, POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], SQRT_BASE = 1e7, MAX = 1e9;
122954
123079
  function clone$2(configObject) {
122955
123080
  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 = {
@@ -125892,7 +126017,7 @@ function ringArea(coords) {
125892
126017
  return total * FACTOR;
125893
126018
  }
125894
126019
  const DEFAULT_THRESHOLD = 1;
125895
- const defaultProps = {
126020
+ const defaultProps$1 = {
125896
126021
  // for text
125897
126022
  obsSetPath: { type: "object" },
125898
126023
  sampleSetPath: { type: "object" },
@@ -125987,9 +126112,9 @@ class ContourLayerWithText extends ContourLayer {
125987
126112
  const circlePoint = point(circleCoord);
125988
126113
  polygonVertices.forEach((polyCoord) => {
125989
126114
  const polyPoint = point(polyCoord);
125990
- const dist = distance$1(circlePoint, polyPoint);
125991
- if (dist < minDist) {
125992
- minDist = dist;
126115
+ const dist2 = distance$1(circlePoint, polyPoint);
126116
+ if (dist2 < minDist) {
126117
+ minDist = dist2;
125993
126118
  minCirclePoint = circleCoord;
125994
126119
  minCirclePointI = circlePointI;
125995
126120
  minPolygonPoint = polyCoord;
@@ -126066,7 +126191,11 @@ class ContourLayerWithText extends ContourLayer {
126066
126191
  }
126067
126192
  }
126068
126193
  ContourLayerWithText.layerName = "ContourLayerWithText";
126069
- ContourLayerWithText.defaultProps = defaultProps;
126194
+ ContourLayerWithText.defaultProps = defaultProps$1;
126195
+ const ViewType = {
126196
+ SCATTERPLOT: "scatterplot",
126197
+ SPATIAL: "spatial"
126198
+ };
126070
126199
  const GLOBAL_LABELS = ["z", "t"];
126071
126200
  const DEFAULT_RASTER_DOMAIN_TYPE = "Min/Max";
126072
126201
  const DEFAULT_RASTER_LAYER_PROPS = {
@@ -126080,6 +126209,1076 @@ const DEFAULT_RASTER_LAYER_PROPS = {
126080
126209
  // viv.RENDERING_MODES.ADDITIVE,
126081
126210
  use3d: false
126082
126211
  };
126212
+ const ARROW_SCREEN_PX = 14;
126213
+ const LABEL_FONT_FAMILY = '"Roboto", "Helvetica", "Arial", sans-serif';
126214
+ const LABEL_FONT_WEIGHT = "bold";
126215
+ const LABEL_FONT_SIZE = 14;
126216
+ const RATIO_CLUSTER = 0.1;
126217
+ const RATIO_DOT = 0.3;
126218
+ const RATIO_GEO_FADE = 0.55;
126219
+ const RATIO_TIPS = 0.7;
126220
+ const RATIO_LABEL = 0.55;
126221
+ const RATIO_LABEL_FULL = 0.75;
126222
+ function textBgColor(strokeColor) {
126223
+ const [r2, g2, b] = strokeColor;
126224
+ const lum = (0.299 * r2 + 0.587 * g2 + 0.114 * b) / 255;
126225
+ return lum > 0.45 ? [20, 20, 20, 210] : [245, 245, 245, 210];
126226
+ }
126227
+ function parseDashArray(strokeDashArray) {
126228
+ if (!strokeDashArray || strokeDashArray === "none")
126229
+ return null;
126230
+ const nums = strokeDashArray.trim().split(/\s+/).map(Number).filter((n3) => !Number.isNaN(n3) && n3 >= 0);
126231
+ return nums.length >= 2 ? [nums[0], nums[1]] : null;
126232
+ }
126233
+ function computeEllipsePolygon(cx, cy, rx, ry, numSegments = 64) {
126234
+ const pts = [];
126235
+ for (let i2 = 0; i2 < numSegments; i2++) {
126236
+ const angle2 = 2 * Math.PI * i2 / numSegments;
126237
+ pts.push([cx + rx * Math.cos(angle2), cy + ry * Math.sin(angle2)]);
126238
+ }
126239
+ return pts;
126240
+ }
126241
+ function createPreviewLayer(inProgress, hoverCoord, strokeColor = [255, 255, 0]) {
126242
+ if (!inProgress || inProgress.vertices.length === 0)
126243
+ return null;
126244
+ const { type, vertices } = inProgress;
126245
+ const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN };
126246
+ const previewColor = [...strokeColor, 160];
126247
+ const cursor = hoverCoord ?? vertices[vertices.length - 1];
126248
+ if (type === "rectangle" && vertices.length === 1) {
126249
+ const [ax, ay] = vertices[0];
126250
+ const [bx, by] = cursor;
126251
+ const path = [[ax, ay], [bx, ay], [bx, by], [ax, by], [ax, ay]];
126252
+ return new PathLayer({
126253
+ ...base,
126254
+ id: "annotation-preview-rectangle",
126255
+ data: [{ path }],
126256
+ getPath: (d) => d.path,
126257
+ getColor: previewColor,
126258
+ getWidth: 1,
126259
+ widthUnits: "pixels",
126260
+ extensions: [new PathStyleExtension({ dash: true })],
126261
+ getDashArray: [8, 4]
126262
+ });
126263
+ }
126264
+ if (type === "line" && vertices.length === 1) {
126265
+ const path = [vertices[0], cursor];
126266
+ return new PathLayer({
126267
+ ...base,
126268
+ id: "annotation-preview-line",
126269
+ data: [{ path }],
126270
+ getPath: (d) => d.path,
126271
+ getColor: previewColor,
126272
+ getWidth: 1,
126273
+ widthUnits: "pixels",
126274
+ extensions: [new PathStyleExtension({ dash: true })],
126275
+ getDashArray: [8, 4]
126276
+ });
126277
+ }
126278
+ if (type === "ellipse" && vertices.length === 1) {
126279
+ const [cx, cy] = vertices[0];
126280
+ const [ex, ey] = cursor;
126281
+ const rx = Math.abs(ex - cx);
126282
+ const ry = Math.abs(ey - cy);
126283
+ if (rx < 1 && ry < 1)
126284
+ return null;
126285
+ const pts = computeEllipsePolygon(cx, cy, Math.max(rx, 1), Math.max(ry, 1));
126286
+ const path = [...pts, pts[0]];
126287
+ return new PathLayer({
126288
+ ...base,
126289
+ id: "annotation-preview-ellipse",
126290
+ data: [{ path }],
126291
+ getPath: (d) => d.path,
126292
+ getColor: previewColor,
126293
+ getWidth: 1,
126294
+ widthUnits: "pixels",
126295
+ extensions: [new PathStyleExtension({ dash: true })],
126296
+ getDashArray: [8, 4]
126297
+ });
126298
+ }
126299
+ if ((type === "polygon" || type === "polyline") && vertices.length >= 1) {
126300
+ const path = [...vertices, cursor];
126301
+ if (type === "polygon" && vertices.length >= 2)
126302
+ path.push(vertices[0]);
126303
+ return new PathLayer({
126304
+ ...base,
126305
+ id: `annotation-preview-${type}`,
126306
+ data: [{ path }],
126307
+ getPath: (d) => d.path,
126308
+ getColor: previewColor,
126309
+ getWidth: 1,
126310
+ widthUnits: "pixels",
126311
+ jointRounded: true,
126312
+ capRounded: true,
126313
+ extensions: [new PathStyleExtension({ dash: true })],
126314
+ getDashArray: [8, 4]
126315
+ });
126316
+ }
126317
+ return null;
126318
+ }
126319
+ function computeTickCap(tipX, tipY, dirX, dirY, dataSize) {
126320
+ const len2 = Math.sqrt(dirX * dirX + dirY * dirY);
126321
+ if (len2 === 0)
126322
+ return null;
126323
+ const ux = dirX / len2;
126324
+ const uy = dirY / len2;
126325
+ const px = -uy;
126326
+ const py = ux;
126327
+ const half = dataSize * 0.55;
126328
+ return [
126329
+ [tipX + px * half, tipY + py * half],
126330
+ [tipX - px * half, tipY - py * half]
126331
+ ];
126332
+ }
126333
+ function computeArrowhead(tipX, tipY, dirX, dirY, dataSize) {
126334
+ const len2 = Math.sqrt(dirX * dirX + dirY * dirY);
126335
+ if (len2 === 0)
126336
+ return null;
126337
+ const ux = dirX / len2;
126338
+ const uy = dirY / len2;
126339
+ const px = -uy;
126340
+ const py = ux;
126341
+ const halfBase = dataSize * 0.4;
126342
+ const bx = tipX - ux * dataSize;
126343
+ const by = tipY - uy * dataSize;
126344
+ return [
126345
+ [tipX, tipY],
126346
+ [bx + px * halfBase, by + py * halfBase],
126347
+ [bx - px * halfBase, by - py * halfBase]
126348
+ ];
126349
+ }
126350
+ function fmtCommas(n3) {
126351
+ return Math.round(n3).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
126352
+ }
126353
+ function getMeasurementLabel(shape, physicalPixelSize, viewType = ViewType.SPATIAL) {
126354
+ const pps = physicalPixelSize;
126355
+ const px = pps?.x ?? 1;
126356
+ const py = pps?.y ?? 1;
126357
+ const unit2 = pps ? pps.unit ?? "" : null;
126358
+ const hasPhys = !!pps;
126359
+ const isEmbedding = viewType === ViewType.SCATTERPLOT;
126360
+ const fmtDist = (d) => {
126361
+ if (hasPhys)
126362
+ return `${d.toFixed(2)} ${unit2}`;
126363
+ if (isEmbedding)
126364
+ return d.toFixed(2);
126365
+ return `${fmtCommas(d)} px`;
126366
+ };
126367
+ const fmtArea = (a2) => {
126368
+ if (hasPhys)
126369
+ return `${a2.toFixed(2)} ${unit2}²`;
126370
+ if (isEmbedding)
126371
+ return a2.toFixed(2);
126372
+ return `${fmtCommas(a2)} px²`;
126373
+ };
126374
+ if (shape.type === "line") {
126375
+ const dx = (shape.x2 ?? 0) - (shape.x1 ?? 0);
126376
+ const dy = (shape.y2 ?? 0) - (shape.y1 ?? 0);
126377
+ const dist2 = hasPhys ? Math.sqrt((dx * px) ** 2 + (dy * py) ** 2) : Math.sqrt(dx * dx + dy * dy);
126378
+ return fmtDist(dist2);
126379
+ }
126380
+ if (shape.type === "rectangle") {
126381
+ return fmtArea(hasPhys ? Math.abs(shape.width ?? 0) * px * Math.abs(shape.height ?? 0) * py : Math.abs((shape.width ?? 0) * (shape.height ?? 0)));
126382
+ }
126383
+ if (shape.type === "ellipse") {
126384
+ const rx = Math.abs(shape.radiusX ?? 0);
126385
+ const ry = Math.abs(shape.radiusY ?? 0);
126386
+ return fmtArea(hasPhys ? Math.PI * rx * px * ry * py : Math.PI * rx * ry);
126387
+ }
126388
+ if (shape.type === "polygon" && shape.points?.length >= 3) {
126389
+ const pts = shape.points;
126390
+ let shoelace = 0;
126391
+ for (let i2 = 0; i2 < pts.length; i2++) {
126392
+ const [ax, ay] = pts[i2];
126393
+ const [bx, by] = pts[(i2 + 1) % pts.length];
126394
+ shoelace += (hasPhys ? ax * px : ax) * (hasPhys ? by * py : by) - (hasPhys ? bx * px : bx) * (hasPhys ? ay * py : ay);
126395
+ }
126396
+ return fmtArea(Math.abs(shoelace / 2));
126397
+ }
126398
+ if (shape.type === "polyline" && shape.points?.length >= 2) {
126399
+ let total = 0;
126400
+ for (let i2 = 0; i2 < shape.points.length - 1; i2++) {
126401
+ const [ax, ay] = shape.points[i2];
126402
+ const [bx, by] = shape.points[i2 + 1];
126403
+ total += hasPhys ? Math.sqrt(((bx - ax) * px) ** 2 + ((by - ay) * py) ** 2) : Math.sqrt((bx - ax) ** 2 + (by - ay) ** 2);
126404
+ }
126405
+ return fmtDist(total);
126406
+ }
126407
+ return null;
126408
+ }
126409
+ function pickBelowPerp(ux, uy) {
126410
+ const rp = [uy, -ux];
126411
+ const lp = [-uy, ux];
126412
+ return rp[1] > lp[1] || rp[1] === lp[1] && rp[0] > lp[0] ? rp : lp;
126413
+ }
126414
+ function readableAngle(deg) {
126415
+ let a2 = deg;
126416
+ if (a2 > 90)
126417
+ a2 -= 180;
126418
+ if (a2 < -90)
126419
+ a2 += 180;
126420
+ return a2;
126421
+ }
126422
+ function getShapeCentroid(shape) {
126423
+ if (shape.type === "rectangle") {
126424
+ return [(shape.x ?? 0) + (shape.width ?? 0) / 2, (shape.y ?? 0) + (shape.height ?? 0) / 2];
126425
+ }
126426
+ if (shape.type === "line") {
126427
+ return [((shape.x1 ?? 0) + (shape.x2 ?? 0)) / 2, ((shape.y1 ?? 0) + (shape.y2 ?? 0)) / 2];
126428
+ }
126429
+ if (shape.type === "ellipse") {
126430
+ return [shape.x1 ?? 0, shape.y1 ?? 0];
126431
+ }
126432
+ if ((shape.type === "polygon" || shape.type === "polyline") && shape.points?.length >= 1) {
126433
+ const mx = shape.points.reduce((s2, p) => s2 + p[0], 0) / shape.points.length;
126434
+ const my = shape.points.reduce((s2, p) => s2 + p[1], 0) / shape.points.length;
126435
+ return [mx, my];
126436
+ }
126437
+ return [0, 0];
126438
+ }
126439
+ function computeClusters(shapeList, zoom, cellPx = 50) {
126440
+ const cellSize = cellPx / 2 ** Math.floor(zoom);
126441
+ const cells = /* @__PURE__ */ new Map();
126442
+ shapeList.forEach(({ shape }) => {
126443
+ const [cx, cy] = getShapeCentroid(shape);
126444
+ const key = `${Math.floor(cx / cellSize)},${Math.floor(cy / cellSize)}`;
126445
+ if (!cells.has(key)) {
126446
+ cells.set(key, { sumX: 0, sumY: 0, count: 0, color: shape.strokeColor ?? [255, 255, 255] });
126447
+ }
126448
+ const c = cells.get(key);
126449
+ c.sumX += cx;
126450
+ c.sumY += cy;
126451
+ c.count++;
126452
+ });
126453
+ return Array.from(cells.values()).map((c) => ({
126454
+ position: [c.sumX / c.count, c.sumY / c.count, 0],
126455
+ count: c.count,
126456
+ color: c.color
126457
+ }));
126458
+ }
126459
+ function createAnnotationLayers(shapes = [], zoom = 0, selectedShapeUid = null, physicalPixelSize = null, authoredZoom = null, semanticZoom = true, viewType = ViewType.SPATIAL) {
126460
+ const selectionLayers = [];
126461
+ if (selectedShapeUid) {
126462
+ const sel = shapes.find((s2) => s2.uid === selectedShapeUid);
126463
+ if (sel) {
126464
+ const { uid: sUid, type: sType, strokeWidth: sStrokeWidth = 3 } = sel;
126465
+ const haloColor = [255, 220, 50, 70];
126466
+ const haloWidth = Math.max(sStrokeWidth + 8, 10);
126467
+ const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN };
126468
+ if (sType === "rectangle") {
126469
+ const { x, y, width, height } = sel;
126470
+ selectionLayers.push(new PathLayer({
126471
+ ...base,
126472
+ id: `annotation-select-${sUid}`,
126473
+ data: [{
126474
+ path: [
126475
+ [x, y],
126476
+ [x + width, y],
126477
+ [x + width, y + height],
126478
+ [x, y + height],
126479
+ [x, y]
126480
+ ]
126481
+ }],
126482
+ getPath: (d) => d.path,
126483
+ getColor: haloColor,
126484
+ getWidth: haloWidth,
126485
+ widthUnits: "pixels",
126486
+ jointRounded: true,
126487
+ capRounded: true
126488
+ }));
126489
+ }
126490
+ if (sType === "line") {
126491
+ const { x1: x12, y1: y12, x2, y2 } = sel;
126492
+ selectionLayers.push(new PathLayer({
126493
+ ...base,
126494
+ id: `annotation-select-${sUid}`,
126495
+ data: [{ path: [[x12, y12], [x2, y2]] }],
126496
+ getPath: (d) => d.path,
126497
+ getColor: haloColor,
126498
+ getWidth: haloWidth,
126499
+ widthUnits: "pixels",
126500
+ capRounded: true
126501
+ }));
126502
+ }
126503
+ if (sType === "ellipse") {
126504
+ const polygon2 = computeEllipsePolygon(sel.x1, sel.y1, sel.radiusX, sel.radiusY);
126505
+ selectionLayers.push(new PathLayer({
126506
+ ...base,
126507
+ id: `annotation-select-${sUid}`,
126508
+ data: [{ path: [...polygon2, polygon2[0]] }],
126509
+ getPath: (d) => d.path,
126510
+ getColor: haloColor,
126511
+ getWidth: haloWidth,
126512
+ widthUnits: "pixels",
126513
+ jointRounded: true
126514
+ }));
126515
+ }
126516
+ if (sType === "polygon" && sel.points?.length >= 3) {
126517
+ selectionLayers.push(new PathLayer({
126518
+ ...base,
126519
+ id: `annotation-select-${sUid}`,
126520
+ data: [{ path: [...sel.points, sel.points[0]] }],
126521
+ getPath: (d) => d.path,
126522
+ getColor: haloColor,
126523
+ getWidth: haloWidth,
126524
+ widthUnits: "pixels",
126525
+ jointRounded: true
126526
+ }));
126527
+ }
126528
+ if (sType === "polyline" && sel.points?.length >= 2) {
126529
+ selectionLayers.push(new PathLayer({
126530
+ ...base,
126531
+ id: `annotation-select-${sUid}`,
126532
+ data: [{ path: sel.points }],
126533
+ getPath: (d) => d.path,
126534
+ getColor: haloColor,
126535
+ getWidth: haloWidth,
126536
+ widthUnits: "pixels",
126537
+ jointRounded: true,
126538
+ capRounded: true
126539
+ }));
126540
+ }
126541
+ }
126542
+ }
126543
+ const layers = [];
126544
+ const dotShapes = [];
126545
+ const clusterDotShapes = [];
126546
+ shapes.forEach((shape, i2) => {
126547
+ const { uid: uid2, type, strokeColor = [255, 255, 255], strokeWidth = 3, strokeDashArray } = shape;
126548
+ const isSelected = uid2 === selectedShapeUid;
126549
+ let shapeOpacity = 1;
126550
+ let tipsOpacity = 1;
126551
+ let labelOpacity = 0;
126552
+ if (isSelected || !semanticZoom || authoredZoom === null) {
126553
+ tipsOpacity = 1;
126554
+ labelOpacity = 1;
126555
+ } else {
126556
+ const zoomRatio = 2 ** (zoom - authoredZoom);
126557
+ if (zoomRatio < RATIO_CLUSTER) {
126558
+ clusterDotShapes.push({ shape });
126559
+ return;
126560
+ }
126561
+ if (zoomRatio < RATIO_DOT) {
126562
+ dotShapes.push({ shape, alpha: 200 });
126563
+ return;
126564
+ }
126565
+ if (zoomRatio < RATIO_GEO_FADE) {
126566
+ const t = (zoomRatio - RATIO_DOT) / (RATIO_GEO_FADE - RATIO_DOT);
126567
+ shapeOpacity = t;
126568
+ dotShapes.push({ shape, alpha: Math.round((1 - t) * 200) });
126569
+ }
126570
+ tipsOpacity = zoomRatio >= RATIO_TIPS ? shapeOpacity : Math.max(0, (zoomRatio - RATIO_GEO_FADE) / (RATIO_TIPS - RATIO_GEO_FADE) * shapeOpacity);
126571
+ if (zoomRatio >= RATIO_LABEL_FULL) {
126572
+ labelOpacity = shapeOpacity;
126573
+ } else if (zoomRatio >= RATIO_LABEL) {
126574
+ labelOpacity = (zoomRatio - RATIO_LABEL) / (RATIO_LABEL_FULL - RATIO_LABEL) * shapeOpacity;
126575
+ }
126576
+ }
126577
+ const arrowDataSize = Math.max(ARROW_SCREEN_PX, strokeWidth * 4) / 2 ** zoom;
126578
+ const base = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: shapeOpacity };
126579
+ const tipsBase = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: tipsOpacity };
126580
+ const labelBase = { coordinateSystem: COORDINATE_SYSTEM.CARTESIAN, opacity: labelOpacity };
126581
+ const labelBgProps = shape.labelBackground ? {
126582
+ background: true,
126583
+ getBackgroundColor: textBgColor(strokeColor),
126584
+ backgroundPadding: [3, 1, 3, 2]
126585
+ } : {};
126586
+ const labelProps = { ...labelBgProps };
126587
+ const dashArray = parseDashArray(strokeDashArray);
126588
+ const dashExt = [new PathStyleExtension({ dash: true })];
126589
+ const getDash = dashArray ?? [0, 0];
126590
+ if (type === "rectangle") {
126591
+ const { x, y, width, height, fillColor = strokeColor, fillOpacity = 0 } = shape;
126592
+ const filled = fillOpacity > 0;
126593
+ const rectPolygon = [[x, y], [x + width, y], [x + width, y + height], [x, y + height]];
126594
+ layers.push(new PolygonLayer({
126595
+ ...base,
126596
+ id: `annotation-rect-${uid2}-${i2}`,
126597
+ data: [{ polygon: rectPolygon }],
126598
+ getPolygon: (d) => d.polygon,
126599
+ filled,
126600
+ stroked: true,
126601
+ getFillColor: filled ? [...fillColor, Math.round(fillOpacity * 255)] : [0, 0, 0, 0],
126602
+ getLineColor: strokeColor,
126603
+ getLineWidth: strokeWidth,
126604
+ lineWidthUnits: "pixels",
126605
+ ...dashArray ? {
126606
+ extensions: [new PathStyleExtension({ dash: true })],
126607
+ getDashArray: dashArray
126608
+ } : {}
126609
+ }));
126610
+ if (shape.text && labelOpacity > 0) {
126611
+ layers.push(new TextLayer({
126612
+ ...labelBase,
126613
+ ...labelProps,
126614
+ id: `annotation-rect-text-${uid2}-${i2}`,
126615
+ data: [{ position: [x, y], text: shape.text }],
126616
+ getPosition: (d) => d.position,
126617
+ getText: (d) => d.text,
126618
+ getColor: strokeColor,
126619
+ getSize: LABEL_FONT_SIZE,
126620
+ sizeUnits: "pixels",
126621
+ fontFamily: LABEL_FONT_FAMILY,
126622
+ fontWeight: LABEL_FONT_WEIGHT,
126623
+ getPixelOffset: [3, -7],
126624
+ getTextAnchor: "start",
126625
+ getAlignmentBaseline: "bottom"
126626
+ }));
126627
+ }
126628
+ }
126629
+ if (type === "line") {
126630
+ const { x1: x12, y1: y12, x2, y2, markerStart, markerEnd } = shape;
126631
+ const dx = x2 - x12;
126632
+ const dy = y2 - y12;
126633
+ const len2 = Math.sqrt(dx * dx + dy * dy);
126634
+ const ux = len2 > 0 ? dx / len2 : 0;
126635
+ const uy = len2 > 0 ? dy / len2 : 0;
126636
+ const srcX = markerStart === "Arrow" ? x12 + ux * arrowDataSize : x12;
126637
+ const srcY = markerStart === "Arrow" ? y12 + uy * arrowDataSize : y12;
126638
+ const tgtX = markerEnd === "Arrow" ? x2 - ux * arrowDataSize : x2;
126639
+ const tgtY = markerEnd === "Arrow" ? y2 - uy * arrowDataSize : y2;
126640
+ layers.push(new PathLayer({
126641
+ ...base,
126642
+ id: `annotation-line-${uid2}-${i2}`,
126643
+ extensions: [new PathStyleExtension({ dash: true })],
126644
+ getDashArray: dashArray ?? [0, 0],
126645
+ data: [{ path: [[srcX, srcY], [tgtX, tgtY]] }],
126646
+ getPath: (d) => d.path,
126647
+ getColor: strokeColor,
126648
+ getWidth: strokeWidth,
126649
+ widthUnits: "pixels",
126650
+ capRounded: true
126651
+ }));
126652
+ if (markerEnd === "Arrow" && tipsOpacity > 0) {
126653
+ const head = computeArrowhead(x2, y2, x2 - x12, y2 - y12, arrowDataSize);
126654
+ if (head) {
126655
+ layers.push(new PolygonLayer({
126656
+ ...tipsBase,
126657
+ id: `annotation-end-arrow-${uid2}-${i2}`,
126658
+ data: [{ polygon: head }],
126659
+ getPolygon: (d) => d.polygon,
126660
+ filled: true,
126661
+ stroked: false,
126662
+ getFillColor: strokeColor
126663
+ }));
126664
+ }
126665
+ }
126666
+ if (markerStart === "Arrow" && tipsOpacity > 0) {
126667
+ const head = computeArrowhead(x12, y12, x12 - x2, y12 - y2, arrowDataSize);
126668
+ if (head) {
126669
+ layers.push(new PolygonLayer({
126670
+ ...tipsBase,
126671
+ id: `annotation-start-arrow-${uid2}-${i2}`,
126672
+ data: [{ polygon: head }],
126673
+ getPolygon: (d) => d.polygon,
126674
+ filled: true,
126675
+ stroked: false,
126676
+ getFillColor: strokeColor
126677
+ }));
126678
+ }
126679
+ }
126680
+ if (markerEnd === "Tick" && tipsOpacity > 0) {
126681
+ const tick = computeTickCap(x2, y2, x2 - x12, y2 - y12, arrowDataSize);
126682
+ if (tick) {
126683
+ layers.push(new PathLayer({
126684
+ ...tipsBase,
126685
+ id: `annotation-end-tick-${uid2}-${i2}`,
126686
+ data: [{ path: tick }],
126687
+ getPath: (d) => d.path,
126688
+ getColor: strokeColor,
126689
+ getWidth: strokeWidth,
126690
+ widthUnits: "pixels",
126691
+ capRounded: true
126692
+ }));
126693
+ }
126694
+ }
126695
+ if (markerStart === "Tick" && tipsOpacity > 0) {
126696
+ const tick = computeTickCap(x12, y12, x12 - x2, y12 - y2, arrowDataSize);
126697
+ if (tick) {
126698
+ layers.push(new PathLayer({
126699
+ ...tipsBase,
126700
+ id: `annotation-start-tick-${uid2}-${i2}`,
126701
+ data: [{ path: tick }],
126702
+ getPath: (d) => d.path,
126703
+ getColor: strokeColor,
126704
+ getWidth: strokeWidth,
126705
+ widthUnits: "pixels",
126706
+ capRounded: true
126707
+ }));
126708
+ }
126709
+ }
126710
+ if (shape.text) {
126711
+ const pos = shape.textPosition ?? "start";
126712
+ let textX;
126713
+ let textY;
126714
+ if (pos === "start") {
126715
+ textX = x12;
126716
+ textY = y12;
126717
+ } else if (pos === "end") {
126718
+ textX = x2;
126719
+ textY = y2;
126720
+ } else {
126721
+ textX = (x12 + x2) / 2;
126722
+ textY = (y12 + y2) / 2;
126723
+ }
126724
+ let pixelOffset = [0, 0];
126725
+ let textAnchor = "middle";
126726
+ let alignmentBaseline = "center";
126727
+ if (pos !== "middle") {
126728
+ const dxT = x2 - x12;
126729
+ const dyT = y2 - y12;
126730
+ const lenT = Math.sqrt(dxT * dxT + dyT * dyT);
126731
+ if (lenT > 0) {
126732
+ const uxT = dxT / lenT;
126733
+ const uyT = dyT / lenT;
126734
+ const sign2 = pos === "start" ? -1 : 1;
126735
+ const bufferPx = shape.textBufferPx ?? 8;
126736
+ const offsetX = sign2 * uxT * bufferPx;
126737
+ const offsetY = sign2 * uyT * bufferPx;
126738
+ pixelOffset = [offsetX, offsetY];
126739
+ const absX = Math.abs(offsetX);
126740
+ const absY = Math.abs(offsetY);
126741
+ if (absX >= absY) {
126742
+ textAnchor = offsetX > 0 ? "start" : "end";
126743
+ }
126744
+ if (absY >= absX) {
126745
+ alignmentBaseline = offsetY > 0 ? "top" : "bottom";
126746
+ }
126747
+ }
126748
+ } else if (len2 > 0) {
126749
+ const belowPerp = pickBelowPerp(ux, uy);
126750
+ const bufferPx = shape.textBufferPx ?? 14;
126751
+ pixelOffset = [-belowPerp[0] * bufferPx, -belowPerp[1] * bufferPx];
126752
+ textAnchor = "middle";
126753
+ alignmentBaseline = "center";
126754
+ }
126755
+ const middleAngle = pos === "middle" && len2 > 0 ? -readableAngle(Math.atan2(dy, dx) * 180 / Math.PI) : null;
126756
+ if (labelOpacity <= 0)
126757
+ return;
126758
+ layers.push(new TextLayer({
126759
+ ...labelBase,
126760
+ ...labelProps,
126761
+ id: `annotation-line-text-${uid2}-${i2}`,
126762
+ data: [{ position: [textX, textY], text: shape.text }],
126763
+ getPosition: (d) => d.position,
126764
+ getText: (d) => d.text,
126765
+ getColor: strokeColor,
126766
+ getSize: LABEL_FONT_SIZE,
126767
+ sizeUnits: "pixels",
126768
+ fontFamily: LABEL_FONT_FAMILY,
126769
+ fontWeight: LABEL_FONT_WEIGHT,
126770
+ getPixelOffset: pixelOffset,
126771
+ getTextAnchor: textAnchor,
126772
+ getAlignmentBaseline: alignmentBaseline,
126773
+ ...middleAngle !== null && { getAngle: middleAngle }
126774
+ }));
126775
+ }
126776
+ }
126777
+ if (type === "ellipse") {
126778
+ const { x1: x12, y1: y12, radiusX, radiusY, fillColor = strokeColor, fillOpacity = 0 } = shape;
126779
+ const polygon2 = computeEllipsePolygon(x12, y12, radiusX, radiusY);
126780
+ const filled = fillOpacity > 0;
126781
+ layers.push(new PolygonLayer({
126782
+ ...base,
126783
+ id: `annotation-ellipse-${uid2}-${i2}`,
126784
+ data: [{ polygon: polygon2 }],
126785
+ getPolygon: (d) => d.polygon,
126786
+ filled,
126787
+ stroked: true,
126788
+ getFillColor: filled ? [...fillColor, Math.round(fillOpacity * 255)] : [0, 0, 0, 0],
126789
+ getLineColor: strokeColor,
126790
+ getLineWidth: strokeWidth,
126791
+ lineWidthUnits: "pixels",
126792
+ ...dashArray ? {
126793
+ extensions: [new PathStyleExtension({ dash: true })],
126794
+ getDashArray: dashArray
126795
+ } : {}
126796
+ }));
126797
+ if (shape.text && labelOpacity > 0) {
126798
+ layers.push(new TextLayer({
126799
+ ...labelBase,
126800
+ ...labelProps,
126801
+ id: `annotation-ellipse-text-${uid2}-${i2}`,
126802
+ data: [{ position: [x12, y12 - radiusY], text: shape.text }],
126803
+ getPosition: (d) => d.position,
126804
+ getText: (d) => d.text,
126805
+ getColor: strokeColor,
126806
+ getSize: LABEL_FONT_SIZE,
126807
+ sizeUnits: "pixels",
126808
+ fontFamily: LABEL_FONT_FAMILY,
126809
+ fontWeight: LABEL_FONT_WEIGHT,
126810
+ getPixelOffset: [0, -4],
126811
+ getTextAnchor: "middle",
126812
+ getAlignmentBaseline: "bottom"
126813
+ }));
126814
+ }
126815
+ }
126816
+ if (type === "polygon") {
126817
+ const { points, fillColor = strokeColor, fillOpacity = 0 } = shape;
126818
+ if (!points || points.length < 3)
126819
+ return;
126820
+ const closedPath = [...points, points[0]];
126821
+ if (fillOpacity > 0) {
126822
+ layers.push(new PolygonLayer({
126823
+ ...base,
126824
+ id: `annotation-polygon-fill-${uid2}-${i2}`,
126825
+ data: [{ polygon: points }],
126826
+ getPolygon: (d) => d.polygon,
126827
+ stroked: false,
126828
+ filled: true,
126829
+ getFillColor: [...fillColor, Math.round(fillOpacity * 255)]
126830
+ }));
126831
+ }
126832
+ layers.push(new PathLayer({
126833
+ ...base,
126834
+ id: `annotation-polygon-${uid2}-${i2}`,
126835
+ extensions: dashExt,
126836
+ getDashArray: getDash,
126837
+ data: [{ path: closedPath }],
126838
+ getPath: (d) => d.path,
126839
+ getColor: strokeColor,
126840
+ getWidth: strokeWidth,
126841
+ widthUnits: "pixels",
126842
+ jointRounded: true
126843
+ }));
126844
+ if (shape.text && labelOpacity > 0) {
126845
+ const minX = Math.min(...points.map((p) => p[0]));
126846
+ const maxX = Math.max(...points.map((p) => p[0]));
126847
+ const minY = Math.min(...points.map((p) => p[1]));
126848
+ const topCenterX = (minX + maxX) / 2;
126849
+ layers.push(new TextLayer({
126850
+ ...labelBase,
126851
+ ...labelProps,
126852
+ id: `annotation-polygon-text-${uid2}-${i2}`,
126853
+ data: [{ position: [topCenterX, minY], text: shape.text }],
126854
+ getPosition: (d) => d.position,
126855
+ getText: (d) => d.text,
126856
+ getColor: strokeColor,
126857
+ getSize: LABEL_FONT_SIZE,
126858
+ sizeUnits: "pixels",
126859
+ fontFamily: LABEL_FONT_FAMILY,
126860
+ fontWeight: LABEL_FONT_WEIGHT,
126861
+ getPixelOffset: [0, -4],
126862
+ getTextAnchor: "middle",
126863
+ getAlignmentBaseline: "bottom"
126864
+ }));
126865
+ }
126866
+ }
126867
+ if (type === "polyline") {
126868
+ const { points, markerStart, markerEnd } = shape;
126869
+ if (!points || points.length < 2)
126870
+ return;
126871
+ let pathPoints = points;
126872
+ if (markerStart === "Arrow") {
126873
+ const [x02, y02] = points[0];
126874
+ const [x12, y12] = points[1];
126875
+ const dx = x02 - x12;
126876
+ const dy = y02 - y12;
126877
+ const len2 = Math.sqrt(dx * dx + dy * dy);
126878
+ if (len2 > 0) {
126879
+ const ux = dx / len2;
126880
+ const uy = dy / len2;
126881
+ pathPoints = [[x02 - ux * arrowDataSize, y02 - uy * arrowDataSize], ...pathPoints.slice(1)];
126882
+ }
126883
+ }
126884
+ if (markerEnd === "Arrow") {
126885
+ const last = pathPoints[pathPoints.length - 1];
126886
+ const prev = pathPoints[pathPoints.length - 2];
126887
+ const dx = last[0] - prev[0];
126888
+ const dy = last[1] - prev[1];
126889
+ const len2 = Math.sqrt(dx * dx + dy * dy);
126890
+ if (len2 > 0) {
126891
+ const ux = dx / len2;
126892
+ const uy = dy / len2;
126893
+ const shortened = [last[0] - ux * arrowDataSize, last[1] - uy * arrowDataSize];
126894
+ pathPoints = [...pathPoints.slice(0, -1), shortened];
126895
+ }
126896
+ }
126897
+ layers.push(new PathLayer({
126898
+ ...base,
126899
+ id: `annotation-polyline-${uid2}-${i2}`,
126900
+ extensions: dashExt,
126901
+ getDashArray: getDash,
126902
+ data: [{ path: pathPoints }],
126903
+ getPath: (d) => d.path,
126904
+ getColor: strokeColor,
126905
+ getWidth: strokeWidth,
126906
+ widthUnits: "pixels",
126907
+ jointRounded: true,
126908
+ capRounded: true
126909
+ }));
126910
+ if (markerStart === "Arrow" && tipsOpacity > 0) {
126911
+ const [x02, y02] = points[0];
126912
+ const [x12, y12] = points[1];
126913
+ const head = computeArrowhead(x02, y02, x02 - x12, y02 - y12, arrowDataSize);
126914
+ if (head) {
126915
+ layers.push(new PolygonLayer({
126916
+ ...tipsBase,
126917
+ id: `annotation-polyline-start-arrow-${uid2}-${i2}`,
126918
+ data: [{ polygon: head }],
126919
+ getPolygon: (d) => d.polygon,
126920
+ filled: true,
126921
+ stroked: false,
126922
+ getFillColor: strokeColor
126923
+ }));
126924
+ }
126925
+ }
126926
+ if (markerEnd === "Arrow" && tipsOpacity > 0) {
126927
+ const last = points[points.length - 1];
126928
+ const prev = points[points.length - 2];
126929
+ const dxArrow = last[0] - prev[0];
126930
+ const dyArrow = last[1] - prev[1];
126931
+ const head = computeArrowhead(last[0], last[1], dxArrow, dyArrow, arrowDataSize);
126932
+ if (head) {
126933
+ layers.push(new PolygonLayer({
126934
+ ...tipsBase,
126935
+ id: `annotation-polyline-end-arrow-${uid2}-${i2}`,
126936
+ data: [{ polygon: head }],
126937
+ getPolygon: (d) => d.polygon,
126938
+ filled: true,
126939
+ stroked: false,
126940
+ getFillColor: strokeColor
126941
+ }));
126942
+ }
126943
+ }
126944
+ if (markerStart === "Tick" && tipsOpacity > 0) {
126945
+ const [x02, y02] = points[0];
126946
+ const [x12, y12] = points[1];
126947
+ const tick = computeTickCap(x02, y02, x02 - x12, y02 - y12, arrowDataSize);
126948
+ if (tick) {
126949
+ layers.push(new PathLayer({
126950
+ ...tipsBase,
126951
+ id: `annotation-polyline-start-tick-${uid2}-${i2}`,
126952
+ data: [{ path: tick }],
126953
+ getPath: (d) => d.path,
126954
+ getColor: strokeColor,
126955
+ getWidth: strokeWidth,
126956
+ widthUnits: "pixels",
126957
+ capRounded: true
126958
+ }));
126959
+ }
126960
+ }
126961
+ if (markerEnd === "Tick" && tipsOpacity > 0) {
126962
+ const last = points[points.length - 1];
126963
+ const prev = points[points.length - 2];
126964
+ const dxTick = last[0] - prev[0];
126965
+ const dyTick = last[1] - prev[1];
126966
+ const tick = computeTickCap(last[0], last[1], dxTick, dyTick, arrowDataSize);
126967
+ if (tick) {
126968
+ layers.push(new PathLayer({
126969
+ ...tipsBase,
126970
+ id: `annotation-polyline-end-tick-${uid2}-${i2}`,
126971
+ data: [{ path: tick }],
126972
+ getPath: (d) => d.path,
126973
+ getColor: strokeColor,
126974
+ getWidth: strokeWidth,
126975
+ widthUnits: "pixels",
126976
+ capRounded: true
126977
+ }));
126978
+ }
126979
+ }
126980
+ if (shape.text) {
126981
+ const pos = shape.textPosition ?? "start";
126982
+ const bufferPx = shape.textBufferPx ?? 8;
126983
+ let textPt;
126984
+ let dirX;
126985
+ let dirY;
126986
+ if (pos === "end") {
126987
+ const last = points[points.length - 1];
126988
+ const prev = points[points.length - 2];
126989
+ textPt = last;
126990
+ dirX = last[0] - prev[0];
126991
+ dirY = last[1] - prev[1];
126992
+ } else if (pos === "middle") {
126993
+ const mx = points.reduce((s2, p) => s2 + p[0], 0) / points.length;
126994
+ const my = points.reduce((s2, p) => s2 + p[1], 0) / points.length;
126995
+ textPt = [mx, my];
126996
+ dirX = 0;
126997
+ dirY = 0;
126998
+ } else {
126999
+ [textPt] = points;
127000
+ dirX = points[0][0] - points[1][0];
127001
+ dirY = points[0][1] - points[1][1];
127002
+ }
127003
+ const [textX, textY] = textPt;
127004
+ const lenT = Math.sqrt(dirX * dirX + dirY * dirY);
127005
+ let polylinePixelOffset = [0, 0];
127006
+ let polylineTextAnchor = "middle";
127007
+ let polylineAlignmentBaseline = pos === "middle" ? "center" : "bottom";
127008
+ if (lenT > 0) {
127009
+ const uxT = dirX / lenT;
127010
+ const uyT = dirY / lenT;
127011
+ const offX = uxT * bufferPx;
127012
+ const offY = uyT * bufferPx;
127013
+ polylinePixelOffset = [offX, offY];
127014
+ if (Math.abs(offX) >= Math.abs(offY)) {
127015
+ polylineTextAnchor = offX > 0 ? "start" : "end";
127016
+ }
127017
+ if (Math.abs(offY) >= Math.abs(offX)) {
127018
+ polylineAlignmentBaseline = offY > 0 ? "top" : "bottom";
127019
+ }
127020
+ }
127021
+ if (labelOpacity <= 0)
127022
+ return;
127023
+ layers.push(new TextLayer({
127024
+ ...labelBase,
127025
+ ...labelProps,
127026
+ id: `annotation-polyline-text-${uid2}-${i2}`,
127027
+ data: [{ position: [textX, textY], text: shape.text }],
127028
+ getPosition: (d) => d.position,
127029
+ getText: (d) => d.text,
127030
+ getColor: strokeColor,
127031
+ getSize: LABEL_FONT_SIZE,
127032
+ sizeUnits: "pixels",
127033
+ fontFamily: LABEL_FONT_FAMILY,
127034
+ fontWeight: LABEL_FONT_WEIGHT,
127035
+ getPixelOffset: polylinePixelOffset,
127036
+ getTextAnchor: polylineTextAnchor,
127037
+ getAlignmentBaseline: polylineAlignmentBaseline
127038
+ }));
127039
+ }
127040
+ }
127041
+ });
127042
+ if (dotShapes.length > 0) {
127043
+ layers.push(new ScatterplotLayer({
127044
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
127045
+ id: "annotation-dots",
127046
+ data: dotShapes.map(({ shape: s2, alpha: alpha2 }) => ({
127047
+ position: getShapeCentroid(s2),
127048
+ color: [...s2.strokeColor ?? [255, 255, 255], alpha2]
127049
+ })),
127050
+ getPosition: (d) => d.position,
127051
+ getFillColor: (d) => d.color,
127052
+ getRadius: 4,
127053
+ radiusUnits: "pixels",
127054
+ filled: true,
127055
+ stroked: false
127056
+ }));
127057
+ }
127058
+ if (clusterDotShapes.length > 0) {
127059
+ const clusters = computeClusters(clusterDotShapes, zoom);
127060
+ layers.push(new ScatterplotLayer({
127061
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
127062
+ id: "annotation-clusters",
127063
+ data: clusters,
127064
+ getPosition: (d) => d.position,
127065
+ getFillColor: (d) => [...d.color, 180],
127066
+ getRadius: (d) => Math.max(6, 4 + Math.sqrt(d.count) * 2),
127067
+ radiusUnits: "pixels",
127068
+ filled: true,
127069
+ stroked: true,
127070
+ getLineColor: (d) => [...d.color, 220],
127071
+ lineWidthMinPixels: 1.5
127072
+ }));
127073
+ const multiClusters = clusters.filter((c) => c.count > 1);
127074
+ if (multiClusters.length > 0) {
127075
+ layers.push(new TextLayer({
127076
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
127077
+ id: "annotation-cluster-counts",
127078
+ data: multiClusters,
127079
+ getPosition: (d) => d.position,
127080
+ getText: (d) => String(d.count),
127081
+ getColor: [255, 255, 255],
127082
+ getSize: 10,
127083
+ sizeUnits: "pixels",
127084
+ fontWeight: "bold",
127085
+ getTextAnchor: "middle",
127086
+ getAlignmentBaseline: "center"
127087
+ }));
127088
+ }
127089
+ }
127090
+ const measureLayers = [];
127091
+ shapes.forEach((shape) => {
127092
+ if (!shape.showMeasure)
127093
+ return;
127094
+ const mIsSelected = shape.uid === selectedShapeUid;
127095
+ const label = getMeasurementLabel(shape, physicalPixelSize, viewType);
127096
+ if (!label)
127097
+ return;
127098
+ const color = shape.strokeColor ?? [255, 255, 255];
127099
+ let mShapeOpacity = 1;
127100
+ let mLabelFactor = 0;
127101
+ if (mIsSelected || !semanticZoom || authoredZoom === null) {
127102
+ mLabelFactor = 1;
127103
+ } else {
127104
+ const mZoomRatio = 2 ** (zoom - authoredZoom);
127105
+ if (mZoomRatio < RATIO_DOT)
127106
+ return;
127107
+ if (mZoomRatio < RATIO_GEO_FADE) {
127108
+ mShapeOpacity = (mZoomRatio - RATIO_DOT) / (RATIO_GEO_FADE - RATIO_DOT);
127109
+ }
127110
+ if (mZoomRatio >= RATIO_LABEL_FULL) {
127111
+ mLabelFactor = 1;
127112
+ } else if (mZoomRatio >= RATIO_LABEL) {
127113
+ mLabelFactor = (mZoomRatio - RATIO_LABEL) / (RATIO_LABEL_FULL - RATIO_LABEL);
127114
+ }
127115
+ }
127116
+ const measureOpacity = mShapeOpacity * mLabelFactor;
127117
+ if (measureOpacity <= 0)
127118
+ return;
127119
+ const base = {
127120
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
127121
+ opacity: measureOpacity,
127122
+ getText: (d) => d.text,
127123
+ getPosition: (d) => d.position,
127124
+ getColor: color,
127125
+ getSize: 13,
127126
+ sizeUnits: "pixels",
127127
+ fontFamily: LABEL_FONT_FAMILY,
127128
+ fontWeight: "bold",
127129
+ // 'auto' builds the font atlas from the actual rendered characters (e.g. µ, ²)
127130
+ // instead of deck.gl's default ASCII-only atlas.
127131
+ characterSet: "auto",
127132
+ ...shape.measureBackground ? {
127133
+ background: true,
127134
+ getBackgroundColor: textBgColor(color),
127135
+ backgroundPadding: [3, 1, 3, 2]
127136
+ } : {}
127137
+ };
127138
+ if (shape.type === "line") {
127139
+ const mx = ((shape.x1 ?? 0) + (shape.x2 ?? 0)) / 2;
127140
+ const my = ((shape.y1 ?? 0) + (shape.y2 ?? 0)) / 2;
127141
+ const dx = (shape.x2 ?? 0) - (shape.x1 ?? 0);
127142
+ const dy = (shape.y2 ?? 0) - (shape.y1 ?? 0);
127143
+ const len2 = Math.sqrt(dx * dx + dy * dy);
127144
+ if (len2 === 0)
127145
+ return;
127146
+ const perp = pickBelowPerp(dx / len2, dy / len2);
127147
+ const angle2 = readableAngle(Math.atan2(dy, dx) * 180 / Math.PI);
127148
+ measureLayers.push(new TextLayer({
127149
+ ...base,
127150
+ id: `annotation-measure-${shape.uid}`,
127151
+ data: [{ position: [mx, my], text: label }],
127152
+ getAngle: -angle2,
127153
+ getTextAnchor: "middle",
127154
+ getAlignmentBaseline: "center",
127155
+ getPixelOffset: [perp[0] * 16, perp[1] * 16]
127156
+ }));
127157
+ } else if (shape.type === "polyline" && shape.points?.length >= 2) {
127158
+ const pts = shape.points;
127159
+ const mi = Math.floor((pts.length - 1) / 2);
127160
+ const [ax, ay] = pts[mi];
127161
+ const [bx, by] = pts[mi + 1];
127162
+ const dx = bx - ax;
127163
+ const dy = by - ay;
127164
+ const len2 = Math.sqrt(dx * dx + dy * dy);
127165
+ if (len2 === 0)
127166
+ return;
127167
+ const perp = pickBelowPerp(dx / len2, dy / len2);
127168
+ const angle2 = readableAngle(Math.atan2(dy, dx) * 180 / Math.PI);
127169
+ measureLayers.push(new TextLayer({
127170
+ ...base,
127171
+ id: `annotation-measure-${shape.uid}`,
127172
+ data: [{ position: [(ax + bx) / 2, (ay + by) / 2], text: label }],
127173
+ getAngle: -angle2,
127174
+ getTextAnchor: "middle",
127175
+ getAlignmentBaseline: "center",
127176
+ getPixelOffset: [perp[0] * 16, perp[1] * 16]
127177
+ }));
127178
+ } else if (shape.type === "rectangle") {
127179
+ const x02 = shape.x ?? 0;
127180
+ const y02 = shape.y ?? 0;
127181
+ const w2 = shape.width ?? 0;
127182
+ const h = shape.height ?? 0;
127183
+ const rx = x02 + (w2 >= 0 ? w2 : 0);
127184
+ const ry = y02 + (h >= 0 ? h : 0);
127185
+ measureLayers.push(new TextLayer({
127186
+ ...base,
127187
+ id: `annotation-measure-${shape.uid}`,
127188
+ data: [{ position: [rx, ry], text: label }],
127189
+ getTextAnchor: "end",
127190
+ getAlignmentBaseline: "bottom",
127191
+ getPixelOffset: [-6, -6]
127192
+ }));
127193
+ } else if (shape.type === "ellipse") {
127194
+ const cx = shape.x1 ?? 0;
127195
+ const cy = shape.y1 ?? 0;
127196
+ const ry = Math.abs(shape.radiusY ?? 0);
127197
+ measureLayers.push(new TextLayer({
127198
+ ...base,
127199
+ id: `annotation-measure-${shape.uid}`,
127200
+ data: [{ position: [cx, cy + ry], text: label }],
127201
+ getTextAnchor: "middle",
127202
+ getAlignmentBaseline: "top",
127203
+ getPixelOffset: [0, 8]
127204
+ }));
127205
+ } else if (shape.type === "polygon" && shape.points?.length >= 3) {
127206
+ const xs = shape.points.map((p) => p[0]);
127207
+ const ys = shape.points.map((p) => p[1]);
127208
+ const cx = (Math.min(...xs) + Math.max(...xs)) / 2;
127209
+ const maxY = Math.max(...ys);
127210
+ measureLayers.push(new TextLayer({
127211
+ ...base,
127212
+ id: `annotation-measure-${shape.uid}`,
127213
+ data: [{ position: [cx, maxY], text: label }],
127214
+ getTextAnchor: "middle",
127215
+ getAlignmentBaseline: "top",
127216
+ getPixelOffset: [0, 8]
127217
+ }));
127218
+ }
127219
+ });
127220
+ return [...selectionLayers, ...layers, ...measureLayers];
127221
+ }
127222
+ const defaultProps = {
127223
+ // Array of annotation shape objects (see annotationShapeObj in @vitessce/schemas).
127224
+ data: { type: "object", value: [], compare: true },
127225
+ // UID of the shape to highlight with a selection halo.
127226
+ selectedShapeUid: { type: "string", value: null },
127227
+ // { x, y, unit } used to format measurement labels in physical units.
127228
+ physicalPixelSize: { type: "object", value: null, compare: true },
127229
+ // The zoom level at which the shapes were authored (reference for semantic zoom).
127230
+ authoredZoom: { type: "number", value: null },
127231
+ // Whether to apply semantic zoom (level-of-detail) based on authoredZoom.
127232
+ semanticZoom: { type: "boolean", value: true },
127233
+ // The view type in which the layer is rendered (affects measurement label formatting).
127234
+ viewType: { type: "string", value: ViewType.SPATIAL },
127235
+ // In-progress shape being drawn, as { type, vertices }.
127236
+ inProgressShape: { type: "object", value: null, compare: true },
127237
+ // Current mouse position (in data coordinates) while drawing.
127238
+ hoverCoord: { type: "array", value: null, compare: true },
127239
+ // Stroke color [r, g, b] of the in-progress shape preview.
127240
+ previewStrokeColor: { type: "color", value: [255, 255, 0] }
127241
+ };
127242
+ class AnnotationLayer extends CompositeLayer {
127243
+ // The semantic zoom and arrowhead sizes depend on the current zoom level,
127244
+ // so the sublayers must also be re-rendered when the viewport changes.
127245
+ // eslint-disable-next-line class-methods-use-this
127246
+ shouldUpdateState({ changeFlags }) {
127247
+ return changeFlags.propsOrDataChanged || changeFlags.viewportChanged;
127248
+ }
127249
+ /**
127250
+ * Prefix the sublayer ID with this layer's ID (so that multiple
127251
+ * AnnotationLayers can co-exist), and combine this layer's
127252
+ * opacity with the per-shape opacity of the sublayer.
127253
+ * Note: we avoid getSubLayerProps here, since it would
127254
+ * overwrite the sublayer extensions (e.g., PathStyleExtension)
127255
+ * and opacity values.
127256
+ * @param {object} layer A DeckGL layer instance.
127257
+ * @returns {object} The cloned layer instance.
127258
+ */
127259
+ wrapSubLayer(layer) {
127260
+ const { id, opacity, pickable, visible } = this.props;
127261
+ return layer.clone({
127262
+ id: `${id}-${layer.id}`,
127263
+ opacity: layer.props.opacity * opacity,
127264
+ pickable,
127265
+ visible
127266
+ });
127267
+ }
127268
+ renderLayers() {
127269
+ const { data, selectedShapeUid, physicalPixelSize, authoredZoom, semanticZoom, viewType, inProgressShape, hoverCoord, previewStrokeColor } = this.props;
127270
+ const zoom = this.context.viewport?.zoom ?? 0;
127271
+ const visibleShapes = (data ?? []).filter((shape) => shape.visible !== false);
127272
+ const annotationLayers = createAnnotationLayers(visibleShapes, zoom, selectedShapeUid, physicalPixelSize, authoredZoom, semanticZoom, viewType);
127273
+ const previewLayer = createPreviewLayer(inProgressShape, hoverCoord, previewStrokeColor.slice(0, 3));
127274
+ return [
127275
+ ...annotationLayers,
127276
+ ...previewLayer ? [previewLayer] : []
127277
+ ].map((layer) => this.wrapSubLayer(layer));
127278
+ }
127279
+ }
127280
+ AnnotationLayer.layerName = "AnnotationLayer";
127281
+ AnnotationLayer.defaultProps = defaultProps;
126083
127282
  function _extends() {
126084
127283
  return _extends = Object.assign ? Object.assign.bind() : function(n3) {
126085
127284
  for (var e2 = 1; e2 < arguments.length; e2++) {
@@ -141287,8 +142486,8 @@ async function getSingleSelectionStats2D({ loader, selection }) {
141287
142486
  const filteredSelection = filterSelection(loader, selection);
141288
142487
  const raster = await data.getRaster({ selection: filteredSelection });
141289
142488
  const selectionStats = getChannelStats(raster.data);
141290
- const { domain, contrastLimits: slider } = selectionStats;
141291
- return { domain, slider };
142489
+ const { domain, contrastLimits: slider, q1, q3 } = selectionStats;
142490
+ return { domain, slider, q1, q3 };
141292
142491
  }
141293
142492
  const getSingleSelectionStats = async ({ loader, selection, use3d }) => {
141294
142493
  const getStats = getSingleSelectionStats2D;
@@ -141298,7 +142497,9 @@ const getMultiSelectionStats = async ({ loader, selections, use3d }) => {
141298
142497
  const stats = await Promise.all(selections.map((selection) => getSingleSelectionStats({ loader, selection, use3d })));
141299
142498
  const domains = stats.map((stat) => stat.domain);
141300
142499
  const sliders = stats.map((stat) => stat.slider);
141301
- return { domains, sliders };
142500
+ const q1s = stats.map((stat) => stat.q1);
142501
+ const q3s = stats.map((stat) => stat.q3);
142502
+ return { domains, sliders, q1s, q3s };
141302
142503
  };
141303
142504
  class InternMap extends Map {
141304
142505
  constructor(entries, key = keyof) {