@vitessce/spatial-utils 3.2.1 → 3.3.0

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.
@@ -1,3 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ var __accessCheck = (obj, member, msg) => {
8
+ if (!member.has(obj))
9
+ throw TypeError("Cannot " + msg);
10
+ };
11
+ var __privateGet = (obj, member, getter) => {
12
+ __accessCheck(obj, member, "read from private field");
13
+ return getter ? getter.call(obj) : member.get(obj);
14
+ };
15
+ var __privateAdd = (obj, member, value) => {
16
+ if (member.has(obj))
17
+ throw TypeError("Cannot add the same private member more than once");
18
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
19
+ };
20
+ var __privateSet = (obj, member, value, setter2) => {
21
+ __accessCheck(obj, member, "write to private field");
22
+ setter2 ? setter2.call(obj, value) : member.set(obj, value);
23
+ return value;
24
+ };
25
+ var __privateMethod = (obj, member, method) => {
26
+ __accessCheck(obj, member, "access private method");
27
+ return method;
28
+ };
29
+ var _bytes, _encoder, _encode_buffer, _strides, _TypedArray, _BYTES_PER_ELEMENT, _shape, _endian, _shape2, _strides2, _metadata, _metadata2, _a2, _b, _overrides, _use_suffix_request, _merge_init, merge_init_fn;
1
30
  import "react";
