@vitessce/spatial-utils 3.2.2 → 3.3.1

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);
@@ -38522,7 +38583,7 @@ const jsonLoader = {
38522
38583
  testText: isJSON,
38523
38584
  parseTextSync: JSON.parse
38524
38585
  };
38525
- const version = "8.8.20";
38586
+ const version = "8.8.27";
38526
38587
  const existingVersion = globalThis.deck && globalThis.deck.VERSION;
38527
38588
  if (existingVersion && existingVersion !== version) {
38528
38589
  throw new Error("deck.gl - multiple versions detected: ".concat(existingVersion, " vs ").concat(version));
@@ -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
  }
@@ -39721,9 +39782,8 @@ function cssToDeviceRatio(gl) {
39721
39782
  luma
39722
39783
  } = gl;
39723
39784
  if (gl.canvas && luma) {
39724
- const {
39725
- clientWidth
39726
- } = luma.canvasSizeInfo;
39785
+ const cachedSize = luma.canvasSizeInfo;
39786
+ const clientWidth = "clientWidth" in cachedSize ? cachedSize.clientWidth : gl.canvas.clientWidth;
39727
39787
  return clientWidth ? gl.drawingBufferWidth / clientWidth : 1;
39728
39788
  }
39729
39789
  return 1;
@@ -39979,7 +40039,7 @@ function setDevicePixelRatio(gl, devicePixelRatio, options) {
39979
40039
  });
39980
40040
  }
39981
40041
  }
39982
- const VERSION$7 = "8.5.16";
40042
+ const VERSION$7 = "8.5.21";
39983
40043
  const STARTUP_MESSAGE = "set luma.log.level=1 (or higher) to trace rendering";