2
31
  function _mergeNamespaces(n3, m) {
3
32
  for (var i2 = 0; i2 < m.length; i2++) {
@@ -21,9 +50,9 @@ function _mergeNamespaces(n3, m) {
21
50
  var freeGlobal$1 = typeof global == "object" && global && global.Object === Object && global;
22
51
  const freeGlobal$2 = freeGlobal$1;
23
52
  var freeSelf$1 = typeof self == "object" && self && self.Object === Object && self;
24
- var root$1 = freeGlobal$2 || freeSelf$1 || Function("return this")();
25
- const root$2 = root$1;
26
- var Symbol$1 = root$2.Symbol;
53
+ var root$2 = freeGlobal$2 || freeSelf$1 || Function("return this")();
54
+ const root$3 = root$2;
55
+ var Symbol$1 = root$3.Symbol;
27
56
  const Symbol$2 = Symbol$1;
28
57
  var objectProto$f = Object.prototype;
29
58
  var hasOwnProperty$e = objectProto$f.hasOwnProperty;
@@ -126,7 +155,7 @@ function isFunction$3(value) {
126
155
  var tag2 = baseGetTag(value);
127
156
  return tag2 == funcTag$2 || tag2 == genTag$1 || tag2 == asyncTag || tag2 == proxyTag;
128
157
  }
129
- var coreJsData = root$2["__core-js_shared__"];
158
+ var coreJsData = root$3["__core-js_shared__"];
130
159
  const coreJsData$1 = coreJsData;
131
160
  var maskSrcKey = function() {
132
161
  var uid2 = /[^.]+$/.exec(coreJsData$1 && coreJsData$1.keys && coreJsData$1.keys.IE_PROTO || "");
@@ -172,7 +201,7 @@ function getNative(object2, key) {
172
201
  var value = getValue$1(object2, key);
173
202
  return baseIsNative(value) ? value : void 0;
174
203
  }
175
- var WeakMap$1 = getNative(root$2, "WeakMap");
204
+ var WeakMap$1 = getNative(root$3, "WeakMap");
176
205
  const WeakMap$2 = WeakMap$1;
177
206
  var objectCreate = Object.create;
178
207
  var baseCreate = function() {
@@ -314,7 +343,7 @@ function stubFalse() {
314
343
  var freeExports$2 = typeof exports == "object" && exports && !exports.nodeType && exports;
315
344
  var freeModule$2 = freeExports$2 && typeof module == "object" && module && !module.nodeType && module;
316
345
  var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
317
- var Buffer$3 = moduleExports$2 ? root$2.Buffer : void 0;
346
+ var Buffer$3 = moduleExports$2 ? root$3.Buffer : void 0;
318
347
  var nativeIsBuffer = Buffer$3 ? Buffer$3.isBuffer : void 0;
319
348
  var isBuffer$3 = nativeIsBuffer || stubFalse;
320
349
  const isBuffer$4 = isBuffer$3;
@@ -521,7 +550,7 @@ ListCache.prototype["delete"] = listCacheDelete;
521
550
  ListCache.prototype.get = listCacheGet;
522
551
  ListCache.prototype.has = listCacheHas;
523
552
  ListCache.prototype.set = listCacheSet;
524
- var Map$1 = getNative(root$2, "Map");
553
+ var Map$1 = getNative(root$3, "Map");
525
554
  const Map$2 = Map$1;
526
555
  function mapCacheClear() {
527
556
  this.size = 0;
@@ -627,7 +656,7 @@ function baseAssignIn(object2, source) {
627
656
  var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
628
657
  var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
629
658
  var moduleExports = freeModule && freeModule.exports === freeExports;
630
- var Buffer$2 = moduleExports ? root$2.Buffer : void 0, allocUnsafe = Buffer$2 ? Buffer$2.allocUnsafe : void 0;
659
+ var Buffer$2 = moduleExports ? root$3.Buffer : void 0, allocUnsafe = Buffer$2 ? Buffer$2.allocUnsafe : void 0;
631
660
  function cloneBuffer(buffer2, isDeep) {
632
661
  if (isDeep) {
633
662
  return buffer2.slice();
@@ -688,11 +717,11 @@ function getAllKeys(object2) {
688
717
  function getAllKeysIn(object2) {
689
718
  return baseGetAllKeys(object2, keysIn, getSymbolsIn$1);
690
719
  }
691
- var DataView$1 = getNative(root$2, "DataView");
720
+ var DataView$1 = getNative(root$3, "DataView");
692
721
  const DataView$2 = DataView$1;
693
- var Promise$1 = getNative(root$2, "Promise");
722
+ var Promise$1 = getNative(root$3, "Promise");
694
723
  const Promise$2 = Promise$1;
695
- var Set$1 = getNative(root$2, "Set");
724
+ var Set$1 = getNative(root$3, "Set");
696
725
  const Set$2 = Set$1;
697
726
  var mapTag$4 = "[object Map]", objectTag$2 = "[object Object]", promiseTag = "[object Promise]", setTag$4 = "[object Set]", weakMapTag$1 = "[object WeakMap]";
698
727
  var dataViewTag$3 = "[object DataView]";
@@ -729,7 +758,7 @@ function initCloneArray(array) {
729
758
  }
730
759
  return result;
731
760
  }
732
- var Uint8Array$1 = root$2.Uint8Array;
761
+ var Uint8Array$1 = root$3.Uint8Array;
733
762
  const Uint8Array$2 = Uint8Array$1;
734
763
  function cloneArrayBuffer(arrayBuffer2) {
735
764
  var result = new arrayBuffer2.constructor(arrayBuffer2.byteLength);
@@ -1130,8 +1159,8 @@ function createRange(fromRight) {
1130
1159
  return baseRange(start, end, step, fromRight);
1131
1160
  };
1132
1161
  }
1133
- var range$4 = createRange();
1134
- const range$5 = range$4;
1162
+ var range$5 = createRange();
1163
+ const range$6 = range$5;
1135
1164
  function assert$c(condition, message) {
1136
1165
  if (!condition) {
1137
1166
  throw new Error("math.gl assertion ".concat(message));
@@ -6373,8 +6402,8 @@ DimensionError.prototype = new RangeError();
6373
6402
  DimensionError.prototype.constructor = RangeError;
6374
6403
  DimensionError.prototype.name = "DimensionError";
6375
6404
  DimensionError.prototype.isDimensionError = true;
6376
- function IndexError(index2, min2, max2) {
6377
- if (!(this instanceof IndexError)) {
6405
+ function IndexError$1(index2, min2, max2) {
6406
+ if (!(this instanceof IndexError$1)) {
6378
6407
  throw new SyntaxError("Constructor must be called with the new operator");
6379
6408
  }
6380
6409
  this.index = index2;
@@ -6394,10 +6423,10 @@ function IndexError(index2, min2, max2) {
6394
6423
  }
6395
6424
  this.stack = new Error().stack;
6396
6425
  }
6397
- IndexError.prototype = new RangeError();
6398
- IndexError.prototype.constructor = RangeError;
6399
- IndexError.prototype.name = "IndexError";
6400
- IndexError.prototype.isIndexError = true;
6426
+ IndexError$1.prototype = new RangeError();
6427
+ IndexError$1.prototype.constructor = RangeError;
6428
+ IndexError$1.prototype.name = "IndexError";
6429
+ IndexError$1.prototype.isIndexError = true;
6401
6430
  function arraySize(x2) {
6402
6431
  var s2 = [];
6403
6432
  while (Array.isArray(x2)) {
@@ -6444,7 +6473,7 @@ function validateIndex(index2, length2) {
6444
6473
  throw new TypeError("Index must be an integer (value: " + index2 + ")");
6445
6474
  }
6446
6475
  if (index2 < 0 || typeof length2 === "number" && index2 >= length2) {
6447
- throw new IndexError(index2, length2);
6476
+ throw new IndexError$1(index2, length2);
6448
6477
  }
6449
6478
  }
6450
6479
  function resize(array, size2, defaultValue2) {
@@ -6506,7 +6535,7 @@ function reshape(array, sizes) {
6506
6535
  throw new DimensionError(0, currentLength, "!=");
6507
6536
  }
6508
6537
  sizes = processSizesWildcard(sizes, currentLength);
6509
- var newLength = product(sizes);
6538
+ var newLength = product$1(sizes);
6510
6539
  if (currentLength !== newLength) {
6511
6540
  throw new DimensionError(newLength, currentLength, "!=");
6512
6541
  }
@@ -6520,7 +6549,7 @@ function reshape(array, sizes) {
6520
6549
  }
6521
6550
  }
6522
6551
  function processSizesWildcard(sizes, currentLength) {
6523
- var newLength = product(sizes);
6552
+ var newLength = product$1(sizes);
6524
6553
  var processedSizes = sizes.slice();
6525
6554
  var WILDCARD = -1;
6526
6555
  var wildCardIndex = sizes.indexOf(WILDCARD);
@@ -6539,7 +6568,7 @@ function processSizesWildcard(sizes, currentLength) {
6539
6568
  }
6540
6569
  return processedSizes;
6541
6570
  }
6542
- function product(array) {
6571
+ function product$1(array) {
6543
6572
  return array.reduce((prev, curr) => prev * curr, 1);
6544
6573
  }
6545
6574
  function _reshape(array, sizes) {
@@ -9488,15 +9517,15 @@ var complex = { exports: {} };
9488
9517
  throw SyntaxError("Invalid Param");
9489
9518
  };
9490
9519
  function logHypot(a2, b) {
9491
- var _a2 = Math.abs(a2);
9492
- var _b = Math.abs(b);
9520
+ var _a3 = Math.abs(a2);
9521
+ var _b2 = Math.abs(b);
9493
9522
  if (a2 === 0) {
9494
- return Math.log(_b);
9523
+ return Math.log(_b2);
9495
9524
  }
9496
9525
  if (b === 0) {
9497
- return Math.log(_a2);
9526
+ return Math.log(_a3);
9498
9527
  }
9499
- if (_a2 < 3e3 && _b < 3e3) {
9528
+ if (_a3 < 3e3 && _b2 < 3e3) {
9500
9529
  return Math.log(a2 * a2 + b * b) * 0.5;
9501
9530
  }
9502
9531
  a2 = a2 / 2;
@@ -22553,11 +22582,11 @@ class ZodType {
22553
22582
  throw result.error;
22554
22583
  }
22555
22584
  safeParse(data, params) {
22556
- var _a2;
22585
+ var _a3;
22557
22586
  const ctx = {
22558
22587
  common: {
22559
22588
  issues: [],
22560
- async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false,
22589
+ async: (_a3 = params === null || params === void 0 ? void 0 : params.async) !== null && _a3 !== void 0 ? _a3 : false,
22561
22590
  contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
22562
22591
  },
22563
22592
  path: (params === null || params === void 0 ? void 0 : params.path) || [],
@@ -22913,7 +22942,7 @@ class ZodString extends ZodType {
22913
22942
  } else if (check.kind === "url") {
22914
22943
  try {
22915
22944
  new URL(input.data);
22916
- } catch (_a2) {
22945
+ } catch (_a3) {
22917
22946
  ctx = this._getOrReturnCtx(input, ctx);
22918
22947
  addIssueToContext(ctx, {
22919
22948
  validation: "url",
@@ -23028,7 +23057,7 @@ class ZodString extends ZodType {
23028
23057
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
23029
23058
  }
23030
23059
  datetime(options) {
23031
- var _a2;
23060
+ var _a3;
23032
23061
  if (typeof options === "string") {
23033
23062
  return this._addCheck({
23034
23063
  kind: "datetime",
@@ -23040,7 +23069,7 @@ class ZodString extends ZodType {
23040
23069
  return this._addCheck({
23041
23070
  kind: "datetime",
23042
23071
  precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
23043
- offset: (_a2 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a2 !== void 0 ? _a2 : false,
23072
+ offset: (_a3 = options === null || options === void 0 ? void 0 : options.offset) !== null && _a3 !== void 0 ? _a3 : false,
23044
23073
  ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
23045
23074
  });
23046
23075
  }
@@ -23143,11 +23172,11 @@ class ZodString extends ZodType {
23143
23172
  }
23144
23173
  }
23145
23174
  ZodString.create = (params) => {
23146
- var _a2;
23175
+ var _a3;
23147
23176
  return new ZodString({
23148
23177
  checks: [],
23149
23178
  typeName: ZodFirstPartyTypeKind.ZodString,
23150
- coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false,
23179
+ coerce: (_a3 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a3 !== void 0 ? _a3 : false,
23151
23180
  ...processCreateParams(params)
23152
23181
  });
23153
23182
  };
@@ -23548,11 +23577,11 @@ class ZodBigInt extends ZodType {
23548
23577
  }
23549
23578
  }
23550
23579
  ZodBigInt.create = (params) => {
23551
- var _a2;
23580
+ var _a3;
23552
23581
  return new ZodBigInt({
23553
23582
  checks: [],
23554
23583
  typeName: ZodFirstPartyTypeKind.ZodBigInt,
23555
- coerce: (_a2 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a2 !== void 0 ? _a2 : false,
23584
+ coerce: (_a3 = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a3 !== void 0 ? _a3 : false,
23556
23585
  ...processCreateParams(params)
23557
23586
  });
23558
23587
  };
@@ -24058,8 +24087,8 @@ class ZodObject extends ZodType {
24058
24087
  unknownKeys: "strict",
24059
24088
  ...message !== void 0 ? {
24060
24089
  errorMap: (issue, ctx) => {
24061
- var _a2, _b, _c, _d;
24062
- const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
24090
+ var _a3, _b2, _c, _d;
24091
+ const defaultError = (_c = (_b2 = (_a3 = this._def).errorMap) === null || _b2 === void 0 ? void 0 : _b2.call(_a3, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
24063
24092
  if (issue.code === "unrecognized_keys")
24064
24093
  return {
24065
24094
  message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
@@ -25439,10 +25468,10 @@ class ZodPipeline extends ZodType {
25439
25468
  const custom = (check, params = {}, fatal) => {
25440
25469
  if (check)
25441
25470
  return ZodAny.create().superRefine((data, ctx) => {
25442
- var _a2, _b;
25471
+ var _a3, _b2;
25443
25472
  if (!check(data)) {
25444
25473
  const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
25445
- const _fatal = (_b = (_a2 = p.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b !== void 0 ? _b : true;
25474
+ const _fatal = (_b2 = (_a3 = p.fatal) !== null && _a3 !== void 0 ? _a3 : fatal) !== null && _b2 !== void 0 ? _b2 : true;
25446
25475
  const p2 = typeof p === "string" ? { message: p } : p;
25447
25476
  ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
25448
25477
  }
@@ -25932,13 +25961,13 @@ function upgradeFrom0_1_0(config3, datasetUid = null) {
25932
25961
  };
25933
25962
  const layout = [];
25934
25963
  config3.staticLayout.forEach((componentDef) => {
25935
- var _a2, _b, _c;
25964
+ var _a3, _b2, _c;
25936
25965
  let newComponentDef = {
25937
25966
  ...componentDef,
25938
25967
  coordinationScopes: {}
25939
25968
  };
25940
25969
  if (componentDef.component === "scatterplot") {
25941
- if (((_a2 = componentDef.props) == null ? void 0 : _a2.mapping) && typeof componentDef.props.mapping === "string") {
25970
+ if (((_a3 = componentDef.props) == null ? void 0 : _a3.mapping) && typeof componentDef.props.mapping === "string") {
25942
25971
  coordinationSpace.embeddingType[componentDef.props.mapping] = componentDef.props.mapping;
25943
25972
  newComponentDef = {
25944
25973
  ...newComponentDef,
@@ -25948,7 +25977,7 @@ function upgradeFrom0_1_0(config3, datasetUid = null) {
25948
25977
  }
25949
25978
  };
25950
25979
  }
25951
- if ((_b = componentDef.props) == null ? void 0 : _b.view) {
25980
+ if ((_b2 = componentDef.props) == null ? void 0 : _b2.view) {
25952
25981
  const newScopeValues = upgradeReplaceViewProp("embedding", componentDef.props.view, coordinationSpace);
25953
25982
  newComponentDef = {
25954
25983
  ...newComponentDef,
@@ -26050,7 +26079,7 @@ function upgradeFrom1_0_0(config3) {
26050
26079
  };
26051
26080
  }
26052
26081
  function upgradeFrom1_0_1(config3) {
26053
- var _a2;
26082
+ var _a3;
26054
26083
  const layout = config3.layout.map((component) => {
26055
26084
  const newComponent = { ...component };
26056
26085
  if (newComponent.component === "layerController") {
@@ -26062,9 +26091,9 @@ function upgradeFrom1_0_1(config3) {
26062
26091
  return newComponent;
26063
26092
  });
26064
26093
  const newConfig = cloneDeep(config3);
26065
- Object.keys(((_a2 = newConfig == null ? void 0 : newConfig.coordinationSpace) == null ? void 0 : _a2.spatialRasterLayers) || {}).forEach((key) => {
26066
- var _a3, _b;
26067
- if ((_b = (_a3 = newConfig.coordinationSpace) == null ? void 0 : _a3.spatialRasterLayers) == null ? void 0 : _b[key]) {
26094
+ Object.keys(((_a3 = newConfig == null ? void 0 : newConfig.coordinationSpace) == null ? void 0 : _a3.spatialRasterLayers) || {}).forEach((key) => {
26095
+ var _a4, _b2;
26096
+ if ((_b2 = (_a4 = newConfig.coordinationSpace) == null ? void 0 : _a4.spatialRasterLayers) == null ? void 0 : _b2[key]) {
26068
26097
  newConfig.coordinationSpace.spatialRasterLayers[key].forEach((layer, index2) => {
26069
26098
  if (newConfig.coordinationSpace) {
26070
26099
  newConfig.coordinationSpace.spatialRasterLayers[key][index2].type = ["bitmask", "raster"].includes(layer.type) ? layer.type : "raster";
@@ -26252,8 +26281,8 @@ function upgradeFrom1_0_12(config3) {
26252
26281
  });
26253
26282
  });
26254
26283
  function getDatasetUidForView(viewDef) {
26255
- var _a2, _b;
26256
- if (((_a2 = viewDef.coordinationScopes) == null ? void 0 : _a2.dataset) && typeof ((_b = viewDef.coordinationScopes) == null ? void 0 : _b.dataset) === "string") {
26284
+ var _a3, _b2;
26285
+ if (((_a3 = viewDef.coordinationScopes) == null ? void 0 : _a3.dataset) && typeof ((_b2 = viewDef.coordinationScopes) == null ? void 0 : _b2.dataset) === "string") {
26257
26286
  return newCoordinationSpace.dataset[viewDef.coordinationScopes.dataset];
26258
26287
  }
26259
26288
  if (datasets.length > 0) {
@@ -26316,8 +26345,8 @@ function upgradeFrom1_0_14(config3) {
26316
26345
  };
26317
26346
  newLayout.forEach((viewDef) => {
26318
26347
  Object.entries(propAnalogies).forEach(([oldProp, newType]) => {
26319
- var _a2;
26320
- if ((_a2 = viewDef.props) == null ? void 0 : _a2[oldProp]) {
26348
+ var _a3;
26349
+ if ((_a3 = viewDef.props) == null ? void 0 : _a3[oldProp]) {
26321
26350
  console.warn(`Warning: the '${oldProp}' prop on the ${viewDef.component} view is deprecated. Please use the '${newType}' coordination type instead.`);
26322
26351
  }
26323
26352
  });
@@ -27459,10 +27488,10 @@ let LRUCache$1 = class LRUCache {
27459
27488
  return !isStale(this, hit);
27460
27489
  }
27461
27490
  get(key) {
27462
- return get(this, key, true);
27491
+ return get$2(this, key, true);
27463
27492
  }
27464
27493
  peek(key) {
27465
- return get(this, key, false);
27494
+ return get$2(this, key, false);
27466
27495
  }
27467
27496
  pop() {
27468
27497
  const node2 = this[LRU_LIST].tail;
@@ -27491,10 +27520,10 @@ let LRUCache$1 = class LRUCache {
27491
27520
  }
27492
27521
  }
27493
27522
  prune() {
27494
- this[CACHE].forEach((value, key) => get(this, key, false));
27523
+ this[CACHE].forEach((value, key) => get$2(this, key, false));
27495
27524
  }
27496
27525
  };
27497
- const get = (self2, key, doUse) => {
27526
+ const get$2 = (self2, key, doUse) => {
27498
27527
  const node2 = self2[CACHE].get(key);
27499
27528
  if (node2) {
27500
27529
  const hit = node2.value;
@@ -27557,11 +27586,11 @@ const forEachStep = (self2, fn, node2, thisp) => {
27557
27586
  fn.call(thisp, hit.value, hit.key, self2);
27558
27587
  };
27559
27588
  var lruCache = LRUCache$1;
27560
- var range$3;
27589
+ var range$4;
27561
27590
  var hasRequiredRange;
27562
27591
  function requireRange() {
27563
27592
  if (hasRequiredRange)
27564
- return range$3;
27593
+ return range$4;
27565
27594
  hasRequiredRange = 1;
27566
27595
  class Range2 {
27567
27596
  constructor(range2, options) {
@@ -27686,7 +27715,7 @@ function requireRange() {
27686
27715
  return false;
27687
27716
  }
27688
27717
  }
27689
- range$3 = Range2;
27718
+ range$4 = Range2;
27690
27719
  const LRU = lruCache;
27691
27720
  const cache2 = new LRU({ max: 1e3 });
27692
27721
  const parseOptions2 = parseOptions_1;
@@ -27917,7 +27946,7 @@ function requireRange() {
27917
27946
  }
27918
27947
  return true;
27919
27948
  };
27920
- return range$3;
27949
+ return range$4;
27921
27950
  }
27922
27951
  var comparator;
27923
27952
  var hasRequiredComparator;
@@ -28531,6 +28560,7 @@ const DataType$2 = {
28531
28560
  const FileType$1 = {
28532
28561
  // Joint file types
28533
28562
  ANNDATA_ZARR: "anndata.zarr",
28563
+ SPATIALDATA_ZARR: "spatialdata.zarr",
28534
28564
  // Atomic file types
28535
28565
  OBS_EMBEDDING_CSV: "obsEmbedding.csv",
28536
28566
  OBS_SPOTS_CSV: "obsSpots.csv",
@@ -28553,6 +28583,16 @@ const FileType$1 = {
28553
28583
  OBS_SEGMENTATIONS_ANNDATA_ZARR: "obsSegmentations.anndata.zarr",
28554
28584
  OBS_LABELS_ANNDATA_ZARR: "obsLabels.anndata.zarr",
28555
28585
  FEATURE_LABELS_ANNDATA_ZARR: "featureLabels.anndata.zarr",
28586
+ // SpatialData
28587
+ IMAGE_SPATIALDATA_ZARR: "image.spatialdata.zarr",
28588
+ LABELS_SPATIALDATA_ZARR: "labels.spatialdata.zarr",
28589
+ SHAPES_SPATIALDATA_ZARR: "shapes.spatialdata.zarr",
28590
+ OBS_FEATURE_MATRIX_SPATIALDATA_ZARR: "obsFeatureMatrix.spatialdata.zarr",
28591
+ OBS_SETS_SPATIALDATA_ZARR: "obsSets.spatialdata.zarr",
28592
+ OBS_SPOTS_SPATIALDATA_ZARR: "obsSpots.spatialdata.zarr",
28593
+ // TODO:
28594
+ // OBS_POINTS_SPATIALDATA_ZARR: 'obsPoints.spatialdata.zarr',
28595
+ // OBS_LOCATIONS_SPATIALDATA_ZARR: 'obsLocations.spatialdata.zarr',
28556
28596
  // MuData
28557
28597
  OBS_FEATURE_MATRIX_MUDATA_ZARR: "obsFeatureMatrix.mudata.zarr",
28558
28598
  OBS_SETS_MUDATA_ZARR: "obsSets.mudata.zarr",
@@ -28989,9 +29029,30 @@ z.object({
28989
29029
  offsetsUrl: z.string().optional(),
28990
29030
  coordinateTransformations: omeCoordinateTransformations.optional()
28991
29031
  });
28992
- z.object({
29032
+ const imageOmeZarrSchema = z.object({
28993
29033
  coordinateTransformations: omeCoordinateTransformations.optional()
28994
29034
  });
29035
+ imageOmeZarrSchema.extend({
29036
+ path: z.string()
29037
+ });
29038
+ z.object({
29039
+ path: z.string()
29040
+ });
29041
+ z.object({
29042
+ path: z.string()
29043
+ });
29044
+ z.object({
29045
+ path: z.string(),
29046
+ tablePath: z.string().optional().describe("The path to a table which annotates the spots. If available but not specified, the spot identifiers may not be aligned with associated tabular data as expected.")
29047
+ });
29048
+ annDataObsFeatureMatrix.extend({
29049
+ region: z.string().describe("The name of a region to use to filter instances (i.e., rows) in the table").optional()
29050
+ });
29051
+ z.object({
29052
+ region: z.string().describe("The name of a region to use to filter instances (i.e., rows) in the table").optional(),
29053
+ tablePath: z.string().optional().describe("The path to a table which contains the index for the set values."),
29054
+ obsSets: annDataObsSets
29055
+ });
28995
29056
  z.object({
28996
29057
  obsIndex: z.string(),
28997
29058
  obsEmbedding: z.array(z.string()).length(2)
@@ -35403,10 +35464,10 @@ var json2csv_umd = { exports: {} };
35403
35464
  value: function promise() {
35404
35465
  var _this = this;
35405
35466
  var returnCSV = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
35406
- return new Promise(function(resolve, reject) {
35467
+ return new Promise(function(resolve2, reject) {
35407
35468
  if (!returnCSV) {
35408
35469
  _this.processor.on("finish", function() {
35409
- return resolve();
35470
+ return resolve2();
35410
35471
  }).on("error", function(err2) {
35411
35472
  return reject(err2);
35412
35473
  });
@@ -35416,7 +35477,7 @@ var json2csv_umd = { exports: {} };
35416
35477
  _this.processor.on("data", function(chunk) {
35417
35478
  return csvBuffer.push(chunk.toString());
35418
35479
  }).on("finish", function() {
35419
- return resolve(fastJoin$3(csvBuffer, ""));
35480
+ return resolve2(fastJoin$3(csvBuffer, ""));
35420
35481
  }).on("error", function(err2) {
35421
35482
  return reject(err2);
35422
35483
  });
@@ -35549,9 +35610,9 @@ const schemePlasma = [[13, 8, 135], [16, 7, 136], [19, 7, 137], [22, 7, 138], [2
35549
35610
  function rgbSpline(spline) {
35550
35611
  return (colors) => {
35551
35612
  const n3 = colors.length;
35552
- let r2 = new Array(n3);
35553
- let g2 = new Array(n3);
35554
- let b = new Array(n3);
35613
+ const r2 = new Array(n3);
35614
+ const g2 = new Array(n3);
35615
+ const b = new Array(n3);
35555
35616
  let i2;
35556
35617
  let color;
35557
35618
  for (i2 = 0; i2 < n3; ++i2) {
@@ -35560,10 +35621,10 @@ function rgbSpline(spline) {
35560
35621
  g2[i2] = color[1] || 0;
35561
35622
  b[i2] = color[2] || 0;
35562
35623
  }
35563
- r2 = spline(r2);
35564
- g2 = spline(g2);
35565
- b = spline(b);
35566
- return (t2) => [r2(t2), g2(t2), b(t2)];
35624
+ const rFunc = spline(r2);
35625
+ const gFunc = spline(g2);
35626
+ const bFunc = spline(b);
35627
+ return (t2) => [rFunc(t2), gFunc(t2), bFunc(t2)];
35567
35628
  };
35568
35629
  }
35569
35630
  function basis(values) {
@@ -35665,8 +35726,8 @@ class WorkerJob {
35665
35726
  });
35666
35727
  this.name = jobName;
35667
35728
  this.workerThread = workerThread;
35668
- this.result = new Promise((resolve, reject) => {
35669
- this._resolve = resolve;
35729
+ this.result = new Promise((resolve2, reject) => {
35730
+ this._resolve = resolve2;
35670
35731
  this._reject = reject;
35671
35732
  });
35672
35733
  }
@@ -36563,8 +36624,8 @@ class RequestScheduler {
36563
36624
  priority: 0,
36564
36625
  getPriority
36565
36626
  };
36566
- const promise = new Promise((resolve) => {
36567
- request.resolve = resolve;
36627
+ const promise = new Promise((resolve2) => {
36628
+ request.resolve = resolve2;
36568
36629
  return request;
36569
36630
  });
36570
36631
  this.requestQueue.push(request);
@@ -36575,7 +36636,7 @@ class RequestScheduler {
36575
36636
  _issueRequest(request) {
36576
36637
  const {
36577
36638
  handle,
36578
- resolve
36639
+ resolve: resolve2
36579
36640
  } = request;
36580
36641
  let isDone = false;
36581
36642
  const done = () => {
@@ -36587,7 +36648,7 @@ class RequestScheduler {
36587
36648
  }
36588
36649
  };
36589
36650
  this.activeRequestCount++;
36590
- return resolve ? resolve({
36651
+ return resolve2 ? resolve2({
36591
36652
  done
36592
36653
  }) : Promise.resolve({
36593
36654
  done
@@ -36789,11 +36850,11 @@ async function getInitialDataUrl(resource) {
36789
36850
  }
36790
36851
  if (resource instanceof Blob) {
36791
36852
  const blobSlice = resource.slice(0, 5);
36792
- return await new Promise((resolve) => {
36853
+ return await new Promise((resolve2) => {
36793
36854
  const reader = new FileReader();
36794
36855
  reader.onload = (event) => {
36795
36856
  var _event$target;
36796
- return resolve(event === null || event === void 0 ? void 0 : (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result);
36857
+ return resolve2(event === null || event === void 0 ? void 0 : (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.result);
36797
36858
  };
36798
36859
  reader.readAsDataURL(blobSlice);
36799
36860
  });
@@ -38160,9 +38221,9 @@ async function loadToImage(url, options) {
38160
38221
  await image2.decode();
38161
38222
  return image2;
38162
38223
  }
38163
- return await new Promise((resolve, reject) => {
38224
+ return await new Promise((resolve2, reject) => {
38164
38225
  try {
38165
- image2.onload = () => resolve(image2);
38226
+ image2.onload = () => resolve2(image2);
38166
38227
  image2.onerror = (err2) => reject(new Error("Could not load image ".concat(url, ": ").concat(err2)));
38167
38228
  } catch (error2) {
38168
38229
  reject(error2);
@@ -39534,7 +39595,7 @@ function installGetterOverride(gl, functionName) {
39534
39595
  configurable: false
39535
39596
  });
39536
39597
  }
39537
- function installSetterSpy(gl, functionName, setter) {
39598
+ function installSetterSpy(gl, functionName, setter2) {
39538
39599
  const originalSetterFunc = gl[functionName].bind(gl);
39539
39600
  gl[functionName] = function set() {
39540
39601
  for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -39543,7 +39604,7 @@ function installSetterSpy(gl, functionName, setter) {
39543
39604
  const {
39544
39605
  valueChanged,
39545
39606
  oldValue
39546
- } = setter(gl.state._updateCache, ...params);
39607
+ } = setter2(gl.state._updateCache, ...params);
39547
39608
  if (valueChanged) {
39548
39609
  originalSetterFunc(...params);
39549
39610
  }
@@ -39630,8 +39691,8 @@ function trackContextState(gl) {
39630
39691
  });
39631
39692
  installProgramSpy(gl);
39632
39693
  for (const key in GL_HOOKED_SETTERS) {
39633
- const setter = GL_HOOKED_SETTERS[key];
39634
- installSetterSpy(gl, key, setter);
39694
+ const setter2 = GL_HOOKED_SETTERS[key];
39695
+ installSetterSpy(gl, key, setter2);
39635
39696
  }
39636
39697
  installGetterOverride(gl, "getParameter");
39637
39698
  installGetterOverride(gl, "isEnabled");
@@ -39659,12 +39720,12 @@ function setParameters(gl, values) {
39659
39720
  const compositeSetters = {};
39660
39721
  for (const key in values) {
39661
39722
  const glConstant = Number(key);
39662
- const setter = GL_PARAMETER_SETTERS[key];
39663
- if (setter) {
39664
- if (typeof setter === "string") {
39665
- compositeSetters[setter] = true;
39723
+ const setter2 = GL_PARAMETER_SETTERS[key];
39724
+ if (setter2) {
39725
+ if (typeof setter2 === "string") {
39726
+ compositeSetters[setter2] = true;
39666
39727
  } else {
39667
- setter(gl, values[key], glConstant);
39728
+ setter2(gl, values[key], glConstant);
39668
39729
  }
39669
39730
  }
39670
39731
  }
@@ -41468,10 +41529,10 @@ let pathPrefix = "";
41468
41529
  function loadImage$1(url, opts2) {
41469
41530
  assert$7(typeof url === "string");
41470
41531
  url = pathPrefix + url;
41471
- return new Promise((resolve, reject) => {
41532
+ return new Promise((resolve2, reject) => {
41472
41533
  try {
41473
41534
  const image2 = new Image();
41474
- image2.onload = () => resolve(image2);
41535
+ image2.onload = () => resolve2(image2);
41475
41536
  image2.onerror = () => reject(new Error("Could not load image ".concat(url, ".")));
41476
41537
  image2.crossOrigin = opts2 && opts2.crossOrigin || "anonymous";
41477
41538
  image2.src = url;
@@ -43249,11 +43310,11 @@ function toUIntArray(value, uniformLength) {
43249
43310
  return toTypedArray$1(value, uniformLength, Uint32Array, UINT_ARRAY);
43250
43311
  }
43251
43312
  function getUniformSetter(gl, location, info) {
43252
- const setter = UNIFORM_SETTERS[info.type];
43253
- if (!setter) {
43313
+ const setter2 = UNIFORM_SETTERS[info.type];
43314
+ if (!setter2) {
43254
43315
  throw new Error("Unknown GLSL uniform type ".concat(info.type));
43255
43316
  }
43256
- return setter().bind(null, gl, location);
43317
+ return setter2().bind(null, gl, location);
43257
43318
  }
43258
43319
  function parseUniformName(name2) {
43259
43320
  if (name2[name2.length - 1] !== "]") {
@@ -43979,10 +44040,10 @@ class Query extends Resource$1 {
43979
44040
  return this._pollingPromise;
43980
44041
  }
43981
44042
  let counter2 = 0;
43982
- this._pollingPromise = new Promise((resolve, reject) => {
44043
+ this._pollingPromise = new Promise((resolve2, reject) => {
43983
44044
  const poll = () => {
43984
44045
  if (this.isResultAvailable()) {
43985
- resolve(this.getResult());
44046
+ resolve2(this.getResult());
43986
44047
  this._pollingPromise = null;
43987
44048
  } else if (counter2++ > limit) {
43988
44049
  reject("Timed out");
@@ -45176,8 +45237,8 @@ class AnimationLoop {
45176
45237
  waitForRender() {
45177
45238
  this.setNeedsRedraw("waitForRender");
45178
45239
  if (!this._nextFramePromise) {
45179
- this._nextFramePromise = new Promise((resolve) => {
45180
- this._resolveNextFrame = resolve;
45240
+ this._nextFramePromise = new Promise((resolve2) => {
45241
+ this._resolveNextFrame = resolve2;
45181
45242
  });
45182
45243
  }
45183
45244
  return this._nextFramePromise;
@@ -45224,13 +45285,13 @@ class AnimationLoop {
45224
45285
  }
45225
45286
  _getPageLoadPromise() {
45226
45287
  if (!this._pageLoadPromise) {
45227
- this._pageLoadPromise = isPage ? new Promise((resolve, reject) => {
45288
+ this._pageLoadPromise = isPage ? new Promise((resolve2, reject) => {
45228
45289
  if (isPage && document.readyState === "complete") {
45229
- resolve(document);
45290
+ resolve2(document);
45230
45291
  return;
45231
45292
  }
45232
45293
  window.addEventListener("load", () => {
45233
- resolve(document);
45294
+ resolve2(document);
45234
45295
  });
45235
45296
  }) : Promise.resolve({});
45236
45297
  }
@@ -74590,7 +74651,7 @@ var libh3 = function(libh32) {
74590
74651
  b[h >> 2] = 0;
74591
74652
  h = h + 4 | 0;
74592
74653
  } while ((h | 0) < (j | 0));
74593
- _b(c, g3);
74654
+ _b2(c, g3);
74594
74655
  h = g3;
74595
74656
  j = b[h >> 2] | 0;
74596
74657
  h = b[h + 4 >> 2] | 0;
@@ -74624,7 +74685,7 @@ var libh3 = function(libh32) {
74624
74685
  b[h >> 2] = 0;
74625
74686
  h = h + 4 | 0;
74626
74687
  } while ((h | 0) < (j | 0));
74627
- _b(d, g3);
74688
+ _b2(d, g3);
74628
74689
  j = g3;
74629
74690
  h = b[j >> 2] | 0;
74630
74691
  j = b[j + 4 >> 2] | 0;
@@ -75766,7 +75827,7 @@ var libh3 = function(libh32) {
75766
75827
  S = k;
75767
75828
  return;
75768
75829
  }
75769
- function _a2(a3, c, d, f2, g3) {
75830
+ function _a3(a3, c, d, f2, g3) {
75770
75831
  a3 = a3 | 0;
75771
75832
  c = c | 0;
75772
75833
  d = d | 0;
@@ -75812,7 +75873,7 @@ var libh3 = function(libh32) {
75812
75873
  S = S + 16 | 0;
75813
75874
  f2 = e3;
75814
75875
  Da(a3 + 4 | 0, f2);
75815
- _a2(f2, b[a3 >> 2] | 0, c, 0, d);
75876
+ _a3(f2, b[a3 >> 2] | 0, c, 0, d);
75816
75877
  S = e3;
75817
75878
  return;
75818
75879
  }
@@ -75925,12 +75986,12 @@ var libh3 = function(libh32) {
75925
75986
  }
75926
75987
  }
75927
75988
  Gc(w3, y3, f2, a3, C3);
75928
- _a2(C3, b[v2 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
75989
+ _a3(C3, b[v2 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
75929
75990
  b[g3 >> 2] = (b[g3 >> 2] | 0) + 1;
75930
75991
  }
75931
75992
  if ((j | 0) < (n3 | 0)) {
75932
75993
  Da(t3, v2);
75933
- _a2(v2, b[F2 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
75994
+ _a3(v2, b[F2 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
75934
75995
  b[g3 >> 2] = (b[g3 >> 2] | 0) + 1;
75935
75996
  }
75936
75997
  b[E2 >> 2] = b[F2 >> 2];
@@ -76191,13 +76252,13 @@ var libh3 = function(libh32) {
76191
76252
  }
76192
76253
  Gc(A3, s3, f2, a3, w3);
76193
76254
  if (!(Hc(A3, w3) | 0) ? !(Hc(s3, w3) | 0) : 0) {
76194
- _a2(w3, b[x3 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
76255
+ _a3(w3, b[x3 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
76195
76256
  b[g3 >> 2] = (b[g3 >> 2] | 0) + 1;
76196
76257
  }
76197
76258
  }
76198
76259
  if ((j | 0) < (l2 | 0)) {
76199
76260
  Da(q2, A3);
76200
- _a2(A3, b[z3 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
76261
+ _a3(A3, b[z3 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
76201
76262
  b[g3 >> 2] = (b[g3 >> 2] | 0) + 1;
76202
76263
  }
76203
76264
  j = j + 1 | 0;
@@ -78548,7 +78609,7 @@ var libh3 = function(libh32) {
78548
78609
  function Zb() {
78549
78610
  return 12;
78550
78611
  }
78551
- function _b(a3, c) {
78612
+ function _b2(a3, c) {
78552
78613
  a3 = a3 | 0;
78553
78614
  c = c | 0;
78554
78615
  var d = 0, e3 = 0, f2 = 0, g3 = 0, h = 0, i2 = 0, j = 0;
@@ -83016,7 +83077,7 @@ var libh3 = function(libh32) {
83016
83077
  _getH3UnidirectionalEdgeBoundary: gc,
83017
83078
  _getH3UnidirectionalEdgesFromHexagon: fc,
83018
83079
  _getOriginH3IndexFromUnidirectionalEdge: bc,
83019
- _getPentagonIndexes: _b,
83080
+ _getPentagonIndexes: _b2,
83020
83081
  _getRes0Indexes: va,
83021
83082
  _h3Distance: qc,
83022
83083
  _h3GetBaseCell: Ab,
@@ -85569,14 +85630,14 @@ function initializeBasisTrascoderModule(BasisModule, wasmBinary) {
85569
85630
  if (wasmBinary) {
85570
85631
  options.wasmBinary = wasmBinary;
85571
85632
  }
85572
- return new Promise((resolve) => {
85633
+ return new Promise((resolve2) => {
85573
85634
  BasisModule(options).then((module2) => {
85574
85635
  const {
85575
85636
  BasisFile,
85576
85637
  initializeBasis
85577
85638
  } = module2;
85578
85639
  initializeBasis();
85579
- resolve({
85640
+ resolve2({
85580
85641
  BasisFile
85581
85642
  });
85582
85643
  });
@@ -85603,7 +85664,7 @@ function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
85603
85664
  if (wasmBinary) {
85604
85665
  options.wasmBinary = wasmBinary;
85605
85666
  }
85606
- return new Promise((resolve) => {
85667
+ return new Promise((resolve2) => {
85607
85668
  BasisEncoderModule(options).then((module2) => {
85608
85669
  const {
85609
85670
  BasisFile,
@@ -85612,7 +85673,7 @@ function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
85612
85673
  BasisEncoder
85613
85674
  } = module2;
85614
85675
  initializeBasis();
85615
- resolve({
85676
+ resolve2({
85616
85677
  BasisFile,
85617
85678
  KTX2File,
85618
85679
  BasisEncoder
@@ -87466,10 +87527,10 @@ function initializeDracoDecoder(DracoDecoderModule, wasmBinary) {
87466
87527
  if (wasmBinary) {
87467
87528
  options.wasmBinary = wasmBinary;
87468
87529
  }
87469
- return new Promise((resolve) => {
87530
+ return new Promise((resolve2) => {
87470
87531
  DracoDecoderModule({
87471
87532
  ...options,
87472
- onModuleLoaded: (draco) => resolve({
87533
+ onModuleLoaded: (draco) => resolve2({
87473
87534
  draco
87474
87535
  })
87475
87536
  });
@@ -88683,7 +88744,7 @@ async function waitForGLTFAssets(gltfObjects) {
88683
88744
  }
88684
88745
  async function waitWhileCondition(condition) {
88685
88746
  while (condition()) {
88686
- await new Promise((resolve) => requestAnimationFrame(resolve));
88747
+ await new Promise((resolve2) => requestAnimationFrame(resolve2));
88687
88748
  }
88688
88749
  }
88689
88750
  const vs$6 = "#version 300 es\n\n// Instance attributes\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin mat3 instanceModelMatrix;\nin vec3 instanceTranslation;\n\n// Uniforms\nuniform float sizeScale;\nuniform float sizeMinPixels;\nuniform float sizeMaxPixels;\nuniform mat4 sceneModelMatrix;\nuniform bool composeModelMatrix;\n\n// Attributes\nin vec4 POSITION;\n\n#ifdef HAS_UV\n in vec2 TEXCOORD_0;\n#endif\n\n#ifdef MODULE_PBR\n #ifdef HAS_NORMALS\n in vec4 NORMAL;\n #endif\n#endif\n\n// Varying\nout vec4 vColor;\n\n// MODULE_PBR contains all the varying definitions needed\n#ifndef MODULE_PBR\n #ifdef HAS_UV\n out vec2 vTEXCOORD_0;\n #endif\n#endif\n\n// Main\nvoid main(void) {\n #if defined(HAS_UV) && !defined(MODULE_PBR)\n vTEXCOORD_0 = TEXCOORD_0;\n geometry.uv = vTEXCOORD_0;\n #endif\n\n geometry.worldPosition = instancePositions;\n geometry.pickingColor = instancePickingColors;\n\n vec3 normal = vec3(0.0, 0.0, 1.0);\n #ifdef MODULE_PBR\n #ifdef HAS_NORMALS\n normal = instanceModelMatrix * (sceneModelMatrix * vec4(NORMAL.xyz, 0.0)).xyz;\n #endif\n #endif\n\n float originalSize = project_size_to_pixel(sizeScale);\n float clampedSize = clamp(originalSize, sizeMinPixels, sizeMaxPixels);\n\n vec3 pos = (instanceModelMatrix * (sceneModelMatrix * POSITION).xyz) * sizeScale * (clampedSize / originalSize) + instanceTranslation;\n if(composeModelMatrix) {\n DECKGL_FILTER_SIZE(pos, geometry);\n // using instancePositions as world coordinates\n // when using globe mode, this branch does not re-orient the model to align with the surface of the earth\n // call project_normal before setting position to avoid rotation\n geometry.normal = project_normal(normal);\n gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\n }\n else {\n pos = project_size(pos);\n DECKGL_FILTER_SIZE(pos, geometry);\n gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position);\n geometry.normal = project_normal(normal);\n }\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n #ifdef MODULE_PBR\n // set PBR data\n pbr_vPosition = geometry.position.xyz;\n #ifdef HAS_NORMALS\n pbr_vNormal = geometry.normal;\n #endif\n\n #ifdef HAS_UV\n pbr_vUV = TEXCOORD_0;\n #else\n pbr_vUV = vec2(0., 0.);\n #endif\n geometry.uv = pbr_vUV;\n #endif\n\n vColor = instanceColors;\n DECKGL_FILTER_COLOR(vColor, geometry);\n}\n";
@@ -91108,12 +91169,12 @@ class Tileset3D {
91108
91169
  this.lastUpdatedVieports = viewports;
91109
91170
  }
91110
91171
  if (!this.updatePromise) {
91111
- this.updatePromise = new Promise((resolve) => {
91172
+ this.updatePromise = new Promise((resolve2) => {
91112
91173
  setTimeout(() => {
91113
91174
  if (this.lastUpdatedVieports) {
91114
91175
  this.doUpdate(this.lastUpdatedVieports);
91115
91176
  }
91116
- resolve(this._frameNumber);
91177
+ resolve2(this._frameNumber);
91117
91178
  this.updatePromise = null;
91118
91179
  }, this.options.debounceTime);
91119
91180
  });
@@ -97320,8 +97381,8 @@ function collectionOf$1(featureCollection2, type, name2) {
97320
97381
  if (!featureCollection2 || featureCollection2.type !== "FeatureCollection") {
97321
97382
  throw new Error("Invalid input to " + name2 + ", FeatureCollection required");
97322
97383
  }
97323
- for (var _i = 0, _a2 = featureCollection2.features; _i < _a2.length; _i++) {
97324
- var feature2 = _a2[_i];
97384
+ for (var _i = 0, _a3 = featureCollection2.features; _i < _a3.length; _i++) {
97385
+ var feature2 = _a3[_i];
97325
97386
  if (!feature2 || feature2.type !== "Feature" || !feature2.geometry) {
97326
97387
  throw new Error("Invalid input to " + name2 + ", Feature with geometry required");
97327
97388
  }
@@ -97720,11 +97781,11 @@ function isPointInMultiPoint(multiPoint2, pt) {
97720
97781
  return output;
97721
97782
  }
97722
97783
  function isMultiPointInMultiPoint(multiPoint1, multiPoint2) {
97723
- for (var _i = 0, _a2 = multiPoint2.coordinates; _i < _a2.length; _i++) {
97724
- var coord2 = _a2[_i];
97784
+ for (var _i = 0, _a3 = multiPoint2.coordinates; _i < _a3.length; _i++) {
97785
+ var coord2 = _a3[_i];
97725
97786
  var matchFound = false;
97726
- for (var _b = 0, _c = multiPoint1.coordinates; _b < _c.length; _b++) {
97727
- var coord1 = _c[_b];
97787
+ for (var _b2 = 0, _c = multiPoint1.coordinates; _b2 < _c.length; _b2++) {
97788
+ var coord1 = _c[_b2];
97728
97789
  if (compareCoords(coord2, coord1)) {
97729
97790
  matchFound = true;
97730
97791
  break;
@@ -97738,8 +97799,8 @@ function isMultiPointInMultiPoint(multiPoint1, multiPoint2) {
97738
97799
  }
97739
97800
  function isMultiPointOnLine(lineString2, multiPoint2) {
97740
97801
  var haveFoundInteriorPoint = false;
97741
- for (var _i = 0, _a2 = multiPoint2.coordinates; _i < _a2.length; _i++) {
97742
- var coord = _a2[_i];
97802
+ for (var _i = 0, _a3 = multiPoint2.coordinates; _i < _a3.length; _i++) {
97803
+ var coord = _a3[_i];
97743
97804
  if (booleanPointOnLine(coord, lineString2, { ignoreEndVertices: true })) {
97744
97805
  haveFoundInteriorPoint = true;
97745
97806
  }
@@ -97753,8 +97814,8 @@ function isMultiPointOnLine(lineString2, multiPoint2) {
97753
97814
  return false;
97754
97815
  }
97755
97816
  function isMultiPointInPoly(polygon2, multiPoint2) {
97756
- for (var _i = 0, _a2 = multiPoint2.coordinates; _i < _a2.length; _i++) {
97757
- var coord = _a2[_i];
97817
+ for (var _i = 0, _a3 = multiPoint2.coordinates; _i < _a3.length; _i++) {
97818
+ var coord = _a3[_i];
97758
97819
  if (!booleanPointInPolygon$1(coord, polygon2, { ignoreBoundary: true })) {
97759
97820
  return false;
97760
97821
  }
@@ -97763,8 +97824,8 @@ function isMultiPointInPoly(polygon2, multiPoint2) {
97763
97824
  }
97764
97825
  function isLineOnLine(lineString1, lineString2) {
97765
97826
  var haveFoundInteriorPoint = false;
97766
- for (var _i = 0, _a2 = lineString2.coordinates; _i < _a2.length; _i++) {
97767
- var coords = _a2[_i];
97827
+ for (var _i = 0, _a3 = lineString2.coordinates; _i < _a3.length; _i++) {
97828
+ var coords = _a3[_i];
97768
97829
  if (booleanPointOnLine({ type: "Point", coordinates: coords }, lineString1, {
97769
97830
  ignoreEndVertices: true
97770
97831
  })) {
@@ -97812,8 +97873,8 @@ function isPolyInPoly(feature1, feature2) {
97812
97873
  var coords = getGeom$1(feature2).coordinates;
97813
97874
  for (var _i = 0, coords_1 = coords; _i < coords_1.length; _i++) {
97814
97875
  var ring = coords_1[_i];
97815
- for (var _a2 = 0, ring_1 = ring; _a2 < ring_1.length; _a2++) {
97816
- var coord = ring_1[_a2];
97876
+ for (var _a3 = 0, ring_1 = ring; _a3 < ring_1.length; _a3++) {
97877
+ var coord = ring_1[_a3];
97817
97878
  if (!booleanPointInPolygon$1(coord, feature1)) {
97818
97879
  return false;
97819
97880
  }
@@ -99057,8 +99118,8 @@ function collectionOf(featureCollection2, type, name2) {
99057
99118
  if (!featureCollection2 || featureCollection2.type !== "FeatureCollection") {
99058
99119
  throw new Error("Invalid input to " + name2 + ", FeatureCollection required");
99059
99120
  }
99060
- for (var _i = 0, _a2 = featureCollection2.features; _i < _a2.length; _i++) {
99061
- var feature2 = _a2[_i];
99121
+ for (var _i = 0, _a3 = featureCollection2.features; _i < _a3.length; _i++) {
99122
+ var feature2 = _a3[_i];
99062
99123
  if (!feature2 || feature2.type !== "Feature" || !feature2.geometry) {
99063
99124
  throw new Error("Invalid input to " + name2 + ", Feature with geometry required");
99064
99125
  }
@@ -99401,7 +99462,7 @@ function requireImplementation() {
99401
99462
  implementation$8 = keysShim2;
99402
99463
  return implementation$8;
99403
99464
  }
99404
- var slice$1 = Array.prototype.slice;
99465
+ var slice$3 = Array.prototype.slice;
99405
99466
  var isArgs = isArguments$2;
99406
99467
  var origKeys = Object.keys;
99407
99468
  var keysShim = origKeys ? function keys(o2) {
@@ -99417,7 +99478,7 @@ keysShim.shim = function shimObjectKeys() {
99417
99478
  if (!keysWorksWithArguments) {
99418
99479
  Object.keys = function keys3(object2) {
99419
99480
  if (isArgs(object2)) {
99420
- return originalKeys(slice$1.call(object2));
99481
+ return originalKeys(slice$3.call(object2));
99421
99482
  }
99422
99483
  return originalKeys(object2);
99423
99484
  };
@@ -99502,7 +99563,7 @@ var hasProto$1 = function hasProto() {
99502
99563
  return { __proto__: test }.foo === test.foo && !({ __proto__: null } instanceof $Object);
99503
99564
  };
99504
99565
  var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
99505
- var slice = Array.prototype.slice;
99566
+ var slice$2 = Array.prototype.slice;
99506
99567
  var toStr$2 = Object.prototype.toString;
99507
99568
  var funcType = "[object Function]";
99508
99569
  var implementation$7 = function bind2(that) {
@@ -99510,13 +99571,13 @@ var implementation$7 = function bind2(that) {
99510
99571
  if (typeof target !== "function" || toStr$2.call(target) !== funcType) {
99511
99572
  throw new TypeError(ERROR_MESSAGE + target);
99512
99573
  }
99513
- var args = slice.call(arguments, 1);
99574
+ var args = slice$2.call(arguments, 1);
99514
99575
  var bound;
99515
99576
  var binder = function() {
99516
99577
  if (this instanceof bound) {
99517
99578
  var result = target.apply(
99518
99579
  this,
99519
- args.concat(slice.call(arguments))
99580
+ args.concat(slice$2.call(arguments))
99520
99581
  );
99521
99582
  if (Object(result) === result) {
99522
99583
  return result;
@@ -99525,7 +99586,7 @@ var implementation$7 = function bind2(that) {
99525
99586
  } else {
99526
99587
  return target.apply(
99527
99588
  that,
99528
- args.concat(slice.call(arguments))
99589
+ args.concat(slice$2.call(arguments))
99529
99590
  );
99530
99591
  }
99531
99592
  };
@@ -110929,7 +110990,7 @@ function cartesianNormalizeInPlace(d) {
110929
110990
  var l2 = sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
110930
110991
  d[0] /= l2, d[1] /= l2, d[2] /= l2;
110931
110992
  }
110932
- var lambda0$1, phi0, lambda1, phi1, lambda2, lambda00$1, phi00$1, p0, deltaSum = adder(), ranges, range$2;
110993
+ var lambda0$1, phi0, lambda1, phi1, lambda2, lambda00$1, phi00$1, p0, deltaSum = adder(), ranges, range$3;
110933
110994
  var boundsStream$1 = {
110934
110995
  point: boundsPoint$1,
110935
110996
  lineStart: boundsLineStart,
@@ -110952,11 +111013,11 @@ var boundsStream$1 = {
110952
111013
  phi1 = 90;
110953
111014
  else if (deltaSum < -epsilon)
110954
111015
  phi0 = -90;
110955
- range$2[0] = lambda0$1, range$2[1] = lambda1;
111016
+ range$3[0] = lambda0$1, range$3[1] = lambda1;
110956
111017
  }
110957
111018
  };
110958
111019
  function boundsPoint$1(lambda, phi) {
110959
- ranges.push(range$2 = [lambda0$1 = lambda, lambda1 = lambda]);
111020
+ ranges.push(range$3 = [lambda0$1 = lambda, lambda1 = lambda]);
110960
111021
  if (phi < phi0)
110961
111022
  phi0 = phi;
110962
111023
  if (phi > phi1)
@@ -111008,7 +111069,7 @@ function linePoint(lambda, phi) {
111008
111069
  }
111009
111070
  }
111010
111071
  } else {
111011
- ranges.push(range$2 = [lambda0$1 = lambda, lambda1 = lambda]);
111072
+ ranges.push(range$3 = [lambda0$1 = lambda, lambda1 = lambda]);
111012
111073
  }
111013
111074
  if (phi < phi0)
111014
111075
  phi0 = phi;
@@ -111020,7 +111081,7 @@ function boundsLineStart() {
111020
111081
  boundsStream$1.point = linePoint;
111021
111082
  }
111022
111083
  function boundsLineEnd() {
111023
- range$2[0] = lambda0$1, range$2[1] = lambda1;
111084
+ range$3[0] = lambda0$1, range$3[1] = lambda1;
111024
111085
  boundsStream$1.point = boundsPoint$1;
111025
111086
  p0 = null;
111026
111087
  }
@@ -111042,7 +111103,7 @@ function boundsRingEnd() {
111042
111103
  areaStream$1.lineEnd();
111043
111104
  if (abs(deltaSum) > epsilon)
111044
111105
  lambda0$1 = -(lambda1 = 180);
111045
- range$2[0] = lambda0$1, range$2[1] = lambda1;
111106
+ range$3[0] = lambda0$1, range$3[1] = lambda1;
111046
111107
  p0 = null;
111047
111108
  }
111048
111109
  function angle(lambda02, lambda12) {
@@ -111078,7 +111139,7 @@ function bounds(feature2) {
111078
111139
  deltaMax = delta, lambda0$1 = b[0], lambda1 = a2[1];
111079
111140
  }
111080
111141
  }
111081
- ranges = range$2 = null;
111142
+ ranges = range$3 = null;
111082
111143
  return lambda0$1 === Infinity || phi0 === Infinity ? [[NaN, NaN], [NaN, NaN]] : [[lambda0$1, phi0], [lambda1, phi1]];
111083
111144
  }
111084
111145
  var W0, W1, X0$1, Y0$1, Z0$1, X1$1, Y1$1, Z1$1, X2$1, Y2$1, Z2$1, lambda00, phi00, x0$4, y0$4, z0;
@@ -111503,7 +111564,7 @@ function ascendingComparator(f2) {
111503
111564
  };
111504
111565
  }
111505
111566
  bisector(ascending);
111506
- function range$1(start, stop, step) {
111567
+ function range$2(start, stop, step) {
111507
111568
  start = +start, stop = +stop, step = (n3 = arguments.length) < 2 ? (stop = start, start = 0, 1) : n3 < 3 ? 1 : +step;
111508
111569
  var i2 = -1, n3 = Math.max(0, Math.ceil((stop - start) / step)) | 0, range2 = new Array(n3);
111509
111570
  while (++i2 < n3) {
@@ -111806,7 +111867,7 @@ function contains(object2, point2) {
111806
111867
  return (object2 && containsObjectType.hasOwnProperty(object2.type) ? containsObjectType[object2.type] : containsGeometry)(object2, point2);
111807
111868
  }
111808
111869
  function graticuleX(y02, y12, dy) {
111809
- var y2 = range$1(y02, y12 - epsilon, dy).concat(y12);
111870
+ var y2 = range$2(y02, y12 - epsilon, dy).concat(y12);
111810
111871
  return function(x2) {
111811
111872
  return y2.map(function(y22) {
111812
111873
  return [x2, y22];
@@ -111814,7 +111875,7 @@ function graticuleX(y02, y12, dy) {
111814
111875
  };
111815
111876
  }
111816
111877
  function graticuleY(x02, x12, dx) {
111817
- var x2 = range$1(x02, x12 - epsilon, dx).concat(x12);
111878
+ var x2 = range$2(x02, x12 - epsilon, dx).concat(x12);
111818
111879
  return function(y2) {
111819
111880
  return x2.map(function(x22) {
111820
111881
  return [x22, y2];
@@ -111827,9 +111888,9 @@ function graticule() {
111827
111888
  return { type: "MultiLineString", coordinates: lines() };
111828
111889
  }
111829
111890
  function lines() {
111830
- return range$1(ceil(X02 / DX) * DX, X12, DX).map(X).concat(range$1(ceil(Y02 / DY) * DY, Y12, DY).map(Y)).concat(range$1(ceil(x02 / dx) * dx, x12, dx).filter(function(x22) {
111891
+ return range$2(ceil(X02 / DX) * DX, X12, DX).map(X).concat(range$2(ceil(Y02 / DY) * DY, Y12, DY).map(Y)).concat(range$2(ceil(x02 / dx) * dx, x12, dx).filter(function(x22) {
111831
111892
  return abs(x22 % DX) > epsilon;
111832
- }).map(x2)).concat(range$1(ceil(y02 / dy) * dy, y12, dy).filter(function(y22) {
111893
+ }).map(x2)).concat(range$2(ceil(y02 / dy) * dy, y12, dy).filter(function(y22) {
111833
111894
  return abs(y22 % DY) > epsilon;
111834
111895
  }).map(y2));
111835
111896
  }
@@ -113516,16 +113577,16 @@ var polygonClipping_umd = { exports: {} };
113516
113577
  };
113517
113578
  Tree2.prototype.keys = function() {
113518
113579
  var keys3 = [];
113519
- this.forEach(function(_a2) {
113520
- var key = _a2.key;
113580
+ this.forEach(function(_a3) {
113581
+ var key = _a3.key;
113521
113582
  return keys3.push(key);
113522
113583
  });
113523
113584
  return keys3;
113524
113585
  };
113525
113586
  Tree2.prototype.values = function() {
113526
113587
  var values = [];
113527
- this.forEach(function(_a2) {
113528
- var data = _a2.data;
113588
+ this.forEach(function(_a3) {
113589
+ var data = _a3.data;
113529
113590
  return values.push(data);
113530
113591
  });
113531
113592
  return values;
@@ -113691,7 +113752,7 @@ var polygonClipping_umd = { exports: {} };
113691
113752
  };
113692
113753
  Tree2.prototype.update = function(key, newKey, newData) {
113693
113754
  var comparator2 = this._comparator;
113694
- var _a2 = split(key, this._root, comparator2), left = _a2.left, right = _a2.right;
113755
+ var _a3 = split(key, this._root, comparator2), left = _a3.left, right = _a3.right;
113695
113756
  if (comparator2(key, newKey) < 0) {
113696
113757
  right = insert2(newKey, newData, right, comparator2);
113697
113758
  } else {
@@ -116068,7 +116129,7 @@ EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
116068
116129
  }
116069
116130
  return this;
116070
116131
  };
116071
- function _listeners(target, type, unwrap) {
116132
+ function _listeners(target, type, unwrap2) {
116072
116133
  var events2 = target._events;
116073
116134
  if (events2 === void 0)
116074
116135
  return [];
@@ -116076,8 +116137,8 @@ function _listeners(target, type, unwrap) {
116076
116137
  if (evlistener === void 0)
116077
116138
  return [];
116078
116139
  if (typeof evlistener === "function")
116079
- return unwrap ? [evlistener.listener || evlistener] : [evlistener];
116080
- return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
116140
+ return unwrap2 ? [evlistener.listener || evlistener] : [evlistener];
116141
+ return unwrap2 ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
116081
116142
  }
116082
116143
  EventEmitter.prototype.listeners = function listeners(type) {
116083
116144
  return _listeners(this, type, true);
@@ -116127,7 +116188,7 @@ function unwrapListeners(arr) {
116127
116188
  return ret;
116128
116189
  }
116129
116190
  function once2(emitter, name2) {
116130
- return new Promise(function(resolve, reject) {
116191
+ return new Promise(function(resolve2, reject) {
116131
116192
  function errorListener(err2) {
116132
116193
  emitter.removeListener(name2, resolver);
116133
116194
  reject(err2);
@@ -116136,7 +116197,7 @@ function once2(emitter, name2) {
116136
116197
  if (typeof emitter.removeListener === "function") {
116137
116198
  emitter.removeListener("error", errorListener);
116138
116199
  }
116139
- resolve([].slice.call(arguments));
116200
+ resolve2([].slice.call(arguments));
116140
116201
  }
116141
116202
  eventTargetAgnosticAddListener(emitter, name2, resolver, { once: true });
116142
116203
  if (name2 !== "error") {
@@ -117487,9 +117548,9 @@ function getEditHandlesForGeometry(geometry2, featureIndex) {
117487
117548
  }
117488
117549
  break;
117489
117550
  case "MultiPolygon":
117490
- for (var _a2 = 0; _a2 < geometry2.coordinates.length; _a2++) {
117491
- for (var b = 0; b < geometry2.coordinates[_a2].length; b++) {
117492
- handles = handles.concat(getEditHandlesForCoordinates(geometry2.coordinates[_a2][b], [_a2, b], featureIndex, editHandleType));
117551
+ for (var _a3 = 0; _a3 < geometry2.coordinates.length; _a3++) {
117552
+ for (var b = 0; b < geometry2.coordinates[_a3].length; b++) {
117553
+ handles = handles.concat(getEditHandlesForCoordinates(geometry2.coordinates[_a3][b], [_a3, b], featureIndex, editHandleType));
117493
117554
  handles = handles.slice(0, -1);
117494
117555
  }
117495
117556
  }
@@ -121324,9 +121385,9 @@ var ExtrudeMode = /* @__PURE__ */ function(_ModifyMode) {
121324
121385
  size2 = coordinates2[a2][b].length;
121325
121386
  }
121326
121387
  } else {
121327
- var _positionIndexes2 = _slicedToArray$3(positionIndexes, 1), _b = _positionIndexes2[0];
121328
- if (coordinates2.length && coordinates2[_b].length) {
121329
- size2 = coordinates2[_b].length;
121388
+ var _positionIndexes2 = _slicedToArray$3(positionIndexes, 1), _b2 = _positionIndexes2[0];
121389
+ if (coordinates2.length && coordinates2[_b2].length) {
121390
+ size2 = coordinates2[_b2].length;
121330
121391
  }
121331
121392
  }
121332
121393
  }
@@ -124739,12 +124800,12 @@ var reIsOctal = /^0o[0-7]+$/i;
124739
124800
  var freeParseInt = parseInt;
124740
124801
  var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
124741
124802
  var freeSelf = typeof self == "object" && self && self.Object === Object && self;
124742
- var root = freeGlobal || freeSelf || Function("return this")();
124803
+ var root$1 = freeGlobal || freeSelf || Function("return this")();
124743
124804
  var objectProto = Object.prototype;
124744
124805
  var objectToString = objectProto.toString;
124745
124806
  var nativeMax = Math.max, nativeMin = Math.min;
124746
124807
  var now = function() {
124747
- return root.Date.now();
124808
+ return root$1.Date.now();
124748
124809
  };
124749
124810
  function debounce(func, wait, options) {
124750
124811
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
@@ -132846,13 +132907,13 @@ class HeatmapBitmapLayer extends BitmapLayer$1 {
132846
132907
  });
132847
132908
  }
132848
132909
  updateState(args) {
132849
- var _a2;
132910
+ var _a3;
132850
132911
  super.updateState(args);
132851
132912
  this.loadTexture(this.props.image);
132852
132913
  const { props: props2, oldProps } = args;
132853
132914
  if (props2.colormap !== oldProps.colormap) {
132854
132915
  const { gl } = this.context;
132855
- (_a2 = this.state.model) == null ? void 0 : _a2.delete();
132916
+ (_a3 = this.state.model) == null ? void 0 : _a3.delete();
132856
132917
  this.state.model = this._getModel(gl);
132857
132918
  this.getAttributeManager().invalidateAll();
132858
132919
  }
@@ -133222,12 +133283,12 @@ class PaddedExpressionHeatmapBitmapLayer extends BitmapLayer$1 {
133222
133283
  });
133223
133284
  }
133224
133285
  updateState(args) {
133225
- var _a2;
133286
+ var _a3;
133226
133287
  super.updateState(args);
133227
133288
  const { props: props2, oldProps } = args;
133228
133289
  if (props2.colormap !== oldProps.colormap) {
133229
133290
  const { gl } = this.context;
133230
- (_a2 = this.state.model) == null ? void 0 : _a2.delete();
133291
+ (_a3 = this.state.model) == null ? void 0 : _a3.delete();
133231
133292
  this.state.model = this._getModel(gl);
133232
133293
  this.getAttributeManager().invalidateAll();
133233
133294
  }
@@ -133341,15 +133402,15 @@ class ScaledExpressionExtension extends LayerExtension {
133341
133402
  };
133342
133403
  }
133343
133404
  updateState({ props: props2, oldProps }) {
133344
- var _a2, _b, _c, _d;
133405
+ var _a3, _b2, _c, _d;
133345
133406
  if (props2.colormap !== oldProps.colormap) {
133346
133407
  const { gl } = this.context;
133347
133408
  if (this.state.model) {
133348
- (_a2 = this.state.model) == null ? void 0 : _a2.delete();
133409
+ (_a3 = this.state.model) == null ? void 0 : _a3.delete();
133349
133410
  this.state.model = this._getModel(gl);
133350
133411
  } else {
133351
133412
  if (this.state.models) {
133352
- (_b = this.state.models) == null ? void 0 : _b.forEach((model) => model == null ? void 0 : model.delete());
133413
+ (_b2 = this.state.models) == null ? void 0 : _b2.forEach((model) => model == null ? void 0 : model.delete());
133353
133414
  }
133354
133415
  if (this.state.topModel) {
133355
133416
  (_c = this.state.topModel) == null ? void 0 : _c.delete();
@@ -133450,23 +133511,23 @@ class SelectionExtension extends LayerExtension {
133450
133511
  }
133451
133512
  }
133452
133513
  SelectionExtension.extensionName = "SelectionExtension";
133453
- const registry$1 = /* @__PURE__ */ new Map();
133514
+ const registry$2 = /* @__PURE__ */ new Map();
133454
133515
  function addDecoder(cases, importFn) {
133455
133516
  if (!Array.isArray(cases)) {
133456
133517
  cases = [cases];
133457
133518
  }
133458
- cases.forEach((c) => registry$1.set(c, importFn));
133519
+ cases.forEach((c) => registry$2.set(c, importFn));
133459
133520
  }
133460
- addDecoder([void 0, 1], () => import("./raw-446b6beb.js").then((m) => m.default));
133461
- addDecoder(5, () => import("./lzw-c5e8dff0.js").then((m) => m.default));
133521
+ addDecoder([void 0, 1], () => import("./raw-a4927efa.js").then((m) => m.default));
133522
+ addDecoder(5, () => import("./lzw-18d035b6.js").then((m) => m.default));
133462
133523
  addDecoder(6, () => {
133463
133524
  throw new Error("old style JPEG compression is not supported.");
133464
133525
  });
133465
- addDecoder(7, () => import("./jpeg-76bff48f.js").then((m) => m.default));
133466
- addDecoder([8, 32946], () => import("./deflate-3240dc7e.js").then((m) => m.default));
133467
- addDecoder(32773, () => import("./packbits-ccf26149.js").then((m) => m.default));
133468
- addDecoder(34887, () => import("./lerc-1ad8fc7c.js").then((m) => m.default));
133469
- addDecoder(50001, () => import("./webimage-bf1c5425.js").then((m) => m.default));
133526
+ addDecoder(7, () => import("./jpeg-7f3e0d5a.js").then((m) => m.default));
133527
+ addDecoder([8, 32946], () => import("./deflate-e679700e.js").then((m) => m.default));
133528
+ addDecoder(32773, () => import("./packbits-588b56d4.js").then((m) => m.default));
133529
+ addDecoder(34887, () => import("./lerc-46e1d208.js").then((m) => m.default));
133530
+ addDecoder(50001, () => import("./webimage-b3b8965b.js").then((m) => m.default));
133470
133531
  function decodeRowAcc(row, stride) {
133471
133532
  let length2 = row.length - stride;
133472
133533
  let offset = 0;
@@ -134932,9 +134993,41 @@ function requireJson2xml() {
134932
134993
  return exports2.convertTonimn(exports2.getTraversalObj(xmlData, options), schema, options);
134933
134994
  };
134934
134995
  })(parser);
134935
- const registry = /* @__PURE__ */ new Map();
134996
+ const registry$1 = /* @__PURE__ */ new Map();
134936
134997
  function addCodec(id, importFn) {
134937
- registry.set(id, importFn);
134998
+ registry$1.set(id, importFn);
134999
+ }
135000
+ class BoundsCheckError extends RangeError {
135001
+ constructor(message) {
135002
+ super(message);
135003
+ this.__zarr__ = "BoundsCheckError";
135004
+ Object.setPrototypeOf(this, BoundsCheckError.prototype);
135005
+ }
135006
+ }
135007
+ class InvalidSliceError extends RangeError {
135008
+ constructor(from, to, stepSize, reason) {
135009
+ super(`slice arguments slice(${from}, ${to}, ${stepSize}) invalid: ${reason}`);
135010
+ this.__zarr__ = "InvalidSliceError";
135011
+ Object.setPrototypeOf(this, InvalidSliceError.prototype);
135012
+ }
135013
+ }
135014
+ function slice$1(start, stop = void 0, step = null) {
135015
+ if (start === void 0) {
135016
+ throw new InvalidSliceError(start, stop, step, "The first argument must not be undefined");
135017
+ }
135018
+ if (typeof start === "string" && start !== ":" || typeof stop === "string" && stop !== ":") {
135019
+ throw new InvalidSliceError(start, stop, step, 'Arguments can only be integers, ":" or null');
135020
+ }
135021
+ if (stop === void 0) {
135022
+ stop = start;
135023
+ start = null;
135024
+ }
135025
+ return {
135026
+ start: start === ":" ? null : start,
135027
+ stop: stop === ":" ? null : stop,
135028
+ step,
135029
+ _slice: true
135030
+ };
134938
135031
  }
134939
135032
  typeof process !== "undefined" && process.versions && process.versions.node;
134940
135033
  function createCommonjsModule(fn) {
@@ -135121,11 +135214,11 @@ var pFinally = (promise, onFinally) => {
135121
135214
  onFinally = onFinally || (() => {
135122
135215
  });
135123
135216
  return promise.then(
135124
- (val) => new Promise((resolve) => {
135125
- resolve(onFinally());
135217
+ (val) => new Promise((resolve2) => {
135218
+ resolve2(onFinally());
135126
135219
  }).then(() => val),
135127
- (err2) => new Promise((resolve) => {
135128
- resolve(onFinally());
135220
+ (err2) => new Promise((resolve2) => {
135221
+ resolve2(onFinally());
135129
135222
  }).then(() => {
135130
135223
  throw err2;
135131
135224
  })
@@ -135137,18 +135230,18 @@ class TimeoutError extends Error {
135137
135230
  this.name = "TimeoutError";
135138
135231
  }
135139
135232
  }
135140
- const pTimeout = (promise, milliseconds, fallback) => new Promise((resolve, reject) => {
135233
+ const pTimeout = (promise, milliseconds, fallback) => new Promise((resolve2, reject) => {
135141
135234
  if (typeof milliseconds !== "number" || milliseconds < 0) {
135142
135235
  throw new TypeError("Expected `milliseconds` to be a positive number");
135143
135236
  }
135144
135237
  if (milliseconds === Infinity) {
135145
- resolve(promise);
135238
+ resolve2(promise);
135146
135239
  return;
135147
135240
  }
135148
135241
  const timer = setTimeout(() => {
135149
135242
  if (typeof fallback === "function") {
135150
135243
  try {
135151
- resolve(fallback());
135244
+ resolve2(fallback());
135152
135245
  } catch (error2) {
135153
135246
  reject(error2);
135154
135247
  }
@@ -135163,7 +135256,7 @@ const pTimeout = (promise, milliseconds, fallback) => new Promise((resolve, reje
135163
135256
  }, milliseconds);
135164
135257
  pFinally(
135165
135258
  // eslint-disable-next-line promise/prefer-await-to-then
135166
- promise.then(resolve, reject),
135259
+ promise.then(resolve2, reject),
135167
135260
  () => {
135168
135261
  clearTimeout(timer);
135169
135262
  }
@@ -140348,17 +140441,128 @@ function getChannelStats(arr) {
140348
140441
  contrastLimits
140349
140442
  };
140350
140443
  }
140351
- function isInterleaved$1(shape) {
140444
+ function isInterleaved$2(shape) {
140352
140445
  const lastDimSize = shape[shape.length - 1];
140353
140446
  return lastDimSize === 3 || lastDimSize === 4;
140354
140447
  }
140448
+ function getDims(labels) {
140449
+ const lookup = new Map(labels.map((name2, i2) => [name2, i2]));
140450
+ if (lookup.size !== labels.length) {
140451
+ throw Error("Labels must be unique, found duplicated label.");
140452
+ }
140453
+ return (name2) => {
140454
+ const index2 = lookup.get(name2);
140455
+ if (index2 === void 0) {
140456
+ throw Error("Invalid dimension.");
140457
+ }
140458
+ return index2;
140459
+ };
140460
+ }
140355
140461
  function getImageSize(source) {
140356
- const interleaved = isInterleaved$1(source.shape);
140462
+ const interleaved = isInterleaved$2(source.shape);
140357
140463
  const [height, width] = source.shape.slice(interleaved ? -3 : -2);
140358
140464
  return { height, width };
140359
140465
  }
140360
140466
  const SIGNAL_ABORTED = "__vivSignalAborted";
140361
140467
  addDecoder(5, () => LZWDecoder);
140468
+ function getIndexer(labels) {
140469
+ const size2 = labels.length;
140470
+ const dims = getDims(labels);
140471
+ return (sel) => {
140472
+ if (Array.isArray(sel)) {
140473
+ return [...sel];
140474
+ }
140475
+ const selection = Array(size2).fill(0);
140476
+ for (const [key, value] of Object.entries(sel)) {
140477
+ selection[dims(key)] = value;
140478
+ }
140479
+ return selection;
140480
+ };
140481
+ }
140482
+ const DTYPE_LOOKUP = {
140483
+ u1: "Uint8",
140484
+ u2: "Uint16",
140485
+ u4: "Uint32",
140486
+ f4: "Float32",
140487
+ f8: "Float64",
140488
+ i1: "Int8",
140489
+ i2: "Int16",
140490
+ i4: "Int32"
140491
+ };
140492
+ class ZarrPixelSource {
140493
+ constructor(data, labels, tileSize) {
140494
+ this.labels = labels;
140495
+ this.tileSize = tileSize;
140496
+ this._indexer = getIndexer(labels);
140497
+ this._data = data;
140498
+ const xChunkSize = data.chunks[this._xIndex];
140499
+ const yChunkSize = data.chunks[this._xIndex - 1];
140500
+ this._readChunks = tileSize === xChunkSize && tileSize === yChunkSize;
140501
+ }
140502
+ get shape() {
140503
+ return this._data.shape;
140504
+ }
140505
+ get dtype() {
140506
+ const suffix = this._data.dtype.slice(1);
140507
+ if (!(suffix in DTYPE_LOOKUP)) {
140508
+ throw Error(`Zarr dtype not supported, got ${suffix}.`);
140509
+ }
140510
+ return DTYPE_LOOKUP[suffix];
140511
+ }
140512
+ get _xIndex() {
140513
+ const interleave = isInterleaved$2(this._data.shape);
140514
+ return this._data.shape.length - (interleave ? 2 : 1);
140515
+ }
140516
+ _chunkIndex(selection, x2, y2) {
140517
+ const sel = this._indexer(selection);
140518
+ sel[this._xIndex] = x2;
140519
+ sel[this._xIndex - 1] = y2;
140520
+ return sel;
140521
+ }
140522
+ _getSlices(x2, y2) {
140523
+ const { height, width } = getImageSize(this);
140524
+ const [xStart, xStop] = [
140525
+ x2 * this.tileSize,
140526
+ Math.min((x2 + 1) * this.tileSize, width)
140527
+ ];
140528
+ const [yStart, yStop] = [
140529
+ y2 * this.tileSize,
140530
+ Math.min((y2 + 1) * this.tileSize, height)
140531
+ ];
140532
+ if (xStart === xStop || yStart === yStop) {
140533
+ throw new BoundsCheckError("Tile slice is zero-sized.");
140534
+ }
140535
+ return [slice$1(xStart, xStop), slice$1(yStart, yStop)];
140536
+ }
140537
+ async getRaster({ selection }) {
140538
+ const sel = this._chunkIndex(selection, null, null);
140539
+ const { data, shape } = await this._data.getRaw(sel);
140540
+ const [height, width] = shape;
140541
+ return { data, width, height };
140542
+ }
140543
+ async getTile(props2) {
140544
+ const { x: x2, y: y2, selection, signal } = props2;
140545
+ let res;
140546
+ if (this._readChunks) {
140547
+ const sel = this._chunkIndex(selection, x2, y2);
140548
+ res = await this._data.getRawChunk(sel, { storeOptions: { signal } });
140549
+ } else {
140550
+ const [xSlice, ySlice] = this._getSlices(x2, y2);
140551
+ const sel = this._chunkIndex(selection, xSlice, ySlice);
140552
+ res = await this._data.getRaw(sel);
140553
+ }
140554
+ const {
140555
+ data,
140556
+ shape: [height, width]
140557
+ } = res;
140558
+ return { data, width, height };
140559
+ }
140560
+ onTileError(err2) {
140561
+ if (!(err2 instanceof BoundsCheckError)) {
140562
+ throw err2;
140563
+ }
140564
+ }
140565
+ }
140362
140566
  const MAX_COLOR_INTENSITY = 255;
140363
140567
  const DEFAULT_COLOR_OFF = [0, 0, 0];
140364
140568
  const MAX_CHANNELS$1 = 6;
@@ -141850,8 +142054,8 @@ const defaultProps$4$1 = {
141850
142054
  };
141851
142055
  const AdditiveColormapExtension = class extends LayerExtension {
141852
142056
  getShaders() {
141853
- var _a2;
141854
- const name2 = ((_a2 = this == null ? void 0 : this.props) == null ? void 0 : _a2.colormap) || defaultProps$4$1.colormap.value;
142057
+ var _a3;
142058
+ const name2 = ((_a3 = this == null ? void 0 : this.props) == null ? void 0 : _a3.colormap) || defaultProps$4$1.colormap.value;
141855
142059
  const apply_cmap = cmaps[name2];
141856
142060
  if (!apply_cmap) {
141857
142061
  throw Error(`No colormap named ${name2} found in registry`);
@@ -141869,7 +142073,7 @@ const AdditiveColormapExtension = class extends LayerExtension {
141869
142073
  }
141870
142074
  }
141871
142075
  draw() {
141872
- var _a2;
142076
+ var _a3;
141873
142077
  const {
141874
142078
  useTransparentColor = defaultProps$4$1.useTransparentColor.value,
141875
142079
  opacity = defaultProps$4$1.opacity.value
@@ -141878,7 +142082,7 @@ const AdditiveColormapExtension = class extends LayerExtension {
141878
142082
  opacity,
141879
142083
  useTransparentColor
141880
142084
  };
141881
- (_a2 = this.state.model) == null ? void 0 : _a2.setUniforms(uniforms);
142085
+ (_a3 = this.state.model) == null ? void 0 : _a3.setUniforms(uniforms);
141882
142086
  }
141883
142087
  };
141884
142088
  AdditiveColormapExtension.extensionName = "AdditiveColormapExtension";
@@ -141963,7 +142167,7 @@ const ColorPaletteExtension = class extends LayerExtension {
141963
142167
  };
141964
142168
  }
141965
142169
  draw() {
141966
- var _a2;
142170
+ var _a3;
141967
142171
  const {
141968
142172
  colors,
141969
142173
  channelsVisible,
@@ -141981,7 +142185,7 @@ const ColorPaletteExtension = class extends LayerExtension {
141981
142185
  transparentColor: (transparentColor || [0, 0, 0]).map((i2) => i2 / 255),
141982
142186
  useTransparentColor: Boolean(useTransparentColor)
141983
142187
  };
141984
- (_a2 = this.state.model) == null ? void 0 : _a2.setUniforms(uniforms);
142188
+ (_a3 = this.state.model) == null ? void 0 : _a3.setUniforms(uniforms);
141985
142189
  }
141986
142190
  };
141987
142191
  ColorPaletteExtension.extensionName = "ColorPaletteExtension";
@@ -142126,7 +142330,7 @@ const LensExtension = class extends LayerExtension {
142126
142330
  this.setState({ onMouseMove, unprojectLensBounds: [0, 0, 0, 0] });
142127
142331
  }
142128
142332
  draw() {
142129
- var _a2;
142333
+ var _a3;
142130
142334
  const { unprojectLensBounds = [0, 0, 0, 0] } = this.state;
142131
142335
  const {
142132
142336
  bounds: bounds2,
@@ -142160,14 +142364,14 @@ const LensExtension = class extends LayerExtension {
142160
142364
  lensBorderRadius,
142161
142365
  colors: paddedColors
142162
142366
  };
142163
- (_a2 = this.state.model) == null ? void 0 : _a2.setUniforms(uniforms);
142367
+ (_a3 = this.state.model) == null ? void 0 : _a3.setUniforms(uniforms);
142164
142368
  }
142165
142369
  finalizeState() {
142166
- var _a2, _b, _c;
142370
+ var _a3, _b2, _c;
142167
142371
  if (this.context.deck) {
142168
142372
  this.context.deck.eventManager.off({
142169
- pointermove: (_a2 = this.state) == null ? void 0 : _a2.onMouseMove,
142170
- pointerleave: (_b = this.state) == null ? void 0 : _b.onMouseMove,
142373
+ pointermove: (_a3 = this.state) == null ? void 0 : _a3.onMouseMove,
142374
+ pointerleave: (_b2 = this.state) == null ? void 0 : _b2.onMouseMove,
142171
142375
  wheel: (_c = this.state) == null ? void 0 : _c.onMouseMove
142172
142376
  });
142173
142377
  }
@@ -142195,8 +142399,8 @@ const BaseExtension$1 = class extends LayerExtension {
142195
142399
  this.opts = this.opts || {};
142196
142400
  }
142197
142401
  getShaders() {
142198
- var _a2;
142199
- const name2 = ((_a2 = this == null ? void 0 : this.props) == null ? void 0 : _a2.colormap) || defaultProps$1$2.colormap.value;
142402
+ var _a3;
142403
+ const name2 = ((_a3 = this == null ? void 0 : this.props) == null ? void 0 : _a3.colormap) || defaultProps$1$2.colormap.value;
142200
142404
  const apply_cmap = cmaps[name2];
142201
142405
  return {
142202
142406
  ...super.getShaders(),
@@ -142304,7 +142508,7 @@ const BaseExtension = class extends LayerExtension {
142304
142508
  this.opts = this.opts || {};
142305
142509
  }
142306
142510
  draw() {
142307
- var _a2;
142511
+ var _a3;
142308
142512
  const { colors, channelsVisible } = this.props;
142309
142513
  const paddedColors = padColors({
142310
142514
  channelsVisible: channelsVisible || this.selections.map(() => true),
@@ -142313,7 +142517,7 @@ const BaseExtension = class extends LayerExtension {
142313
142517
  const uniforms = {
142314
142518
  colors: paddedColors
142315
142519
  };
142316
- (_a2 = this.state.model) == null ? void 0 : _a2.setUniforms(uniforms);
142520
+ (_a3 = this.state.model) == null ? void 0 : _a3.setUniforms(uniforms);
142317
142521
  }
142318
142522
  };
142319
142523
  BaseExtension.extensionName = "BaseExtension";
@@ -142411,7 +142615,7 @@ const channels = {
142411
142615
  },
142412
142616
  fs: fs$2
142413
142617
  };
142414
- function range(len2) {
142618
+ function range$1(len2) {
142415
142619
  return [...Array(len2).keys()];
142416
142620
  }
142417
142621
  function padWithDefault$2(arr, defaultValue2, padWidth) {
@@ -142452,8 +142656,8 @@ function padContrastLimits({
142452
142656
  return paddedContrastLimits;
142453
142657
  }
142454
142658
  function getPhysicalSizeScalingMatrix$1(loader) {
142455
- var _a2;
142456
- const { x: x2, y: y2, z: z2 } = ((_a2 = loader == null ? void 0 : loader.meta) == null ? void 0 : _a2.physicalSizes) ?? {};
142659
+ var _a3;
142660
+ const { x: x2, y: y2, z: z2 } = ((_a3 = loader == null ? void 0 : loader.meta) == null ? void 0 : _a3.physicalSizes) ?? {};
142457
142661
  if ((x2 == null ? void 0 : x2.size) && (y2 == null ? void 0 : y2.size) && (z2 == null ? void 0 : z2.size)) {
142458
142662
  const min2 = Math.min(z2.size, x2.size, y2.size);
142459
142663
  const ratio = [x2.size / min2, y2.size / min2, z2.size / min2];
@@ -142474,6 +142678,67 @@ function makeBoundingBox(viewState) {
142474
142678
  viewport.unproject([0, viewport.height])
142475
142679
  ];
142476
142680
  }
142681
+ const TARGETS = [1, 2, 3, 4, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1e3];
142682
+ const MIN_TARGET = TARGETS[0];
142683
+ const MAX_TARGET = TARGETS[TARGETS.length - 1];
142684
+ const SI_PREFIXES = [
142685
+ { symbol: "Y", exponent: 24 },
142686
+ { symbol: "Z", exponent: 21 },
142687
+ { symbol: "E", exponent: 18 },
142688
+ { symbol: "P", exponent: 15 },
142689
+ { symbol: "T", exponent: 12 },
142690
+ { symbol: "G", exponent: 9 },
142691
+ { symbol: "M", exponent: 6 },
142692
+ { symbol: "k", exponent: 3 },
142693
+ { symbol: "h", exponent: 2 },
142694
+ { symbol: "da", exponent: 1 },
142695
+ { symbol: "", exponent: 0 },
142696
+ { symbol: "d", exponent: -1 },
142697
+ { symbol: "c", exponent: -2 },
142698
+ { symbol: "m", exponent: -3 },
142699
+ { symbol: "µ", exponent: -6 },
142700
+ { symbol: "n", exponent: -9 },
142701
+ { symbol: "p", exponent: -12 },
142702
+ { symbol: "f", exponent: -15 },
142703
+ { symbol: "a", exponent: -18 },
142704
+ { symbol: "z", exponent: -21 },
142705
+ { symbol: "y", exponent: -24 }
142706
+ ];
142707
+ function sizeToMeters(size2, unit2) {
142708
+ if (!unit2 || unit2 === "m") {
142709
+ return size2;
142710
+ }
142711
+ if (unit2.length > 1) {
142712
+ let unitPrefix = unit2.substring(0, unit2.length - 1);
142713
+ if (unitPrefix === "u") {
142714
+ unitPrefix = "µ";
142715
+ }
142716
+ const unitObj = SI_PREFIXES.find((p) => p.symbol === unitPrefix);
142717
+ if (unitObj) {
142718
+ return size2 * 10 ** unitObj.exponent;
142719
+ }
142720
+ }
142721
+ throw new Error("Received unknown unit");
142722
+ }
142723
+ function snapValue(value) {
142724
+ let magnitude = 0;
142725
+ if (value < MIN_TARGET || value > MAX_TARGET) {
142726
+ magnitude = Math.floor(Math.log10(value));
142727
+ }
142728
+ let snappedUnit = SI_PREFIXES.find(
142729
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude
142730
+ );
142731
+ let adjustedValue = value / 10 ** snappedUnit.exponent;
142732
+ if (adjustedValue > 500 && adjustedValue <= 1e3) {
142733
+ snappedUnit = SI_PREFIXES.find(
142734
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude + 3
142735
+ );
142736
+ adjustedValue = value / 10 ** snappedUnit.exponent;
142737
+ }
142738
+ const targetNewUnits = TARGETS.find((t2) => t2 > adjustedValue);
142739
+ const targetOrigUnits = targetNewUnits * 10 ** snappedUnit.exponent;
142740
+ return [targetOrigUnits, targetNewUnits, snappedUnit.symbol];
142741
+ }
142477
142742
  const fs$1$1 = `#define SHADER_NAME xr-layer-fragment-shader
142478
142743
 
142479
142744
  precision highp float;
@@ -142658,7 +142923,7 @@ const XRLayer = class extends Layer {
142658
142923
  }
142659
142924
  }
142660
142925
  updateState({ props: props2, oldProps, changeFlags, ...rest }) {
142661
- var _a2, _b;
142926
+ var _a3, _b2;
142662
142927
  super.updateState({ props: props2, oldProps, changeFlags, ...rest });
142663
142928
  if (changeFlags.extensionsChanged || props2.interpolation !== oldProps.interpolation) {
142664
142929
  const { gl } = this.context;
@@ -142668,7 +142933,7 @@ const XRLayer = class extends Layer {
142668
142933
  this.setState({ model: this._getModel(gl) });
142669
142934
  this.getAttributeManager().invalidateAll();
142670
142935
  }
142671
- if (props2.channelData !== oldProps.channelData && ((_a2 = props2.channelData) == null ? void 0 : _a2.data) !== ((_b = oldProps.channelData) == null ? void 0 : _b.data) || props2.interpolation !== oldProps.interpolation) {
142936
+ if (props2.channelData !== oldProps.channelData && ((_a3 = props2.channelData) == null ? void 0 : _a3.data) !== ((_b2 = oldProps.channelData) == null ? void 0 : _b2.data) || props2.interpolation !== oldProps.interpolation) {
142672
142937
  this.loadChannelTextures(props2.channelData);
142673
142938
  }
142674
142939
  const attributeManager = this.getAttributeManager();
@@ -142752,7 +143017,7 @@ const XRLayer = class extends Layer {
142752
143017
  }
142753
143018
  }
142754
143019
  dataToTexture(data, width, height) {
142755
- var _a2;
143020
+ var _a3;
142756
143021
  const { interpolation } = this.props;
142757
143022
  const attrs = getRenderingAttrs$1(
142758
143023
  this.props.dtype,
@@ -142762,7 +143027,7 @@ const XRLayer = class extends Layer {
142762
143027
  return new Texture2D(this.context.gl, {
142763
143028
  width,
142764
143029
  height,
142765
- data: ((_a2 = attrs.cast) == null ? void 0 : _a2.call(attrs, data)) ?? data,
143030
+ data: ((_a3 = attrs.cast) == null ? void 0 : _a3.call(attrs, data)) ?? data,
142766
143031
  mipmaps: false,
142767
143032
  parameters: {
142768
143033
  [GL$1.TEXTURE_MIN_FILTER]: attrs.filter,
@@ -142912,7 +143177,7 @@ function renderSubLayers(props2) {
142912
143177
  data.width < base.tileSize ? width : right,
142913
143178
  top
142914
143179
  ];
142915
- if (isInterleaved$1(base.shape)) {
143180
+ if (isInterleaved$2(base.shape)) {
142916
143181
  const { photometricInterpretation = 2 } = base.meta;
142917
143182
  return new BitmapLayer2(props2, {
142918
143183
  image: data,
@@ -142999,13 +143264,13 @@ const ImageLayer = class extends CompositeLayer {
142999
143264
  const getRaster = (selection) => loader.getRaster({ selection, signal });
143000
143265
  const dataPromises = selections.map(getRaster);
143001
143266
  Promise.all(dataPromises).then((rasters) => {
143002
- var _a2, _b;
143267
+ var _a3, _b2;
143003
143268
  const raster = {
143004
143269
  data: rasters.map((d) => d.data),
143005
- width: (_a2 = rasters[0]) == null ? void 0 : _a2.width,
143006
- height: (_b = rasters[0]) == null ? void 0 : _b.height
143270
+ width: (_a3 = rasters[0]) == null ? void 0 : _a3.width,
143271
+ height: (_b2 = rasters[0]) == null ? void 0 : _b2.height
143007
143272
  };
143008
- if (isInterleaved$1(loader.shape)) {
143273
+ if (isInterleaved$2(loader.shape)) {
143009
143274
  raster.data = raster.data[0];
143010
143275
  if (raster.data.length === raster.width * raster.height * 3) {
143011
143276
  raster.format = GL$1.RGB;
@@ -143035,7 +143300,7 @@ const ImageLayer = class extends CompositeLayer {
143035
143300
  if (!(width && height))
143036
143301
  return null;
143037
143302
  const bounds2 = [0, height, width, 0];
143038
- if (isInterleaved$1(loader.shape)) {
143303
+ if (isInterleaved$2(loader.shape)) {
143039
143304
  const { photometricInterpretation = 2 } = loader.meta;
143040
143305
  return new BitmapLayer2(this.props, {
143041
143306
  image: this.state,
@@ -143104,7 +143369,7 @@ const MultiscaleImageLayer = class extends CompositeLayer {
143104
143369
  width: tiles[0].width,
143105
143370
  height: tiles[0].height
143106
143371
  };
143107
- if (isInterleaved$1(loader[resolution].shape)) {
143372
+ if (isInterleaved$2(loader[resolution].shape)) {
143108
143373
  tile.data = tile.data[0];
143109
143374
  if (tile.data.length === tile.width * tile.height * 3) {
143110
143375
  tile.format = GL$1.RGB;
@@ -143241,26 +143506,27 @@ const OverviewLayer = class extends CompositeLayer {
143241
143506
  OverviewLayer.layerName = "OverviewLayer";
143242
143507
  OverviewLayer.defaultProps = defaultProps$3;
143243
143508
  function getPosition(boundingBox, position, length2) {
143244
- const viewLength = boundingBox[2][0] - boundingBox[0][0];
143509
+ const viewWidth = boundingBox[2][0] - boundingBox[0][0];
143510
+ const viewHeight = boundingBox[2][1] - boundingBox[0][1];
143245
143511
  switch (position) {
143246
143512
  case "bottom-right": {
143247
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
143248
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
143513
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
143514
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
143249
143515
  return [yCoord, xLeftCoord];
143250
143516
  }
143251
143517
  case "top-right": {
143252
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
143253
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
143518
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
143519
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
143254
143520
  return [yCoord, xLeftCoord];
143255
143521
  }
143256
143522
  case "top-left": {
143257
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
143258
- const xLeftCoord = viewLength * length2;
143523
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
143524
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
143259
143525
  return [yCoord, xLeftCoord];
143260
143526
  }
143261
143527
  case "bottom-left": {
143262
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
143263
- const xLeftCoord = viewLength * length2;
143528
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
143529
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
143264
143530
  return [yCoord, xLeftCoord];
143265
143531
  }
143266
143532
  default: {
@@ -143278,11 +143544,12 @@ const defaultProps$2 = {
143278
143544
  unit: { type: "string", value: "", compare: true },
143279
143545
  size: { type: "number", value: 1, compare: true },
143280
143546
  position: { type: "string", value: "bottom-right", compare: true },
143281
- length: { type: "number", value: 0.085, compare: true }
143547
+ length: { type: "number", value: 0.085, compare: true },
143548
+ snap: { type: "boolean", value: false, compare: true }
143282
143549
  };
143283
143550
  const ScaleBarLayer = class extends CompositeLayer {
143284
143551
  renderLayers() {
143285
- const { id, unit: unit2, size: size2, position, viewState, length: length2 } = this.props;
143552
+ const { id, unit: unit2, size: size2, position, viewState, length: length2, snap } = this.props;
143286
143553
  const boundingBox = makeBoundingBox(viewState);
143287
143554
  const { zoom } = viewState;
143288
143555
  const viewLength = boundingBox[2][0] - boundingBox[0][0];
@@ -143291,15 +143558,27 @@ const ScaleBarLayer = class extends CompositeLayer {
143291
143558
  2 ** (-zoom + 1.5),
143292
143559
  (boundingBox[2][1] - boundingBox[0][1]) * 7e-3
143293
143560
  );
143294
- const numUnits = barLength * size2;
143561
+ let adjustedBarLength = barLength;
143562
+ let displayNumber = (barLength * size2).toPrecision(5);
143563
+ let displayUnit = unit2;
143564
+ if (snap) {
143565
+ const meterSize = sizeToMeters(size2, unit2);
143566
+ const numUnits = barLength * meterSize;
143567
+ const [snappedOrigUnits, snappedNewUnits, snappedUnitPrefix] = snapValue(numUnits);
143568
+ adjustedBarLength = snappedOrigUnits / meterSize;
143569
+ displayNumber = snappedNewUnits;
143570
+ displayUnit = `${snappedUnitPrefix}m`;
143571
+ }
143295
143572
  const [yCoord, xLeftCoord] = getPosition(boundingBox, position, length2);
143573
+ const xRightCoord = xLeftCoord + barLength;
143574
+ const isLeft = position.endsWith("-left");
143296
143575
  const lengthBar = new LineLayer({
143297
143576
  id: `scale-bar-length-${id}`,
143298
143577
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
143299
143578
  data: [
143300
143579
  [
143301
- [xLeftCoord, yCoord],
143302
- [xLeftCoord + barLength, yCoord]
143580
+ [isLeft ? xLeftCoord : xRightCoord - adjustedBarLength, yCoord],
143581
+ [isLeft ? xLeftCoord + adjustedBarLength : xRightCoord, yCoord]
143303
143582
  ]
143304
143583
  ],
143305
143584
  getSourcePosition: (d) => d[0],
@@ -143312,8 +143591,14 @@ const ScaleBarLayer = class extends CompositeLayer {
143312
143591
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
143313
143592
  data: [
143314
143593
  [
143315
- [xLeftCoord, yCoord - barHeight],
143316
- [xLeftCoord, yCoord + barHeight]
143594
+ [
143595
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
143596
+ yCoord - barHeight
143597
+ ],
143598
+ [
143599
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
143600
+ yCoord + barHeight
143601
+ ]
143317
143602
  ]
143318
143603
  ],
143319
143604
  getSourcePosition: (d) => d[0],
@@ -143326,8 +143611,14 @@ const ScaleBarLayer = class extends CompositeLayer {
143326
143611
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
143327
143612
  data: [
143328
143613
  [
143329
- [xLeftCoord + barLength, yCoord - barHeight],
143330
- [xLeftCoord + barLength, yCoord + barHeight]
143614
+ [
143615
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
143616
+ yCoord - barHeight
143617
+ ],
143618
+ [
143619
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
143620
+ yCoord + barHeight
143621
+ ]
143331
143622
  ]
143332
143623
  ],
143333
143624
  getSourcePosition: (d) => d[0],
@@ -143340,8 +143631,11 @@ const ScaleBarLayer = class extends CompositeLayer {
143340
143631
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
143341
143632
  data: [
143342
143633
  {
143343
- text: numUnits.toPrecision(5) + unit2,
143344
- position: [xLeftCoord + barLength * 0.5, yCoord + barHeight * 4]
143634
+ text: `${displayNumber}${displayUnit}`,
143635
+ position: [
143636
+ isLeft ? xLeftCoord + barLength * 0.5 : xRightCoord - barLength * 0.5,
143637
+ yCoord + barHeight * 4
143638
+ ]
143345
143639
  }
143346
143640
  ],
143347
143641
  getColor: [220, 220, 220, 255],
@@ -143350,8 +143644,8 @@ const ScaleBarLayer = class extends CompositeLayer {
143350
143644
  sizeUnits: "meters",
143351
143645
  sizeScale: 2 ** -zoom,
143352
143646
  characterSet: [
143353
- ...unit2.split(""),
143354
- ...range(10).map((i2) => String(i2)),
143647
+ ...displayUnit.split(""),
143648
+ ...range$1(10).map((i2) => String(i2)),
143355
143649
  ".",
143356
143650
  "e",
143357
143651
  "+"
@@ -143717,7 +144011,7 @@ const XR3DLayer = class extends Layer {
143717
144011
  }
143718
144012
  }
143719
144013
  updateState({ props: props2, oldProps, changeFlags }) {
143720
- var _a2, _b;
144014
+ var _a3, _b2;
143721
144015
  if (changeFlags.extensionsChanged || props2.colormap !== oldProps.colormap || props2.renderingMode !== oldProps.renderingMode || props2.clippingPlanes.length !== oldProps.clippingPlanes.length) {
143722
144016
  const { gl } = this.context;
143723
144017
  if (this.state.model) {
@@ -143725,7 +144019,7 @@ const XR3DLayer = class extends Layer {
143725
144019
  }
143726
144020
  this.setState({ model: this._getModel(gl) });
143727
144021
  }
143728
- if (props2.channelData && ((_a2 = props2 == null ? void 0 : props2.channelData) == null ? void 0 : _a2.data) !== ((_b = oldProps == null ? void 0 : oldProps.channelData) == null ? void 0 : _b.data)) {
144022
+ if (props2.channelData && ((_a3 = props2 == null ? void 0 : props2.channelData) == null ? void 0 : _a3.data) !== ((_b2 = oldProps == null ? void 0 : oldProps.channelData) == null ? void 0 : _b2.data)) {
143729
144023
  this.loadTexture(props2.channelData);
143730
144024
  }
143731
144025
  }
@@ -143834,13 +144128,13 @@ const XR3DLayer = class extends Layer {
143834
144128
  }
143835
144129
  }
143836
144130
  dataToTexture(data, width, height, depth) {
143837
- var _a2;
144131
+ var _a3;
143838
144132
  const attrs = getRenderingAttrs();
143839
144133
  const texture = new Texture3D(this.context.gl, {
143840
144134
  width,
143841
144135
  height,
143842
144136
  depth,
143843
- data: ((_a2 = attrs.cast) == null ? void 0 : _a2.call(attrs, data)) ?? data,
144137
+ data: ((_a3 = attrs.cast) == null ? void 0 : _a3.call(attrs, data)) ?? data,
143844
144138
  format: attrs.dataFormat,
143845
144139
  dataFormat: attrs.format,
143846
144140
  type: attrs.type,
@@ -144009,14 +144303,14 @@ const VolumeLayer = class extends CompositeLayer {
144009
144303
  loader[resolution]
144010
144304
  );
144011
144305
  Promise.all(volumePromises).then((volumes) => {
144012
- var _a2, _b, _c;
144306
+ var _a3, _b2, _c;
144013
144307
  if (onViewportLoad) {
144014
144308
  onViewportLoad(volumes);
144015
144309
  }
144016
144310
  const volume = {
144017
144311
  data: volumes.map((d) => d.data),
144018
- width: (_a2 = volumes[0]) == null ? void 0 : _a2.width,
144019
- height: (_b = volumes[0]) == null ? void 0 : _b.height,
144312
+ width: (_a3 = volumes[0]) == null ? void 0 : _a3.width,
144313
+ height: (_b2 = volumes[0]) == null ? void 0 : _b2.height,
144020
144314
  depth: (_c = volumes[0]) == null ? void 0 : _c.depth
144021
144315
  };
144022
144316
  this.setState({
@@ -144549,9 +144843,9 @@ function multiSetsToTextureData(multiFeatureValues, setColorValues, channelIsSet
144549
144843
  let totalValuesLength = 0;
144550
144844
  let totalColorsLength = 0;
144551
144845
  channelIsSetColorMode.forEach((isSetColorMode, channelIndex) => {
144552
- var _a2, _b, _c, _d, _e;
144846
+ var _a3, _b2, _c, _d, _e;
144553
144847
  if (isSetColorMode) {
144554
- totalValuesLength += ((_b = (_a2 = setColorValues[channelIndex]) == null ? void 0 : _a2.obsIndex) == null ? void 0 : _b.length) || 0;
144848
+ totalValuesLength += ((_b2 = (_a3 = setColorValues[channelIndex]) == null ? void 0 : _a3.obsIndex) == null ? void 0 : _b2.length) || 0;
144555
144849
  totalColorsLength += (((_d = (_c = setColorValues[channelIndex]) == null ? void 0 : _c.setColors) == null ? void 0 : _d.length) || 0) * 3;
144556
144850
  } else {
144557
144851
  totalValuesLength += ((_e = multiFeatureValues[channelIndex]) == null ? void 0 : _e.length) || 0;
@@ -144732,7 +145026,7 @@ class BitmaskLayer2 extends XRLayer {
144732
145026
  } = this.state;
144733
145027
  if (textures && model) {
144734
145028
  const scaleFactor = 1 / 2 ** (maxZoom - zoom);
144735
- const colors = fromEntries(range$5(MAX_CHANNELS).map((i2) => [`color${i2}`, getColor(channelColors[i2])]));
145029
+ const colors = fromEntries(range$6(MAX_CHANNELS).map((i2) => [`color${i2}`, getColor(channelColors[i2])]));
144736
145030
  model.setUniforms(Object.assign({}, uniforms, {
144737
145031
  ...colors,
144738
145032
  // Bitmask image channel data textures
@@ -144952,8 +145246,8 @@ const getMultiSelectionStats = async ({ loader, selections, use3d }) => {
144952
145246
  return { domains, sliders };
144953
145247
  };
144954
145248
  function getPhysicalSizeScalingMatrix(loader) {
144955
- var _a2;
144956
- const { x: x2, y: y2, z: z2 } = ((_a2 = loader == null ? void 0 : loader.meta) == null ? void 0 : _a2.physicalSizes) ?? {};
145249
+ var _a3;
145250
+ const { x: x2, y: y2, z: z2 } = ((_a3 = loader == null ? void 0 : loader.meta) == null ? void 0 : _a3.physicalSizes) ?? {};
144957
145251
  if ((x2 == null ? void 0 : x2.size) && (y2 == null ? void 0 : y2.size) && (z2 == null ? void 0 : z2.size)) {
144958
145252
  const min2 = Math.min(z2.size, x2.size, y2.size);
144959
145253
  const ratio = [x2.size / min2, y2.size / min2, z2.size / min2];
@@ -145044,7 +145338,7 @@ const getStatsForResolution = (loader, resolution) => {
145044
145338
  };
145045
145339
  };
145046
145340
  const canLoadResolution = (loader, resolution) => {
145047
- var _a2, _b, _c;
145341
+ var _a3, _b2, _c;
145048
145342
  const {
145049
145343
  totalBytes,
145050
145344
  height,
@@ -145054,7 +145348,7 @@ const canLoadResolution = (loader, resolution) => {
145054
145348
  loader,
145055
145349
  resolution
145056
145350
  );
145057
- const maxHeapSize = ((_a2 = window.performance) == null ? void 0 : _a2.memory) && ((_c = (_b = window.performance) == null ? void 0 : _b.memory) == null ? void 0 : _c.jsHeapSizeLimit) / 2;
145351
+ const maxHeapSize = ((_a3 = window.performance) == null ? void 0 : _a3.memory) && ((_c = (_b2 = window.performance) == null ? void 0 : _b2.memory) == null ? void 0 : _c.jsHeapSizeLimit) / 2;
145058
145352
  const maxSize = maxHeapSize || 2 ** 31 - 1;
145059
145353
  return totalBytes < maxSize && height <= 2048 && depthDownsampled <= 2048 && width <= 2048 && depthDownsampled > 1;
145060
145354
  };
@@ -145099,19 +145393,19 @@ function physicalSizeToMatrix(xSize, ySize, zSize, xUnit, yUnit, zUnit) {
145099
145393
  function getMetaWithTransformMatrices(imageMeta, imageLoaders) {
145100
145394
  const sources = imageLoaders.map((loader) => getSourceFromLoader(loader));
145101
145395
  if (imageMeta.map((meta2) => {
145102
- var _a2, _b, _c, _d, _e, _f;
145103
- return ((_b = (_a2 = meta2 == null ? void 0 : meta2.metadata) == null ? void 0 : _a2.transform) == null ? void 0 : _b.matrix) || ((_d = (_c = meta2 == null ? void 0 : meta2.metadata) == null ? void 0 : _c.transform) == null ? void 0 : _d.scale) || ((_f = (_e = meta2 == null ? void 0 : meta2.metadata) == null ? void 0 : _e.transform) == null ? void 0 : _f.translate);
145396
+ var _a3, _b2, _c, _d, _e, _f;
145397
+ return ((_b2 = (_a3 = meta2 == null ? void 0 : meta2.metadata) == null ? void 0 : _a3.transform) == null ? void 0 : _b2.matrix) || ((_d = (_c = meta2 == null ? void 0 : meta2.metadata) == null ? void 0 : _c.transform) == null ? void 0 : _d.scale) || ((_f = (_e = meta2 == null ? void 0 : meta2.metadata) == null ? void 0 : _e.transform) == null ? void 0 : _f.translate);
145104
145398
  }).some(Boolean) || sources.every(
145105
145399
  (source) => {
145106
- var _a2, _b, _c, _d;
145107
- return !((_b = (_a2 = source.meta) == null ? void 0 : _a2.physicalSizes) == null ? void 0 : _b.x) || !((_d = (_c = source.meta) == null ? void 0 : _c.physicalSizes) == null ? void 0 : _d.y);
145400
+ var _a3, _b2, _c, _d;
145401
+ return !((_b2 = (_a3 = source.meta) == null ? void 0 : _a3.physicalSizes) == null ? void 0 : _b2.x) || !((_d = (_c = source.meta) == null ? void 0 : _c.physicalSizes) == null ? void 0 : _d.y);
145108
145402
  }
145109
145403
  )) {
145110
145404
  return imageMeta;
145111
145405
  }
145112
145406
  const minPhysicalSize = sources.reduce((acc, source) => {
145113
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
145114
- const hasZPhyscialSize = (_c = (_b = (_a2 = source.meta) == null ? void 0 : _a2.physicalSizes) == null ? void 0 : _b.z) == null ? void 0 : _c.size;
145407
+ var _a3, _b2, _c, _d, _e, _f, _g, _h, _i;
145408
+ const hasZPhyscialSize = (_c = (_b2 = (_a3 = source.meta) == null ? void 0 : _a3.physicalSizes) == null ? void 0 : _b2.z) == null ? void 0 : _c.size;
145115
145409
  const sizes = [
145116
145410
  unit(`${(_d = source.meta) == null ? void 0 : _d.physicalSizes.x.size} ${(_e = source.meta) == null ? void 0 : _e.physicalSizes.x.unit}`.replace("µ", "u")),
145117
145411
  unit(`${(_f = source.meta) == null ? void 0 : _f.physicalSizes.y.size} ${(_g = source.meta) == null ? void 0 : _g.physicalSizes.y.unit}`.replace("µ", "u"))
@@ -145125,9 +145419,9 @@ function getMetaWithTransformMatrices(imageMeta, imageLoaders) {
145125
145419
  return acc;
145126
145420
  }, []);
145127
145421
  const imageMetaWithTransform = imageMeta.map((meta2, j) => {
145128
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
145422
+ var _a3, _b2, _c, _d, _e, _f, _g, _h, _i;
145129
145423
  const source = sources[j];
145130
- const hasZPhyscialSize = (_c = (_b = (_a2 = source.meta) == null ? void 0 : _a2.physicalSizes) == null ? void 0 : _b.z) == null ? void 0 : _c.size;
145424
+ const hasZPhyscialSize = (_c = (_b2 = (_a3 = source.meta) == null ? void 0 : _a3.physicalSizes) == null ? void 0 : _b2.z) == null ? void 0 : _c.size;
145131
145425
  const sizes = [
145132
145426
  unit(`${(_d = source.meta) == null ? void 0 : _d.physicalSizes.x.size} ${(_e = source.meta) == null ? void 0 : _e.physicalSizes.x.unit}`.replace("µ", "u")),
145133
145427
  unit(`${(_f = source.meta) == null ? void 0 : _f.physicalSizes.y.size} ${(_g = source.meta) == null ? void 0 : _g.physicalSizes.y.unit}`.replace("µ", "u"))
@@ -145182,7 +145476,7 @@ function buildDefaultSelection(source) {
145182
145476
  }
145183
145477
  return selection;
145184
145478
  }
145185
- function isInterleaved(shape) {
145479
+ function isInterleaved$1(shape) {
145186
145480
  const lastDimSize = shape[shape.length - 1];
145187
145481
  return lastDimSize === 3 || lastDimSize === 4;
145188
145482
  }
@@ -145190,7 +145484,7 @@ async function initializeLayerChannels(loader, use3d) {
145190
145484
  const result = [];
145191
145485
  const source = getSourceFromLoader(loader);
145192
145486
  let defaultSelection = buildDefaultSelection(source);
145193
- defaultSelection = isInterleaved(source.shape) ? [{ ...defaultSelection[0], c: 0 }] : defaultSelection;
145487
+ defaultSelection = isInterleaved$1(source.shape) ? [{ ...defaultSelection[0], c: 0 }] : defaultSelection;
145194
145488
  const stats = await getMultiSelectionStats({
145195
145489
  loader: loader.data,
145196
145490
  selections: defaultSelection,
@@ -145231,9 +145525,9 @@ async function initializeRasterLayersAndChannels(rasterLayers, rasterRenderLayer
145231
145525
  const layerIndex = Math.floor(rasterLayers.length / 2);
145232
145526
  const loader = nextImageLoaders[layerIndex];
145233
145527
  const autoImageLayerDefPromise = initializeLayerChannels(loader).then((channels2) => {
145234
- var _a2, _b, _c, _d, _e;
145528
+ var _a3, _b2, _c, _d, _e;
145235
145529
  return Promise.resolve({
145236
- type: ((_b = (_a2 = nextImageMetaAndLayers[layerIndex]) == null ? void 0 : _a2.metadata) == null ? void 0 : _b.isBitmask) ? "bitmask" : "raster",
145530
+ type: ((_b2 = (_a3 = nextImageMetaAndLayers[layerIndex]) == null ? void 0 : _a3.metadata) == null ? void 0 : _b2.isBitmask) ? "bitmask" : "raster",
145237
145531
  index: layerIndex,
145238
145532
  ...DEFAULT_RASTER_LAYER_PROPS,
145239
145533
  channels: channels2.map((channel, j) => ({
@@ -145251,9 +145545,9 @@ async function initializeRasterLayersAndChannels(rasterLayers, rasterRenderLayer
145251
145545
  const layerIndex = globalIndicesOfRenderLayers[i2];
145252
145546
  const loader = nextImageLoaders[layerIndex];
145253
145547
  const autoImageLayerDefPromise = initializeLayerChannels(loader).then((channels2) => {
145254
- var _a2, _b, _c, _d, _e;
145548
+ var _a3, _b2, _c, _d, _e;
145255
145549
  return Promise.resolve({
145256
- type: ((_b = (_a2 = nextImageMetaAndLayers[layerIndex]) == null ? void 0 : _a2.metadata) == null ? void 0 : _b.isBitmask) ? "bitmask" : "raster",
145550
+ type: ((_b2 = (_a3 = nextImageMetaAndLayers[layerIndex]) == null ? void 0 : _a3.metadata) == null ? void 0 : _b2.isBitmask) ? "bitmask" : "raster",
145257
145551
  index: layerIndex,
145258
145552
  ...DEFAULT_RASTER_LAYER_PROPS,
145259
145553
  channels: channels2.map((channel, j) => ({
@@ -145342,7 +145636,7 @@ function hexToRgb(hex) {
145342
145636
  ];
145343
145637
  }
145344
145638
  function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
145345
- var _a2;
145639
+ var _a3;
145346
145640
  let result = [];
145347
145641
  if (Array.isArray(coordinateTransformations)) {
145348
145642
  result = coordinateTransformations.map((transform2) => {
@@ -145368,7 +145662,7 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
145368
145662
  return transform2;
145369
145663
  });
145370
145664
  }
145371
- if (Array.isArray((_a2 = datasets == null ? void 0 : datasets[0]) == null ? void 0 : _a2.coordinateTransformations)) {
145665
+ if (Array.isArray((_a3 = datasets == null ? void 0 : datasets[0]) == null ? void 0 : _a3.coordinateTransformations)) {
145372
145666
  result = [
145373
145667
  ...datasets[0].coordinateTransformations,
145374
145668
  ...result
@@ -145376,6 +145670,1490 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
145376
145670
  }
145377
145671
  return result;
145378
145672
  }
145673
+ class NodeNotFoundError extends Error {
145674
+ constructor(msg) {
145675
+ super(msg);
145676
+ this.name = "NodeNotFoundError";
145677
+ }
145678
+ }
145679
+ class KeyError extends Error {
145680
+ constructor(msg) {
145681
+ super(msg);
145682
+ this.name = "KeyError";
145683
+ }
145684
+ }
145685
+ class BoolArray {
145686
+ constructor(x2, byteOffset, length2) {
145687
+ __privateAdd(this, _bytes, void 0);
145688
+ if (typeof x2 === "number") {
145689
+ __privateSet(this, _bytes, new Uint8Array(x2));
145690
+ } else if (x2 instanceof ArrayBuffer) {
145691
+ __privateSet(this, _bytes, new Uint8Array(x2, byteOffset, length2));
145692
+ } else {
145693
+ __privateSet(this, _bytes, new Uint8Array(Array.from(x2, (v) => v ? 1 : 0)));
145694
+ }
145695
+ }
145696
+ get BYTES_PER_ELEMENT() {
145697
+ return 1;
145698
+ }
145699
+ get byteOffset() {
145700
+ return __privateGet(this, _bytes).byteOffset;
145701
+ }
145702
+ get byteLength() {
145703
+ return __privateGet(this, _bytes).byteLength;
145704
+ }
145705
+ /** @type {ArrayBuffer} */
145706
+ get buffer() {
145707
+ return __privateGet(this, _bytes).buffer;
145708
+ }
145709
+ /** @type {number} */
145710
+ get length() {
145711
+ return __privateGet(this, _bytes).length;
145712
+ }
145713
+ get(idx) {
145714
+ let value = __privateGet(this, _bytes)[idx];
145715
+ return typeof value === "number" ? value !== 0 : value;
145716
+ }
145717
+ set(idx, value) {
145718
+ __privateGet(this, _bytes)[idx] = value ? 1 : 0;
145719
+ }
145720
+ fill(value) {
145721
+ __privateGet(this, _bytes).fill(value ? 1 : 0);
145722
+ }
145723
+ *[Symbol.iterator]() {
145724
+ for (let i2 = 0; i2 < this.length; i2++) {
145725
+ yield this.get(i2);
145726
+ }
145727
+ }
145728
+ }
145729
+ _bytes = new WeakMap();
145730
+ class ByteStringArray {
145731
+ constructor(chars, x2, byteOffset, length2) {
145732
+ __publicField(this, "_data");
145733
+ __publicField(this, "chars");
145734
+ __privateAdd(this, _encoder, void 0);
145735
+ this.chars = chars;
145736
+ __privateSet(this, _encoder, new TextEncoder());
145737
+ if (typeof x2 === "number") {
145738
+ this._data = new Uint8Array(x2 * chars);
145739
+ } else if (x2 instanceof ArrayBuffer) {
145740
+ if (length2)
145741
+ length2 = length2 * chars;
145742
+ this._data = new Uint8Array(x2, byteOffset, length2);
145743
+ } else {
145744
+ let values = Array.from(x2);
145745
+ this._data = new Uint8Array(values.length * chars);
145746
+ for (let i2 = 0; i2 < values.length; i2++) {
145747
+ this.set(i2, values[i2]);
145748
+ }
145749
+ }
145750
+ }
145751
+ get BYTES_PER_ELEMENT() {
145752
+ return this.chars;
145753
+ }
145754
+ get byteOffset() {
145755
+ return this._data.byteOffset;
145756
+ }
145757
+ get byteLength() {
145758
+ return this._data.byteLength;
145759
+ }
145760
+ /** @type {ArrayBuffer} */
145761
+ get buffer() {
145762
+ return this._data.buffer;
145763
+ }
145764
+ /** @type {number} */
145765
+ get length() {
145766
+ return this.byteLength / this.BYTES_PER_ELEMENT;
145767
+ }
145768
+ get(idx) {
145769
+ const view = new Uint8Array(this.buffer, this.byteOffset + this.chars * idx, this.chars);
145770
+ return new TextDecoder().decode(view).replace(/\x00/g, "");
145771
+ }
145772
+ set(idx, value) {
145773
+ const view = new Uint8Array(this.buffer, this.byteOffset + this.chars * idx, this.chars);
145774
+ view.fill(0);
145775
+ view.set(__privateGet(this, _encoder).encode(value));
145776
+ }
145777
+ fill(value) {
145778
+ const encoded = __privateGet(this, _encoder).encode(value);
145779
+ for (let i2 = 0; i2 < this.length; i2++) {
145780
+ this._data.set(encoded, i2 * this.chars);
145781
+ }
145782
+ }
145783
+ *[Symbol.iterator]() {
145784
+ for (let i2 = 0; i2 < this.length; i2++) {
145785
+ yield this.get(i2);
145786
+ }
145787
+ }
145788
+ }
145789
+ _encoder = new WeakMap();
145790
+ const _UnicodeStringArray = class {
145791
+ constructor(chars, x2, byteOffset, length2) {
145792
+ __publicField(this, "_data");
145793
+ __publicField(this, "chars");
145794
+ __privateAdd(this, _encode_buffer, void 0);
145795
+ this.chars = chars;
145796
+ if (typeof x2 === "number") {
145797
+ this._data = new Int32Array(x2 * chars);
145798
+ } else if (x2 instanceof ArrayBuffer) {
145799
+ if (length2)
145800
+ length2 *= chars;
145801
+ this._data = new Int32Array(x2, byteOffset, length2);
145802
+ } else {
145803
+ const values = x2;
145804
+ const d = new _UnicodeStringArray(chars, 1);
145805
+ this._data = new Int32Array(function* () {
145806
+ for (let str of values) {
145807
+ d.set(0, str);
145808
+ yield* d._data;
145809
+ }
145810
+ }());
145811
+ }
145812
+ __privateSet(this, _encode_buffer, new Int32Array(chars));
145813
+ }
145814
+ get BYTES_PER_ELEMENT() {
145815
+ return this._data.BYTES_PER_ELEMENT * this.chars;
145816
+ }
145817
+ get byteLength() {
145818
+ return this._data.byteLength;
145819
+ }
145820
+ get byteOffset() {
145821
+ return this._data.byteOffset;
145822
+ }
145823
+ /** @type {ArrayBuffer} */
145824
+ get buffer() {
145825
+ return this._data.buffer;
145826
+ }
145827
+ /** @type {number} */
145828
+ get length() {
145829
+ return this._data.length / this.chars;
145830
+ }
145831
+ get(idx) {
145832
+ const offset = this.chars * idx;
145833
+ let result = "";
145834
+ for (let i2 = 0; i2 < this.chars; i2++) {
145835
+ result += String.fromCodePoint(this._data[offset + i2]);
145836
+ }
145837
+ return result.replace(/\u0000/g, "");
145838
+ }
145839
+ set(idx, value) {
145840
+ const offset = this.chars * idx;
145841
+ const view = this._data.subarray(offset, offset + this.chars);
145842
+ view.fill(0);
145843
+ for (let i2 = 0; i2 < this.chars; i2++) {
145844
+ view[i2] = value.codePointAt(i2) ?? 0;
145845
+ }
145846
+ }
145847
+ fill(value) {
145848
+ this.set(0, value);
145849
+ let encoded = this._data.subarray(0, this.chars);
145850
+ for (let i2 = 1; i2 < this.length; i2++) {
145851
+ this._data.set(encoded, i2 * this.chars);
145852
+ }
145853
+ }
145854
+ *[Symbol.iterator]() {
145855
+ for (let i2 = 0; i2 < this.length; i2++) {
145856
+ yield this.get(i2);
145857
+ }
145858
+ }
145859
+ };
145860
+ let UnicodeStringArray = _UnicodeStringArray;
145861
+ _encode_buffer = new WeakMap();
145862
+ function json_decode_object(bytes) {
145863
+ const str = new TextDecoder().decode(bytes);
145864
+ return JSON.parse(str);
145865
+ }
145866
+ function byteswap_inplace(view, bytes_per_element2) {
145867
+ const numFlips = bytes_per_element2 / 2;
145868
+ const endByteIndex = bytes_per_element2 - 1;
145869
+ let t2 = 0;
145870
+ for (let i2 = 0; i2 < view.length; i2 += bytes_per_element2) {
145871
+ for (let j = 0; j < numFlips; j += 1) {
145872
+ t2 = view[i2 + j];
145873
+ view[i2 + j] = view[i2 + endByteIndex - j];
145874
+ view[i2 + endByteIndex - j] = t2;
145875
+ }
145876
+ }
145877
+ }
145878
+ const CONSTRUCTORS = {
145879
+ int8: Int8Array,
145880
+ int16: Int16Array,
145881
+ int32: Int32Array,
145882
+ int64: globalThis.BigInt64Array,
145883
+ uint8: Uint8Array,
145884
+ uint16: Uint16Array,
145885
+ uint32: Uint32Array,
145886
+ uint64: globalThis.BigUint64Array,
145887
+ float32: Float32Array,
145888
+ float64: Float64Array,
145889
+ bool: BoolArray
145890
+ };
145891
+ const V2_STRING_REGEX = /v2:([US])(\d+)/;
145892
+ function get_ctr(data_type) {
145893
+ if (data_type === "v2:object") {
145894
+ return globalThis.Array;
145895
+ }
145896
+ let match = data_type.match(V2_STRING_REGEX);
145897
+ if (match) {
145898
+ let [, kind, chars] = match;
145899
+ return (kind === "U" ? UnicodeStringArray : ByteStringArray).bind(null, Number(chars));
145900
+ }
145901
+ let ctr = CONSTRUCTORS[data_type];
145902
+ if (!ctr) {
145903
+ throw new Error(`Unknown or unsupported data_type: ${data_type}`);
145904
+ }
145905
+ return ctr;
145906
+ }
145907
+ function get_strides(shape, order) {
145908
+ return (order === "C" ? row_major_stride : col_major_stride)(shape);
145909
+ }
145910
+ function row_major_stride(shape) {
145911
+ const ndim = shape.length;
145912
+ const stride = globalThis.Array(ndim);
145913
+ for (let i2 = ndim - 1, step = 1; i2 >= 0; i2--) {
145914
+ stride[i2] = step;
145915
+ step *= shape[i2];
145916
+ }
145917
+ return stride;
145918
+ }
145919
+ function col_major_stride(shape) {
145920
+ const ndim = shape.length;
145921
+ const stride = globalThis.Array(ndim);
145922
+ for (let i2 = 0, step = 1; i2 < ndim; i2++) {
145923
+ stride[i2] = step;
145924
+ step *= shape[i2];
145925
+ }
145926
+ return stride;
145927
+ }
145928
+ function create_chunk_key_encoder({ name: name2, configuration }) {
145929
+ if (name2 === "default") {
145930
+ return (chunk_coords) => ["c", ...chunk_coords].join(configuration.separator);
145931
+ }
145932
+ if (name2 === "v2") {
145933
+ return (chunk_coords) => chunk_coords.join(configuration.separator) || "0";
145934
+ }
145935
+ throw new Error(`Unknown chunk key encoding: ${name2}`);
145936
+ }
145937
+ function get_array_order(codecs) {
145938
+ var _a3;
145939
+ const maybe_transpose_codec = codecs.find((c) => c.name === "transpose");
145940
+ return ((_a3 = maybe_transpose_codec == null ? void 0 : maybe_transpose_codec.configuration) == null ? void 0 : _a3.order) === "F" ? "F" : "C";
145941
+ }
145942
+ const endian_regex = /^([<|>])(.*)$/;
145943
+ function coerce_dtype(dtype) {
145944
+ if (dtype === "|O") {
145945
+ return { data_type: "v2:object" };
145946
+ }
145947
+ let match = dtype.match(endian_regex);
145948
+ if (!match) {
145949
+ throw new Error(`Invalid dtype: ${dtype}`);
145950
+ }
145951
+ let [, endian, rest] = match;
145952
+ let data_type = {
145953
+ "b1": "bool",
145954
+ "i1": "int8",
145955
+ "u1": "uint8",
145956
+ "i2": "int16",
145957
+ "u2": "uint16",
145958
+ "i4": "int32",
145959
+ "u4": "uint32",
145960
+ "i8": "int64",
145961
+ "u8": "uint64",
145962
+ "f4": "float32",
145963
+ "f8": "float64"
145964
+ }[rest] ?? (rest.startsWith("S") || rest.startsWith("U") ? `v2:${rest}` : void 0);
145965
+ if (!data_type) {
145966
+ throw new Error(`Unsupported or unknown dtype: ${dtype}`);
145967
+ }
145968
+ if (endian === "|") {
145969
+ return { data_type };
145970
+ }
145971
+ return { data_type, endian: endian === "<" ? "little" : "big" };
145972
+ }
145973
+ function v2_to_v3_array_metadata(meta2, attributes = {}) {
145974
+ let codecs = [];
145975
+ let dtype = coerce_dtype(meta2.dtype);
145976
+ if (meta2.order === "F") {
145977
+ codecs.push({ name: "transpose", configuration: { order: "F" } });
145978
+ }
145979
+ if ("endian" in dtype && dtype.endian === "big") {
145980
+ codecs.push({ name: "bytes", configuration: { endian: "big" } });
145981
+ }
145982
+ for (let { id, ...configuration } of meta2.filters ?? []) {
145983
+ codecs.push({ name: id, configuration });
145984
+ }
145985
+ if (meta2.compressor) {
145986
+ let { id, ...configuration } = meta2.compressor;
145987
+ codecs.push({ name: id, configuration });
145988
+ }
145989
+ return {
145990
+ zarr_format: 3,
145991
+ node_type: "array",
145992
+ shape: meta2.shape,
145993
+ data_type: dtype.data_type,
145994
+ chunk_grid: {
145995
+ name: "regular",
145996
+ configuration: {
145997
+ chunk_shape: meta2.chunks
145998
+ }
145999
+ },
146000
+ chunk_key_encoding: {
146001
+ name: "v2",
146002
+ configuration: {
146003
+ separator: meta2.dimension_separator ?? "."
146004
+ }
146005
+ },
146006
+ codecs,
146007
+ fill_value: meta2.fill_value,
146008
+ attributes
146009
+ };
146010
+ }
146011
+ function v2_to_v3_group_metadata(_meta2, attributes = {}) {
146012
+ return {
146013
+ zarr_format: 3,
146014
+ node_type: "group",
146015
+ attributes
146016
+ };
146017
+ }
146018
+ function is_dtype(dtype, query) {
146019
+ if (query !== "number" && query !== "bigint" && query !== "boolean" && query !== "object" && query !== "string") {
146020
+ return dtype === query;
146021
+ }
146022
+ let is_boolean = dtype === "bool";
146023
+ if (query === "boolean")
146024
+ return is_boolean;
146025
+ let is_string = dtype.startsWith("v2:U") || dtype.startsWith("v2:S");
146026
+ if (query === "string")
146027
+ return is_string;
146028
+ let is_bigint = dtype === "int64" || dtype === "uint64";
146029
+ if (query === "bigint")
146030
+ return is_bigint;
146031
+ let is_object = dtype === "v2:object";
146032
+ if (query === "object")
146033
+ return is_object;
146034
+ return !is_string && !is_bigint && !is_boolean && !is_object;
146035
+ }
146036
+ function is_sharding_codec(codec) {
146037
+ return (codec == null ? void 0 : codec.name) === "sharding_indexed";
146038
+ }
146039
+ function ensure_correct_scalar(metadata) {
146040
+ if ((metadata.data_type === "uint64" || metadata.data_type === "int64") && metadata.fill_value != void 0) {
146041
+ return BigInt(metadata.fill_value);
146042
+ }
146043
+ return metadata.fill_value;
146044
+ }
146045
+ function proxy(arr) {
146046
+ if (arr instanceof BoolArray || arr instanceof ByteStringArray || arr instanceof UnicodeStringArray) {
146047
+ return new Proxy(arr, {
146048
+ get(target, prop) {
146049
+ return target.get(Number(prop));
146050
+ },
146051
+ set(target, prop, value) {
146052
+ target.set(Number(prop), value);
146053
+ return true;
146054
+ }
146055
+ });
146056
+ }
146057
+ return arr;
146058
+ }
146059
+ function empty_like(chunk, order) {
146060
+ let data;
146061
+ if (chunk.data instanceof ByteStringArray || chunk.data instanceof UnicodeStringArray) {
146062
+ data = new chunk.constructor(
146063
+ // @ts-expect-error
146064
+ chunk.data.length,
146065
+ chunk.data.chars
146066
+ );
146067
+ } else {
146068
+ data = new chunk.constructor(chunk.data.length);
146069
+ }
146070
+ return {
146071
+ data,
146072
+ shape: chunk.shape,
146073
+ stride: get_strides(chunk.shape, order)
146074
+ };
146075
+ }
146076
+ function convert_array_order(src2, target) {
146077
+ let out = empty_like(src2, target);
146078
+ let n_dims = src2.shape.length;
146079
+ let size2 = src2.data.length;
146080
+ let index2 = Array(n_dims).fill(0);
146081
+ let src_data = proxy(src2.data);
146082
+ let out_data = proxy(out.data);
146083
+ for (let src_idx = 0; src_idx < size2; src_idx++) {
146084
+ let out_idx = 0;
146085
+ for (let dim = 0; dim < n_dims; dim++) {
146086
+ out_idx += index2[dim] * out.stride[dim];
146087
+ }
146088
+ out_data[out_idx] = src_data[src_idx];
146089
+ index2[0] += 1;
146090
+ for (let dim = 0; dim < n_dims; dim++) {
146091
+ if (index2[dim] === src2.shape[dim]) {
146092
+ if (dim + 1 === n_dims) {
146093
+ break;
146094
+ }
146095
+ index2[dim] = 0;
146096
+ index2[dim + 1] += 1;
146097
+ }
146098
+ }
146099
+ }
146100
+ return out;
146101
+ }
146102
+ function get_order(arr) {
146103
+ if (!arr.stride)
146104
+ return "C";
146105
+ let row_major_strides = get_strides(arr.shape, "C");
146106
+ return arr.stride.every((s2, i2) => s2 === row_major_strides[i2]) ? "C" : "F";
146107
+ }
146108
+ class TransposeCodec {
146109
+ constructor(configuration) {
146110
+ __publicField(this, "configuration");
146111
+ __publicField(this, "kind", "array_to_array");
146112
+ this.configuration = configuration;
146113
+ }
146114
+ static fromConfig(configuration) {
146115
+ return new TransposeCodec(configuration);
146116
+ }
146117
+ encode(arr) {
146118
+ if (get_order(arr) === this.configuration.order) {
146119
+ return arr;
146120
+ }
146121
+ return convert_array_order(arr, this.configuration.order);
146122
+ }
146123
+ decode(arr) {
146124
+ return arr;
146125
+ }
146126
+ }
146127
+ const LITTLE_ENDIAN_OS = system_is_little_endian();
146128
+ function system_is_little_endian() {
146129
+ const a2 = new Uint32Array([305419896]);
146130
+ const b = new Uint8Array(a2.buffer, a2.byteOffset, a2.byteLength);
146131
+ return !(b[0] === 18);
146132
+ }
146133
+ function bytes_per_element(TypedArray2) {
146134
+ if ("BYTES_PER_ELEMENT" in TypedArray2) {
146135
+ return TypedArray2.BYTES_PER_ELEMENT;
146136
+ }
146137
+ return 4;
146138
+ }
146139
+ const _BytesCodec = class {
146140
+ constructor(configuration, meta2) {
146141
+ __publicField(this, "kind", "array_to_bytes");
146142
+ __privateAdd(this, _strides, void 0);
146143
+ __privateAdd(this, _TypedArray, void 0);
146144
+ __privateAdd(this, _BYTES_PER_ELEMENT, void 0);
146145
+ __privateAdd(this, _shape, void 0);
146146
+ __privateAdd(this, _endian, void 0);
146147
+ __privateSet(this, _endian, configuration.endian);
146148
+ __privateSet(this, _TypedArray, get_ctr(meta2.data_type));
146149
+ __privateSet(this, _shape, meta2.shape);
146150
+ __privateSet(this, _strides, get_strides(meta2.shape, get_array_order(meta2.codecs)));
146151
+ const sample = new (__privateGet(this, _TypedArray))(0);
146152
+ __privateSet(this, _BYTES_PER_ELEMENT, sample.BYTES_PER_ELEMENT);
146153
+ }
146154
+ static fromConfig(configuration, meta2) {
146155
+ return new _BytesCodec(configuration, meta2);
146156
+ }
146157
+ encode(arr) {
146158
+ let bytes = new Uint8Array(arr.data.buffer);
146159
+ if (LITTLE_ENDIAN_OS && __privateGet(this, _endian) === "big") {
146160
+ byteswap_inplace(bytes, bytes_per_element(__privateGet(this, _TypedArray)));
146161
+ }
146162
+ return bytes;
146163
+ }
146164
+ decode(bytes) {
146165
+ if (LITTLE_ENDIAN_OS && __privateGet(this, _endian) === "big") {
146166
+ byteswap_inplace(bytes, bytes_per_element(__privateGet(this, _TypedArray)));
146167
+ }
146168
+ return {
146169
+ data: new (__privateGet(this, _TypedArray))(bytes.buffer, bytes.byteOffset, bytes.byteLength / __privateGet(this, _BYTES_PER_ELEMENT)),
146170
+ shape: __privateGet(this, _shape),
146171
+ stride: __privateGet(this, _strides)
146172
+ };
146173
+ }
146174
+ };
146175
+ let BytesCodec = _BytesCodec;
146176
+ _strides = new WeakMap();
146177
+ _TypedArray = new WeakMap();
146178
+ _BYTES_PER_ELEMENT = new WeakMap();
146179
+ _shape = new WeakMap();
146180
+ _endian = new WeakMap();
146181
+ class Crc32cCodec {
146182
+ constructor() {
146183
+ __publicField(this, "kind", "bytes_to_bytes");
146184
+ }
146185
+ static fromConfig() {
146186
+ return new Crc32cCodec();
146187
+ }
146188
+ encode(_) {
146189
+ throw new Error("Not implemented");
146190
+ }
146191
+ decode(arr) {
146192
+ return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength - 4);
146193
+ }
146194
+ }
146195
+ const _VLenUTF8 = class {
146196
+ constructor(shape) {
146197
+ __publicField(this, "kind", "array_to_bytes");
146198
+ __privateAdd(this, _shape2, void 0);
146199
+ __privateAdd(this, _strides2, void 0);
146200
+ __privateSet(this, _shape2, shape);
146201
+ __privateSet(this, _strides2, get_strides(shape, "C"));
146202
+ }
146203
+ static fromConfig(_, meta2) {
146204
+ return new _VLenUTF8(meta2.shape);
146205
+ }
146206
+ encode(_chunk) {
146207
+ throw new Error("Method not implemented.");
146208
+ }
146209
+ decode(bytes) {
146210
+ let decoder = new TextDecoder();
146211
+ let view = new DataView(bytes.buffer);
146212
+ let data = Array(view.getUint32(0, true));
146213
+ let pos = 4;
146214
+ for (let i2 = 0; i2 < data.length; i2++) {
146215
+ let item_length = view.getUint32(pos, true);
146216
+ pos += 4;
146217
+ data[i2] = decoder.decode(bytes.buffer.slice(pos, pos + item_length));
146218
+ pos += item_length;
146219
+ }
146220
+ return { data, shape: __privateGet(this, _shape2), stride: __privateGet(this, _strides2) };
146221
+ }
146222
+ };
146223
+ let VLenUTF8 = _VLenUTF8;
146224
+ _shape2 = new WeakMap();
146225
+ _strides2 = new WeakMap();
146226
+ function create_default_registry() {
146227
+ return (/* @__PURE__ */ new Map()).set("blosc", () => import("./blosc-0acfcf7e.js").then((m) => m.default)).set("gzip", () => import("./gzip-dd5ab7c8.js").then((m) => m.default)).set("lz4", () => import("./lz4-abb4416a.js").then((m) => m.default)).set("zlib", () => import("./zlib-cd823c38.js").then((m) => m.default)).set("zstd", () => import("./zstd-4072ca78.js").then((m) => m.default)).set("transpose", () => TransposeCodec).set("bytes", () => BytesCodec).set("crc32c", () => Crc32cCodec).set("vlen-utf8", () => VLenUTF8);
146228
+ }
146229
+ const registry = create_default_registry();
146230
+ function create_codec_pipeline(chunk_metadata) {
146231
+ let codecs;
146232
+ return {
146233
+ async encode(chunk) {
146234
+ if (!codecs)
146235
+ codecs = await load_codecs(chunk_metadata);
146236
+ for (const codec of codecs.array_to_array) {
146237
+ chunk = await codec.encode(chunk);
146238
+ }
146239
+ let bytes = await codecs.array_to_bytes.encode(chunk);
146240
+ for (const codec of codecs.bytes_to_bytes) {
146241
+ bytes = await codec.encode(bytes);
146242
+ }
146243
+ return bytes;
146244
+ },
146245
+ async decode(bytes) {
146246
+ if (!codecs)
146247
+ codecs = await load_codecs(chunk_metadata);
146248
+ for (let i2 = codecs.bytes_to_bytes.length - 1; i2 >= 0; i2--) {
146249
+ bytes = await codecs.bytes_to_bytes[i2].decode(bytes);
146250
+ }
146251
+ let chunk = await codecs.array_to_bytes.decode(bytes);
146252
+ for (let i2 = codecs.array_to_array.length - 1; i2 >= 0; i2--) {
146253
+ chunk = await codecs.array_to_array[i2].decode(chunk);
146254
+ }
146255
+ return chunk;
146256
+ }
146257
+ };
146258
+ }
146259
+ async function load_codecs(chunk_meta) {
146260
+ let promises = chunk_meta.codecs.map(async (meta2) => {
146261
+ var _a3;
146262
+ let Codec = await ((_a3 = registry.get(meta2.name)) == null ? void 0 : _a3());
146263
+ if (!Codec) {
146264
+ throw new Error(`Unknown codec: ${meta2.name}`);
146265
+ }
146266
+ return { Codec, meta: meta2 };
146267
+ });
146268
+ let array_to_array = [];
146269
+ let array_to_bytes;
146270
+ let bytes_to_bytes = [];
146271
+ for await (let { Codec, meta: meta2 } of promises) {
146272
+ let codec = Codec.fromConfig(meta2.configuration, chunk_meta);
146273
+ switch (codec.kind) {
146274
+ case "array_to_array":
146275
+ array_to_array.push(codec);
146276
+ break;
146277
+ case "array_to_bytes":
146278
+ array_to_bytes = codec;
146279
+ break;
146280
+ default:
146281
+ bytes_to_bytes.push(codec);
146282
+ }
146283
+ }
146284
+ if (!array_to_bytes) {
146285
+ if (!is_typed_array_like_meta(chunk_meta)) {
146286
+ throw new Error(`Cannot encode ${chunk_meta.data_type} to bytes without a codec`);
146287
+ }
146288
+ array_to_bytes = BytesCodec.fromConfig({ endian: "little" }, chunk_meta);
146289
+ }
146290
+ return { array_to_array, array_to_bytes, bytes_to_bytes };
146291
+ }
146292
+ function is_typed_array_like_meta(meta2) {
146293
+ return meta2.data_type !== "v2:object";
146294
+ }
146295
+ const MAX_BIG_UINT = 18446744073709551615n;
146296
+ function create_sharded_chunk_getter(location, shard_shape, encode_shard_key, sharding_config) {
146297
+ if (location.store.getRange === void 0) {
146298
+ throw new Error("Store does not support range requests");
146299
+ }
146300
+ let get_range = location.store.getRange.bind(location.store);
146301
+ let index_shape = shard_shape.map((d, i2) => d / sharding_config.chunk_shape[i2]);
146302
+ let index_codec = create_codec_pipeline({
146303
+ data_type: "uint64",
146304
+ shape: [...index_shape, 2],
146305
+ codecs: sharding_config.index_codecs
146306
+ });
146307
+ let cache2 = {};
146308
+ return async (chunk_coord) => {
146309
+ let shard_coord = chunk_coord.map((d, i2) => Math.floor(d / index_shape[i2]));
146310
+ let shard_path = location.resolve(encode_shard_key(shard_coord)).path;
146311
+ let index2;
146312
+ if (shard_path in cache2) {
146313
+ index2 = cache2[shard_path];
146314
+ } else {
146315
+ let checksum_size = 4;
146316
+ let index_size = 16 * index_shape.reduce((a2, b) => a2 * b, 1);
146317
+ let bytes = await get_range(shard_path, {
146318
+ suffixLength: index_size + checksum_size
146319
+ });
146320
+ index2 = cache2[shard_path] = bytes ? await index_codec.decode(bytes) : null;
146321
+ }
146322
+ if (index2 === null) {
146323
+ return void 0;
146324
+ }
146325
+ let { data, shape, stride } = index2;
146326
+ let linear_offset = chunk_coord.map((d, i2) => d % shape[i2]).reduce((acc, sel, idx) => acc + sel * stride[idx], 0);
146327
+ let offset = data[linear_offset];
146328
+ let length2 = data[linear_offset + 1];
146329
+ if (offset === MAX_BIG_UINT && length2 === MAX_BIG_UINT) {
146330
+ return void 0;
146331
+ }
146332
+ return get_range(shard_path, {
146333
+ offset: Number(offset),
146334
+ length: Number(length2)
146335
+ });
146336
+ };
146337
+ }
146338
+ class Location {
146339
+ constructor(store, path = "/") {
146340
+ __publicField(this, "store");
146341
+ __publicField(this, "path");
146342
+ this.store = store;
146343
+ this.path = path;
146344
+ }
146345
+ resolve(path) {
146346
+ let root2 = new URL(`file://${this.path.endsWith("/") ? this.path : `${this.path}/`}`);
146347
+ return new Location(this.store, new URL(path, root2).pathname);
146348
+ }
146349
+ }
146350
+ function root(store) {
146351
+ return new Location(store ?? /* @__PURE__ */ new Map());
146352
+ }
146353
+ class Group extends Location {
146354
+ constructor(store, path, metadata) {
146355
+ super(store, path);
146356
+ __publicField(this, "kind", "group");
146357
+ __privateAdd(this, _metadata, void 0);
146358
+ __privateSet(this, _metadata, metadata);
146359
+ }
146360
+ get attrs() {
146361
+ return __privateGet(this, _metadata).attributes;
146362
+ }
146363
+ }
146364
+ _metadata = new WeakMap();
146365
+ const CONTEXT_MARKER = Symbol("zarrita.context");
146366
+ function get_context(obj) {
146367
+ return obj[CONTEXT_MARKER];
146368
+ }
146369
+ function create_context(location, metadata) {
146370
+ let { configuration } = metadata.codecs.find(is_sharding_codec) ?? {};
146371
+ let shared_context = {
146372
+ encode_chunk_key: create_chunk_key_encoder(metadata.chunk_key_encoding),
146373
+ TypedArray: get_ctr(metadata.data_type),
146374
+ fill_value: metadata.fill_value
146375
+ };
146376
+ if (configuration) {
146377
+ let native_order2 = get_array_order(configuration.codecs);
146378
+ return {
146379
+ ...shared_context,
146380
+ kind: "sharded",
146381
+ chunk_shape: configuration.chunk_shape,
146382
+ codec: create_codec_pipeline({
146383
+ data_type: metadata.data_type,
146384
+ shape: configuration.chunk_shape,
146385
+ codecs: configuration.codecs
146386
+ }),
146387
+ get_strides(shape, order) {
146388
+ return get_strides(shape, order ?? native_order2);
146389
+ },
146390
+ get_chunk_bytes: create_sharded_chunk_getter(location, metadata.chunk_grid.configuration.chunk_shape, shared_context.encode_chunk_key, configuration)
146391
+ };
146392
+ }
146393
+ let native_order = get_array_order(metadata.codecs);
146394
+ return {
146395
+ ...shared_context,
146396
+ kind: "regular",
146397
+ chunk_shape: metadata.chunk_grid.configuration.chunk_shape,
146398
+ codec: create_codec_pipeline({
146399
+ data_type: metadata.data_type,
146400
+ shape: metadata.chunk_grid.configuration.chunk_shape,
146401
+ codecs: metadata.codecs
146402
+ }),
146403
+ get_strides(shape, order) {
146404
+ return get_strides(shape, order ?? native_order);
146405
+ },
146406
+ async get_chunk_bytes(chunk_coords, options) {
146407
+ let chunk_key = shared_context.encode_chunk_key(chunk_coords);
146408
+ let chunk_path = location.resolve(chunk_key).path;
146409
+ return location.store.get(chunk_path, options);
146410
+ }
146411
+ };
146412
+ }
146413
+ let Array$1 = (_b = class extends Location {
146414
+ constructor(store, path, metadata) {
146415
+ super(store, path);
146416
+ __publicField(this, "kind", "array");
146417
+ __privateAdd(this, _metadata2, void 0);
146418
+ __publicField(this, _a2);
146419
+ __privateSet(this, _metadata2, {
146420
+ ...metadata,
146421
+ fill_value: ensure_correct_scalar(metadata)
146422
+ });
146423
+ this[CONTEXT_MARKER] = create_context(this, metadata);
146424
+ }
146425
+ get attrs() {
146426
+ return __privateGet(this, _metadata2).attributes;
146427
+ }
146428
+ get shape() {
146429
+ return __privateGet(this, _metadata2).shape;
146430
+ }
146431
+ get chunks() {
146432
+ return this[CONTEXT_MARKER].chunk_shape;
146433
+ }
146434
+ get dtype() {
146435
+ return __privateGet(this, _metadata2).data_type;
146436
+ }
146437
+ async getChunk(chunk_coords, options) {
146438
+ let context = this[CONTEXT_MARKER];
146439
+ let maybe_bytes = await context.get_chunk_bytes(chunk_coords, options);
146440
+ if (!maybe_bytes) {
146441
+ let size2 = context.chunk_shape.reduce((a2, b) => a2 * b, 1);
146442
+ let data = new context.TypedArray(size2);
146443
+ data.fill(context.fill_value);
146444
+ return {
146445
+ data,
146446
+ shape: context.chunk_shape,
146447
+ stride: context.get_strides(context.chunk_shape)
146448
+ };
146449
+ }
146450
+ return context.codec.decode(maybe_bytes);
146451
+ }
146452
+ /**
146453
+ * A helper method to narrow `zarr.Array` Dtype.
146454
+ *
146455
+ * ```typescript
146456
+ * let arr: zarr.Array<DataType, FetchStore> = zarr.open(store, { kind: "array" });
146457
+ *
146458
+ * // Option 1: narrow by scalar type (e.g. "bool", "raw", "bigint", "number")
146459
+ * if (arr.is("bigint")) {
146460
+ * // zarr.Array<"int64" | "uint64", FetchStore>
146461
+ * }
146462
+ *
146463
+ * // Option 3: exact match
146464
+ * if (arr.is("float32")) {
146465
+ * // zarr.Array<"float32", FetchStore, "/">
146466
+ * }
146467
+ * ```
146468
+ */
146469
+ is(query) {
146470
+ return is_dtype(this.dtype, query);
146471
+ }
146472
+ }, _a2 = CONTEXT_MARKER, _metadata2 = new WeakMap(), _b);
146473
+ function create_version_counter() {
146474
+ let version_counts = /* @__PURE__ */ new WeakMap();
146475
+ function get_counts(store) {
146476
+ let counts = version_counts.get(store) ?? { v2: 0, v3: 0 };
146477
+ version_counts.set(store, counts);
146478
+ return counts;
146479
+ }
146480
+ return {
146481
+ increment(store, version2) {
146482
+ get_counts(store)[version2] += 1;
146483
+ },
146484
+ version_max(store) {
146485
+ let counts = get_counts(store);
146486
+ return counts.v3 > counts.v2 ? "v3" : "v2";
146487
+ }
146488
+ };
146489
+ }
146490
+ let VERSION_COUNTER = create_version_counter();
146491
+ async function load_attrs(location) {
146492
+ let meta_bytes = await location.store.get(location.resolve(".zattrs").path);
146493
+ if (!meta_bytes)
146494
+ return {};
146495
+ return json_decode_object(meta_bytes);
146496
+ }
146497
+ async function open_v2(location, options = {}) {
146498
+ let loc = "store" in location ? location : new Location(location);
146499
+ let attrs = {};
146500
+ if (options.attrs ?? true)
146501
+ attrs = await load_attrs(loc);
146502
+ if (options.kind === "array")
146503
+ return open_array_v2(loc, attrs);
146504
+ if (options.kind === "group")
146505
+ return open_group_v2(loc, attrs);
146506
+ return open_array_v2(loc, attrs).catch((err2) => {
146507
+ if (err2 instanceof NodeNotFoundError)
146508
+ return open_group_v2(loc, attrs);
146509
+ throw err2;
146510
+ });
146511
+ }
146512
+ async function open_array_v2(location, attrs) {
146513
+ let { path } = location.resolve(".zarray");
146514
+ let meta2 = await location.store.get(path);
146515
+ if (!meta2) {
146516
+ throw new NodeNotFoundError(path);
146517
+ }
146518
+ VERSION_COUNTER.increment(location.store, "v2");
146519
+ return new Array$1(location.store, location.path, v2_to_v3_array_metadata(json_decode_object(meta2), attrs));
146520
+ }
146521
+ async function open_group_v2(location, attrs) {
146522
+ let { path } = location.resolve(".zgroup");
146523
+ let meta2 = await location.store.get(path);
146524
+ if (!meta2) {
146525
+ throw new NodeNotFoundError(path);
146526
+ }
146527
+ VERSION_COUNTER.increment(location.store, "v2");
146528
+ return new Group(location.store, location.path, v2_to_v3_group_metadata(json_decode_object(meta2), attrs));
146529
+ }
146530
+ async function _open_v3(location) {
146531
+ let { store, path } = location.resolve("zarr.json");
146532
+ let meta2 = await location.store.get(path);
146533
+ if (!meta2) {
146534
+ throw new NodeNotFoundError(path);
146535
+ }
146536
+ let meta_doc = json_decode_object(meta2);
146537
+ if (meta_doc.node_type === "array" && (meta_doc.data_type === "uint64" || meta_doc.data_type === "int64") && meta_doc.fill_value != void 0) {
146538
+ meta_doc.fill_value = BigInt(meta_doc.fill_value);
146539
+ }
146540
+ return meta_doc.node_type === "array" ? new Array$1(store, location.path, meta_doc) : new Group(store, location.path, meta_doc);
146541
+ }
146542
+ async function open_v3(location, options = {}) {
146543
+ let loc = "store" in location ? location : new Location(location);
146544
+ let node2 = await _open_v3(loc);
146545
+ VERSION_COUNTER.increment(loc.store, "v3");
146546
+ if (options.kind === void 0)
146547
+ return node2;
146548
+ if (options.kind === "array" && node2 instanceof Array$1)
146549
+ return node2;
146550
+ if (options.kind === "group" && node2 instanceof Group)
146551
+ return node2;
146552
+ let kind = node2 instanceof Array$1 ? "array" : "group";
146553
+ throw new Error(`Expected node of kind ${options.kind}, found ${kind}.`);
146554
+ }
146555
+ async function open(location, options = {}) {
146556
+ const store = "store" in location ? location.store : location;
146557
+ const version_max = VERSION_COUNTER.version_max(store);
146558
+ let open_primary = version_max === "v2" ? open.v2 : open.v3;
146559
+ let open_secondary = version_max === "v2" ? open.v3 : open.v2;
146560
+ return open_primary(location, options).catch((err2) => {
146561
+ if (err2 instanceof NodeNotFoundError) {
146562
+ return open_secondary(location, options);
146563
+ }
146564
+ throw err2;
146565
+ });
146566
+ }
146567
+ open.v2 = open_v2;
146568
+ open.v3 = open_v3;
146569
+ function* range(start, stop, step = 1) {
146570
+ if (stop === void 0) {
146571
+ stop = start;
146572
+ start = 0;
146573
+ }
146574
+ for (let i2 = start; i2 < stop; i2 += step) {
146575
+ yield i2;
146576
+ }
146577
+ }
146578
+ function* product(...iterables) {
146579
+ if (iterables.length === 0) {
146580
+ return;
146581
+ }
146582
+ const iterators = iterables.map((it) => it[Symbol.iterator]());
146583
+ const results = iterators.map((it) => it.next());
146584
+ if (results.some((r2) => r2.done)) {
146585
+ throw new Error("Input contains an empty iterator.");
146586
+ }
146587
+ for (let i2 = 0; ; ) {
146588
+ if (results[i2].done) {
146589
+ iterators[i2] = iterables[i2][Symbol.iterator]();
146590
+ results[i2] = iterators[i2].next();
146591
+ if (++i2 >= iterators.length) {
146592
+ return;
146593
+ }
146594
+ } else {
146595
+ yield results.map(({ value }) => value);
146596
+ i2 = 0;
146597
+ }
146598
+ results[i2] = iterators[i2].next();
146599
+ }
146600
+ }
146601
+ function slice_indices(start, stop, step, length2) {
146602
+ if (step === 0) {
146603
+ throw new Error("slice step cannot be zero");
146604
+ }
146605
+ step = step ?? 1;
146606
+ const step_is_negative = step < 0;
146607
+ const [lower, upper] = step_is_negative ? [-1, length2 - 1] : [0, length2];
146608
+ if (start === null) {
146609
+ start = step_is_negative ? upper : lower;
146610
+ } else {
146611
+ if (start < 0) {
146612
+ start += length2;
146613
+ if (start < lower) {
146614
+ start = lower;
146615
+ }
146616
+ } else if (start > upper) {
146617
+ start = upper;
146618
+ }
146619
+ }
146620
+ if (stop === null) {
146621
+ stop = step_is_negative ? lower : upper;
146622
+ } else {
146623
+ if (stop < 0) {
146624
+ stop += length2;
146625
+ if (stop < lower) {
146626
+ stop = lower;
146627
+ }
146628
+ } else if (stop > upper) {
146629
+ stop = upper;
146630
+ }
146631
+ }
146632
+ return [start, stop, step];
146633
+ }
146634
+ function slice(start, stop, step = null) {
146635
+ if (stop === void 0) {
146636
+ stop = start;
146637
+ start = null;
146638
+ }
146639
+ return {
146640
+ start,
146641
+ stop,
146642
+ step,
146643
+ indices(length2) {
146644
+ return slice_indices(this.start, this.stop, this.step, length2);
146645
+ }
146646
+ };
146647
+ }
146648
+ function create_queue() {
146649
+ const promises = [];
146650
+ return {
146651
+ add: (fn) => promises.push(fn()),
146652
+ onIdle: () => Promise.all(promises)
146653
+ };
146654
+ }
146655
+ class IndexError extends Error {
146656
+ constructor(msg) {
146657
+ super(msg);
146658
+ this.name = "IndexError";
146659
+ }
146660
+ }
146661
+ function err_too_many_indices(selection, shape) {
146662
+ throw new IndexError(`too many indicies for array; expected ${shape.length}, got ${selection.length}`);
146663
+ }
146664
+ function err_boundscheck(dim_len) {
146665
+ throw new IndexError(`index out of bounds for dimension with length ${dim_len}`);
146666
+ }
146667
+ function err_negative_step() {
146668
+ throw new IndexError("only slices with step >= 1 are supported");
146669
+ }
146670
+ function check_selection_length(selection, shape) {
146671
+ if (selection.length > shape.length) {
146672
+ err_too_many_indices(selection, shape);
146673
+ }
146674
+ }
146675
+ function normalize_integer_selection(dim_sel, dim_len) {
146676
+ dim_sel = Math.trunc(dim_sel);
146677
+ if (dim_sel < 0) {
146678
+ dim_sel = dim_len + dim_sel;
146679
+ }
146680
+ if (dim_sel >= dim_len || dim_sel < 0) {
146681
+ err_boundscheck(dim_len);
146682
+ }
146683
+ return dim_sel;
146684
+ }
146685
+ class IntDimIndexer {
146686
+ constructor({ dim_sel, dim_len, dim_chunk_len }) {
146687
+ __publicField(this, "dim_sel");
146688
+ __publicField(this, "dim_len");
146689
+ __publicField(this, "dim_chunk_len");
146690
+ __publicField(this, "nitems");
146691
+ dim_sel = normalize_integer_selection(dim_sel, dim_len);
146692
+ this.dim_sel = dim_sel;
146693
+ this.dim_len = dim_len;
146694
+ this.dim_chunk_len = dim_chunk_len;
146695
+ this.nitems = 1;
146696
+ }
146697
+ *[Symbol.iterator]() {
146698
+ const dim_chunk_ix = Math.floor(this.dim_sel / this.dim_chunk_len);
146699
+ const dim_offset = dim_chunk_ix * this.dim_chunk_len;
146700
+ const dim_chunk_sel = this.dim_sel - dim_offset;
146701
+ yield { dim_chunk_ix, dim_chunk_sel };
146702
+ }
146703
+ }
146704
+ class SliceDimIndexer {
146705
+ constructor({ dim_sel, dim_len, dim_chunk_len }) {
146706
+ __publicField(this, "start");
146707
+ __publicField(this, "stop");
146708
+ __publicField(this, "step");
146709
+ __publicField(this, "dim_len");
146710
+ __publicField(this, "dim_chunk_len");
146711
+ __publicField(this, "nitems");
146712
+ __publicField(this, "nchunks");
146713
+ const [start, stop, step] = dim_sel.indices(dim_len);
146714
+ this.start = start;
146715
+ this.stop = stop;
146716
+ this.step = step;
146717
+ if (this.step < 1)
146718
+ err_negative_step();
146719
+ this.dim_len = dim_len;
146720
+ this.dim_chunk_len = dim_chunk_len;
146721
+ this.nitems = Math.max(0, Math.ceil((this.stop - this.start) / this.step));
146722
+ this.nchunks = Math.ceil(this.dim_len / this.dim_chunk_len);
146723
+ }
146724
+ *[Symbol.iterator]() {
146725
+ const dim_chunk_ix_from = Math.floor(this.start / this.dim_chunk_len);
146726
+ const dim_chunk_ix_to = Math.ceil(this.stop / this.dim_chunk_len);
146727
+ for (const dim_chunk_ix of range(dim_chunk_ix_from, dim_chunk_ix_to)) {
146728
+ const dim_offset = dim_chunk_ix * this.dim_chunk_len;
146729
+ const dim_limit = Math.min(this.dim_len, (dim_chunk_ix + 1) * this.dim_chunk_len);
146730
+ const dim_chunk_len = dim_limit - dim_offset;
146731
+ let dim_out_offset = 0;
146732
+ let dim_chunk_sel_start = 0;
146733
+ if (this.start < dim_offset) {
146734
+ const remainder = (dim_offset - this.start) % this.step;
146735
+ if (remainder)
146736
+ dim_chunk_sel_start += this.step - remainder;
146737
+ dim_out_offset = Math.ceil((dim_offset - this.start) / this.step);
146738
+ } else {
146739
+ dim_chunk_sel_start = this.start - dim_offset;
146740
+ }
146741
+ const dim_chunk_sel_stop = this.stop > dim_limit ? dim_chunk_len : this.stop - dim_offset;
146742
+ const dim_chunk_sel = [
146743
+ dim_chunk_sel_start,
146744
+ dim_chunk_sel_stop,
146745
+ this.step
146746
+ ];
146747
+ const dim_chunk_nitems = Math.ceil((dim_chunk_sel_stop - dim_chunk_sel_start) / this.step);
146748
+ const dim_out_sel = [
146749
+ dim_out_offset,
146750
+ dim_out_offset + dim_chunk_nitems,
146751
+ 1
146752
+ ];
146753
+ yield { dim_chunk_ix, dim_chunk_sel, dim_out_sel };
146754
+ }
146755
+ }
146756
+ }
146757
+ function normalize_selection(selection, shape) {
146758
+ let normalized = [];
146759
+ if (selection === null) {
146760
+ normalized = shape.map((_) => slice(null));
146761
+ } else if (Array.isArray(selection)) {
146762
+ normalized = selection.map((s2) => s2 ?? slice(null));
146763
+ }
146764
+ check_selection_length(normalized, shape);
146765
+ return normalized;
146766
+ }
146767
+ class BasicIndexer {
146768
+ constructor({ selection, shape, chunk_shape }) {
146769
+ __publicField(this, "dim_indexers");
146770
+ __publicField(this, "shape");
146771
+ this.dim_indexers = normalize_selection(selection, shape).map((dim_sel, i2) => {
146772
+ return new (typeof dim_sel === "number" ? IntDimIndexer : SliceDimIndexer)({
146773
+ // @ts-expect-error ts inference not strong enough to know correct chunk
146774
+ dim_sel,
146775
+ dim_len: shape[i2],
146776
+ dim_chunk_len: chunk_shape[i2]
146777
+ });
146778
+ });
146779
+ this.shape = this.dim_indexers.filter((ixr) => ixr instanceof SliceDimIndexer).map((sixr) => sixr.nitems);
146780
+ }
146781
+ *[Symbol.iterator]() {
146782
+ for (const dim_projections of product(...this.dim_indexers)) {
146783
+ const chunk_coords = dim_projections.map((p) => p.dim_chunk_ix);
146784
+ const mapping = dim_projections.map((p) => {
146785
+ if ("dim_out_sel" in p) {
146786
+ return { from: p.dim_chunk_sel, to: p.dim_out_sel };
146787
+ }
146788
+ return { from: p.dim_chunk_sel, to: null };
146789
+ });
146790
+ yield { chunk_coords, mapping };
146791
+ }
146792
+ }
146793
+ }
146794
+ function unwrap(arr, idx) {
146795
+ return "get" in arr ? arr.get(idx) : arr[idx];
146796
+ }
146797
+ async function get$1(arr, selection, opts2, setter2) {
146798
+ var _a3;
146799
+ const context = get_context(arr);
146800
+ const indexer = new BasicIndexer({
146801
+ selection,
146802
+ shape: arr.shape,
146803
+ chunk_shape: arr.chunks
146804
+ });
146805
+ const out = setter2.prepare(new context.TypedArray(indexer.shape.reduce((a2, b) => a2 * b, 1)), indexer.shape, context.get_strides(indexer.shape, opts2.order));
146806
+ const queue = ((_a3 = opts2.create_queue) == null ? void 0 : _a3.call(opts2)) ?? create_queue();
146807
+ for (const { chunk_coords, mapping } of indexer) {
146808
+ queue.add(() => arr.getChunk(chunk_coords, opts2.opts).then(({ data, shape, stride }) => {
146809
+ const chunk = setter2.prepare(data, shape, stride);
146810
+ setter2.set_from_chunk(out, chunk, mapping);
146811
+ }).catch((err2) => {
146812
+ if (!(err2 instanceof KeyError))
146813
+ throw err2;
146814
+ if (context.fill_value) {
146815
+ setter2.set_scalar(out, mapping.map((m) => m.to).filter((s2) => s2 !== null), context.fill_value);
146816
+ }
146817
+ }));
146818
+ }
146819
+ await queue.onIdle();
146820
+ return indexer.shape.length === 0 ? unwrap(out.data, 0) : out;
146821
+ }
146822
+ function object_array_view(arr, offset = 0, size2) {
146823
+ let length2 = size2 ?? arr.length - offset;
146824
+ return {
146825
+ length: length2,
146826
+ subarray(from, to = length2) {
146827
+ return object_array_view(arr, offset + from, to - from);
146828
+ },
146829
+ set(data, start = 0) {
146830
+ for (let i2 = 0; i2 < data.length; i2++) {
146831
+ arr[offset + start + i2] = data.get(i2);
146832
+ }
146833
+ },
146834
+ get(index2) {
146835
+ return arr[offset + index2];
146836
+ }
146837
+ };
146838
+ }
146839
+ function compat_chunk(arr) {
146840
+ if (arr.data instanceof globalThis.Array) {
146841
+ return {
146842
+ // @ts-expect-error
146843
+ data: object_array_view(arr.data),
146844
+ stride: arr.stride,
146845
+ bytes_per_element: 1
146846
+ };
146847
+ }
146848
+ return {
146849
+ data: new Uint8Array(arr.data.buffer, arr.data.byteOffset, arr.data.byteLength),
146850
+ stride: arr.stride,
146851
+ bytes_per_element: arr.data.BYTES_PER_ELEMENT
146852
+ };
146853
+ }
146854
+ function get_typed_array_constructor(arr) {
146855
+ if ("chars" in arr) {
146856
+ return arr.constructor.bind(null, arr.chars);
146857
+ }
146858
+ return arr.constructor;
146859
+ }
146860
+ function compat_scalar(arr, value) {
146861
+ if (arr.data instanceof globalThis.Array) {
146862
+ return object_array_view([value]);
146863
+ }
146864
+ let TypedArray2 = get_typed_array_constructor(arr.data);
146865
+ let data = new TypedArray2([value]);
146866
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
146867
+ }
146868
+ const setter = {
146869
+ prepare(data, shape, stride) {
146870
+ return { data, shape, stride };
146871
+ },
146872
+ set_scalar(dest, sel, value) {
146873
+ let view = compat_chunk(dest);
146874
+ set_scalar_binary(view, sel, compat_scalar(dest, value), view.bytes_per_element);
146875
+ },
146876
+ set_from_chunk(dest, src2, projections) {
146877
+ let view = compat_chunk(dest);
146878
+ set_from_chunk_binary(view, compat_chunk(src2), view.bytes_per_element, projections);
146879
+ }
146880
+ };
146881
+ async function get(arr, selection = null, opts2 = {}) {
146882
+ return get$1(arr, selection, opts2, setter);
146883
+ }
146884
+ function indices_len(start, stop, step) {
146885
+ if (step < 0 && stop < start) {
146886
+ return Math.floor((start - stop - 1) / -step) + 1;
146887
+ }
146888
+ if (start < stop)
146889
+ return Math.floor((stop - start - 1) / step) + 1;
146890
+ return 0;
146891
+ }
146892
+ function set_scalar_binary(out, out_selection, value, bytes_per_element2) {
146893
+ if (out_selection.length === 0) {
146894
+ out.data.set(value, 0);
146895
+ return;
146896
+ }
146897
+ const [slice2, ...slices] = out_selection;
146898
+ const [curr_stride, ...stride] = out.stride;
146899
+ if (typeof slice2 === "number") {
146900
+ const data = out.data.subarray(curr_stride * slice2 * bytes_per_element2);
146901
+ set_scalar_binary({ data, stride }, slices, value, bytes_per_element2);
146902
+ return;
146903
+ }
146904
+ const [from, to, step] = slice2;
146905
+ const len2 = indices_len(from, to, step);
146906
+ if (slices.length === 0) {
146907
+ for (let i2 = 0; i2 < len2; i2++) {
146908
+ out.data.set(value, curr_stride * (from + step * i2) * bytes_per_element2);
146909
+ }
146910
+ return;
146911
+ }
146912
+ for (let i2 = 0; i2 < len2; i2++) {
146913
+ const data = out.data.subarray(curr_stride * (from + step * i2) * bytes_per_element2);
146914
+ set_scalar_binary({ data, stride }, slices, value, bytes_per_element2);
146915
+ }
146916
+ }
146917
+ function set_from_chunk_binary(dest, src2, bytes_per_element2, projections) {
146918
+ const [proj, ...projs] = projections;
146919
+ const [dstride, ...dstrides] = dest.stride;
146920
+ const [sstride, ...sstrides] = src2.stride;
146921
+ if (proj.from === null) {
146922
+ if (projs.length === 0) {
146923
+ dest.data.set(src2.data.subarray(0, bytes_per_element2), proj.to * bytes_per_element2);
146924
+ return;
146925
+ }
146926
+ set_from_chunk_binary({
146927
+ data: dest.data.subarray(dstride * proj.to * bytes_per_element2),
146928
+ stride: dstrides
146929
+ }, src2, bytes_per_element2, projs);
146930
+ return;
146931
+ }
146932
+ if (proj.to === null) {
146933
+ if (projs.length === 0) {
146934
+ let offset = proj.from * bytes_per_element2;
146935
+ dest.data.set(src2.data.subarray(offset, offset + bytes_per_element2), 0);
146936
+ return;
146937
+ }
146938
+ set_from_chunk_binary(dest, {
146939
+ data: src2.data.subarray(sstride * proj.from * bytes_per_element2),
146940
+ stride: sstrides
146941
+ }, bytes_per_element2, projs);
146942
+ return;
146943
+ }
146944
+ const [from, to, step] = proj.to;
146945
+ const [sfrom, _, sstep] = proj.from;
146946
+ const len2 = indices_len(from, to, step);
146947
+ if (projs.length === 0) {
146948
+ if (step === 1 && sstep === 1 && dstride === 1 && sstride === 1) {
146949
+ let offset = sfrom * bytes_per_element2;
146950
+ let size2 = len2 * bytes_per_element2;
146951
+ dest.data.set(src2.data.subarray(offset, offset + size2), from * bytes_per_element2);
146952
+ return;
146953
+ }
146954
+ for (let i2 = 0; i2 < len2; i2++) {
146955
+ let offset = sstride * (sfrom + sstep * i2) * bytes_per_element2;
146956
+ dest.data.set(src2.data.subarray(offset, offset + bytes_per_element2), dstride * (from + step * i2) * bytes_per_element2);
146957
+ }
146958
+ return;
146959
+ }
146960
+ for (let i2 = 0; i2 < len2; i2++) {
146961
+ set_from_chunk_binary({
146962
+ data: dest.data.subarray(dstride * (from + i2 * step) * bytes_per_element2),
146963
+ stride: dstrides
146964
+ }, {
146965
+ data: src2.data.subarray(sstride * (sfrom + i2 * sstep) * bytes_per_element2),
146966
+ stride: sstrides
146967
+ }, bytes_per_element2, projs);
146968
+ }
146969
+ }
146970
+ function fetch_range(url, offset, length2, opts2 = {}) {
146971
+ if (offset !== void 0 && length2 !== void 0) {
146972
+ opts2 = {
146973
+ ...opts2,
146974
+ headers: {
146975
+ ...opts2.headers,
146976
+ Range: `bytes=${offset}-${offset + length2 - 1}`
146977
+ }
146978
+ };
146979
+ }
146980
+ return fetch(url, opts2);
146981
+ }
146982
+ function resolve(root2, path) {
146983
+ const base = typeof root2 === "string" ? new URL(root2) : root2;
146984
+ if (!base.pathname.endsWith("/")) {
146985
+ base.pathname += "/";
146986
+ }
146987
+ const resolved = new URL(path.slice(1), base);
146988
+ resolved.search = base.search;
146989
+ return resolved;
146990
+ }
146991
+ async function handle_response(response) {
146992
+ if (response.status === 404 || response.status === 403) {
146993
+ return void 0;
146994
+ }
146995
+ if (response.status == 200 || response.status == 206) {
146996
+ return new Uint8Array(await response.arrayBuffer());
146997
+ }
146998
+ throw new Error(`Unexpected response status ${response.status} ${response.statusText}`);
146999
+ }
147000
+ async function fetch_suffix(url, suffix_length, init, use_suffix_request) {
147001
+ if (use_suffix_request) {
147002
+ return fetch(url, {
147003
+ ...init,
147004
+ headers: { ...init.headers, Range: `bytes=-${suffix_length}` }
147005
+ });
147006
+ }
147007
+ let response = await fetch(url, { ...init, method: "HEAD" });
147008
+ if (!response.ok) {
147009
+ return response;
147010
+ }
147011
+ let content_length = response.headers.get("Content-Length");
147012
+ let length2 = Number(content_length);
147013
+ return fetch_range(url, length2 - suffix_length, length2, init);
147014
+ }
147015
+ class FetchStore {
147016
+ constructor(url, options = {}) {
147017
+ __privateAdd(this, _merge_init);
147018
+ __publicField(this, "url");
147019
+ __privateAdd(this, _overrides, void 0);
147020
+ __privateAdd(this, _use_suffix_request, void 0);
147021
+ this.url = url;
147022
+ __privateSet(this, _overrides, options.overrides ?? {});
147023
+ __privateSet(this, _use_suffix_request, options.useSuffixRequest ?? false);
147024
+ }
147025
+ async get(key, options = {}) {
147026
+ let href = resolve(this.url, key).href;
147027
+ let response = await fetch(href, __privateMethod(this, _merge_init, merge_init_fn).call(this, options));
147028
+ return handle_response(response);
147029
+ }
147030
+ async getRange(key, range2, options = {}) {
147031
+ let url = resolve(this.url, key);
147032
+ let init = __privateMethod(this, _merge_init, merge_init_fn).call(this, options);
147033
+ let response;
147034
+ if ("suffixLength" in range2) {
147035
+ response = await fetch_suffix(url, range2.suffixLength, init, __privateGet(this, _use_suffix_request));
147036
+ } else {
147037
+ response = await fetch_range(url, range2.offset, range2.length, init);
147038
+ }
147039
+ return handle_response(response);
147040
+ }
147041
+ }
147042
+ _overrides = new WeakMap();
147043
+ _use_suffix_request = new WeakMap();
147044
+ _merge_init = new WeakSet();
147045
+ merge_init_fn = function(overrides) {
147046
+ return {
147047
+ ...__privateGet(this, _overrides),
147048
+ ...overrides,
147049
+ headers: {
147050
+ ...__privateGet(this, _overrides).headers,
147051
+ ...overrides.headers
147052
+ }
147053
+ };
147054
+ };
147055
+ const FetchStore$1 = FetchStore;
147056
+ function getV2DataType(dtype) {
147057
+ const mapping = {
147058
+ int8: "|i1",
147059
+ uint8: "|u1",
147060
+ int16: "<i2",
147061
+ uint16: "<u2",
147062
+ int32: "<i4",
147063
+ uint32: "<u4",
147064
+ int64: "<i8",
147065
+ uint64: "<u8",
147066
+ float32: "<f4",
147067
+ float64: "<f8"
147068
+ };
147069
+ if (!(dtype in mapping)) {
147070
+ throw new Error(`Unsupported dtype ${dtype}`);
147071
+ }
147072
+ return mapping[dtype];
147073
+ }
147074
+ function createZarrArrayAdapter(arr) {
147075
+ return new Proxy(arr, {
147076
+ get(target, prop) {
147077
+ if (prop === "getRaw") {
147078
+ return (selection) => get(target, selection ? selection.map((s2) => {
147079
+ if (typeof s2 === "object" && s2 !== null) {
147080
+ return slice(s2.start, s2.stop, s2.step);
147081
+ }
147082
+ return s2;
147083
+ }) : target.shape.map(() => null));
147084
+ }
147085
+ if (prop === "getRawChunk") {
147086
+ throw new Error("getRawChunk should not have been called");
147087
+ }
147088
+ if (prop === "dtype") {
147089
+ return getV2DataType(target.dtype);
147090
+ }
147091
+ return Reflect.get(target, prop);
147092
+ }
147093
+ });
147094
+ }
147095
+ function zarrOpenRoot(url, requestInit2) {
147096
+ const store = new FetchStore$1(url, { overrides: requestInit2 });
147097
+ return root(store);
147098
+ }
147099
+ function prevPowerOf2(x2) {
147100
+ return 2 ** Math.floor(Math.log2(x2));
147101
+ }
147102
+ function isInterleaved(shape) {
147103
+ const lastDimSize = shape[shape.length - 1];
147104
+ return lastDimSize === 3 || lastDimSize === 4;
147105
+ }
147106
+ function guessTileSize(arr) {
147107
+ const interleaved = isInterleaved(arr.shape);
147108
+ const [yChunk, xChunk] = arr.chunks.slice(interleaved ? -3 : -2);
147109
+ const size2 = Math.min(yChunk, xChunk);
147110
+ return prevPowerOf2(size2);
147111
+ }
147112
+ function isAxis(axisOrLabel) {
147113
+ return typeof axisOrLabel[0] !== "string";
147114
+ }
147115
+ async function loadMultiscales(root2) {
147116
+ const rootAttrs = (await open(root2)).attrs;
147117
+ let paths = ["0"];
147118
+ let labels = ["t", "c", "z", "y", "x"];
147119
+ if ("multiscales" in rootAttrs) {
147120
+ const { datasets, axes } = rootAttrs.multiscales[0];
147121
+ paths = datasets.map((d) => d.path);
147122
+ if (axes) {
147123
+ if (isAxis(axes)) {
147124
+ labels = axes.map((axis) => axis.name);
147125
+ } else {
147126
+ labels = axes;
147127
+ }
147128
+ }
147129
+ }
147130
+ const data = paths.map((path) => open(root2.resolve(path), { kind: "array" }));
147131
+ return {
147132
+ data: await Promise.all(data),
147133
+ rootAttrs,
147134
+ labels
147135
+ };
147136
+ }
147137
+ class ZarritaPixelSource extends ZarrPixelSource {
147138
+ constructor(arr, labels, tileSize) {
147139
+ super(arr, labels, tileSize);
147140
+ this._readChunks = false;
147141
+ }
147142
+ }
147143
+ async function loadOmeZarr(url, requestInit2) {
147144
+ const root2 = await zarrOpenRoot(url, requestInit2);
147145
+ const { data, rootAttrs, labels } = await loadMultiscales(root2);
147146
+ const tileSize = guessTileSize(data[0]);
147147
+ const pyramid = data.map((arr) => new ZarritaPixelSource(
147148
+ createZarrArrayAdapter(arr),
147149
+ labels,
147150
+ tileSize
147151
+ ));
147152
+ return {
147153
+ data: pyramid,
147154
+ metadata: rootAttrs
147155
+ };
147156
+ }
145379
147157
  function getDomains() {
145380
147158
  const domains = {};
145381
147159
  const needMin = ["Int8", "Int16", "Int32"];
@@ -145388,11 +147166,14 @@ function getDomains() {
145388
147166
  }
145389
147167
  const DOMAINS = getDomains();
145390
147168
  export {
145391
- filterSelection as A,
147169
+ getBoundingCube as A,
145392
147170
  BaseDecoder as B,
145393
- DOMAINS as C,
147171
+ abbreviateNumber as C,
145394
147172
  DEFAULT_CELLS_LAYER as D,
147173
+ filterSelection as E,
147174
+ DOMAINS as F,
145395
147175
  GLOBAL_LABELS as G,
147176
+ ZarritaPixelSource as Z,
145396
147177
  DEFAULT_MOLECULES_LAYER as a,
145397
147178
  DEFAULT_NEIGHBORHOODS_LAYER as b,
145398
147179
  DEFAULT_RASTER_DOMAIN_TYPE as c,
@@ -145402,7 +147183,7 @@ export {
145402
147183
  getDefaultExportFromCjs as g,
145403
147184
  getSourceFromLoader as h,
145404
147185
  initializeLayerChannels as i,
145405
- isInterleaved as j,
147186
+ isInterleaved$1 as j,
145406
147187
  isRgb as k,
145407
147188
  getNgffAxes as l,
145408
147189
  getNgffAxesForTiff as m,
@@ -145413,10 +147194,10 @@ export {
145413
147194
  canLoadResolution as r,
145414
147195
  square as s,
145415
147196
  normalizeCoordinateTransformations as t,
145416
- toRgbUIString as u,
145417
- getSingleSelectionStats as v,
145418
- getMultiSelectionStats as w,
145419
- getPhysicalSizeScalingMatrix as x,
145420
- getBoundingCube as y,
145421
- abbreviateNumber as z
147197
+ loadOmeZarr as u,
147198
+ guessTileSize as v,
147199
+ toRgbUIString as w,
147200
+ getSingleSelectionStats as x,
147201
+ getMultiSelectionStats as y,
147202
+ getPhysicalSizeScalingMatrix as z
145422
147203
  };