39984
40044
  class StatsManager {
39985
40045
  constructor() {
@@ -40100,7 +40160,6 @@ let Resource$1 = class Resource {
40100
40160
  this._handle = this._createHandle();
40101
40161
  }
40102
40162
  this.byteLength = 0;
40103
- this._initStats();
40104
40163
  this._addStats();
40105
40164
  }
40106
40165
  toString() {
@@ -40236,9 +40295,6 @@ let Resource$1 = class Resource {
40236
40295
  this.gl.luma = this.gl.luma || {};
40237
40296
  return this.gl.luma;
40238
40297
  }
40239
- _initStats() {
40240
- this.gl.stats = this.gl.stats || new StatsManager();
40241
- }
40242
40298
  _addStats() {
40243
40299
  const name2 = this[Symbol.toStringTag];
40244
40300
  const stats = lumaStats.get("Resource Counts");
@@ -40253,27 +40309,29 @@ let Resource$1 = class Resource {
40253
40309
  }
40254
40310
  _trackAllocatedMemory(bytes) {
40255
40311
  let name2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this[Symbol.toStringTag];
40256
- this._doTrackAllocatedMemory(bytes, name2);
40257
- this._doTrackAllocatedMemory(bytes, name2, this.gl.stats.get("Memory Usage"));
40312
+ this._trackAllocatedMemoryForContext(bytes, name2);
40313
+ this._trackAllocatedMemoryForContext(bytes, name2, this.gl.canvas && this.gl.canvas.id);
40314
+ this.byteLength = bytes;
40258
40315
  }
40259
- _doTrackAllocatedMemory(bytes) {
40316
+ _trackAllocatedMemoryForContext(bytes) {
40260
40317
  let name2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this[Symbol.toStringTag];
40261
- let stats = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : lumaStats.get("Memory Usage");
40318
+ let id = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
40319
+ const stats = lumaStats.get("Memory Usage".concat(id));
40262
40320
  stats.get("GPU Memory").addCount(bytes);
40263
40321
  stats.get("".concat(name2, " Memory")).addCount(bytes);
40264
- this.byteLength = bytes;
40265
40322
  }
40266
40323
  _trackDeallocatedMemory() {
40267
40324
  let name2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this[Symbol.toStringTag];
40268
- this._doTrackDeallocatedMemory(name2);
40269
- this._doTrackDeallocatedMemory(name2, this.gl.stats.get("Memory Usage"));
40325
+ this._trackDeallocatedMemoryForContext(name2);
40326
+ this._trackDeallocatedMemoryForContext(name2, this.gl.canvas && this.gl.canvas.id);
40327
+ this.byteLength = 0;
40270
40328
  }
40271
- _doTrackDeallocatedMemory() {
40329
+ _trackDeallocatedMemoryForContext() {
40272
40330
  let name2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this[Symbol.toStringTag];
40273
- let stats = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : lumaStats.get("Memory Usage");
40331
+ let id = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
40332
+ const stats = lumaStats.get("Memory Usage".concat(id));
40274
40333
  stats.get("GPU Memory").subtractCount(this.byteLength);
40275
40334
  stats.get("".concat(name2, " Memory")).subtractCount(this.byteLength);
40276
- this.byteLength = 0;
40277
40335
  }
40278
40336
  };
40279
40337
  const ERR_TYPE_DEDUCTION = "Failed to deduce GL constant from typed array";
@@ -41468,10 +41526,10 @@ let pathPrefix = "";
41468
41526
  function loadImage$1(url, opts2) {
41469
41527
  assert$7(typeof url === "string");
41470
41528
  url = pathPrefix + url;
41471
- return new Promise((resolve, reject) => {
41529
+ return new Promise((resolve2, reject) => {
41472
41530
  try {
41473
41531
  const image2 = new Image();
41474
- image2.onload = () => resolve(image2);
41532
+ image2.onload = () => resolve2(image2);
41475
41533
  image2.onerror = () => reject(new Error("Could not load image ".concat(url, ".")));
41476
41534
  image2.crossOrigin = opts2 && opts2.crossOrigin || "anonymous";
41477
41535
  image2.src = url;
@@ -43249,11 +43307,11 @@ function toUIntArray(value, uniformLength) {
43249
43307
  return toTypedArray$1(value, uniformLength, Uint32Array, UINT_ARRAY);
43250
43308
  }
43251
43309
  function getUniformSetter(gl, location, info) {
43252
- const setter = UNIFORM_SETTERS[info.type];
43253
- if (!setter) {
43310
+ const setter2 = UNIFORM_SETTERS[info.type];
43311
+ if (!setter2) {
43254
43312
  throw new Error("Unknown GLSL uniform type ".concat(info.type));
43255
43313
  }
43256
- return setter().bind(null, gl, location);
43314
+ return setter2().bind(null, gl, location);
43257
43315
  }
43258
43316
  function parseUniformName(name2) {
43259
43317
  if (name2[name2.length - 1] !== "]") {
@@ -43979,10 +44037,10 @@ class Query extends Resource$1 {
43979
44037
  return this._pollingPromise;
43980
44038
  }
43981
44039
  let counter2 = 0;
43982
- this._pollingPromise = new Promise((resolve, reject) => {
44040
+ this._pollingPromise = new Promise((resolve2, reject) => {
43983
44041
  const poll = () => {
43984
44042
  if (this.isResultAvailable()) {
43985
- resolve(this.getResult());
44043
+ resolve2(this.getResult());
43986
44044
  this._pollingPromise = null;
43987
44045
  } else if (counter2++ > limit) {
43988
44046
  reject("Timed out");
@@ -45176,8 +45234,8 @@ class AnimationLoop {
45176
45234
  waitForRender() {
45177
45235
  this.setNeedsRedraw("waitForRender");
45178
45236
  if (!this._nextFramePromise) {
45179
- this._nextFramePromise = new Promise((resolve) => {
45180
- this._resolveNextFrame = resolve;
45237
+ this._nextFramePromise = new Promise((resolve2) => {
45238
+ this._resolveNextFrame = resolve2;
45181
45239
  });
45182
45240
  }
45183
45241
  return this._nextFramePromise;
@@ -45224,13 +45282,13 @@ class AnimationLoop {
45224
45282
  }
45225
45283
  _getPageLoadPromise() {
45226
45284
  if (!this._pageLoadPromise) {
45227
- this._pageLoadPromise = isPage ? new Promise((resolve, reject) => {
45285
+ this._pageLoadPromise = isPage ? new Promise((resolve2, reject) => {
45228
45286
  if (isPage && document.readyState === "complete") {
45229
- resolve(document);
45287
+ resolve2(document);
45230
45288
  return;
45231
45289
  }
45232
45290
  window.addEventListener("load", () => {
45233
- resolve(document);
45291
+ resolve2(document);
45234
45292
  });
45235
45293
  }) : Promise.resolve({});
45236
45294
  }
@@ -49888,6 +49946,7 @@ const picking = {
49888
49946
  inject: {
49889
49947
  "vs:DECKGL_FILTER_GL_POSITION": "\n // for picking depth values\n picking_setPickingAttribute(position.z / position.w);\n ",
49890
49948
  "vs:DECKGL_FILTER_COLOR": "\n picking_setPickingColor(geometry.pickingColor);\n ",
49949
+ "fs:#decl": "\nuniform bool picking_uAttribute;\n ",
49891
49950
  "fs:DECKGL_FILTER_COLOR": {
49892
49951
  order: 99,
49893
49952
  injection: "\n // use highlight color if this fragment belongs to the selected object.\n color = picking_filterHighlightColor(color);\n\n // use picking color if rendering to picking FBO.\n color = picking_filterPickingColor(color);\n "
@@ -50698,6 +50757,9 @@ class Viewport {
50698
50757
  this.projectFlat = this.projectFlat.bind(this);
50699
50758
  this.unprojectFlat = this.unprojectFlat.bind(this);
50700
50759
  }
50760
+ get subViewports() {
50761
+ return null;
50762
+ }
50701
50763
  get metersPerPixel() {
50702
50764
  return this.distanceScales.metersPerUnit[2] / this.scale;
50703
50765
  }
@@ -59589,7 +59651,7 @@ class Attribute extends DataColumn {
59589
59651
  const {
59590
59652
  startIndices
59591
59653
  } = this;
59592
- const vertexIndex = startIndices ? startIndices[row] : row;
59654
+ const vertexIndex = startIndices ? row < startIndices.length ? startIndices[row] : this.numInstances : row;
59593
59655
  return vertexIndex * this.size;
59594
59656
  }
59595
59657
  getShaderAttributes() {
@@ -62233,7 +62295,7 @@ class Layer extends Component {
62233
62295
  if (Array.isArray(highlightColor)) {
62234
62296
  parameters.pickingHighlightColor = highlightColor;
62235
62297
  }
62236
- if (Number.isInteger(highlightedObjectIndex)) {
62298
+ if (forceUpdate || highlightedObjectIndex !== oldProps.highlightedObjectIndex) {
62237
62299
  parameters.pickingSelectedColor = Number.isFinite(highlightedObjectIndex) && highlightedObjectIndex >= 0 ? this.encodePickingColor(highlightedObjectIndex) : null;
62238
62300
  }
62239
62301
  this.setModuleParameters(parameters);
@@ -63596,7 +63658,7 @@ function interpolateQuad(quad, ut, vt) {
63596
63658
  }
63597
63659
  const vs$g = "\n#define SHADER_NAME bitmap-layer-vertex-shader\n\nattribute vec2 texCoords;\nattribute vec3 positions;\nattribute vec3 positions64Low;\n\nvarying vec2 vTexCoord;\nvarying vec2 vTexPos;\n\nuniform float coordinateConversion;\n\nconst vec3 pickingColor = vec3(1.0, 0.0, 0.0);\n\nvoid main(void) {\n geometry.worldPosition = positions;\n geometry.uv = texCoords;\n geometry.pickingColor = pickingColor;\n\n gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position);\n DECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n\n vTexCoord = texCoords;\n\n if (coordinateConversion < -0.5) {\n vTexPos = geometry.position.xy + project_uCommonOrigin.xy;\n } else if (coordinateConversion > 0.5) {\n vTexPos = geometry.worldPosition.xy;\n }\n\n vec4 color = vec4(0.0);\n DECKGL_FILTER_COLOR(color, geometry);\n}\n";
63598
63660
  const packUVsIntoRGB = "\nvec3 packUVsIntoRGB(vec2 uv) {\n // Extract the top 8 bits. We want values to be truncated down so we can add a fraction\n vec2 uv8bit = floor(uv * 256.);\n\n // Calculate the normalized remainders of u and v parts that do not fit into 8 bits\n // Scale and clamp to 0-1 range\n vec2 uvFraction = fract(uv * 256.);\n vec2 uvFraction4bit = floor(uvFraction * 16.);\n\n // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates\n float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.;\n\n return vec3(uv8bit, fractions) / 255.;\n}\n";
63599
- const fs$i = "\n#define SHADER_NAME bitmap-layer-fragment-shader\n\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D bitmapTexture;\n\nvarying vec2 vTexCoord;\nvarying vec2 vTexPos;\n\nuniform float desaturate;\nuniform vec4 transparentColor;\nuniform vec3 tintColor;\nuniform float opacity;\n\nuniform float coordinateConversion;\nuniform vec4 bounds;\n\n/* projection utils */\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / PI / 2.0;\n\n// from degrees to Web Mercator\nvec2 lnglat_to_mercator(vec2 lnglat) {\n float x = lnglat.x;\n float y = clamp(lnglat.y, -89.9, 89.9);\n return vec2(\n radians(x) + PI,\n PI + log(tan(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\n// from Web Mercator to degrees\nvec2 mercator_to_lnglat(vec2 xy) {\n xy /= WORLD_SCALE;\n return degrees(vec2(\n xy.x - PI,\n atan(exp(xy.y - PI)) * 2.0 - PI * 0.5\n ));\n}\n/* End projection utils */\n\n// apply desaturation\nvec3 color_desaturate(vec3 color) {\n float luminance = (color.r + color.g + color.b) * 0.333333333;\n return mix(color, vec3(luminance), desaturate);\n}\n\n// apply tint\nvec3 color_tint(vec3 color) {\n return color * tintColor;\n}\n\n// blend with background color\nvec4 apply_opacity(vec3 color, float alpha) {\n return mix(transparentColor, vec4(color, 1.0), alpha);\n}\n\nvec2 getUV(vec2 pos) {\n return vec2(\n (pos.x - bounds[0]) / (bounds[2] - bounds[0]),\n (pos.y - bounds[3]) / (bounds[1] - bounds[3])\n );\n}\n\n".concat(packUVsIntoRGB, "\n\nvoid main(void) {\n vec2 uv = vTexCoord;\n if (coordinateConversion < -0.5) {\n vec2 lnglat = mercator_to_lnglat(vTexPos);\n uv = getUV(lnglat);\n } else if (coordinateConversion > 0.5) {\n vec2 commonPos = lnglat_to_mercator(vTexPos);\n uv = getUV(commonPos);\n }\n vec4 bitmapColor = texture2D(bitmapTexture, uv);\n\n gl_FragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * opacity);\n\n geometry.uv = uv;\n DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n\n if (picking_uActive) {\n // Since instance information is not used, we can use picking color for pixel index\n gl_FragColor.rgb = packUVsIntoRGB(uv);\n }\n}\n");
63661
+ const fs$i = "\n#define SHADER_NAME bitmap-layer-fragment-shader\n\n#ifdef GL_ES\nprecision highp float;\n#endif\n\nuniform sampler2D bitmapTexture;\n\nvarying vec2 vTexCoord;\nvarying vec2 vTexPos;\n\nuniform float desaturate;\nuniform vec4 transparentColor;\nuniform vec3 tintColor;\nuniform float opacity;\n\nuniform float coordinateConversion;\nuniform vec4 bounds;\n\n/* projection utils */\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / PI / 2.0;\n\n// from degrees to Web Mercator\nvec2 lnglat_to_mercator(vec2 lnglat) {\n float x = lnglat.x;\n float y = clamp(lnglat.y, -89.9, 89.9);\n return vec2(\n radians(x) + PI,\n PI + log(tan(PI * 0.25 + radians(y) * 0.5))\n ) * WORLD_SCALE;\n}\n\n// from Web Mercator to degrees\nvec2 mercator_to_lnglat(vec2 xy) {\n xy /= WORLD_SCALE;\n return degrees(vec2(\n xy.x - PI,\n atan(exp(xy.y - PI)) * 2.0 - PI * 0.5\n ));\n}\n/* End projection utils */\n\n// apply desaturation\nvec3 color_desaturate(vec3 color) {\n float luminance = (color.r + color.g + color.b) * 0.333333333;\n return mix(color, vec3(luminance), desaturate);\n}\n\n// apply tint\nvec3 color_tint(vec3 color) {\n return color * tintColor;\n}\n\n// blend with background color\nvec4 apply_opacity(vec3 color, float alpha) {\n return mix(transparentColor, vec4(color, 1.0), alpha);\n}\n\nvec2 getUV(vec2 pos) {\n return vec2(\n (pos.x - bounds[0]) / (bounds[2] - bounds[0]),\n (pos.y - bounds[3]) / (bounds[1] - bounds[3])\n );\n}\n\n".concat(packUVsIntoRGB, "\n\nvoid main(void) {\n vec2 uv = vTexCoord;\n if (coordinateConversion < -0.5) {\n vec2 lnglat = mercator_to_lnglat(vTexPos);\n uv = getUV(lnglat);\n } else if (coordinateConversion > 0.5) {\n vec2 commonPos = lnglat_to_mercator(vTexPos);\n uv = getUV(commonPos);\n }\n vec4 bitmapColor = texture2D(bitmapTexture, uv);\n\n gl_FragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * opacity);\n\n geometry.uv = uv;\n DECKGL_FILTER_COLOR(gl_FragColor, geometry);\n\n if (picking_uActive && !picking_uAttribute) {\n // Since instance information is not used, we can use picking color for pixel index\n gl_FragColor.rgb = packUVsIntoRGB(uv);\n }\n}\n");
63600
63662
  const defaultProps$I = {
63601
63663
  image: {
63602
63664
  type: "image",
@@ -71736,18 +71798,22 @@ function getBoundingBox(viewport, zRange, extent2) {
71736
71798
  }
71737
71799
  function getCullBounds({
71738
71800
  viewport,
71739
- z: z2,
71801
+ z: z2 = 0,
71740
71802
  cullRect
71741
71803
  }) {
71742
- const x2 = cullRect.x - viewport.x;
71743
- const y2 = cullRect.y - viewport.y;
71744
- const {
71745
- width,
71746
- height
71747
- } = cullRect;
71804
+ const subViewports = viewport.subViewports || [viewport];
71805
+ return subViewports.map((v) => getCullBoundsInViewport(v, z2, cullRect));
71806
+ }
71807
+ function getCullBoundsInViewport(viewport, z2, cullRect) {
71748
71808
  if (!Array.isArray(z2)) {
71809
+ const x2 = cullRect.x - viewport.x;
71810
+ const y2 = cullRect.y - viewport.y;
71811
+ const {
71812
+ width,
71813
+ height
71814
+ } = cullRect;
71749
71815
  const unprojectOption = {
71750
- targetZ: z2 || 0
71816
+ targetZ: z2
71751
71817
  };
71752
71818
  const topLeft = viewport.unproject([x2, y2], unprojectOption);
71753
71819
  const topRight = viewport.unproject([x2 + width, y2], unprojectOption);
@@ -71755,16 +71821,8 @@ function getCullBounds({
71755
71821
  const bottomRight = viewport.unproject([x2 + width, y2 + height], unprojectOption);
71756
71822
  return [Math.min(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]), Math.min(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1]), Math.max(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]), Math.max(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1])];
71757
71823
  }
71758
- const bounds0 = getCullBounds({
71759
- viewport,
71760
- z: z2[0],
71761
- cullRect
71762
- });
71763
- const bounds1 = getCullBounds({
71764
- viewport,
71765
- z: z2[1],
71766
- cullRect
71767
- });
71824
+ const bounds0 = getCullBoundsInViewport(viewport, z2[0], cullRect);
71825
+ const bounds1 = getCullBoundsInViewport(viewport, z2[1], cullRect);
71768
71826
  return [Math.min(bounds0[0], bounds1[0]), Math.min(bounds0[1], bounds1[1]), Math.max(bounds0[2], bounds1[2]), Math.max(bounds0[3], bounds1[3])];
71769
71827
  }
71770
71828
  function getIndexingCoords(bbox2, scale2, modelMatrixInverse) {
@@ -71994,7 +72052,7 @@ class Tileset2D {
71994
72052
  return false;
71995
72053
  }
71996
72054
  if (cullRect && this._viewport) {
71997
- const [minX, minY, maxX, maxY] = getCullBounds({
72055
+ const boundsArr = this._getCullBounds({
71998
72056
  viewport: this._viewport,
71999
72057
  z: this._zRange,
72000
72058
  cullRect
@@ -72002,12 +72060,20 @@ class Tileset2D {
72002
72060
  const {
72003
72061
  bbox: bbox2
72004
72062
  } = tile;
72005
- if ("west" in bbox2) {
72006
- return bbox2.west < maxX && bbox2.east > minX && bbox2.south < maxY && bbox2.north > minY;
72063
+ for (const [minX, minY, maxX, maxY] of boundsArr) {
72064
+ let overlaps;
72065
+ if ("west" in bbox2) {
72066
+ overlaps = bbox2.west < maxX && bbox2.east > minX && bbox2.south < maxY && bbox2.north > minY;
72067
+ } else {
72068
+ const y02 = Math.min(bbox2.top, bbox2.bottom);
72069
+ const y12 = Math.max(bbox2.top, bbox2.bottom);
72070
+ overlaps = bbox2.left < maxX && bbox2.right > minX && y02 < maxY && y12 > minY;
72071
+ }
72072
+ if (overlaps) {
72073
+ return true;
72074
+ }
72007
72075
  }
72008
- const y02 = Math.min(bbox2.top, bbox2.bottom);
72009
- const y12 = Math.max(bbox2.top, bbox2.bottom);
72010
- return bbox2.left < maxX && bbox2.right > minX && y02 < maxY && y12 > minY;
72076
+ return false;
72011
72077
  }
72012
72078
  return true;
72013
72079
  }
@@ -72456,14 +72522,19 @@ class TileLayer extends CompositeLayer {
72456
72522
  info,
72457
72523
  sourceLayer
72458
72524
  }) {
72525
+ const sourceTile = sourceLayer.props.tile;
72459
72526
  if (info.picked) {
72460
- info.tile = sourceLayer.props.tile;
72527
+ info.tile = sourceTile;
72461
72528
  }
72529
+ info.sourceTile = sourceTile;
72462
72530
  return info;
72463
72531
  }
72464
72532
  _updateAutoHighlight(info) {
72465
- if (info.sourceLayer) {
72466
- info.sourceLayer.updateAutoHighlight(info);
72533
+ const sourceTile = info.sourceTile;
72534
+ if (sourceTile && sourceTile.layers) {
72535
+ for (const layer of sourceTile.layers) {
72536
+ layer.updateAutoHighlight(info);
72537
+ }
72467
72538
  }
72468
72539
  }
72469
72540
  renderLayers() {
@@ -74590,7 +74661,7 @@ var libh3 = function(libh32) {
74590
74661
  b[h >> 2] = 0;
74591
74662
  h = h + 4 | 0;
74592
74663
  } while ((h | 0) < (j | 0));
74593
- _b(c, g3);
74664
+ _b2(c, g3);
74594
74665
  h = g3;
74595
74666
  j = b[h >> 2] | 0;
74596
74667
  h = b[h + 4 >> 2] | 0;
@@ -74624,7 +74695,7 @@ var libh3 = function(libh32) {
74624
74695
  b[h >> 2] = 0;
74625
74696
  h = h + 4 | 0;
74626
74697
  } while ((h | 0) < (j | 0));
74627
- _b(d, g3);
74698
+ _b2(d, g3);
74628
74699
  j = g3;
74629
74700
  h = b[j >> 2] | 0;
74630
74701
  j = b[j + 4 >> 2] | 0;
@@ -75766,7 +75837,7 @@ var libh3 = function(libh32) {
75766
75837
  S = k;
75767
75838
  return;
75768
75839
  }
75769
- function _a2(a3, c, d, f2, g3) {
75840
+ function _a3(a3, c, d, f2, g3) {
75770
75841
  a3 = a3 | 0;
75771
75842
  c = c | 0;
75772
75843
  d = d | 0;
@@ -75812,7 +75883,7 @@ var libh3 = function(libh32) {
75812
75883
  S = S + 16 | 0;
75813
75884
  f2 = e3;
75814
75885
  Da(a3 + 4 | 0, f2);
75815
- _a2(f2, b[a3 >> 2] | 0, c, 0, d);
75886
+ _a3(f2, b[a3 >> 2] | 0, c, 0, d);
75816
75887
  S = e3;
75817
75888
  return;
75818
75889
  }
@@ -75925,12 +75996,12 @@ var libh3 = function(libh32) {
75925
75996
  }
75926
75997
  }
75927
75998
  Gc(w3, y3, f2, a3, C3);
75928
- _a2(C3, b[v2 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
75999
+ _a3(C3, b[v2 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
75929
76000
  b[g3 >> 2] = (b[g3 >> 2] | 0) + 1;
75930
76001
  }
75931
76002
  if ((j | 0) < (n3 | 0)) {
75932
76003
  Da(t3, v2);
75933
- _a2(v2, b[F2 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
76004
+ _a3(v2, b[F2 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
75934
76005
  b[g3 >> 2] = (b[g3 >> 2] | 0) + 1;
75935
76006
  }
75936
76007
  b[E2 >> 2] = b[F2 >> 2];
@@ -76191,13 +76262,13 @@ var libh3 = function(libh32) {
76191
76262
  }
76192
76263
  Gc(A3, s3, f2, a3, w3);
76193
76264
  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);
76265
+ _a3(w3, b[x3 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
76195
76266
  b[g3 >> 2] = (b[g3 >> 2] | 0) + 1;
76196
76267
  }
76197
76268
  }
76198
76269
  if ((j | 0) < (l2 | 0)) {
76199
76270
  Da(q2, A3);
76200
- _a2(A3, b[z3 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
76271
+ _a3(A3, b[z3 >> 2] | 0, k, 1, g3 + 8 + (b[g3 >> 2] << 4) | 0);
76201
76272
  b[g3 >> 2] = (b[g3 >> 2] | 0) + 1;
76202
76273
  }
76203
76274
  j = j + 1 | 0;
@@ -78548,7 +78619,7 @@ var libh3 = function(libh32) {
78548
78619
  function Zb() {
78549
78620
  return 12;
78550
78621
  }
78551
- function _b(a3, c) {
78622
+ function _b2(a3, c) {
78552
78623
  a3 = a3 | 0;
78553
78624
  c = c | 0;
78554
78625
  var d = 0, e3 = 0, f2 = 0, g3 = 0, h = 0, i2 = 0, j = 0;
@@ -83016,7 +83087,7 @@ var libh3 = function(libh32) {
83016
83087
  _getH3UnidirectionalEdgeBoundary: gc,
83017
83088
  _getH3UnidirectionalEdgesFromHexagon: fc,
83018
83089
  _getOriginH3IndexFromUnidirectionalEdge: bc,
83019
- _getPentagonIndexes: _b,
83090
+ _getPentagonIndexes: _b2,
83020
83091
  _getRes0Indexes: va,
83021
83092
  _h3Distance: qc,
83022
83093
  _h3GetBaseCell: Ab,
@@ -84781,6 +84852,9 @@ class ScenegraphNode {
84781
84852
  toString() {
84782
84853
  return "{type: ScenegraphNode, id: ".concat(this.id, ")}");
84783
84854
  }
84855
+ getBounds() {
84856
+ return null;
84857
+ }
84784
84858
  setPosition(position) {
84785
84859
  assert$7(position.length === 3, "setPosition requires vector argument");
84786
84860
  this.position = position;
@@ -84931,6 +85005,34 @@ class GroupNode extends ScenegraphNode {
84931
85005
  this.removeAll();
84932
85006
  super.delete();
84933
85007
  }
85008
+ getBounds() {
85009
+ const result = [[Infinity, Infinity, Infinity], [-Infinity, -Infinity, -Infinity]];
85010
+ this.traverse((node2, _ref) => {
85011
+ let {
85012
+ worldMatrix
85013
+ } = _ref;
85014
+ const bounds2 = node2.getBounds();
85015
+ if (!bounds2) {
85016
+ return;
85017
+ }
85018
+ const [min2, max2] = bounds2;
85019
+ const center2 = new Vector3(min2).add(max2).divide([2, 2, 2]);
85020
+ worldMatrix.transformAsPoint(center2, center2);
85021
+ const halfSize = new Vector3(max2).subtract(min2).divide([2, 2, 2]);
85022
+ worldMatrix.transformAsVector(halfSize, halfSize);
85023
+ for (let v = 0; v < 8; v++) {
85024
+ const position = new Vector3(v & 1 ? -1 : 1, v & 2 ? -1 : 1, v & 4 ? -1 : 1).multiply(halfSize).add(center2);
85025
+ for (let i2 = 0; i2 < 3; i2++) {
85026
+ result[0][i2] = Math.min(result[0][i2], position[i2]);
85027
+ result[1][i2] = Math.max(result[1][i2], position[i2]);
85028
+ }
85029
+ }
85030
+ });
85031
+ if (!Number.isFinite(result[0][0])) {
85032
+ return null;
85033
+ }
85034
+ return result;
85035
+ }
84934
85036
  traverse(visitor) {
84935
85037
  let {
84936
85038
  worldMatrix = new Matrix4()
@@ -85180,6 +85282,7 @@ class ModelNode extends ScenegraphNode {
85180
85282
  } else {
85181
85283
  this.model = new Model(gl, props2);
85182
85284
  }
85285
+ this.bounds = null;
85183
85286
  this.managedResources = props2.managedResources || [];
85184
85287
  }
85185
85288
  setProps(props2) {
@@ -85187,6 +85290,9 @@ class ModelNode extends ScenegraphNode {
85187
85290
  this._setModelNodeProps(props2);
85188
85291
  return this;
85189
85292
  }
85293
+ getBounds() {
85294
+ return this.bounds;
85295
+ }
85190
85296
  delete() {
85191
85297
  if (this.model) {
85192
85298
  this.model.delete();
@@ -85371,17 +85477,21 @@ function createGLTFModel(gl, options) {
85371
85477
  const managedResources = [];
85372
85478
  managedResources.push(...materialParser.generatedTextures);
85373
85479
  managedResources.push(...Object.values(attributes).map((attribute) => attribute.buffer));
85374
- const model = new ModelNode(gl, Object.assign({
85480
+ const model = new ModelNode(gl, {
85375
85481
  id,
85376
85482
  drawMode,
85377
85483
  vertexCount,
85378
85484
  modules: [pbr],
85379
- defines: materialParser.defines,
85380
85485
  parameters: materialParser.parameters,
85381
85486
  vs: addVersionToShader(gl, vs$7),
85382
85487
  fs: addVersionToShader(gl, fs$7),
85383
- managedResources
85384
- }, modelOptions));
85488
+ managedResources,
85489
+ ...modelOptions,
85490
+ defines: {
85491
+ ...materialParser.defines,
85492
+ ...modelOptions.defines
85493
+ }
85494
+ });
85385
85495
  model.setProps({
85386
85496
  attributes
85387
85497
  });
@@ -85476,13 +85586,15 @@ class GLTFInstantiator {
85476
85586
  log$2.warn("getVertexCount() not found")();
85477
85587
  }
85478
85588
  createPrimitive(gltfPrimitive, i2, gltfMesh) {
85479
- return createGLTFModel(this.gl, Object.assign({
85589
+ const model = createGLTFModel(this.gl, Object.assign({
85480
85590
  id: gltfPrimitive.name || "".concat(gltfMesh.name || gltfMesh.id, "-primitive-").concat(i2),
85481
85591
  drawMode: gltfPrimitive.mode || 4,
85482
85592
  vertexCount: gltfPrimitive.indices ? gltfPrimitive.indices.count : this.getVertexCount(gltfPrimitive.attributes),
85483
85593
  attributes: this.createAttributes(gltfPrimitive.attributes, gltfPrimitive.indices),
85484
85594
  material: gltfPrimitive.material
85485
85595
  }, this.options));
85596
+ model.bounds = [gltfPrimitive.attributes.POSITION.min, gltfPrimitive.attributes.POSITION.max];
85597
+ return model;
85486
85598
  }
85487
85599
  createAttributes(attributes, indices) {
85488
85600
  const loadedAttributes = {};
@@ -85569,14 +85681,14 @@ function initializeBasisTrascoderModule(BasisModule, wasmBinary) {
85569
85681
  if (wasmBinary) {
85570
85682
  options.wasmBinary = wasmBinary;
85571
85683
  }
85572
- return new Promise((resolve) => {
85684
+ return new Promise((resolve2) => {
85573
85685
  BasisModule(options).then((module2) => {
85574
85686
  const {
85575
85687
  BasisFile,
85576
85688
  initializeBasis
85577
85689
  } = module2;
85578
85690
  initializeBasis();
85579
- resolve({
85691
+ resolve2({
85580
85692
  BasisFile
85581
85693
  });
85582
85694
  });
@@ -85603,7 +85715,7 @@ function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
85603
85715
  if (wasmBinary) {
85604
85716
  options.wasmBinary = wasmBinary;
85605
85717
  }
85606
- return new Promise((resolve) => {
85718
+ return new Promise((resolve2) => {
85607
85719
  BasisEncoderModule(options).then((module2) => {
85608
85720
  const {
85609
85721
  BasisFile,
@@ -85612,7 +85724,7 @@ function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
85612
85724
  BasisEncoder
85613
85725
  } = module2;
85614
85726
  initializeBasis();
85615
- resolve({
85727
+ resolve2({
85616
85728
  BasisFile,
85617
85729
  KTX2File,
85618
85730
  BasisEncoder
@@ -87466,10 +87578,10 @@ function initializeDracoDecoder(DracoDecoderModule, wasmBinary) {
87466
87578
  if (wasmBinary) {
87467
87579
  options.wasmBinary = wasmBinary;
87468
87580
  }
87469
- return new Promise((resolve) => {
87581
+ return new Promise((resolve2) => {
87470
87582
  DracoDecoderModule({
87471
87583
  ...options,
87472
- onModuleLoaded: (draco) => resolve({
87584
+ onModuleLoaded: (draco) => resolve2({
87473
87585
  draco
87474
87586
  })
87475
87587
  });
@@ -88683,7 +88795,7 @@ async function waitForGLTFAssets(gltfObjects) {
88683
88795
  }
88684
88796
  async function waitWhileCondition(condition) {
88685
88797
  while (condition()) {
88686
- await new Promise((resolve) => requestAnimationFrame(resolve));
88798
+ await new Promise((resolve2) => requestAnimationFrame(resolve2));
88687
88799
  }
88688
88800
  }
88689
88801
  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 +91220,12 @@ class Tileset3D {
91108
91220
  this.lastUpdatedVieports = viewports;
91109
91221
  }
91110
91222
  if (!this.updatePromise) {
91111
- this.updatePromise = new Promise((resolve) => {
91223
+ this.updatePromise = new Promise((resolve2) => {
91112
91224
  setTimeout(() => {
91113
91225
  if (this.lastUpdatedVieports) {
91114
91226
  this.doUpdate(this.lastUpdatedVieports);
91115
91227
  }
91116
- resolve(this._frameNumber);
91228
+ resolve2(this._frameNumber);
91117
91229
  this.updatePromise = null;
91118
91230
  }, this.options.debounceTime);
91119
91231
  });
@@ -93410,15 +93522,11 @@ class Tile3DLayer extends CompositeLayer {
93410
93522
  info,
93411
93523
  sourceLayer
93412
93524
  }) {
93413
- const {
93414
- layerMap
93415
- } = this.state;
93416
- const layerId = sourceLayer && sourceLayer.id;
93417
- if (layerId) {
93418
- const substr = layerId.substring(this.id.length + 1);
93419
- const tileId = substr.substring(substr.indexOf("-") + 1);
93420
- info.object = layerMap[tileId] && layerMap[tileId].tile;
93525
+ const sourceTile = sourceLayer && sourceLayer.props.tile;
93526
+ if (info.picked) {
93527
+ info.object = sourceTile;
93421
93528
  }
93529
+ info.sourceTile = sourceTile;
93422
93530
  return info;
93423
93531
  }
93424
93532
  filterSubLayer({
@@ -93434,8 +93542,10 @@ class Tile3DLayer extends CompositeLayer {
93434
93542
  return tile.selected && tile.viewportIds.includes(viewportId);
93435
93543
  }
93436
93544
  _updateAutoHighlight(info) {
93437
- if (info.sourceLayer) {
93438
- info.sourceLayer.updateAutoHighlight(info);
93545
+ const sourceTile = info.sourceTile;
93546
+ const layerCache = this.state.layerMap[sourceTile === null || sourceTile === void 0 ? void 0 : sourceTile.id];
93547
+ if (layerCache && layerCache.layer) {
93548
+ layerCache.layer.updateAutoHighlight(info);
93439
93549
  }
93440
93550
  }
93441
93551
  async _loadTileset(tilesetUrl) {
@@ -97320,8 +97430,8 @@ function collectionOf$1(featureCollection2, type, name2) {
97320
97430
  if (!featureCollection2 || featureCollection2.type !== "FeatureCollection") {
97321
97431
  throw new Error("Invalid input to " + name2 + ", FeatureCollection required");
97322
97432
  }
97323
- for (var _i = 0, _a2 = featureCollection2.features; _i < _a2.length; _i++) {
97324
- var feature2 = _a2[_i];
97433
+ for (var _i = 0, _a3 = featureCollection2.features; _i < _a3.length; _i++) {
97434
+ var feature2 = _a3[_i];
97325
97435
  if (!feature2 || feature2.type !== "Feature" || !feature2.geometry) {
97326
97436
  throw new Error("Invalid input to " + name2 + ", Feature with geometry required");
97327
97437
  }
@@ -97720,11 +97830,11 @@ function isPointInMultiPoint(multiPoint2, pt) {
97720
97830
  return output;
97721
97831
  }
97722
97832
  function isMultiPointInMultiPoint(multiPoint1, multiPoint2) {
97723
- for (var _i = 0, _a2 = multiPoint2.coordinates; _i < _a2.length; _i++) {
97724
- var coord2 = _a2[_i];
97833
+ for (var _i = 0, _a3 = multiPoint2.coordinates; _i < _a3.length; _i++) {
97834
+ var coord2 = _a3[_i];
97725
97835
  var matchFound = false;
97726
- for (var _b = 0, _c = multiPoint1.coordinates; _b < _c.length; _b++) {
97727
- var coord1 = _c[_b];
97836
+ for (var _b2 = 0, _c = multiPoint1.coordinates; _b2 < _c.length; _b2++) {
97837
+ var coord1 = _c[_b2];
97728
97838
  if (compareCoords(coord2, coord1)) {
97729
97839
  matchFound = true;
97730
97840
  break;
@@ -97738,8 +97848,8 @@ function isMultiPointInMultiPoint(multiPoint1, multiPoint2) {
97738
97848
  }
97739
97849
  function isMultiPointOnLine(lineString2, multiPoint2) {
97740
97850
  var haveFoundInteriorPoint = false;
97741
- for (var _i = 0, _a2 = multiPoint2.coordinates; _i < _a2.length; _i++) {
97742
- var coord = _a2[_i];
97851
+ for (var _i = 0, _a3 = multiPoint2.coordinates; _i < _a3.length; _i++) {
97852
+ var coord = _a3[_i];
97743
97853
  if (booleanPointOnLine(coord, lineString2, { ignoreEndVertices: true })) {
97744
97854
  haveFoundInteriorPoint = true;
97745
97855
  }
@@ -97753,8 +97863,8 @@ function isMultiPointOnLine(lineString2, multiPoint2) {
97753
97863
  return false;
97754
97864
  }
97755
97865
  function isMultiPointInPoly(polygon2, multiPoint2) {
97756
- for (var _i = 0, _a2 = multiPoint2.coordinates; _i < _a2.length; _i++) {
97757
- var coord = _a2[_i];
97866
+ for (var _i = 0, _a3 = multiPoint2.coordinates; _i < _a3.length; _i++) {
97867
+ var coord = _a3[_i];
97758
97868
  if (!booleanPointInPolygon$1(coord, polygon2, { ignoreBoundary: true })) {
97759
97869
  return false;
97760
97870
  }
@@ -97763,8 +97873,8 @@ function isMultiPointInPoly(polygon2, multiPoint2) {
97763
97873
  }
97764
97874
  function isLineOnLine(lineString1, lineString2) {
97765
97875
  var haveFoundInteriorPoint = false;
97766
- for (var _i = 0, _a2 = lineString2.coordinates; _i < _a2.length; _i++) {
97767
- var coords = _a2[_i];
97876
+ for (var _i = 0, _a3 = lineString2.coordinates; _i < _a3.length; _i++) {
97877
+ var coords = _a3[_i];
97768
97878
  if (booleanPointOnLine({ type: "Point", coordinates: coords }, lineString1, {
97769
97879
  ignoreEndVertices: true
97770
97880
  })) {
@@ -97812,8 +97922,8 @@ function isPolyInPoly(feature1, feature2) {
97812
97922
  var coords = getGeom$1(feature2).coordinates;
97813
97923
  for (var _i = 0, coords_1 = coords; _i < coords_1.length; _i++) {
97814
97924
  var ring = coords_1[_i];
97815
- for (var _a2 = 0, ring_1 = ring; _a2 < ring_1.length; _a2++) {
97816
- var coord = ring_1[_a2];
97925
+ for (var _a3 = 0, ring_1 = ring; _a3 < ring_1.length; _a3++) {
97926
+ var coord = ring_1[_a3];
97817
97927
  if (!booleanPointInPolygon$1(coord, feature1)) {
97818
97928
  return false;
97819
97929
  }
@@ -99057,8 +99167,8 @@ function collectionOf(featureCollection2, type, name2) {
99057
99167
  if (!featureCollection2 || featureCollection2.type !== "FeatureCollection") {
99058
99168
  throw new Error("Invalid input to " + name2 + ", FeatureCollection required");
99059
99169
  }
99060
- for (var _i = 0, _a2 = featureCollection2.features; _i < _a2.length; _i++) {
99061
- var feature2 = _a2[_i];
99170
+ for (var _i = 0, _a3 = featureCollection2.features; _i < _a3.length; _i++) {
99171
+ var feature2 = _a3[_i];
99062
99172
  if (!feature2 || feature2.type !== "Feature" || !feature2.geometry) {
99063
99173
  throw new Error("Invalid input to " + name2 + ", Feature with geometry required");
99064
99174
  }
@@ -99401,7 +99511,7 @@ function requireImplementation() {
99401
99511
  implementation$8 = keysShim2;
99402
99512
  return implementation$8;
99403
99513
  }
99404
- var slice$1 = Array.prototype.slice;
99514
+ var slice$3 = Array.prototype.slice;
99405
99515
  var isArgs = isArguments$2;
99406
99516
  var origKeys = Object.keys;
99407
99517
  var keysShim = origKeys ? function keys(o2) {
@@ -99417,7 +99527,7 @@ keysShim.shim = function shimObjectKeys() {
99417
99527
  if (!keysWorksWithArguments) {
99418
99528
  Object.keys = function keys3(object2) {
99419
99529
  if (isArgs(object2)) {
99420
- return originalKeys(slice$1.call(object2));
99530
+ return originalKeys(slice$3.call(object2));
99421
99531
  }
99422
99532
  return originalKeys(object2);
99423
99533
  };
@@ -99502,7 +99612,7 @@ var hasProto$1 = function hasProto() {
99502
99612
  return { __proto__: test }.foo === test.foo && !({ __proto__: null } instanceof $Object);
99503
99613
  };
99504
99614
  var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
99505
- var slice = Array.prototype.slice;
99615
+ var slice$2 = Array.prototype.slice;
99506
99616
  var toStr$2 = Object.prototype.toString;
99507
99617
  var funcType = "[object Function]";
99508
99618
  var implementation$7 = function bind2(that) {
@@ -99510,13 +99620,13 @@ var implementation$7 = function bind2(that) {
99510
99620
  if (typeof target !== "function" || toStr$2.call(target) !== funcType) {
99511
99621
  throw new TypeError(ERROR_MESSAGE + target);
99512
99622
  }
99513
- var args = slice.call(arguments, 1);
99623
+ var args = slice$2.call(arguments, 1);
99514
99624
  var bound;
99515
99625
  var binder = function() {
99516
99626
  if (this instanceof bound) {
99517
99627
  var result = target.apply(
99518
99628
  this,
99519
- args.concat(slice.call(arguments))
99629
+ args.concat(slice$2.call(arguments))
99520
99630
  );
99521
99631
  if (Object(result) === result) {
99522
99632
  return result;
@@ -99525,7 +99635,7 @@ var implementation$7 = function bind2(that) {
99525
99635
  } else {
99526
99636
  return target.apply(
99527
99637
  that,
99528
- args.concat(slice.call(arguments))
99638
+ args.concat(slice$2.call(arguments))
99529
99639
  );
99530
99640
  }
99531
99641
  };
@@ -110929,7 +111039,7 @@ function cartesianNormalizeInPlace(d) {
110929
111039
  var l2 = sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
110930
111040
  d[0] /= l2, d[1] /= l2, d[2] /= l2;
110931
111041
  }
110932
- var lambda0$1, phi0, lambda1, phi1, lambda2, lambda00$1, phi00$1, p0, deltaSum = adder(), ranges, range$2;
111042
+ var lambda0$1, phi0, lambda1, phi1, lambda2, lambda00$1, phi00$1, p0, deltaSum = adder(), ranges, range$3;
110933
111043
  var boundsStream$1 = {
110934
111044
  point: boundsPoint$1,
110935
111045
  lineStart: boundsLineStart,
@@ -110952,11 +111062,11 @@ var boundsStream$1 = {
110952
111062
  phi1 = 90;
110953
111063
  else if (deltaSum < -epsilon)
110954
111064
  phi0 = -90;
110955
- range$2[0] = lambda0$1, range$2[1] = lambda1;
111065
+ range$3[0] = lambda0$1, range$3[1] = lambda1;
110956
111066
  }
110957
111067
  };
110958
111068
  function boundsPoint$1(lambda, phi) {
110959
- ranges.push(range$2 = [lambda0$1 = lambda, lambda1 = lambda]);
111069
+ ranges.push(range$3 = [lambda0$1 = lambda, lambda1 = lambda]);
110960
111070
  if (phi < phi0)
110961
111071
  phi0 = phi;
110962
111072
  if (phi > phi1)
@@ -111008,7 +111118,7 @@ function linePoint(lambda, phi) {
111008
111118
  }
111009
111119
  }
111010
111120
  } else {
111011
- ranges.push(range$2 = [lambda0$1 = lambda, lambda1 = lambda]);
111121
+ ranges.push(range$3 = [lambda0$1 = lambda, lambda1 = lambda]);
111012
111122
  }
111013
111123
  if (phi < phi0)
111014
111124
  phi0 = phi;
@@ -111020,7 +111130,7 @@ function boundsLineStart() {
111020
111130
  boundsStream$1.point = linePoint;
111021
111131
  }
111022
111132
  function boundsLineEnd() {
111023
- range$2[0] = lambda0$1, range$2[1] = lambda1;
111133
+ range$3[0] = lambda0$1, range$3[1] = lambda1;
111024
111134
  boundsStream$1.point = boundsPoint$1;
111025
111135
  p0 = null;
111026
111136
  }
@@ -111042,7 +111152,7 @@ function boundsRingEnd() {
111042
111152
  areaStream$1.lineEnd();
111043
111153
  if (abs(deltaSum) > epsilon)
111044
111154
  lambda0$1 = -(lambda1 = 180);
111045
- range$2[0] = lambda0$1, range$2[1] = lambda1;
111155
+ range$3[0] = lambda0$1, range$3[1] = lambda1;
111046
111156
  p0 = null;
111047
111157
  }
111048
111158
  function angle(lambda02, lambda12) {
@@ -111078,7 +111188,7 @@ function bounds(feature2) {
111078
111188
  deltaMax = delta, lambda0$1 = b[0], lambda1 = a2[1];
111079
111189
  }
111080
111190
  }
111081
- ranges = range$2 = null;
111191
+ ranges = range$3 = null;
111082
111192
  return lambda0$1 === Infinity || phi0 === Infinity ? [[NaN, NaN], [NaN, NaN]] : [[lambda0$1, phi0], [lambda1, phi1]];
111083
111193
  }
111084
111194
  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 +111613,7 @@ function ascendingComparator(f2) {
111503
111613
  };
111504
111614
  }
111505
111615
  bisector(ascending);
111506
- function range$1(start, stop, step) {
111616
+ function range$2(start, stop, step) {
111507
111617
  start = +start, stop = +stop, step = (n3 = arguments.length) < 2 ? (stop = start, start = 0, 1) : n3 < 3 ? 1 : +step;
111508
111618
  var i2 = -1, n3 = Math.max(0, Math.ceil((stop - start) / step)) | 0, range2 = new Array(n3);
111509
111619
  while (++i2 < n3) {
@@ -111806,7 +111916,7 @@ function contains(object2, point2) {
111806
111916
  return (object2 && containsObjectType.hasOwnProperty(object2.type) ? containsObjectType[object2.type] : containsGeometry)(object2, point2);
111807
111917
  }
111808
111918
  function graticuleX(y02, y12, dy) {
111809
- var y2 = range$1(y02, y12 - epsilon, dy).concat(y12);
111919
+ var y2 = range$2(y02, y12 - epsilon, dy).concat(y12);
111810
111920
  return function(x2) {
111811
111921
  return y2.map(function(y22) {
111812
111922
  return [x2, y22];
@@ -111814,7 +111924,7 @@ function graticuleX(y02, y12, dy) {
111814
111924
  };
111815
111925
  }
111816
111926
  function graticuleY(x02, x12, dx) {
111817
- var x2 = range$1(x02, x12 - epsilon, dx).concat(x12);
111927
+ var x2 = range$2(x02, x12 - epsilon, dx).concat(x12);
111818
111928
  return function(y2) {
111819
111929
  return x2.map(function(x22) {
111820
111930
  return [x22, y2];
@@ -111827,9 +111937,9 @@ function graticule() {
111827
111937
  return { type: "MultiLineString", coordinates: lines() };
111828
111938
  }
111829
111939
  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) {
111940
+ 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
111941
  return abs(x22 % DX) > epsilon;
111832
- }).map(x2)).concat(range$1(ceil(y02 / dy) * dy, y12, dy).filter(function(y22) {
111942
+ }).map(x2)).concat(range$2(ceil(y02 / dy) * dy, y12, dy).filter(function(y22) {
111833
111943
  return abs(y22 % DY) > epsilon;
111834
111944
  }).map(y2));
111835
111945
  }
@@ -113516,16 +113626,16 @@ var polygonClipping_umd = { exports: {} };
113516
113626
  };
113517
113627
  Tree2.prototype.keys = function() {
113518
113628
  var keys3 = [];
113519
- this.forEach(function(_a2) {
113520
- var key = _a2.key;
113629
+ this.forEach(function(_a3) {
113630
+ var key = _a3.key;
113521
113631
  return keys3.push(key);
113522
113632
  });
113523
113633
  return keys3;
113524
113634
  };
113525
113635
  Tree2.prototype.values = function() {
113526
113636
  var values = [];
113527
- this.forEach(function(_a2) {
113528
- var data = _a2.data;
113637
+ this.forEach(function(_a3) {
113638
+ var data = _a3.data;
113529
113639
  return values.push(data);
113530
113640
  });
113531
113641
  return values;
@@ -113691,7 +113801,7 @@ var polygonClipping_umd = { exports: {} };
113691
113801
  };
113692
113802
  Tree2.prototype.update = function(key, newKey, newData) {
113693
113803
  var comparator2 = this._comparator;
113694
- var _a2 = split(key, this._root, comparator2), left = _a2.left, right = _a2.right;
113804
+ var _a3 = split(key, this._root, comparator2), left = _a3.left, right = _a3.right;
113695
113805
  if (comparator2(key, newKey) < 0) {
113696
113806
  right = insert2(newKey, newData, right, comparator2);
113697
113807
  } else {
@@ -116068,7 +116178,7 @@ EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
116068
116178
  }
116069
116179
  return this;
116070
116180
  };
116071
- function _listeners(target, type, unwrap) {
116181
+ function _listeners(target, type, unwrap2) {
116072
116182
  var events2 = target._events;
116073
116183
  if (events2 === void 0)
116074
116184
  return [];
@@ -116076,8 +116186,8 @@ function _listeners(target, type, unwrap) {
116076
116186
  if (evlistener === void 0)
116077
116187
  return [];
116078
116188
  if (typeof evlistener === "function")
116079
- return unwrap ? [evlistener.listener || evlistener] : [evlistener];
116080
- return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
116189
+ return unwrap2 ? [evlistener.listener || evlistener] : [evlistener];
116190
+ return unwrap2 ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
116081
116191
  }
116082
116192
  EventEmitter.prototype.listeners = function listeners(type) {
116083
116193
  return _listeners(this, type, true);
@@ -116127,7 +116237,7 @@ function unwrapListeners(arr) {
116127
116237
  return ret;
116128
116238
  }
116129
116239
  function once2(emitter, name2) {
116130
- return new Promise(function(resolve, reject) {
116240
+ return new Promise(function(resolve2, reject) {
116131
116241
  function errorListener(err2) {
116132
116242
  emitter.removeListener(name2, resolver);
116133
116243
  reject(err2);
@@ -116136,7 +116246,7 @@ function once2(emitter, name2) {
116136
116246
  if (typeof emitter.removeListener === "function") {
116137
116247
  emitter.removeListener("error", errorListener);
116138
116248
  }
116139
- resolve([].slice.call(arguments));
116249
+ resolve2([].slice.call(arguments));
116140
116250
  }
116141
116251
  eventTargetAgnosticAddListener(emitter, name2, resolver, { once: true });
116142
116252
  if (name2 !== "error") {
@@ -117487,9 +117597,9 @@ function getEditHandlesForGeometry(geometry2, featureIndex) {
117487
117597
  }
117488
117598
  break;
117489
117599
  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));
117600
+ for (var _a3 = 0; _a3 < geometry2.coordinates.length; _a3++) {
117601
+ for (var b = 0; b < geometry2.coordinates[_a3].length; b++) {
117602
+ handles = handles.concat(getEditHandlesForCoordinates(geometry2.coordinates[_a3][b], [_a3, b], featureIndex, editHandleType));
117493
117603
  handles = handles.slice(0, -1);
117494
117604
  }
117495
117605
  }
@@ -121324,9 +121434,9 @@ var ExtrudeMode = /* @__PURE__ */ function(_ModifyMode) {
121324
121434
  size2 = coordinates2[a2][b].length;
121325
121435
  }
121326
121436
  } else {
121327
- var _positionIndexes2 = _slicedToArray$3(positionIndexes, 1), _b = _positionIndexes2[0];
121328
- if (coordinates2.length && coordinates2[_b].length) {
121329
- size2 = coordinates2[_b].length;
121437
+ var _positionIndexes2 = _slicedToArray$3(positionIndexes, 1), _b2 = _positionIndexes2[0];
121438
+ if (coordinates2.length && coordinates2[_b2].length) {
121439
+ size2 = coordinates2[_b2].length;
121330
121440
  }
121331
121441
  }
121332
121442
  }
@@ -124739,12 +124849,12 @@ var reIsOctal = /^0o[0-7]+$/i;
124739
124849
  var freeParseInt = parseInt;
124740
124850
  var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
124741
124851
  var freeSelf = typeof self == "object" && self && self.Object === Object && self;
124742
- var root = freeGlobal || freeSelf || Function("return this")();
124852
+ var root$1 = freeGlobal || freeSelf || Function("return this")();
124743
124853
  var objectProto = Object.prototype;
124744
124854
  var objectToString = objectProto.toString;
124745
124855
  var nativeMax = Math.max, nativeMin = Math.min;
124746
124856
  var now = function() {
124747
- return root.Date.now();
124857
+ return root$1.Date.now();
124748
124858
  };
124749
124859
  function debounce(func, wait, options) {
124750
124860
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
@@ -132846,13 +132956,13 @@ class HeatmapBitmapLayer extends BitmapLayer$1 {
132846
132956
  });
132847
132957
  }
132848
132958
  updateState(args) {
132849
- var _a2;
132959
+ var _a3;
132850
132960
  super.updateState(args);
132851
132961
  this.loadTexture(this.props.image);
132852
132962
  const { props: props2, oldProps } = args;
132853
132963
  if (props2.colormap !== oldProps.colormap) {
132854
132964
  const { gl } = this.context;
132855
- (_a2 = this.state.model) == null ? void 0 : _a2.delete();
132965
+ (_a3 = this.state.model) == null ? void 0 : _a3.delete();
132856
132966
  this.state.model = this._getModel(gl);
132857
132967
  this.getAttributeManager().invalidateAll();
132858
132968
  }
@@ -133222,12 +133332,12 @@ class PaddedExpressionHeatmapBitmapLayer extends BitmapLayer$1 {
133222
133332
  });
133223
133333
  }
133224
133334
  updateState(args) {
133225
- var _a2;
133335
+ var _a3;
133226
133336
  super.updateState(args);
133227
133337
  const { props: props2, oldProps } = args;
133228
133338
  if (props2.colormap !== oldProps.colormap) {
133229
133339
  const { gl } = this.context;
133230
- (_a2 = this.state.model) == null ? void 0 : _a2.delete();
133340
+ (_a3 = this.state.model) == null ? void 0 : _a3.delete();
133231
133341
  this.state.model = this._getModel(gl);
133232
133342
  this.getAttributeManager().invalidateAll();
133233
133343
  }
@@ -133341,15 +133451,15 @@ class ScaledExpressionExtension extends LayerExtension {
133341
133451
  };
133342
133452
  }
133343
133453
  updateState({ props: props2, oldProps }) {
133344
- var _a2, _b, _c, _d;
133454
+ var _a3, _b2, _c, _d;
133345
133455
  if (props2.colormap !== oldProps.colormap) {
133346
133456
  const { gl } = this.context;
133347
133457
  if (this.state.model) {
133348
- (_a2 = this.state.model) == null ? void 0 : _a2.delete();
133458
+ (_a3 = this.state.model) == null ? void 0 : _a3.delete();
133349
133459
  this.state.model = this._getModel(gl);
133350
133460
  } else {
133351
133461
  if (this.state.models) {
133352
- (_b = this.state.models) == null ? void 0 : _b.forEach((model) => model == null ? void 0 : model.delete());
133462
+ (_b2 = this.state.models) == null ? void 0 : _b2.forEach((model) => model == null ? void 0 : model.delete());
133353
133463
  }
133354
133464
  if (this.state.topModel) {
133355
133465
  (_c = this.state.topModel) == null ? void 0 : _c.delete();
@@ -133450,23 +133560,23 @@ class SelectionExtension extends LayerExtension {
133450
133560
  }
133451
133561
  }
133452
133562
  SelectionExtension.extensionName = "SelectionExtension";
133453
- const registry$1 = /* @__PURE__ */ new Map();
133563
+ const registry$2 = /* @__PURE__ */ new Map();
133454
133564
  function addDecoder(cases, importFn) {
133455
133565
  if (!Array.isArray(cases)) {
133456
133566
  cases = [cases];
133457
133567
  }
133458
- cases.forEach((c) => registry$1.set(c, importFn));
133568
+ cases.forEach((c) => registry$2.set(c, importFn));
133459
133569
  }
133460
- addDecoder([void 0, 1], () => import("./raw-97a0822f.js").then((m) => m.default));
133461
- addDecoder(5, () => import("./lzw-5ac3b5e2.js").then((m) => m.default));
133570
+ addDecoder([void 0, 1], () => import("./raw-7e5381d5.js").then((m) => m.default));
133571
+ addDecoder(5, () => import("./lzw-a22317ac.js").then((m) => m.default));
133462
133572
  addDecoder(6, () => {
133463
133573
  throw new Error("old style JPEG compression is not supported.");
133464
133574
  });
133465
- addDecoder(7, () => import("./jpeg-81916128.js").then((m) => m.default));
133466
- addDecoder([8, 32946], () => import("./deflate-90c1ea8c.js").then((m) => m.default));
133467
- addDecoder(32773, () => import("./packbits-4d0460ce.js").then((m) => m.default));
133468
- addDecoder(34887, () => import("./lerc-7dc5ecab.js").then((m) => m.default));
133469
- addDecoder(50001, () => import("./webimage-2f02c049.js").then((m) => m.default));
133575
+ addDecoder(7, () => import("./jpeg-780f2a29.js").then((m) => m.default));
133576
+ addDecoder([8, 32946], () => import("./deflate-d62c010f.js").then((m) => m.default));
133577
+ addDecoder(32773, () => import("./packbits-757ef203.js").then((m) => m.default));
133578
+ addDecoder(34887, () => import("./lerc-11712e42.js").then((m) => m.default));
133579
+ addDecoder(50001, () => import("./webimage-ec283d98.js").then((m) => m.default));
133470
133580
  function decodeRowAcc(row, stride) {
133471
133581
  let length2 = row.length - stride;
133472
133582
  let offset = 0;
@@ -134932,9 +135042,41 @@ function requireJson2xml() {
134932
135042
  return exports2.convertTonimn(exports2.getTraversalObj(xmlData, options), schema, options);
134933
135043
  };
134934
135044
  })(parser);
134935
- const registry = /* @__PURE__ */ new Map();
135045
+ const registry$1 = /* @__PURE__ */ new Map();
134936
135046
  function addCodec(id, importFn) {
134937
- registry.set(id, importFn);
135047
+ registry$1.set(id, importFn);
135048
+ }
135049
+ class BoundsCheckError extends RangeError {
135050
+ constructor(message) {
135051
+ super(message);
135052
+ this.__zarr__ = "BoundsCheckError";
135053
+ Object.setPrototypeOf(this, BoundsCheckError.prototype);
135054
+ }
135055
+ }
135056
+ class InvalidSliceError extends RangeError {
135057
+ constructor(from, to, stepSize, reason) {
135058
+ super(`slice arguments slice(${from}, ${to}, ${stepSize}) invalid: ${reason}`);
135059
+ this.__zarr__ = "InvalidSliceError";
135060
+ Object.setPrototypeOf(this, InvalidSliceError.prototype);
135061
+ }
135062
+ }
135063
+ function slice$1(start, stop = void 0, step = null) {
135064
+ if (start === void 0) {
135065
+ throw new InvalidSliceError(start, stop, step, "The first argument must not be undefined");
135066
+ }
135067
+ if (typeof start === "string" && start !== ":" || typeof stop === "string" && stop !== ":") {
135068
+ throw new InvalidSliceError(start, stop, step, 'Arguments can only be integers, ":" or null');
135069
+ }
135070
+ if (stop === void 0) {
135071
+ stop = start;
135072
+ start = null;
135073
+ }
135074
+ return {
135075
+ start: start === ":" ? null : start,
135076
+ stop: stop === ":" ? null : stop,
135077
+ step,
135078
+ _slice: true
135079
+ };
134938
135080
  }
134939
135081
  typeof process !== "undefined" && process.versions && process.versions.node;
134940
135082
  function createCommonjsModule(fn) {
@@ -135121,11 +135263,11 @@ var pFinally = (promise, onFinally) => {
135121
135263
  onFinally = onFinally || (() => {
135122
135264
  });
135123
135265
  return promise.then(
135124
- (val) => new Promise((resolve) => {
135125
- resolve(onFinally());
135266
+ (val) => new Promise((resolve2) => {
135267
+ resolve2(onFinally());
135126
135268
  }).then(() => val),
135127
- (err2) => new Promise((resolve) => {
135128
- resolve(onFinally());
135269
+ (err2) => new Promise((resolve2) => {
135270
+ resolve2(onFinally());
135129
135271
  }).then(() => {
135130
135272
  throw err2;
135131
135273
  })
@@ -135137,18 +135279,18 @@ class TimeoutError extends Error {
135137
135279
  this.name = "TimeoutError";
135138
135280
  }
135139
135281
  }
135140
- const pTimeout = (promise, milliseconds, fallback) => new Promise((resolve, reject) => {
135282
+ const pTimeout = (promise, milliseconds, fallback) => new Promise((resolve2, reject) => {
135141
135283
  if (typeof milliseconds !== "number" || milliseconds < 0) {
135142
135284
  throw new TypeError("Expected `milliseconds` to be a positive number");
135143
135285
  }
135144
135286
  if (milliseconds === Infinity) {
135145
- resolve(promise);
135287
+ resolve2(promise);
135146
135288
  return;
135147
135289
  }
135148
135290
  const timer = setTimeout(() => {
135149
135291
  if (typeof fallback === "function") {
135150
135292
  try {
135151
- resolve(fallback());
135293
+ resolve2(fallback());
135152
135294
  } catch (error2) {
135153
135295
  reject(error2);
135154
135296
  }
@@ -135163,7 +135305,7 @@ const pTimeout = (promise, milliseconds, fallback) => new Promise((resolve, reje
135163
135305
  }, milliseconds);
135164
135306
  pFinally(
135165
135307
  // eslint-disable-next-line promise/prefer-await-to-then
135166
- promise.then(resolve, reject),
135308
+ promise.then(resolve2, reject),
135167
135309
  () => {
135168
135310
  clearTimeout(timer);
135169
135311
  }
@@ -140348,17 +140490,128 @@ function getChannelStats(arr) {
140348
140490
  contrastLimits
140349
140491
  };
140350
140492
  }
140351
- function isInterleaved$1(shape) {
140493
+ function isInterleaved$2(shape) {
140352
140494
  const lastDimSize = shape[shape.length - 1];
140353
140495
  return lastDimSize === 3 || lastDimSize === 4;
140354
140496
  }
140497
+ function getDims(labels) {
140498
+ const lookup = new Map(labels.map((name2, i2) => [name2, i2]));
140499
+ if (lookup.size !== labels.length) {
140500
+ throw Error("Labels must be unique, found duplicated label.");
140501
+ }
140502
+ return (name2) => {
140503
+ const index2 = lookup.get(name2);
140504
+ if (index2 === void 0) {
140505
+ throw Error("Invalid dimension.");
140506
+ }
140507
+ return index2;
140508
+ };
140509
+ }
140355
140510
  function getImageSize(source) {
140356
- const interleaved = isInterleaved$1(source.shape);
140511
+ const interleaved = isInterleaved$2(source.shape);
140357
140512
  const [height, width] = source.shape.slice(interleaved ? -3 : -2);
140358
140513
  return { height, width };
140359
140514
  }
140360
140515
  const SIGNAL_ABORTED = "__vivSignalAborted";
140361
140516
  addDecoder(5, () => LZWDecoder);
140517
+ function getIndexer(labels) {
140518
+ const size2 = labels.length;
140519
+ const dims = getDims(labels);
140520
+ return (sel) => {
140521
+ if (Array.isArray(sel)) {
140522
+ return [...sel];
140523
+ }
140524
+ const selection = Array(size2).fill(0);
140525
+ for (const [key, value] of Object.entries(sel)) {
140526
+ selection[dims(key)] = value;
140527
+ }
140528
+ return selection;
140529
+ };
140530
+ }
140531
+ const DTYPE_LOOKUP = {
140532
+ u1: "Uint8",
140533
+ u2: "Uint16",
140534
+ u4: "Uint32",
140535
+ f4: "Float32",
140536
+ f8: "Float64",
140537
+ i1: "Int8",
140538
+ i2: "Int16",
140539
+ i4: "Int32"
140540
+ };
140541
+ class ZarrPixelSource {
140542
+ constructor(data, labels, tileSize) {
140543
+ this.labels = labels;
140544
+ this.tileSize = tileSize;
140545
+ this._indexer = getIndexer(labels);
140546
+ this._data = data;
140547
+ const xChunkSize = data.chunks[this._xIndex];
140548
+ const yChunkSize = data.chunks[this._xIndex - 1];
140549
+ this._readChunks = tileSize === xChunkSize && tileSize === yChunkSize;
140550
+ }
140551
+ get shape() {
140552
+ return this._data.shape;
140553
+ }
140554
+ get dtype() {
140555
+ const suffix = this._data.dtype.slice(1);
140556
+ if (!(suffix in DTYPE_LOOKUP)) {
140557
+ throw Error(`Zarr dtype not supported, got ${suffix}.`);
140558
+ }
140559
+ return DTYPE_LOOKUP[suffix];
140560
+ }
140561
+ get _xIndex() {
140562
+ const interleave = isInterleaved$2(this._data.shape);
140563
+ return this._data.shape.length - (interleave ? 2 : 1);
140564
+ }
140565
+ _chunkIndex(selection, x2, y2) {
140566
+ const sel = this._indexer(selection);
140567
+ sel[this._xIndex] = x2;
140568
+ sel[this._xIndex - 1] = y2;
140569
+ return sel;
140570
+ }
140571
+ _getSlices(x2, y2) {
140572
+ const { height, width } = getImageSize(this);
140573
+ const [xStart, xStop] = [
140574
+ x2 * this.tileSize,
140575
+ Math.min((x2 + 1) * this.tileSize, width)
140576
+ ];
140577
+ const [yStart, yStop] = [
140578
+ y2 * this.tileSize,
140579
+ Math.min((y2 + 1) * this.tileSize, height)
140580
+ ];
140581
+ if (xStart === xStop || yStart === yStop) {
140582
+ throw new BoundsCheckError("Tile slice is zero-sized.");
140583
+ }
140584
+ return [slice$1(xStart, xStop), slice$1(yStart, yStop)];
140585
+ }
140586
+ async getRaster({ selection }) {
140587
+ const sel = this._chunkIndex(selection, null, null);
140588
+ const { data, shape } = await this._data.getRaw(sel);
140589
+ const [height, width] = shape;
140590
+ return { data, width, height };
140591
+ }
140592
+ async getTile(props2) {
140593
+ const { x: x2, y: y2, selection, signal } = props2;
140594
+ let res;
140595
+ if (this._readChunks) {
140596
+ const sel = this._chunkIndex(selection, x2, y2);
140597
+ res = await this._data.getRawChunk(sel, { storeOptions: { signal } });
140598
+ } else {
140599
+ const [xSlice, ySlice] = this._getSlices(x2, y2);
140600
+ const sel = this._chunkIndex(selection, xSlice, ySlice);
140601
+ res = await this._data.getRaw(sel);
140602
+ }
140603
+ const {
140604
+ data,
140605
+ shape: [height, width]
140606
+ } = res;
140607
+ return { data, width, height };
140608
+ }
140609
+ onTileError(err2) {
140610
+ if (!(err2 instanceof BoundsCheckError)) {
140611
+ throw err2;
140612
+ }
140613
+ }
140614
+ }
140362
140615
  const MAX_COLOR_INTENSITY = 255;
140363
140616
  const DEFAULT_COLOR_OFF = [0, 0, 0];
140364
140617
  const MAX_CHANNELS$1 = 6;
@@ -141850,8 +142103,8 @@ const defaultProps$4$1 = {
141850
142103
  };
141851
142104
  const AdditiveColormapExtension = class extends LayerExtension {
141852
142105
  getShaders() {
141853
- var _a2;
141854
- const name2 = ((_a2 = this == null ? void 0 : this.props) == null ? void 0 : _a2.colormap) || defaultProps$4$1.colormap.value;
142106
+ var _a3;
142107
+ const name2 = ((_a3 = this == null ? void 0 : this.props) == null ? void 0 : _a3.colormap) || defaultProps$4$1.colormap.value;
141855
142108
  const apply_cmap = cmaps[name2];
141856
142109
  if (!apply_cmap) {
141857
142110
  throw Error(`No colormap named ${name2} found in registry`);
@@ -141869,7 +142122,7 @@ const AdditiveColormapExtension = class extends LayerExtension {
141869
142122
  }
141870
142123
  }
141871
142124
  draw() {
141872
- var _a2;
142125
+ var _a3;
141873
142126
  const {
141874
142127
  useTransparentColor = defaultProps$4$1.useTransparentColor.value,
141875
142128
  opacity = defaultProps$4$1.opacity.value
@@ -141878,7 +142131,7 @@ const AdditiveColormapExtension = class extends LayerExtension {
141878
142131
  opacity,
141879
142132
  useTransparentColor
141880
142133
  };
141881
- (_a2 = this.state.model) == null ? void 0 : _a2.setUniforms(uniforms);
142134
+ (_a3 = this.state.model) == null ? void 0 : _a3.setUniforms(uniforms);
141882
142135
  }
141883
142136
  };
141884
142137
  AdditiveColormapExtension.extensionName = "AdditiveColormapExtension";
@@ -141963,7 +142216,7 @@ const ColorPaletteExtension = class extends LayerExtension {
141963
142216
  };
141964
142217
  }
141965
142218
  draw() {
141966
- var _a2;
142219
+ var _a3;
141967
142220
  const {
141968
142221
  colors,
141969
142222
  channelsVisible,
@@ -141981,7 +142234,7 @@ const ColorPaletteExtension = class extends LayerExtension {
141981
142234
  transparentColor: (transparentColor || [0, 0, 0]).map((i2) => i2 / 255),
141982
142235
  useTransparentColor: Boolean(useTransparentColor)
141983
142236
  };
141984
- (_a2 = this.state.model) == null ? void 0 : _a2.setUniforms(uniforms);
142237
+ (_a3 = this.state.model) == null ? void 0 : _a3.setUniforms(uniforms);
141985
142238
  }
141986
142239
  };
141987
142240
  ColorPaletteExtension.extensionName = "ColorPaletteExtension";
@@ -142126,7 +142379,7 @@ const LensExtension = class extends LayerExtension {
142126
142379
  this.setState({ onMouseMove, unprojectLensBounds: [0, 0, 0, 0] });
142127
142380
  }
142128
142381
  draw() {
142129
- var _a2;
142382
+ var _a3;
142130
142383
  const { unprojectLensBounds = [0, 0, 0, 0] } = this.state;
142131
142384
  const {
142132
142385
  bounds: bounds2,
@@ -142160,14 +142413,14 @@ const LensExtension = class extends LayerExtension {
142160
142413
  lensBorderRadius,
142161
142414
  colors: paddedColors
142162
142415
  };
142163
- (_a2 = this.state.model) == null ? void 0 : _a2.setUniforms(uniforms);
142416
+ (_a3 = this.state.model) == null ? void 0 : _a3.setUniforms(uniforms);
142164
142417
  }
142165
142418
  finalizeState() {
142166
- var _a2, _b, _c;
142419
+ var _a3, _b2, _c;
142167
142420
  if (this.context.deck) {
142168
142421
  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,
142422
+ pointermove: (_a3 = this.state) == null ? void 0 : _a3.onMouseMove,
142423
+ pointerleave: (_b2 = this.state) == null ? void 0 : _b2.onMouseMove,
142171
142424
  wheel: (_c = this.state) == null ? void 0 : _c.onMouseMove
142172
142425
  });
142173
142426
  }
@@ -142195,8 +142448,8 @@ const BaseExtension$1 = class extends LayerExtension {
142195
142448
  this.opts = this.opts || {};
142196
142449
  }
142197
142450
  getShaders() {
142198
- var _a2;
142199
- const name2 = ((_a2 = this == null ? void 0 : this.props) == null ? void 0 : _a2.colormap) || defaultProps$1$2.colormap.value;
142451
+ var _a3;
142452
+ const name2 = ((_a3 = this == null ? void 0 : this.props) == null ? void 0 : _a3.colormap) || defaultProps$1$2.colormap.value;
142200
142453
  const apply_cmap = cmaps[name2];
142201
142454
  return {
142202
142455
  ...super.getShaders(),
@@ -142304,7 +142557,7 @@ const BaseExtension = class extends LayerExtension {
142304
142557
  this.opts = this.opts || {};
142305
142558
  }
142306
142559
  draw() {
142307
- var _a2;
142560
+ var _a3;
142308
142561
  const { colors, channelsVisible } = this.props;
142309
142562
  const paddedColors = padColors({
142310
142563
  channelsVisible: channelsVisible || this.selections.map(() => true),
@@ -142313,7 +142566,7 @@ const BaseExtension = class extends LayerExtension {
142313
142566
  const uniforms = {
142314
142567
  colors: paddedColors
142315
142568
  };
142316
- (_a2 = this.state.model) == null ? void 0 : _a2.setUniforms(uniforms);
142569
+ (_a3 = this.state.model) == null ? void 0 : _a3.setUniforms(uniforms);
142317
142570
  }
142318
142571
  };
142319
142572
  BaseExtension.extensionName = "BaseExtension";
@@ -142411,7 +142664,7 @@ const channels = {
142411
142664
  },
142412
142665
  fs: fs$2
142413
142666
  };
142414
- function range(len2) {
142667
+ function range$1(len2) {
142415
142668
  return [...Array(len2).keys()];
142416
142669
  }
142417
142670
  function padWithDefault$2(arr, defaultValue2, padWidth) {
@@ -142452,8 +142705,8 @@ function padContrastLimits({
142452
142705
  return paddedContrastLimits;
142453
142706
  }
142454
142707
  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) ?? {};
142708
+ var _a3;
142709
+ const { x: x2, y: y2, z: z2 } = ((_a3 = loader == null ? void 0 : loader.meta) == null ? void 0 : _a3.physicalSizes) ?? {};
142457
142710
  if ((x2 == null ? void 0 : x2.size) && (y2 == null ? void 0 : y2.size) && (z2 == null ? void 0 : z2.size)) {
142458
142711
  const min2 = Math.min(z2.size, x2.size, y2.size);
142459
142712
  const ratio = [x2.size / min2, y2.size / min2, z2.size / min2];
@@ -142719,7 +142972,7 @@ const XRLayer = class extends Layer {
142719
142972
  }
142720
142973
  }
142721
142974
  updateState({ props: props2, oldProps, changeFlags, ...rest }) {
142722
- var _a2, _b;
142975
+ var _a3, _b2;
142723
142976
  super.updateState({ props: props2, oldProps, changeFlags, ...rest });
142724
142977
  if (changeFlags.extensionsChanged || props2.interpolation !== oldProps.interpolation) {
142725
142978
  const { gl } = this.context;
@@ -142729,7 +142982,7 @@ const XRLayer = class extends Layer {
142729
142982
  this.setState({ model: this._getModel(gl) });
142730
142983
  this.getAttributeManager().invalidateAll();
142731
142984
  }
142732
- 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) {
142985
+ 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) {
142733
142986
  this.loadChannelTextures(props2.channelData);
142734
142987
  }
142735
142988
  const attributeManager = this.getAttributeManager();
@@ -142813,7 +143066,7 @@ const XRLayer = class extends Layer {
142813
143066
  }
142814
143067
  }
142815
143068
  dataToTexture(data, width, height) {
142816
- var _a2;
143069
+ var _a3;
142817
143070
  const { interpolation } = this.props;
142818
143071
  const attrs = getRenderingAttrs$1(
142819
143072
  this.props.dtype,
@@ -142823,7 +143076,7 @@ const XRLayer = class extends Layer {
142823
143076
  return new Texture2D(this.context.gl, {
142824
143077
  width,
142825
143078
  height,
142826
- data: ((_a2 = attrs.cast) == null ? void 0 : _a2.call(attrs, data)) ?? data,
143079
+ data: ((_a3 = attrs.cast) == null ? void 0 : _a3.call(attrs, data)) ?? data,
142827
143080
  mipmaps: false,
142828
143081
  parameters: {
142829
143082
  [GL$1.TEXTURE_MIN_FILTER]: attrs.filter,
@@ -142973,7 +143226,7 @@ function renderSubLayers(props2) {
142973
143226
  data.width < base.tileSize ? width : right,
142974
143227
  top
142975
143228
  ];
142976
- if (isInterleaved$1(base.shape)) {
143229
+ if (isInterleaved$2(base.shape)) {
142977
143230
  const { photometricInterpretation = 2 } = base.meta;
142978
143231
  return new BitmapLayer2(props2, {
142979
143232
  image: data,
@@ -143060,13 +143313,13 @@ const ImageLayer = class extends CompositeLayer {
143060
143313
  const getRaster = (selection) => loader.getRaster({ selection, signal });
143061
143314
  const dataPromises = selections.map(getRaster);
143062
143315
  Promise.all(dataPromises).then((rasters) => {
143063
- var _a2, _b;
143316
+ var _a3, _b2;
143064
143317
  const raster = {
143065
143318
  data: rasters.map((d) => d.data),
143066
- width: (_a2 = rasters[0]) == null ? void 0 : _a2.width,
143067
- height: (_b = rasters[0]) == null ? void 0 : _b.height
143319
+ width: (_a3 = rasters[0]) == null ? void 0 : _a3.width,
143320
+ height: (_b2 = rasters[0]) == null ? void 0 : _b2.height
143068
143321
  };
143069
- if (isInterleaved$1(loader.shape)) {
143322
+ if (isInterleaved$2(loader.shape)) {
143070
143323
  raster.data = raster.data[0];
143071
143324
  if (raster.data.length === raster.width * raster.height * 3) {
143072
143325
  raster.format = GL$1.RGB;
@@ -143096,7 +143349,7 @@ const ImageLayer = class extends CompositeLayer {
143096
143349
  if (!(width && height))
143097
143350
  return null;
143098
143351
  const bounds2 = [0, height, width, 0];
143099
- if (isInterleaved$1(loader.shape)) {
143352
+ if (isInterleaved$2(loader.shape)) {
143100
143353
  const { photometricInterpretation = 2 } = loader.meta;
143101
143354
  return new BitmapLayer2(this.props, {
143102
143355
  image: this.state,
@@ -143165,7 +143418,7 @@ const MultiscaleImageLayer = class extends CompositeLayer {
143165
143418
  width: tiles[0].width,
143166
143419
  height: tiles[0].height
143167
143420
  };
143168
- if (isInterleaved$1(loader[resolution].shape)) {
143421
+ if (isInterleaved$2(loader[resolution].shape)) {
143169
143422
  tile.data = tile.data[0];
143170
143423
  if (tile.data.length === tile.width * tile.height * 3) {
143171
143424
  tile.format = GL$1.RGB;
@@ -143441,7 +143694,7 @@ const ScaleBarLayer = class extends CompositeLayer {
143441
143694
  sizeScale: 2 ** -zoom,
143442
143695
  characterSet: [
143443
143696
  ...displayUnit.split(""),
143444
- ...range(10).map((i2) => String(i2)),
143697
+ ...range$1(10).map((i2) => String(i2)),
143445
143698
  ".",
143446
143699
  "e",
143447
143700
  "+"
@@ -143807,7 +144060,7 @@ const XR3DLayer = class extends Layer {
143807
144060
  }
143808
144061
  }
143809
144062
  updateState({ props: props2, oldProps, changeFlags }) {
143810
- var _a2, _b;
144063
+ var _a3, _b2;
143811
144064
  if (changeFlags.extensionsChanged || props2.colormap !== oldProps.colormap || props2.renderingMode !== oldProps.renderingMode || props2.clippingPlanes.length !== oldProps.clippingPlanes.length) {
143812
144065
  const { gl } = this.context;
143813
144066
  if (this.state.model) {
@@ -143815,7 +144068,7 @@ const XR3DLayer = class extends Layer {
143815
144068
  }
143816
144069
  this.setState({ model: this._getModel(gl) });
143817
144070
  }
143818
- 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)) {
144071
+ 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)) {
143819
144072
  this.loadTexture(props2.channelData);
143820
144073
  }
143821
144074
  }
@@ -143924,13 +144177,13 @@ const XR3DLayer = class extends Layer {
143924
144177
  }
143925
144178
  }
143926
144179
  dataToTexture(data, width, height, depth) {
143927
- var _a2;
144180
+ var _a3;
143928
144181
  const attrs = getRenderingAttrs();
143929
144182
  const texture = new Texture3D(this.context.gl, {
143930
144183
  width,
143931
144184
  height,
143932
144185
  depth,
143933
- data: ((_a2 = attrs.cast) == null ? void 0 : _a2.call(attrs, data)) ?? data,
144186
+ data: ((_a3 = attrs.cast) == null ? void 0 : _a3.call(attrs, data)) ?? data,
143934
144187
  format: attrs.dataFormat,
143935
144188
  dataFormat: attrs.format,
143936
144189
  type: attrs.type,
@@ -144099,14 +144352,14 @@ const VolumeLayer = class extends CompositeLayer {
144099
144352
  loader[resolution]
144100
144353
  );
144101
144354
  Promise.all(volumePromises).then((volumes) => {
144102
- var _a2, _b, _c;
144355
+ var _a3, _b2, _c;
144103
144356
  if (onViewportLoad) {
144104
144357
  onViewportLoad(volumes);
144105
144358
  }
144106
144359
  const volume = {
144107
144360
  data: volumes.map((d) => d.data),
144108
- width: (_a2 = volumes[0]) == null ? void 0 : _a2.width,
144109
- height: (_b = volumes[0]) == null ? void 0 : _b.height,
144361
+ width: (_a3 = volumes[0]) == null ? void 0 : _a3.width,
144362
+ height: (_b2 = volumes[0]) == null ? void 0 : _b2.height,
144110
144363
  depth: (_c = volumes[0]) == null ? void 0 : _c.depth
144111
144364
  };
144112
144365
  this.setState({
@@ -144639,9 +144892,9 @@ function multiSetsToTextureData(multiFeatureValues, setColorValues, channelIsSet
144639
144892
  let totalValuesLength = 0;
144640
144893
  let totalColorsLength = 0;
144641
144894
  channelIsSetColorMode.forEach((isSetColorMode, channelIndex) => {
144642
- var _a2, _b, _c, _d, _e;
144895
+ var _a3, _b2, _c, _d, _e;
144643
144896
  if (isSetColorMode) {
144644
- totalValuesLength += ((_b = (_a2 = setColorValues[channelIndex]) == null ? void 0 : _a2.obsIndex) == null ? void 0 : _b.length) || 0;
144897
+ totalValuesLength += ((_b2 = (_a3 = setColorValues[channelIndex]) == null ? void 0 : _a3.obsIndex) == null ? void 0 : _b2.length) || 0;
144645
144898
  totalColorsLength += (((_d = (_c = setColorValues[channelIndex]) == null ? void 0 : _c.setColors) == null ? void 0 : _d.length) || 0) * 3;
144646
144899
  } else {
144647
144900
  totalValuesLength += ((_e = multiFeatureValues[channelIndex]) == null ? void 0 : _e.length) || 0;
@@ -144822,7 +145075,7 @@ class BitmaskLayer2 extends XRLayer {
144822
145075
  } = this.state;
144823
145076
  if (textures && model) {
144824
145077
  const scaleFactor = 1 / 2 ** (maxZoom - zoom);
144825
- const colors = fromEntries(range$5(MAX_CHANNELS).map((i2) => [`color${i2}`, getColor(channelColors[i2])]));
145078
+ const colors = fromEntries(range$6(MAX_CHANNELS).map((i2) => [`color${i2}`, getColor(channelColors[i2])]));
144826
145079
  model.setUniforms(Object.assign({}, uniforms, {
144827
145080
  ...colors,
144828
145081
  // Bitmask image channel data textures
@@ -145042,8 +145295,8 @@ const getMultiSelectionStats = async ({ loader, selections, use3d }) => {
145042
145295
  return { domains, sliders };
145043
145296
  };
145044
145297
  function getPhysicalSizeScalingMatrix(loader) {
145045
- var _a2;
145046
- const { x: x2, y: y2, z: z2 } = ((_a2 = loader == null ? void 0 : loader.meta) == null ? void 0 : _a2.physicalSizes) ?? {};
145298
+ var _a3;
145299
+ const { x: x2, y: y2, z: z2 } = ((_a3 = loader == null ? void 0 : loader.meta) == null ? void 0 : _a3.physicalSizes) ?? {};
145047
145300
  if ((x2 == null ? void 0 : x2.size) && (y2 == null ? void 0 : y2.size) && (z2 == null ? void 0 : z2.size)) {
145048
145301
  const min2 = Math.min(z2.size, x2.size, y2.size);
145049
145302
  const ratio = [x2.size / min2, y2.size / min2, z2.size / min2];
@@ -145134,7 +145387,7 @@ const getStatsForResolution = (loader, resolution) => {
145134
145387
  };
145135
145388
  };
145136
145389
  const canLoadResolution = (loader, resolution) => {
145137
- var _a2, _b, _c;
145390
+ var _a3, _b2, _c;
145138
145391
  const {
145139
145392
  totalBytes,
145140
145393
  height,
@@ -145144,7 +145397,7 @@ const canLoadResolution = (loader, resolution) => {
145144
145397
  loader,
145145
145398
  resolution
145146
145399
  );
145147
- 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;
145400
+ 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;
145148
145401
  const maxSize = maxHeapSize || 2 ** 31 - 1;
145149
145402
  return totalBytes < maxSize && height <= 2048 && depthDownsampled <= 2048 && width <= 2048 && depthDownsampled > 1;
145150
145403
  };
@@ -145189,19 +145442,19 @@ function physicalSizeToMatrix(xSize, ySize, zSize, xUnit, yUnit, zUnit) {
145189
145442
  function getMetaWithTransformMatrices(imageMeta, imageLoaders) {
145190
145443
  const sources = imageLoaders.map((loader) => getSourceFromLoader(loader));
145191
145444
  if (imageMeta.map((meta2) => {
145192
- var _a2, _b, _c, _d, _e, _f;
145193
- 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);
145445
+ var _a3, _b2, _c, _d, _e, _f;
145446
+ 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);
145194
145447
  }).some(Boolean) || sources.every(
145195
145448
  (source) => {
145196
- var _a2, _b, _c, _d;
145197
- 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);
145449
+ var _a3, _b2, _c, _d;
145450
+ 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);
145198
145451
  }
145199
145452
  )) {
145200
145453
  return imageMeta;
145201
145454
  }
145202
145455
  const minPhysicalSize = sources.reduce((acc, source) => {
145203
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
145204
- const hasZPhyscialSize = (_c = (_b = (_a2 = source.meta) == null ? void 0 : _a2.physicalSizes) == null ? void 0 : _b.z) == null ? void 0 : _c.size;
145456
+ var _a3, _b2, _c, _d, _e, _f, _g, _h, _i;
145457
+ const hasZPhyscialSize = (_c = (_b2 = (_a3 = source.meta) == null ? void 0 : _a3.physicalSizes) == null ? void 0 : _b2.z) == null ? void 0 : _c.size;
145205
145458
  const sizes = [
145206
145459
  unit(`${(_d = source.meta) == null ? void 0 : _d.physicalSizes.x.size} ${(_e = source.meta) == null ? void 0 : _e.physicalSizes.x.unit}`.replace("µ", "u")),
145207
145460
  unit(`${(_f = source.meta) == null ? void 0 : _f.physicalSizes.y.size} ${(_g = source.meta) == null ? void 0 : _g.physicalSizes.y.unit}`.replace("µ", "u"))
@@ -145215,9 +145468,9 @@ function getMetaWithTransformMatrices(imageMeta, imageLoaders) {
145215
145468
  return acc;
145216
145469
  }, []);
145217
145470
  const imageMetaWithTransform = imageMeta.map((meta2, j) => {
145218
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
145471
+ var _a3, _b2, _c, _d, _e, _f, _g, _h, _i;
145219
145472
  const source = sources[j];
145220
- const hasZPhyscialSize = (_c = (_b = (_a2 = source.meta) == null ? void 0 : _a2.physicalSizes) == null ? void 0 : _b.z) == null ? void 0 : _c.size;
145473
+ const hasZPhyscialSize = (_c = (_b2 = (_a3 = source.meta) == null ? void 0 : _a3.physicalSizes) == null ? void 0 : _b2.z) == null ? void 0 : _c.size;
145221
145474
  const sizes = [
145222
145475
  unit(`${(_d = source.meta) == null ? void 0 : _d.physicalSizes.x.size} ${(_e = source.meta) == null ? void 0 : _e.physicalSizes.x.unit}`.replace("µ", "u")),
145223
145476
  unit(`${(_f = source.meta) == null ? void 0 : _f.physicalSizes.y.size} ${(_g = source.meta) == null ? void 0 : _g.physicalSizes.y.unit}`.replace("µ", "u"))
@@ -145272,7 +145525,7 @@ function buildDefaultSelection(source) {
145272
145525
  }
145273
145526
  return selection;
145274
145527
  }
145275
- function isInterleaved(shape) {
145528
+ function isInterleaved$1(shape) {
145276
145529
  const lastDimSize = shape[shape.length - 1];
145277
145530
  return lastDimSize === 3 || lastDimSize === 4;
145278
145531
  }
@@ -145280,7 +145533,7 @@ async function initializeLayerChannels(loader, use3d) {
145280
145533
  const result = [];
145281
145534
  const source = getSourceFromLoader(loader);
145282
145535
  let defaultSelection = buildDefaultSelection(source);
145283
- defaultSelection = isInterleaved(source.shape) ? [{ ...defaultSelection[0], c: 0 }] : defaultSelection;
145536
+ defaultSelection = isInterleaved$1(source.shape) ? [{ ...defaultSelection[0], c: 0 }] : defaultSelection;
145284
145537
  const stats = await getMultiSelectionStats({
145285
145538
  loader: loader.data,
145286
145539
  selections: defaultSelection,
@@ -145321,9 +145574,9 @@ async function initializeRasterLayersAndChannels(rasterLayers, rasterRenderLayer
145321
145574
  const layerIndex = Math.floor(rasterLayers.length / 2);
145322
145575
  const loader = nextImageLoaders[layerIndex];
145323
145576
  const autoImageLayerDefPromise = initializeLayerChannels(loader).then((channels2) => {
145324
- var _a2, _b, _c, _d, _e;
145577
+ var _a3, _b2, _c, _d, _e;
145325
145578
  return Promise.resolve({
145326
- type: ((_b = (_a2 = nextImageMetaAndLayers[layerIndex]) == null ? void 0 : _a2.metadata) == null ? void 0 : _b.isBitmask) ? "bitmask" : "raster",
145579
+ type: ((_b2 = (_a3 = nextImageMetaAndLayers[layerIndex]) == null ? void 0 : _a3.metadata) == null ? void 0 : _b2.isBitmask) ? "bitmask" : "raster",
145327
145580
  index: layerIndex,
145328
145581
  ...DEFAULT_RASTER_LAYER_PROPS,
145329
145582
  channels: channels2.map((channel, j) => ({
@@ -145341,9 +145594,9 @@ async function initializeRasterLayersAndChannels(rasterLayers, rasterRenderLayer
145341
145594
  const layerIndex = globalIndicesOfRenderLayers[i2];
145342
145595
  const loader = nextImageLoaders[layerIndex];
145343
145596
  const autoImageLayerDefPromise = initializeLayerChannels(loader).then((channels2) => {
145344
- var _a2, _b, _c, _d, _e;
145597
+ var _a3, _b2, _c, _d, _e;
145345
145598
  return Promise.resolve({
145346
- type: ((_b = (_a2 = nextImageMetaAndLayers[layerIndex]) == null ? void 0 : _a2.metadata) == null ? void 0 : _b.isBitmask) ? "bitmask" : "raster",
145599
+ type: ((_b2 = (_a3 = nextImageMetaAndLayers[layerIndex]) == null ? void 0 : _a3.metadata) == null ? void 0 : _b2.isBitmask) ? "bitmask" : "raster",
145347
145600
  index: layerIndex,
145348
145601
  ...DEFAULT_RASTER_LAYER_PROPS,
145349
145602
  channels: channels2.map((channel, j) => ({
@@ -145432,7 +145685,7 @@ function hexToRgb(hex) {
145432
145685
  ];
145433
145686
  }
145434
145687
  function normalizeCoordinateTransformations(coordinateTransformations, datasets) {
145435
- var _a2;
145688
+ var _a3;
145436
145689
  let result = [];
145437
145690
  if (Array.isArray(coordinateTransformations)) {
145438
145691
  result = coordinateTransformations.map((transform2) => {
@@ -145458,7 +145711,7 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
145458
145711
  return transform2;
145459
145712
  });
145460
145713
  }
145461
- if (Array.isArray((_a2 = datasets == null ? void 0 : datasets[0]) == null ? void 0 : _a2.coordinateTransformations)) {
145714
+ if (Array.isArray((_a3 = datasets == null ? void 0 : datasets[0]) == null ? void 0 : _a3.coordinateTransformations)) {
145462
145715
  result = [
145463
145716
  ...datasets[0].coordinateTransformations,
145464
145717
  ...result
@@ -145466,6 +145719,1490 @@ function normalizeCoordinateTransformations(coordinateTransformations, datasets)
145466
145719
  }
145467
145720
  return result;
145468
145721
  }
145722
+ class NodeNotFoundError extends Error {
145723
+ constructor(msg) {
145724
+ super(msg);
145725
+ this.name = "NodeNotFoundError";
145726
+ }
145727
+ }
145728
+ class KeyError extends Error {
145729
+ constructor(msg) {
145730
+ super(msg);
145731
+ this.name = "KeyError";
145732
+ }
145733
+ }
145734
+ class BoolArray {
145735
+ constructor(x2, byteOffset, length2) {
145736
+ __privateAdd(this, _bytes, void 0);
145737
+ if (typeof x2 === "number") {
145738
+ __privateSet(this, _bytes, new Uint8Array(x2));
145739
+ } else if (x2 instanceof ArrayBuffer) {
145740
+ __privateSet(this, _bytes, new Uint8Array(x2, byteOffset, length2));
145741
+ } else {
145742
+ __privateSet(this, _bytes, new Uint8Array(Array.from(x2, (v) => v ? 1 : 0)));
145743
+ }
145744
+ }
145745
+ get BYTES_PER_ELEMENT() {
145746
+ return 1;
145747
+ }
145748
+ get byteOffset() {
145749
+ return __privateGet(this, _bytes).byteOffset;
145750
+ }
145751
+ get byteLength() {
145752
+ return __privateGet(this, _bytes).byteLength;
145753
+ }
145754
+ /** @type {ArrayBuffer} */
145755
+ get buffer() {
145756
+ return __privateGet(this, _bytes).buffer;
145757
+ }
145758
+ /** @type {number} */
145759
+ get length() {
145760
+ return __privateGet(this, _bytes).length;
145761
+ }
145762
+ get(idx) {
145763
+ let value = __privateGet(this, _bytes)[idx];
145764
+ return typeof value === "number" ? value !== 0 : value;
145765
+ }
145766
+ set(idx, value) {
145767
+ __privateGet(this, _bytes)[idx] = value ? 1 : 0;
145768
+ }
145769
+ fill(value) {
145770
+ __privateGet(this, _bytes).fill(value ? 1 : 0);
145771
+ }
145772
+ *[Symbol.iterator]() {
145773
+ for (let i2 = 0; i2 < this.length; i2++) {
145774
+ yield this.get(i2);
145775
+ }
145776
+ }
145777
+ }
145778
+ _bytes = new WeakMap();
145779
+ class ByteStringArray {
145780
+ constructor(chars, x2, byteOffset, length2) {
145781
+ __publicField(this, "_data");
145782
+ __publicField(this, "chars");
145783
+ __privateAdd(this, _encoder, void 0);
145784
+ this.chars = chars;
145785
+ __privateSet(this, _encoder, new TextEncoder());
145786
+ if (typeof x2 === "number") {
145787
+ this._data = new Uint8Array(x2 * chars);
145788
+ } else if (x2 instanceof ArrayBuffer) {
145789
+ if (length2)
145790
+ length2 = length2 * chars;
145791
+ this._data = new Uint8Array(x2, byteOffset, length2);
145792
+ } else {
145793
+ let values = Array.from(x2);
145794
+ this._data = new Uint8Array(values.length * chars);
145795
+ for (let i2 = 0; i2 < values.length; i2++) {
145796
+ this.set(i2, values[i2]);
145797
+ }
145798
+ }
145799
+ }
145800
+ get BYTES_PER_ELEMENT() {
145801
+ return this.chars;
145802
+ }
145803
+ get byteOffset() {
145804
+ return this._data.byteOffset;
145805
+ }
145806
+ get byteLength() {
145807
+ return this._data.byteLength;
145808
+ }
145809
+ /** @type {ArrayBuffer} */
145810
+ get buffer() {
145811
+ return this._data.buffer;
145812
+ }
145813
+ /** @type {number} */
145814
+ get length() {
145815
+ return this.byteLength / this.BYTES_PER_ELEMENT;
145816
+ }
145817
+ get(idx) {
145818
+ const view = new Uint8Array(this.buffer, this.byteOffset + this.chars * idx, this.chars);
145819
+ return new TextDecoder().decode(view).replace(/\x00/g, "");
145820
+ }
145821
+ set(idx, value) {
145822
+ const view = new Uint8Array(this.buffer, this.byteOffset + this.chars * idx, this.chars);
145823
+ view.fill(0);
145824
+ view.set(__privateGet(this, _encoder).encode(value));
145825
+ }
145826
+ fill(value) {
145827
+ const encoded = __privateGet(this, _encoder).encode(value);
145828
+ for (let i2 = 0; i2 < this.length; i2++) {
145829
+ this._data.set(encoded, i2 * this.chars);
145830
+ }
145831
+ }
145832
+ *[Symbol.iterator]() {
145833
+ for (let i2 = 0; i2 < this.length; i2++) {
145834
+ yield this.get(i2);
145835
+ }
145836
+ }
145837
+ }
145838
+ _encoder = new WeakMap();
145839
+ const _UnicodeStringArray = class {
145840
+ constructor(chars, x2, byteOffset, length2) {
145841
+ __publicField(this, "_data");
145842
+ __publicField(this, "chars");
145843
+ __privateAdd(this, _encode_buffer, void 0);
145844
+ this.chars = chars;
145845
+ if (typeof x2 === "number") {
145846
+ this._data = new Int32Array(x2 * chars);
145847
+ } else if (x2 instanceof ArrayBuffer) {
145848
+ if (length2)
145849
+ length2 *= chars;
145850
+ this._data = new Int32Array(x2, byteOffset, length2);
145851
+ } else {
145852
+ const values = x2;
145853
+ const d = new _UnicodeStringArray(chars, 1);
145854
+ this._data = new Int32Array(function* () {
145855
+ for (let str of values) {
145856
+ d.set(0, str);
145857
+ yield* d._data;
145858
+ }
145859
+ }());
145860
+ }
145861
+ __privateSet(this, _encode_buffer, new Int32Array(chars));
145862
+ }
145863
+ get BYTES_PER_ELEMENT() {
145864
+ return this._data.BYTES_PER_ELEMENT * this.chars;
145865
+ }
145866
+ get byteLength() {
145867
+ return this._data.byteLength;
145868
+ }
145869
+ get byteOffset() {
145870
+ return this._data.byteOffset;
145871
+ }
145872
+ /** @type {ArrayBuffer} */
145873
+ get buffer() {
145874
+ return this._data.buffer;
145875
+ }
145876
+ /** @type {number} */
145877
+ get length() {
145878
+ return this._data.length / this.chars;
145879
+ }
145880
+ get(idx) {
145881
+ const offset = this.chars * idx;
145882
+ let result = "";
145883
+ for (let i2 = 0; i2 < this.chars; i2++) {
145884
+ result += String.fromCodePoint(this._data[offset + i2]);
145885
+ }
145886
+ return result.replace(/\u0000/g, "");
145887
+ }
145888
+ set(idx, value) {
145889
+ const offset = this.chars * idx;
145890
+ const view = this._data.subarray(offset, offset + this.chars);
145891
+ view.fill(0);
145892
+ for (let i2 = 0; i2 < this.chars; i2++) {
145893
+ view[i2] = value.codePointAt(i2) ?? 0;
145894
+ }
145895
+ }
145896
+ fill(value) {
145897
+ this.set(0, value);
145898
+ let encoded = this._data.subarray(0, this.chars);
145899
+ for (let i2 = 1; i2 < this.length; i2++) {
145900
+ this._data.set(encoded, i2 * this.chars);
145901
+ }
145902
+ }
145903
+ *[Symbol.iterator]() {
145904
+ for (let i2 = 0; i2 < this.length; i2++) {
145905
+ yield this.get(i2);
145906
+ }
145907
+ }
145908
+ };
145909
+ let UnicodeStringArray = _UnicodeStringArray;
145910
+ _encode_buffer = new WeakMap();
145911
+ function json_decode_object(bytes) {
145912
+ const str = new TextDecoder().decode(bytes);
145913
+ return JSON.parse(str);
145914
+ }
145915
+ function byteswap_inplace(view, bytes_per_element2) {
145916
+ const numFlips = bytes_per_element2 / 2;
145917
+ const endByteIndex = bytes_per_element2 - 1;
145918
+ let t2 = 0;
145919
+ for (let i2 = 0; i2 < view.length; i2 += bytes_per_element2) {
145920
+ for (let j = 0; j < numFlips; j += 1) {
145921
+ t2 = view[i2 + j];
145922
+ view[i2 + j] = view[i2 + endByteIndex - j];
145923
+ view[i2 + endByteIndex - j] = t2;
145924
+ }
145925
+ }
145926
+ }
145927
+ const CONSTRUCTORS = {
145928
+ int8: Int8Array,
145929
+ int16: Int16Array,
145930
+ int32: Int32Array,
145931
+ int64: globalThis.BigInt64Array,
145932
+ uint8: Uint8Array,
145933
+ uint16: Uint16Array,
145934
+ uint32: Uint32Array,
145935
+ uint64: globalThis.BigUint64Array,
145936
+ float32: Float32Array,
145937
+ float64: Float64Array,
145938
+ bool: BoolArray
145939
+ };
145940
+ const V2_STRING_REGEX = /v2:([US])(\d+)/;
145941
+ function get_ctr(data_type) {
145942
+ if (data_type === "v2:object") {
145943
+ return globalThis.Array;
145944
+ }
145945
+ let match = data_type.match(V2_STRING_REGEX);
145946
+ if (match) {
145947
+ let [, kind, chars] = match;
145948
+ return (kind === "U" ? UnicodeStringArray : ByteStringArray).bind(null, Number(chars));
145949
+ }
145950
+ let ctr = CONSTRUCTORS[data_type];
145951
+ if (!ctr) {
145952
+ throw new Error(`Unknown or unsupported data_type: ${data_type}`);
145953
+ }
145954
+ return ctr;
145955
+ }
145956
+ function get_strides(shape, order) {
145957
+ return (order === "C" ? row_major_stride : col_major_stride)(shape);
145958
+ }
145959
+ function row_major_stride(shape) {
145960
+ const ndim = shape.length;
145961
+ const stride = globalThis.Array(ndim);
145962
+ for (let i2 = ndim - 1, step = 1; i2 >= 0; i2--) {
145963
+ stride[i2] = step;
145964
+ step *= shape[i2];
145965
+ }
145966
+ return stride;
145967
+ }
145968
+ function col_major_stride(shape) {
145969
+ const ndim = shape.length;
145970
+ const stride = globalThis.Array(ndim);
145971
+ for (let i2 = 0, step = 1; i2 < ndim; i2++) {
145972
+ stride[i2] = step;
145973
+ step *= shape[i2];
145974
+ }
145975
+ return stride;
145976
+ }
145977
+ function create_chunk_key_encoder({ name: name2, configuration }) {
145978
+ if (name2 === "default") {
145979
+ return (chunk_coords) => ["c", ...chunk_coords].join(configuration.separator);
145980
+ }
145981
+ if (name2 === "v2") {
145982
+ return (chunk_coords) => chunk_coords.join(configuration.separator) || "0";
145983
+ }
145984
+ throw new Error(`Unknown chunk key encoding: ${name2}`);
145985
+ }
145986
+ function get_array_order(codecs) {
145987
+ var _a3;
145988
+ const maybe_transpose_codec = codecs.find((c) => c.name === "transpose");
145989
+ return ((_a3 = maybe_transpose_codec == null ? void 0 : maybe_transpose_codec.configuration) == null ? void 0 : _a3.order) === "F" ? "F" : "C";
145990
+ }
145991
+ const endian_regex = /^([<|>])(.*)$/;
145992
+ function coerce_dtype(dtype) {
145993
+ if (dtype === "|O") {
145994
+ return { data_type: "v2:object" };
145995
+ }
145996
+ let match = dtype.match(endian_regex);
145997
+ if (!match) {
145998
+ throw new Error(`Invalid dtype: ${dtype}`);
145999
+ }
146000
+ let [, endian, rest] = match;
146001
+ let data_type = {
146002
+ "b1": "bool",
146003
+ "i1": "int8",
146004
+ "u1": "uint8",
146005
+ "i2": "int16",
146006
+ "u2": "uint16",
146007
+ "i4": "int32",
146008
+ "u4": "uint32",
146009
+ "i8": "int64",
146010
+ "u8": "uint64",
146011
+ "f4": "float32",
146012
+ "f8": "float64"
146013
+ }[rest] ?? (rest.startsWith("S") || rest.startsWith("U") ? `v2:${rest}` : void 0);
146014
+ if (!data_type) {
146015
+ throw new Error(`Unsupported or unknown dtype: ${dtype}`);
146016
+ }
146017
+ if (endian === "|") {
146018
+ return { data_type };
146019
+ }
146020
+ return { data_type, endian: endian === "<" ? "little" : "big" };
146021
+ }
146022
+ function v2_to_v3_array_metadata(meta2, attributes = {}) {
146023
+ let codecs = [];
146024
+ let dtype = coerce_dtype(meta2.dtype);
146025
+ if (meta2.order === "F") {
146026
+ codecs.push({ name: "transpose", configuration: { order: "F" } });
146027
+ }
146028
+ if ("endian" in dtype && dtype.endian === "big") {
146029
+ codecs.push({ name: "bytes", configuration: { endian: "big" } });
146030
+ }
146031
+ for (let { id, ...configuration } of meta2.filters ?? []) {
146032
+ codecs.push({ name: id, configuration });
146033
+ }
146034
+ if (meta2.compressor) {
146035
+ let { id, ...configuration } = meta2.compressor;
146036
+ codecs.push({ name: id, configuration });
146037
+ }
146038
+ return {
146039
+ zarr_format: 3,
146040
+ node_type: "array",
146041
+ shape: meta2.shape,
146042
+ data_type: dtype.data_type,
146043
+ chunk_grid: {
146044
+ name: "regular",
146045
+ configuration: {
146046
+ chunk_shape: meta2.chunks
146047
+ }
146048
+ },
146049
+ chunk_key_encoding: {
146050
+ name: "v2",
146051
+ configuration: {
146052
+ separator: meta2.dimension_separator ?? "."
146053
+ }
146054
+ },
146055
+ codecs,
146056
+ fill_value: meta2.fill_value,
146057
+ attributes
146058
+ };
146059
+ }
146060
+ function v2_to_v3_group_metadata(_meta2, attributes = {}) {
146061
+ return {
146062
+ zarr_format: 3,
146063
+ node_type: "group",
146064
+ attributes
146065
+ };
146066
+ }
146067
+ function is_dtype(dtype, query) {
146068
+ if (query !== "number" && query !== "bigint" && query !== "boolean" && query !== "object" && query !== "string") {
146069
+ return dtype === query;
146070
+ }
146071
+ let is_boolean = dtype === "bool";
146072
+ if (query === "boolean")
146073
+ return is_boolean;
146074
+ let is_string = dtype.startsWith("v2:U") || dtype.startsWith("v2:S");
146075
+ if (query === "string")
146076
+ return is_string;
146077
+ let is_bigint = dtype === "int64" || dtype === "uint64";
146078
+ if (query === "bigint")
146079
+ return is_bigint;
146080
+ let is_object = dtype === "v2:object";
146081
+ if (query === "object")
146082
+ return is_object;
146083
+ return !is_string && !is_bigint && !is_boolean && !is_object;
146084
+ }
146085
+ function is_sharding_codec(codec) {
146086
+ return (codec == null ? void 0 : codec.name) === "sharding_indexed";
146087
+ }
146088
+ function ensure_correct_scalar(metadata) {
146089
+ if ((metadata.data_type === "uint64" || metadata.data_type === "int64") && metadata.fill_value != void 0) {
146090
+ return BigInt(metadata.fill_value);
146091
+ }
146092
+ return metadata.fill_value;
146093
+ }
146094
+ function proxy(arr) {
146095
+ if (arr instanceof BoolArray || arr instanceof ByteStringArray || arr instanceof UnicodeStringArray) {
146096
+ return new Proxy(arr, {
146097
+ get(target, prop) {
146098
+ return target.get(Number(prop));
146099
+ },
146100
+ set(target, prop, value) {
146101
+ target.set(Number(prop), value);
146102
+ return true;
146103
+ }
146104
+ });
146105
+ }
146106
+ return arr;
146107
+ }
146108
+ function empty_like(chunk, order) {
146109
+ let data;
146110
+ if (chunk.data instanceof ByteStringArray || chunk.data instanceof UnicodeStringArray) {
146111
+ data = new chunk.constructor(
146112
+ // @ts-expect-error
146113
+ chunk.data.length,
146114
+ chunk.data.chars
146115
+ );
146116
+ } else {
146117
+ data = new chunk.constructor(chunk.data.length);
146118
+ }
146119
+ return {
146120
+ data,
146121
+ shape: chunk.shape,
146122
+ stride: get_strides(chunk.shape, order)
146123
+ };
146124
+ }
146125
+ function convert_array_order(src2, target) {
146126
+ let out = empty_like(src2, target);
146127
+ let n_dims = src2.shape.length;
146128
+ let size2 = src2.data.length;
146129
+ let index2 = Array(n_dims).fill(0);
146130
+ let src_data = proxy(src2.data);
146131
+ let out_data = proxy(out.data);
146132
+ for (let src_idx = 0; src_idx < size2; src_idx++) {
146133
+ let out_idx = 0;
146134
+ for (let dim = 0; dim < n_dims; dim++) {
146135
+ out_idx += index2[dim] * out.stride[dim];
146136
+ }
146137
+ out_data[out_idx] = src_data[src_idx];
146138
+ index2[0] += 1;
146139
+ for (let dim = 0; dim < n_dims; dim++) {
146140
+ if (index2[dim] === src2.shape[dim]) {
146141
+ if (dim + 1 === n_dims) {
146142
+ break;
146143
+ }
146144
+ index2[dim] = 0;
146145
+ index2[dim + 1] += 1;
146146
+ }
146147
+ }
146148
+ }
146149
+ return out;
146150
+ }
146151
+ function get_order(arr) {
146152
+ if (!arr.stride)
146153
+ return "C";
146154
+ let row_major_strides = get_strides(arr.shape, "C");
146155
+ return arr.stride.every((s2, i2) => s2 === row_major_strides[i2]) ? "C" : "F";
146156
+ }
146157
+ class TransposeCodec {
146158
+ constructor(configuration) {
146159
+ __publicField(this, "configuration");
146160
+ __publicField(this, "kind", "array_to_array");
146161
+ this.configuration = configuration;
146162
+ }
146163
+ static fromConfig(configuration) {
146164
+ return new TransposeCodec(configuration);
146165
+ }
146166
+ encode(arr) {
146167
+ if (get_order(arr) === this.configuration.order) {
146168
+ return arr;
146169
+ }
146170
+ return convert_array_order(arr, this.configuration.order);
146171
+ }
146172
+ decode(arr) {
146173
+ return arr;
146174
+ }
146175
+ }
146176
+ const LITTLE_ENDIAN_OS = system_is_little_endian();
146177
+ function system_is_little_endian() {
146178
+ const a2 = new Uint32Array([305419896]);
146179
+ const b = new Uint8Array(a2.buffer, a2.byteOffset, a2.byteLength);
146180
+ return !(b[0] === 18);
146181
+ }
146182
+ function bytes_per_element(TypedArray2) {
146183
+ if ("BYTES_PER_ELEMENT" in TypedArray2) {
146184
+ return TypedArray2.BYTES_PER_ELEMENT;
146185
+ }
146186
+ return 4;
146187
+ }
146188
+ const _BytesCodec = class {
146189
+ constructor(configuration, meta2) {
146190
+ __publicField(this, "kind", "array_to_bytes");
146191
+ __privateAdd(this, _strides, void 0);
146192
+ __privateAdd(this, _TypedArray, void 0);
146193
+ __privateAdd(this, _BYTES_PER_ELEMENT, void 0);
146194
+ __privateAdd(this, _shape, void 0);
146195
+ __privateAdd(this, _endian, void 0);
146196
+ __privateSet(this, _endian, configuration.endian);
146197
+ __privateSet(this, _TypedArray, get_ctr(meta2.data_type));
146198
+ __privateSet(this, _shape, meta2.shape);
146199
+ __privateSet(this, _strides, get_strides(meta2.shape, get_array_order(meta2.codecs)));
146200
+ const sample = new (__privateGet(this, _TypedArray))(0);
146201
+ __privateSet(this, _BYTES_PER_ELEMENT, sample.BYTES_PER_ELEMENT);
146202
+ }
146203
+ static fromConfig(configuration, meta2) {
146204
+ return new _BytesCodec(configuration, meta2);
146205
+ }
146206
+ encode(arr) {
146207
+ let bytes = new Uint8Array(arr.data.buffer);
146208
+ if (LITTLE_ENDIAN_OS && __privateGet(this, _endian) === "big") {
146209
+ byteswap_inplace(bytes, bytes_per_element(__privateGet(this, _TypedArray)));
146210
+ }
146211
+ return bytes;
146212
+ }
146213
+ decode(bytes) {
146214
+ if (LITTLE_ENDIAN_OS && __privateGet(this, _endian) === "big") {
146215
+ byteswap_inplace(bytes, bytes_per_element(__privateGet(this, _TypedArray)));
146216
+ }
146217
+ return {
146218
+ data: new (__privateGet(this, _TypedArray))(bytes.buffer, bytes.byteOffset, bytes.byteLength / __privateGet(this, _BYTES_PER_ELEMENT)),
146219
+ shape: __privateGet(this, _shape),
146220
+ stride: __privateGet(this, _strides)
146221
+ };
146222
+ }
146223
+ };
146224
+ let BytesCodec = _BytesCodec;
146225
+ _strides = new WeakMap();
146226
+ _TypedArray = new WeakMap();
146227
+ _BYTES_PER_ELEMENT = new WeakMap();
146228
+ _shape = new WeakMap();
146229
+ _endian = new WeakMap();
146230
+ class Crc32cCodec {
146231
+ constructor() {
146232
+ __publicField(this, "kind", "bytes_to_bytes");
146233
+ }
146234
+ static fromConfig() {
146235
+ return new Crc32cCodec();
146236
+ }
146237
+ encode(_) {
146238
+ throw new Error("Not implemented");
146239
+ }
146240
+ decode(arr) {
146241
+ return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength - 4);
146242
+ }
146243
+ }
146244
+ const _VLenUTF8 = class {
146245
+ constructor(shape) {
146246
+ __publicField(this, "kind", "array_to_bytes");
146247
+ __privateAdd(this, _shape2, void 0);
146248
+ __privateAdd(this, _strides2, void 0);
146249
+ __privateSet(this, _shape2, shape);
146250
+ __privateSet(this, _strides2, get_strides(shape, "C"));
146251
+ }
146252
+ static fromConfig(_, meta2) {
146253
+ return new _VLenUTF8(meta2.shape);
146254
+ }
146255
+ encode(_chunk) {
146256
+ throw new Error("Method not implemented.");
146257
+ }
146258
+ decode(bytes) {
146259
+ let decoder = new TextDecoder();
146260
+ let view = new DataView(bytes.buffer);
146261
+ let data = Array(view.getUint32(0, true));
146262
+ let pos = 4;
146263
+ for (let i2 = 0; i2 < data.length; i2++) {
146264
+ let item_length = view.getUint32(pos, true);
146265
+ pos += 4;
146266
+ data[i2] = decoder.decode(bytes.buffer.slice(pos, pos + item_length));
146267
+ pos += item_length;
146268
+ }
146269
+ return { data, shape: __privateGet(this, _shape2), stride: __privateGet(this, _strides2) };
146270
+ }
146271
+ };
146272
+ let VLenUTF8 = _VLenUTF8;
146273
+ _shape2 = new WeakMap();
146274
+ _strides2 = new WeakMap();
146275
+ function create_default_registry() {
146276
+ 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);
146277
+ }
146278
+ const registry = create_default_registry();
146279
+ function create_codec_pipeline(chunk_metadata) {
146280
+ let codecs;
146281
+ return {
146282
+ async encode(chunk) {
146283
+ if (!codecs)
146284
+ codecs = await load_codecs(chunk_metadata);
146285
+ for (const codec of codecs.array_to_array) {
146286
+ chunk = await codec.encode(chunk);
146287
+ }
146288
+ let bytes = await codecs.array_to_bytes.encode(chunk);
146289
+ for (const codec of codecs.bytes_to_bytes) {
146290
+ bytes = await codec.encode(bytes);
146291
+ }
146292
+ return bytes;
146293
+ },
146294
+ async decode(bytes) {
146295
+ if (!codecs)
146296
+ codecs = await load_codecs(chunk_metadata);
146297
+ for (let i2 = codecs.bytes_to_bytes.length - 1; i2 >= 0; i2--) {
146298
+ bytes = await codecs.bytes_to_bytes[i2].decode(bytes);
146299
+ }
146300
+ let chunk = await codecs.array_to_bytes.decode(bytes);
146301
+ for (let i2 = codecs.array_to_array.length - 1; i2 >= 0; i2--) {
146302
+ chunk = await codecs.array_to_array[i2].decode(chunk);
146303
+ }
146304
+ return chunk;
146305
+ }
146306
+ };
146307
+ }
146308
+ async function load_codecs(chunk_meta) {
146309
+ let promises = chunk_meta.codecs.map(async (meta2) => {
146310
+ var _a3;
146311
+ let Codec = await ((_a3 = registry.get(meta2.name)) == null ? void 0 : _a3());
146312
+ if (!Codec) {
146313
+ throw new Error(`Unknown codec: ${meta2.name}`);
146314
+ }
146315
+ return { Codec, meta: meta2 };
146316
+ });
146317
+ let array_to_array = [];
146318
+ let array_to_bytes;
146319
+ let bytes_to_bytes = [];
146320
+ for await (let { Codec, meta: meta2 } of promises) {
146321
+ let codec = Codec.fromConfig(meta2.configuration, chunk_meta);
146322
+ switch (codec.kind) {
146323
+ case "array_to_array":
146324
+ array_to_array.push(codec);
146325
+ break;
146326
+ case "array_to_bytes":
146327
+ array_to_bytes = codec;
146328
+ break;
146329
+ default:
146330
+ bytes_to_bytes.push(codec);
146331
+ }
146332
+ }
146333
+ if (!array_to_bytes) {
146334
+ if (!is_typed_array_like_meta(chunk_meta)) {
146335
+ throw new Error(`Cannot encode ${chunk_meta.data_type} to bytes without a codec`);
146336
+ }
146337
+ array_to_bytes = BytesCodec.fromConfig({ endian: "little" }, chunk_meta);
146338
+ }
146339
+ return { array_to_array, array_to_bytes, bytes_to_bytes };
146340
+ }
146341
+ function is_typed_array_like_meta(meta2) {
146342
+ return meta2.data_type !== "v2:object";
146343
+ }
146344
+ const MAX_BIG_UINT = 18446744073709551615n;
146345
+ function create_sharded_chunk_getter(location, shard_shape, encode_shard_key, sharding_config) {
146346
+ if (location.store.getRange === void 0) {
146347
+ throw new Error("Store does not support range requests");
146348
+ }
146349
+ let get_range = location.store.getRange.bind(location.store);
146350
+ let index_shape = shard_shape.map((d, i2) => d / sharding_config.chunk_shape[i2]);
146351
+ let index_codec = create_codec_pipeline({
146352
+ data_type: "uint64",
146353
+ shape: [...index_shape, 2],
146354
+ codecs: sharding_config.index_codecs
146355
+ });
146356
+ let cache2 = {};
146357
+ return async (chunk_coord) => {
146358
+ let shard_coord = chunk_coord.map((d, i2) => Math.floor(d / index_shape[i2]));
146359
+ let shard_path = location.resolve(encode_shard_key(shard_coord)).path;
146360
+ let index2;
146361
+ if (shard_path in cache2) {
146362
+ index2 = cache2[shard_path];
146363
+ } else {
146364
+ let checksum_size = 4;
146365
+ let index_size = 16 * index_shape.reduce((a2, b) => a2 * b, 1);
146366
+ let bytes = await get_range(shard_path, {
146367
+ suffixLength: index_size + checksum_size
146368
+ });
146369
+ index2 = cache2[shard_path] = bytes ? await index_codec.decode(bytes) : null;
146370
+ }
146371
+ if (index2 === null) {
146372
+ return void 0;
146373
+ }
146374
+ let { data, shape, stride } = index2;
146375
+ let linear_offset = chunk_coord.map((d, i2) => d % shape[i2]).reduce((acc, sel, idx) => acc + sel * stride[idx], 0);
146376
+ let offset = data[linear_offset];
146377
+ let length2 = data[linear_offset + 1];
146378
+ if (offset === MAX_BIG_UINT && length2 === MAX_BIG_UINT) {
146379
+ return void 0;
146380
+ }
146381
+ return get_range(shard_path, {
146382
+ offset: Number(offset),
146383
+ length: Number(length2)
146384
+ });
146385
+ };
146386
+ }
146387
+ class Location {
146388
+ constructor(store, path = "/") {
146389
+ __publicField(this, "store");
146390
+ __publicField(this, "path");
146391
+ this.store = store;
146392
+ this.path = path;
146393
+ }
146394
+ resolve(path) {
146395
+ let root2 = new URL(`file://${this.path.endsWith("/") ? this.path : `${this.path}/`}`);
146396
+ return new Location(this.store, new URL(path, root2).pathname);
146397
+ }
146398
+ }
146399
+ function root(store) {
146400
+ return new Location(store ?? /* @__PURE__ */ new Map());
146401
+ }
146402
+ class Group extends Location {
146403
+ constructor(store, path, metadata) {
146404
+ super(store, path);
146405
+ __publicField(this, "kind", "group");
146406
+ __privateAdd(this, _metadata, void 0);
146407
+ __privateSet(this, _metadata, metadata);
146408
+ }
146409
+ get attrs() {
146410
+ return __privateGet(this, _metadata).attributes;
146411
+ }
146412
+ }
146413
+ _metadata = new WeakMap();
146414
+ const CONTEXT_MARKER = Symbol("zarrita.context");
146415
+ function get_context(obj) {
146416
+ return obj[CONTEXT_MARKER];
146417
+ }
146418
+ function create_context(location, metadata) {
146419
+ let { configuration } = metadata.codecs.find(is_sharding_codec) ?? {};
146420
+ let shared_context = {
146421
+ encode_chunk_key: create_chunk_key_encoder(metadata.chunk_key_encoding),
146422
+ TypedArray: get_ctr(metadata.data_type),
146423
+ fill_value: metadata.fill_value
146424
+ };
146425
+ if (configuration) {
146426
+ let native_order2 = get_array_order(configuration.codecs);
146427
+ return {
146428
+ ...shared_context,
146429
+ kind: "sharded",
146430
+ chunk_shape: configuration.chunk_shape,
146431
+ codec: create_codec_pipeline({
146432
+ data_type: metadata.data_type,
146433
+ shape: configuration.chunk_shape,
146434
+ codecs: configuration.codecs
146435
+ }),
146436
+ get_strides(shape, order) {
146437
+ return get_strides(shape, order ?? native_order2);
146438
+ },
146439
+ get_chunk_bytes: create_sharded_chunk_getter(location, metadata.chunk_grid.configuration.chunk_shape, shared_context.encode_chunk_key, configuration)
146440
+ };
146441
+ }
146442
+ let native_order = get_array_order(metadata.codecs);
146443
+ return {
146444
+ ...shared_context,
146445
+ kind: "regular",
146446
+ chunk_shape: metadata.chunk_grid.configuration.chunk_shape,
146447
+ codec: create_codec_pipeline({
146448
+ data_type: metadata.data_type,
146449
+ shape: metadata.chunk_grid.configuration.chunk_shape,
146450
+ codecs: metadata.codecs
146451
+ }),
146452
+ get_strides(shape, order) {
146453
+ return get_strides(shape, order ?? native_order);
146454
+ },
146455
+ async get_chunk_bytes(chunk_coords, options) {
146456
+ let chunk_key = shared_context.encode_chunk_key(chunk_coords);
146457
+ let chunk_path = location.resolve(chunk_key).path;
146458
+ return location.store.get(chunk_path, options);
146459
+ }
146460
+ };
146461
+ }
146462
+ let Array$1 = (_b = class extends Location {
146463
+ constructor(store, path, metadata) {
146464
+ super(store, path);
146465
+ __publicField(this, "kind", "array");
146466
+ __privateAdd(this, _metadata2, void 0);
146467
+ __publicField(this, _a2);
146468
+ __privateSet(this, _metadata2, {
146469
+ ...metadata,
146470
+ fill_value: ensure_correct_scalar(metadata)
146471
+ });
146472
+ this[CONTEXT_MARKER] = create_context(this, metadata);
146473
+ }
146474
+ get attrs() {
146475
+ return __privateGet(this, _metadata2).attributes;
146476
+ }
146477
+ get shape() {
146478
+ return __privateGet(this, _metadata2).shape;
146479
+ }
146480
+ get chunks() {
146481
+ return this[CONTEXT_MARKER].chunk_shape;
146482
+ }
146483
+ get dtype() {
146484
+ return __privateGet(this, _metadata2).data_type;
146485
+ }
146486
+ async getChunk(chunk_coords, options) {
146487
+ let context = this[CONTEXT_MARKER];
146488
+ let maybe_bytes = await context.get_chunk_bytes(chunk_coords, options);
146489
+ if (!maybe_bytes) {
146490
+ let size2 = context.chunk_shape.reduce((a2, b) => a2 * b, 1);
146491
+ let data = new context.TypedArray(size2);
146492
+ data.fill(context.fill_value);
146493
+ return {
146494
+ data,
146495
+ shape: context.chunk_shape,
146496
+ stride: context.get_strides(context.chunk_shape)
146497
+ };
146498
+ }
146499
+ return context.codec.decode(maybe_bytes);
146500
+ }
146501
+ /**
146502
+ * A helper method to narrow `zarr.Array` Dtype.
146503
+ *
146504
+ * ```typescript
146505
+ * let arr: zarr.Array<DataType, FetchStore> = zarr.open(store, { kind: "array" });
146506
+ *
146507
+ * // Option 1: narrow by scalar type (e.g. "bool", "raw", "bigint", "number")
146508
+ * if (arr.is("bigint")) {
146509
+ * // zarr.Array<"int64" | "uint64", FetchStore>
146510
+ * }
146511
+ *
146512
+ * // Option 3: exact match
146513
+ * if (arr.is("float32")) {
146514
+ * // zarr.Array<"float32", FetchStore, "/">
146515
+ * }
146516
+ * ```
146517
+ */
146518
+ is(query) {
146519
+ return is_dtype(this.dtype, query);
146520
+ }
146521
+ }, _a2 = CONTEXT_MARKER, _metadata2 = new WeakMap(), _b);
146522
+ function create_version_counter() {
146523
+ let version_counts = /* @__PURE__ */ new WeakMap();
146524
+ function get_counts(store) {
146525
+ let counts = version_counts.get(store) ?? { v2: 0, v3: 0 };
146526
+ version_counts.set(store, counts);
146527
+ return counts;
146528
+ }
146529
+ return {
146530
+ increment(store, version2) {
146531
+ get_counts(store)[version2] += 1;
146532
+ },
146533
+ version_max(store) {
146534
+ let counts = get_counts(store);
146535
+ return counts.v3 > counts.v2 ? "v3" : "v2";
146536
+ }
146537
+ };
146538
+ }
146539
+ let VERSION_COUNTER = create_version_counter();
146540
+ async function load_attrs(location) {
146541
+ let meta_bytes = await location.store.get(location.resolve(".zattrs").path);
146542
+ if (!meta_bytes)
146543
+ return {};
146544
+ return json_decode_object(meta_bytes);
146545
+ }
146546
+ async function open_v2(location, options = {}) {
146547
+ let loc = "store" in location ? location : new Location(location);
146548
+ let attrs = {};
146549
+ if (options.attrs ?? true)
146550
+ attrs = await load_attrs(loc);
146551
+ if (options.kind === "array")
146552
+ return open_array_v2(loc, attrs);
146553
+ if (options.kind === "group")
146554
+ return open_group_v2(loc, attrs);
146555
+ return open_array_v2(loc, attrs).catch((err2) => {
146556
+ if (err2 instanceof NodeNotFoundError)
146557
+ return open_group_v2(loc, attrs);
146558
+ throw err2;
146559
+ });
146560
+ }
146561
+ async function open_array_v2(location, attrs) {
146562
+ let { path } = location.resolve(".zarray");
146563
+ let meta2 = await location.store.get(path);
146564
+ if (!meta2) {
146565
+ throw new NodeNotFoundError(path);
146566
+ }
146567
+ VERSION_COUNTER.increment(location.store, "v2");
146568
+ return new Array$1(location.store, location.path, v2_to_v3_array_metadata(json_decode_object(meta2), attrs));
146569
+ }
146570
+ async function open_group_v2(location, attrs) {
146571
+ let { path } = location.resolve(".zgroup");
146572
+ let meta2 = await location.store.get(path);
146573
+ if (!meta2) {
146574
+ throw new NodeNotFoundError(path);
146575
+ }
146576
+ VERSION_COUNTER.increment(location.store, "v2");
146577
+ return new Group(location.store, location.path, v2_to_v3_group_metadata(json_decode_object(meta2), attrs));
146578
+ }
146579
+ async function _open_v3(location) {
146580
+ let { store, path } = location.resolve("zarr.json");
146581
+ let meta2 = await location.store.get(path);
146582
+ if (!meta2) {
146583
+ throw new NodeNotFoundError(path);
146584
+ }
146585
+ let meta_doc = json_decode_object(meta2);
146586
+ if (meta_doc.node_type === "array" && (meta_doc.data_type === "uint64" || meta_doc.data_type === "int64") && meta_doc.fill_value != void 0) {
146587
+ meta_doc.fill_value = BigInt(meta_doc.fill_value);
146588
+ }
146589
+ return meta_doc.node_type === "array" ? new Array$1(store, location.path, meta_doc) : new Group(store, location.path, meta_doc);
146590
+ }
146591
+ async function open_v3(location, options = {}) {
146592
+ let loc = "store" in location ? location : new Location(location);
146593
+ let node2 = await _open_v3(loc);
146594
+ VERSION_COUNTER.increment(loc.store, "v3");
146595
+ if (options.kind === void 0)
146596
+ return node2;
146597
+ if (options.kind === "array" && node2 instanceof Array$1)
146598
+ return node2;
146599
+ if (options.kind === "group" && node2 instanceof Group)
146600
+ return node2;
146601
+ let kind = node2 instanceof Array$1 ? "array" : "group";
146602
+ throw new Error(`Expected node of kind ${options.kind}, found ${kind}.`);
146603
+ }
146604
+ async function open(location, options = {}) {
146605
+ const store = "store" in location ? location.store : location;
146606
+ const version_max = VERSION_COUNTER.version_max(store);
146607
+ let open_primary = version_max === "v2" ? open.v2 : open.v3;
146608
+ let open_secondary = version_max === "v2" ? open.v3 : open.v2;
146609
+ return open_primary(location, options).catch((err2) => {
146610
+ if (err2 instanceof NodeNotFoundError) {
146611
+ return open_secondary(location, options);
146612
+ }
146613
+ throw err2;
146614
+ });
146615
+ }
146616
+ open.v2 = open_v2;
146617
+ open.v3 = open_v3;
146618
+ function* range(start, stop, step = 1) {
146619
+ if (stop === void 0) {
146620
+ stop = start;
146621
+ start = 0;
146622
+ }
146623
+ for (let i2 = start; i2 < stop; i2 += step) {
146624
+ yield i2;
146625
+ }
146626
+ }
146627
+ function* product(...iterables) {
146628
+ if (iterables.length === 0) {
146629
+ return;
146630
+ }
146631
+ const iterators = iterables.map((it) => it[Symbol.iterator]());
146632
+ const results = iterators.map((it) => it.next());
146633
+ if (results.some((r2) => r2.done)) {
146634
+ throw new Error("Input contains an empty iterator.");
146635
+ }
146636
+ for (let i2 = 0; ; ) {
146637
+ if (results[i2].done) {
146638
+ iterators[i2] = iterables[i2][Symbol.iterator]();
146639
+ results[i2] = iterators[i2].next();
146640
+ if (++i2 >= iterators.length) {
146641
+ return;
146642
+ }
146643
+ } else {
146644
+ yield results.map(({ value }) => value);
146645
+ i2 = 0;
146646
+ }
146647
+ results[i2] = iterators[i2].next();
146648
+ }
146649
+ }
146650
+ function slice_indices(start, stop, step, length2) {
146651
+ if (step === 0) {
146652
+ throw new Error("slice step cannot be zero");
146653
+ }
146654
+ step = step ?? 1;
146655
+ const step_is_negative = step < 0;
146656
+ const [lower, upper] = step_is_negative ? [-1, length2 - 1] : [0, length2];
146657
+ if (start === null) {
146658
+ start = step_is_negative ? upper : lower;
146659
+ } else {
146660
+ if (start < 0) {
146661
+ start += length2;
146662
+ if (start < lower) {
146663
+ start = lower;
146664
+ }
146665
+ } else if (start > upper) {
146666
+ start = upper;
146667
+ }
146668
+ }
146669
+ if (stop === null) {
146670
+ stop = step_is_negative ? lower : upper;
146671
+ } else {
146672
+ if (stop < 0) {
146673
+ stop += length2;
146674
+ if (stop < lower) {
146675
+ stop = lower;
146676
+ }
146677
+ } else if (stop > upper) {
146678
+ stop = upper;
146679
+ }
146680
+ }
146681
+ return [start, stop, step];
146682
+ }
146683
+ function slice(start, stop, step = null) {
146684
+ if (stop === void 0) {
146685
+ stop = start;
146686
+ start = null;
146687
+ }
146688
+ return {
146689
+ start,
146690
+ stop,
146691
+ step,
146692
+ indices(length2) {
146693
+ return slice_indices(this.start, this.stop, this.step, length2);
146694
+ }
146695
+ };
146696
+ }
146697
+ function create_queue() {
146698
+ const promises = [];
146699
+ return {
146700
+ add: (fn) => promises.push(fn()),
146701
+ onIdle: () => Promise.all(promises)
146702
+ };
146703
+ }
146704
+ class IndexError extends Error {
146705
+ constructor(msg) {
146706
+ super(msg);
146707
+ this.name = "IndexError";
146708
+ }
146709
+ }
146710
+ function err_too_many_indices(selection, shape) {
146711
+ throw new IndexError(`too many indicies for array; expected ${shape.length}, got ${selection.length}`);
146712
+ }
146713
+ function err_boundscheck(dim_len) {
146714
+ throw new IndexError(`index out of bounds for dimension with length ${dim_len}`);
146715
+ }
146716
+ function err_negative_step() {
146717
+ throw new IndexError("only slices with step >= 1 are supported");
146718
+ }
146719
+ function check_selection_length(selection, shape) {
146720
+ if (selection.length > shape.length) {
146721
+ err_too_many_indices(selection, shape);
146722
+ }
146723
+ }
146724
+ function normalize_integer_selection(dim_sel, dim_len) {
146725
+ dim_sel = Math.trunc(dim_sel);
146726
+ if (dim_sel < 0) {
146727
+ dim_sel = dim_len + dim_sel;
146728
+ }
146729
+ if (dim_sel >= dim_len || dim_sel < 0) {
146730
+ err_boundscheck(dim_len);
146731
+ }
146732
+ return dim_sel;
146733
+ }
146734
+ class IntDimIndexer {
146735
+ constructor({ dim_sel, dim_len, dim_chunk_len }) {
146736
+ __publicField(this, "dim_sel");
146737
+ __publicField(this, "dim_len");
146738
+ __publicField(this, "dim_chunk_len");
146739
+ __publicField(this, "nitems");
146740
+ dim_sel = normalize_integer_selection(dim_sel, dim_len);
146741
+ this.dim_sel = dim_sel;
146742
+ this.dim_len = dim_len;
146743
+ this.dim_chunk_len = dim_chunk_len;
146744
+ this.nitems = 1;
146745
+ }
146746
+ *[Symbol.iterator]() {
146747
+ const dim_chunk_ix = Math.floor(this.dim_sel / this.dim_chunk_len);
146748
+ const dim_offset = dim_chunk_ix * this.dim_chunk_len;
146749
+ const dim_chunk_sel = this.dim_sel - dim_offset;
146750
+ yield { dim_chunk_ix, dim_chunk_sel };
146751
+ }
146752
+ }
146753
+ class SliceDimIndexer {
146754
+ constructor({ dim_sel, dim_len, dim_chunk_len }) {
146755
+ __publicField(this, "start");
146756
+ __publicField(this, "stop");
146757
+ __publicField(this, "step");
146758
+ __publicField(this, "dim_len");
146759
+ __publicField(this, "dim_chunk_len");
146760
+ __publicField(this, "nitems");
146761
+ __publicField(this, "nchunks");
146762
+ const [start, stop, step] = dim_sel.indices(dim_len);
146763
+ this.start = start;
146764
+ this.stop = stop;
146765
+ this.step = step;
146766
+ if (this.step < 1)
146767
+ err_negative_step();
146768
+ this.dim_len = dim_len;
146769
+ this.dim_chunk_len = dim_chunk_len;
146770
+ this.nitems = Math.max(0, Math.ceil((this.stop - this.start) / this.step));
146771
+ this.nchunks = Math.ceil(this.dim_len / this.dim_chunk_len);
146772
+ }
146773
+ *[Symbol.iterator]() {
146774
+ const dim_chunk_ix_from = Math.floor(this.start / this.dim_chunk_len);
146775
+ const dim_chunk_ix_to = Math.ceil(this.stop / this.dim_chunk_len);
146776
+ for (const dim_chunk_ix of range(dim_chunk_ix_from, dim_chunk_ix_to)) {
146777
+ const dim_offset = dim_chunk_ix * this.dim_chunk_len;
146778
+ const dim_limit = Math.min(this.dim_len, (dim_chunk_ix + 1) * this.dim_chunk_len);
146779
+ const dim_chunk_len = dim_limit - dim_offset;
146780
+ let dim_out_offset = 0;
146781
+ let dim_chunk_sel_start = 0;
146782
+ if (this.start < dim_offset) {
146783
+ const remainder = (dim_offset - this.start) % this.step;
146784
+ if (remainder)
146785
+ dim_chunk_sel_start += this.step - remainder;
146786
+ dim_out_offset = Math.ceil((dim_offset - this.start) / this.step);
146787
+ } else {
146788
+ dim_chunk_sel_start = this.start - dim_offset;
146789
+ }
146790
+ const dim_chunk_sel_stop = this.stop > dim_limit ? dim_chunk_len : this.stop - dim_offset;
146791
+ const dim_chunk_sel = [
146792
+ dim_chunk_sel_start,
146793
+ dim_chunk_sel_stop,
146794
+ this.step
146795
+ ];
146796
+ const dim_chunk_nitems = Math.ceil((dim_chunk_sel_stop - dim_chunk_sel_start) / this.step);
146797
+ const dim_out_sel = [
146798
+ dim_out_offset,
146799
+ dim_out_offset + dim_chunk_nitems,
146800
+ 1
146801
+ ];
146802
+ yield { dim_chunk_ix, dim_chunk_sel, dim_out_sel };
146803
+ }
146804
+ }
146805
+ }
146806
+ function normalize_selection(selection, shape) {
146807
+ let normalized = [];
146808
+ if (selection === null) {
146809
+ normalized = shape.map((_) => slice(null));
146810
+ } else if (Array.isArray(selection)) {
146811
+ normalized = selection.map((s2) => s2 ?? slice(null));
146812
+ }
146813
+ check_selection_length(normalized, shape);
146814
+ return normalized;
146815
+ }
146816
+ class BasicIndexer {
146817
+ constructor({ selection, shape, chunk_shape }) {
146818
+ __publicField(this, "dim_indexers");
146819
+ __publicField(this, "shape");
146820
+ this.dim_indexers = normalize_selection(selection, shape).map((dim_sel, i2) => {
146821
+ return new (typeof dim_sel === "number" ? IntDimIndexer : SliceDimIndexer)({
146822
+ // @ts-expect-error ts inference not strong enough to know correct chunk
146823
+ dim_sel,
146824
+ dim_len: shape[i2],
146825
+ dim_chunk_len: chunk_shape[i2]
146826
+ });
146827
+ });
146828
+ this.shape = this.dim_indexers.filter((ixr) => ixr instanceof SliceDimIndexer).map((sixr) => sixr.nitems);
146829
+ }
146830
+ *[Symbol.iterator]() {
146831
+ for (const dim_projections of product(...this.dim_indexers)) {
146832
+ const chunk_coords = dim_projections.map((p) => p.dim_chunk_ix);
146833
+ const mapping = dim_projections.map((p) => {
146834
+ if ("dim_out_sel" in p) {
146835
+ return { from: p.dim_chunk_sel, to: p.dim_out_sel };
146836
+ }
146837
+ return { from: p.dim_chunk_sel, to: null };
146838
+ });
146839
+ yield { chunk_coords, mapping };
146840
+ }
146841
+ }
146842
+ }
146843
+ function unwrap(arr, idx) {
146844
+ return "get" in arr ? arr.get(idx) : arr[idx];
146845
+ }
146846
+ async function get$1(arr, selection, opts2, setter2) {
146847
+ var _a3;
146848
+ const context = get_context(arr);
146849
+ const indexer = new BasicIndexer({
146850
+ selection,
146851
+ shape: arr.shape,
146852
+ chunk_shape: arr.chunks
146853
+ });
146854
+ const out = setter2.prepare(new context.TypedArray(indexer.shape.reduce((a2, b) => a2 * b, 1)), indexer.shape, context.get_strides(indexer.shape, opts2.order));
146855
+ const queue = ((_a3 = opts2.create_queue) == null ? void 0 : _a3.call(opts2)) ?? create_queue();
146856
+ for (const { chunk_coords, mapping } of indexer) {
146857
+ queue.add(() => arr.getChunk(chunk_coords, opts2.opts).then(({ data, shape, stride }) => {
146858
+ const chunk = setter2.prepare(data, shape, stride);
146859
+ setter2.set_from_chunk(out, chunk, mapping);
146860
+ }).catch((err2) => {
146861
+ if (!(err2 instanceof KeyError))
146862
+ throw err2;
146863
+ if (context.fill_value) {
146864
+ setter2.set_scalar(out, mapping.map((m) => m.to).filter((s2) => s2 !== null), context.fill_value);
146865
+ }
146866
+ }));
146867
+ }
146868
+ await queue.onIdle();
146869
+ return indexer.shape.length === 0 ? unwrap(out.data, 0) : out;
146870
+ }
146871
+ function object_array_view(arr, offset = 0, size2) {
146872
+ let length2 = size2 ?? arr.length - offset;
146873
+ return {
146874
+ length: length2,
146875
+ subarray(from, to = length2) {
146876
+ return object_array_view(arr, offset + from, to - from);
146877
+ },
146878
+ set(data, start = 0) {
146879
+ for (let i2 = 0; i2 < data.length; i2++) {
146880
+ arr[offset + start + i2] = data.get(i2);
146881
+ }
146882
+ },
146883
+ get(index2) {
146884
+ return arr[offset + index2];
146885
+ }
146886
+ };
146887
+ }
146888
+ function compat_chunk(arr) {
146889
+ if (arr.data instanceof globalThis.Array) {
146890
+ return {
146891
+ // @ts-expect-error
146892
+ data: object_array_view(arr.data),
146893
+ stride: arr.stride,
146894
+ bytes_per_element: 1
146895
+ };
146896
+ }
146897
+ return {
146898
+ data: new Uint8Array(arr.data.buffer, arr.data.byteOffset, arr.data.byteLength),
146899
+ stride: arr.stride,
146900
+ bytes_per_element: arr.data.BYTES_PER_ELEMENT
146901
+ };
146902
+ }
146903
+ function get_typed_array_constructor(arr) {
146904
+ if ("chars" in arr) {
146905
+ return arr.constructor.bind(null, arr.chars);
146906
+ }
146907
+ return arr.constructor;
146908
+ }
146909
+ function compat_scalar(arr, value) {
146910
+ if (arr.data instanceof globalThis.Array) {
146911
+ return object_array_view([value]);
146912
+ }
146913
+ let TypedArray2 = get_typed_array_constructor(arr.data);
146914
+ let data = new TypedArray2([value]);
146915
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
146916
+ }
146917
+ const setter = {
146918
+ prepare(data, shape, stride) {
146919
+ return { data, shape, stride };
146920
+ },
146921
+ set_scalar(dest, sel, value) {
146922
+ let view = compat_chunk(dest);
146923
+ set_scalar_binary(view, sel, compat_scalar(dest, value), view.bytes_per_element);
146924
+ },
146925
+ set_from_chunk(dest, src2, projections) {
146926
+ let view = compat_chunk(dest);
146927
+ set_from_chunk_binary(view, compat_chunk(src2), view.bytes_per_element, projections);
146928
+ }
146929
+ };
146930
+ async function get(arr, selection = null, opts2 = {}) {
146931
+ return get$1(arr, selection, opts2, setter);
146932
+ }
146933
+ function indices_len(start, stop, step) {
146934
+ if (step < 0 && stop < start) {
146935
+ return Math.floor((start - stop - 1) / -step) + 1;
146936
+ }
146937
+ if (start < stop)
146938
+ return Math.floor((stop - start - 1) / step) + 1;
146939
+ return 0;
146940
+ }
146941
+ function set_scalar_binary(out, out_selection, value, bytes_per_element2) {
146942
+ if (out_selection.length === 0) {
146943
+ out.data.set(value, 0);
146944
+ return;
146945
+ }
146946
+ const [slice2, ...slices] = out_selection;
146947
+ const [curr_stride, ...stride] = out.stride;
146948
+ if (typeof slice2 === "number") {
146949
+ const data = out.data.subarray(curr_stride * slice2 * bytes_per_element2);
146950
+ set_scalar_binary({ data, stride }, slices, value, bytes_per_element2);
146951
+ return;
146952
+ }
146953
+ const [from, to, step] = slice2;
146954
+ const len2 = indices_len(from, to, step);
146955
+ if (slices.length === 0) {
146956
+ for (let i2 = 0; i2 < len2; i2++) {
146957
+ out.data.set(value, curr_stride * (from + step * i2) * bytes_per_element2);
146958
+ }
146959
+ return;
146960
+ }
146961
+ for (let i2 = 0; i2 < len2; i2++) {
146962
+ const data = out.data.subarray(curr_stride * (from + step * i2) * bytes_per_element2);
146963
+ set_scalar_binary({ data, stride }, slices, value, bytes_per_element2);
146964
+ }
146965
+ }
146966
+ function set_from_chunk_binary(dest, src2, bytes_per_element2, projections) {
146967
+ const [proj, ...projs] = projections;
146968
+ const [dstride, ...dstrides] = dest.stride;
146969
+ const [sstride, ...sstrides] = src2.stride;
146970
+ if (proj.from === null) {
146971
+ if (projs.length === 0) {
146972
+ dest.data.set(src2.data.subarray(0, bytes_per_element2), proj.to * bytes_per_element2);
146973
+ return;
146974
+ }
146975
+ set_from_chunk_binary({
146976
+ data: dest.data.subarray(dstride * proj.to * bytes_per_element2),
146977
+ stride: dstrides
146978
+ }, src2, bytes_per_element2, projs);
146979
+ return;
146980
+ }
146981
+ if (proj.to === null) {
146982
+ if (projs.length === 0) {
146983
+ let offset = proj.from * bytes_per_element2;
146984
+ dest.data.set(src2.data.subarray(offset, offset + bytes_per_element2), 0);
146985
+ return;
146986
+ }
146987
+ set_from_chunk_binary(dest, {
146988
+ data: src2.data.subarray(sstride * proj.from * bytes_per_element2),
146989
+ stride: sstrides
146990
+ }, bytes_per_element2, projs);
146991
+ return;
146992
+ }
146993
+ const [from, to, step] = proj.to;
146994
+ const [sfrom, _, sstep] = proj.from;
146995
+ const len2 = indices_len(from, to, step);
146996
+ if (projs.length === 0) {
146997
+ if (step === 1 && sstep === 1 && dstride === 1 && sstride === 1) {
146998
+ let offset = sfrom * bytes_per_element2;
146999
+ let size2 = len2 * bytes_per_element2;
147000
+ dest.data.set(src2.data.subarray(offset, offset + size2), from * bytes_per_element2);
147001
+ return;
147002
+ }
147003
+ for (let i2 = 0; i2 < len2; i2++) {
147004
+ let offset = sstride * (sfrom + sstep * i2) * bytes_per_element2;
147005
+ dest.data.set(src2.data.subarray(offset, offset + bytes_per_element2), dstride * (from + step * i2) * bytes_per_element2);
147006
+ }
147007
+ return;
147008
+ }
147009
+ for (let i2 = 0; i2 < len2; i2++) {
147010
+ set_from_chunk_binary({
147011
+ data: dest.data.subarray(dstride * (from + i2 * step) * bytes_per_element2),
147012
+ stride: dstrides
147013
+ }, {
147014
+ data: src2.data.subarray(sstride * (sfrom + i2 * sstep) * bytes_per_element2),
147015
+ stride: sstrides
147016
+ }, bytes_per_element2, projs);
147017
+ }
147018
+ }
147019
+ function fetch_range(url, offset, length2, opts2 = {}) {
147020
+ if (offset !== void 0 && length2 !== void 0) {
147021
+ opts2 = {
147022
+ ...opts2,
147023
+ headers: {
147024
+ ...opts2.headers,
147025
+ Range: `bytes=${offset}-${offset + length2 - 1}`
147026
+ }
147027
+ };
147028
+ }
147029
+ return fetch(url, opts2);
147030
+ }
147031
+ function resolve(root2, path) {
147032
+ const base = typeof root2 === "string" ? new URL(root2) : root2;
147033
+ if (!base.pathname.endsWith("/")) {
147034
+ base.pathname += "/";
147035
+ }
147036
+ const resolved = new URL(path.slice(1), base);
147037
+ resolved.search = base.search;
147038
+ return resolved;
147039
+ }
147040
+ async function handle_response(response) {
147041
+ if (response.status === 404 || response.status === 403) {
147042
+ return void 0;
147043
+ }
147044
+ if (response.status == 200 || response.status == 206) {
147045
+ return new Uint8Array(await response.arrayBuffer());
147046
+ }
147047
+ throw new Error(`Unexpected response status ${response.status} ${response.statusText}`);
147048
+ }
147049
+ async function fetch_suffix(url, suffix_length, init, use_suffix_request) {
147050
+ if (use_suffix_request) {
147051
+ return fetch(url, {
147052
+ ...init,
147053
+ headers: { ...init.headers, Range: `bytes=-${suffix_length}` }
147054
+ });
147055
+ }
147056
+ let response = await fetch(url, { ...init, method: "HEAD" });
147057
+ if (!response.ok) {
147058
+ return response;
147059
+ }
147060
+ let content_length = response.headers.get("Content-Length");
147061
+ let length2 = Number(content_length);
147062
+ return fetch_range(url, length2 - suffix_length, length2, init);
147063
+ }
147064
+ class FetchStore {
147065
+ constructor(url, options = {}) {
147066
+ __privateAdd(this, _merge_init);
147067
+ __publicField(this, "url");
147068
+ __privateAdd(this, _overrides, void 0);
147069
+ __privateAdd(this, _use_suffix_request, void 0);
147070
+ this.url = url;
147071
+ __privateSet(this, _overrides, options.overrides ?? {});
147072
+ __privateSet(this, _use_suffix_request, options.useSuffixRequest ?? false);
147073
+ }
147074
+ async get(key, options = {}) {
147075
+ let href = resolve(this.url, key).href;
147076
+ let response = await fetch(href, __privateMethod(this, _merge_init, merge_init_fn).call(this, options));
147077
+ return handle_response(response);
147078
+ }
147079
+ async getRange(key, range2, options = {}) {
147080
+ let url = resolve(this.url, key);
147081
+ let init = __privateMethod(this, _merge_init, merge_init_fn).call(this, options);
147082
+ let response;
147083
+ if ("suffixLength" in range2) {
147084
+ response = await fetch_suffix(url, range2.suffixLength, init, __privateGet(this, _use_suffix_request));
147085
+ } else {
147086
+ response = await fetch_range(url, range2.offset, range2.length, init);
147087
+ }
147088
+ return handle_response(response);
147089
+ }
147090
+ }
147091
+ _overrides = new WeakMap();
147092
+ _use_suffix_request = new WeakMap();
147093
+ _merge_init = new WeakSet();
147094
+ merge_init_fn = function(overrides) {
147095
+ return {
147096
+ ...__privateGet(this, _overrides),
147097
+ ...overrides,
147098
+ headers: {
147099
+ ...__privateGet(this, _overrides).headers,
147100
+ ...overrides.headers
147101
+ }
147102
+ };
147103
+ };
147104
+ const FetchStore$1 = FetchStore;
147105
+ function getV2DataType(dtype) {
147106
+ const mapping = {
147107
+ int8: "|i1",
147108
+ uint8: "|u1",
147109
+ int16: "<i2",
147110
+ uint16: "<u2",
147111
+ int32: "<i4",
147112
+ uint32: "<u4",
147113
+ int64: "<i8",
147114
+ uint64: "<u8",
147115
+ float32: "<f4",
147116
+ float64: "<f8"
147117
+ };
147118
+ if (!(dtype in mapping)) {
147119
+ throw new Error(`Unsupported dtype ${dtype}`);
147120
+ }
147121
+ return mapping[dtype];
147122
+ }
147123
+ function createZarrArrayAdapter(arr) {
147124
+ return new Proxy(arr, {
147125
+ get(target, prop) {
147126
+ if (prop === "getRaw") {
147127
+ return (selection) => get(target, selection ? selection.map((s2) => {
147128
+ if (typeof s2 === "object" && s2 !== null) {
147129
+ return slice(s2.start, s2.stop, s2.step);
147130
+ }
147131
+ return s2;
147132
+ }) : target.shape.map(() => null));
147133
+ }
147134
+ if (prop === "getRawChunk") {
147135
+ throw new Error("getRawChunk should not have been called");
147136
+ }
147137
+ if (prop === "dtype") {
147138
+ return getV2DataType(target.dtype);
147139
+ }
147140
+ return Reflect.get(target, prop);
147141
+ }
147142
+ });
147143
+ }
147144
+ function zarrOpenRoot(url, requestInit2) {
147145
+ const store = new FetchStore$1(url, { overrides: requestInit2 });
147146
+ return root(store);
147147
+ }
147148
+ function prevPowerOf2(x2) {
147149
+ return 2 ** Math.floor(Math.log2(x2));
147150
+ }
147151
+ function isInterleaved(shape) {
147152
+ const lastDimSize = shape[shape.length - 1];
147153
+ return lastDimSize === 3 || lastDimSize === 4;
147154
+ }
147155
+ function guessTileSize(arr) {
147156
+ const interleaved = isInterleaved(arr.shape);
147157
+ const [yChunk, xChunk] = arr.chunks.slice(interleaved ? -3 : -2);
147158
+ const size2 = Math.min(yChunk, xChunk);
147159
+ return prevPowerOf2(size2);
147160
+ }
147161
+ function isAxis(axisOrLabel) {
147162
+ return typeof axisOrLabel[0] !== "string";
147163
+ }
147164
+ async function loadMultiscales(root2) {
147165
+ const rootAttrs = (await open(root2)).attrs;
147166
+ let paths = ["0"];
147167
+ let labels = ["t", "c", "z", "y", "x"];
147168
+ if ("multiscales" in rootAttrs) {
147169
+ const { datasets, axes } = rootAttrs.multiscales[0];
147170
+ paths = datasets.map((d) => d.path);
147171
+ if (axes) {
147172
+ if (isAxis(axes)) {
147173
+ labels = axes.map((axis) => axis.name);
147174
+ } else {
147175
+ labels = axes;
147176
+ }
147177
+ }
147178
+ }
147179
+ const data = paths.map((path) => open(root2.resolve(path), { kind: "array" }));
147180
+ return {
147181
+ data: await Promise.all(data),
147182
+ rootAttrs,
147183
+ labels
147184
+ };
147185
+ }
147186
+ class ZarritaPixelSource extends ZarrPixelSource {
147187
+ constructor(arr, labels, tileSize) {
147188
+ super(arr, labels, tileSize);
147189
+ this._readChunks = false;
147190
+ }
147191
+ }
147192
+ async function loadOmeZarr(url, requestInit2) {
147193
+ const root2 = await zarrOpenRoot(url, requestInit2);
147194
+ const { data, rootAttrs, labels } = await loadMultiscales(root2);
147195
+ const tileSize = guessTileSize(data[0]);
147196
+ const pyramid = data.map((arr) => new ZarritaPixelSource(
147197
+ createZarrArrayAdapter(arr),
147198
+ labels,
147199
+ tileSize
147200
+ ));
147201
+ return {
147202
+ data: pyramid,
147203
+ metadata: rootAttrs
147204
+ };
147205
+ }
145469
147206
  function getDomains() {
145470
147207
  const domains = {};
145471
147208
  const needMin = ["Int8", "Int16", "Int32"];
@@ -145478,11 +147215,14 @@ function getDomains() {
145478
147215
  }
145479
147216
  const DOMAINS = getDomains();
145480
147217
  export {
145481
- filterSelection as A,
147218
+ getBoundingCube as A,
145482
147219
  BaseDecoder as B,
145483
- DOMAINS as C,
147220
+ abbreviateNumber as C,
145484
147221
  DEFAULT_CELLS_LAYER as D,
147222
+ filterSelection as E,
147223
+ DOMAINS as F,
145485
147224
  GLOBAL_LABELS as G,
147225
+ ZarritaPixelSource as Z,
145486
147226
  DEFAULT_MOLECULES_LAYER as a,
145487
147227
  DEFAULT_NEIGHBORHOODS_LAYER as b,
145488
147228
  DEFAULT_RASTER_DOMAIN_TYPE as c,
@@ -145492,7 +147232,7 @@ export {
145492
147232
  getDefaultExportFromCjs as g,
145493
147233
  getSourceFromLoader as h,
145494
147234
  initializeLayerChannels as i,
145495
- isInterleaved as j,
147235
+ isInterleaved$1 as j,
145496
147236
  isRgb as k,
145497
147237
  getNgffAxes as l,
145498
147238
  getNgffAxesForTiff as m,
@@ -145503,10 +147243,10 @@ export {
145503
147243
  canLoadResolution as r,
145504
147244
  square as s,
145505
147245
  normalizeCoordinateTransformations as t,
145506
- toRgbUIString as u,
145507
- getSingleSelectionStats as v,
145508
- getMultiSelectionStats as w,
145509
- getPhysicalSizeScalingMatrix as x,
145510
- getBoundingCube as y,
145511
- abbreviateNumber as z
147246
+ loadOmeZarr as u,
147247
+ guessTileSize as v,
147248
+ toRgbUIString as w,
147249
+ getSingleSelectionStats as x,
147250
+ getMultiSelectionStats as y,
147251
+ getPhysicalSizeScalingMatrix as z
145512
147252
  };