@loaders.gl/pmtiles 4.2.1 → 4.3.0-alpha.2

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.
package/dist/dist.dev.js CHANGED
@@ -12,6 +12,7 @@ var __exports__ = (() => {
12
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
13
13
  var __getProtoOf = Object.getPrototypeOf;
14
14
  var __hasOwnProp = Object.prototype.hasOwnProperty;
15
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
15
16
  var __commonJS = (cb, mod) => function __require() {
16
17
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
18
  };
@@ -37,6 +38,10 @@ var __exports__ = (() => {
37
38
  mod
38
39
  ));
39
40
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+ var __publicField = (obj, key, value) => {
42
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
43
+ return value;
44
+ };
40
45
 
41
46
  // external-global-plugin:@loaders.gl/core
42
47
  var require_core = __commonJS({
@@ -54,19 +59,19 @@ var __exports__ = (() => {
54
59
  var eMax = (1 << eLen) - 1;
55
60
  var eBias = eMax >> 1;
56
61
  var nBits = -7;
57
- var i3 = isLE ? nBytes - 1 : 0;
62
+ var i2 = isLE ? nBytes - 1 : 0;
58
63
  var d = isLE ? -1 : 1;
59
- var s = buffer[offset + i3];
60
- i3 += d;
64
+ var s = buffer[offset + i2];
65
+ i2 += d;
61
66
  e = s & (1 << -nBits) - 1;
62
67
  s >>= -nBits;
63
68
  nBits += eLen;
64
- for (; nBits > 0; e = e * 256 + buffer[offset + i3], i3 += d, nBits -= 8) {
69
+ for (; nBits > 0; e = e * 256 + buffer[offset + i2], i2 += d, nBits -= 8) {
65
70
  }
66
71
  m = e & (1 << -nBits) - 1;
67
72
  e >>= -nBits;
68
73
  nBits += mLen;
69
- for (; nBits > 0; m = m * 256 + buffer[offset + i3], i3 += d, nBits -= 8) {
74
+ for (; nBits > 0; m = m * 256 + buffer[offset + i2], i2 += d, nBits -= 8) {
70
75
  }
71
76
  if (e === 0) {
72
77
  e = 1 - eBias;
@@ -84,7 +89,7 @@ var __exports__ = (() => {
84
89
  var eMax = (1 << eLen) - 1;
85
90
  var eBias = eMax >> 1;
86
91
  var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
87
- var i3 = isLE ? 0 : nBytes - 1;
92
+ var i2 = isLE ? 0 : nBytes - 1;
88
93
  var d = isLE ? 1 : -1;
89
94
  var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
90
95
  value = Math.abs(value);
@@ -117,13 +122,13 @@ var __exports__ = (() => {
117
122
  e = 0;
118
123
  }
119
124
  }
120
- for (; mLen >= 8; buffer[offset + i3] = m & 255, i3 += d, m /= 256, mLen -= 8) {
125
+ for (; mLen >= 8; buffer[offset + i2] = m & 255, i2 += d, m /= 256, mLen -= 8) {
121
126
  }
122
127
  e = e << mLen | m;
123
128
  eLen += mLen;
124
- for (; eLen > 0; buffer[offset + i3] = e & 255, i3 += d, e /= 256, eLen -= 8) {
129
+ for (; eLen > 0; buffer[offset + i2] = e & 255, i2 += d, e /= 256, eLen -= 8) {
125
130
  }
126
- buffer[offset + i3 - d] |= s * 128;
131
+ buffer[offset + i2 - d] |= s * 128;
127
132
  };
128
133
  }
129
134
  });
@@ -345,14 +350,14 @@ var __exports__ = (() => {
345
350
  this.writeVarint(tag << 3 | type);
346
351
  },
347
352
  realloc: function(min) {
348
- var length2 = this.length || 16;
349
- while (length2 < this.pos + min)
350
- length2 *= 2;
351
- if (length2 !== this.length) {
352
- var buf = new Uint8Array(length2);
353
+ var length = this.length || 16;
354
+ while (length < this.pos + min)
355
+ length *= 2;
356
+ if (length !== this.length) {
357
+ var buf = new Uint8Array(length);
353
358
  buf.set(this.buf);
354
359
  this.buf = buf;
355
- this.length = length2;
360
+ this.length = length;
356
361
  }
357
362
  },
358
363
  finish: function() {
@@ -433,8 +438,8 @@ var __exports__ = (() => {
433
438
  var len = buffer.length;
434
439
  this.writeVarint(len);
435
440
  this.realloc(len);
436
- for (var i3 = 0; i3 < len; i3++)
437
- this.buf[this.pos++] = buffer[i3];
441
+ for (var i2 = 0; i2 < len; i2++)
442
+ this.buf[this.pos++] = buffer[i2];
438
443
  },
439
444
  writeRawMessage: function(fn, obj) {
440
445
  this.pos++;
@@ -623,44 +628,44 @@ var __exports__ = (() => {
623
628
  function makeRoomForExtraLength(startPos, len, pbf) {
624
629
  var extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
625
630
  pbf.realloc(extraLen);
626
- for (var i3 = pbf.pos - 1; i3 >= startPos; i3--)
627
- pbf.buf[i3 + extraLen] = pbf.buf[i3];
631
+ for (var i2 = pbf.pos - 1; i2 >= startPos; i2--)
632
+ pbf.buf[i2 + extraLen] = pbf.buf[i2];
628
633
  }
629
634
  function writePackedVarint(arr, pbf) {
630
- for (var i3 = 0; i3 < arr.length; i3++)
631
- pbf.writeVarint(arr[i3]);
635
+ for (var i2 = 0; i2 < arr.length; i2++)
636
+ pbf.writeVarint(arr[i2]);
632
637
  }
633
638
  function writePackedSVarint(arr, pbf) {
634
- for (var i3 = 0; i3 < arr.length; i3++)
635
- pbf.writeSVarint(arr[i3]);
639
+ for (var i2 = 0; i2 < arr.length; i2++)
640
+ pbf.writeSVarint(arr[i2]);
636
641
  }
637
642
  function writePackedFloat(arr, pbf) {
638
- for (var i3 = 0; i3 < arr.length; i3++)
639
- pbf.writeFloat(arr[i3]);
643
+ for (var i2 = 0; i2 < arr.length; i2++)
644
+ pbf.writeFloat(arr[i2]);
640
645
  }
641
646
  function writePackedDouble(arr, pbf) {
642
- for (var i3 = 0; i3 < arr.length; i3++)
643
- pbf.writeDouble(arr[i3]);
647
+ for (var i2 = 0; i2 < arr.length; i2++)
648
+ pbf.writeDouble(arr[i2]);
644
649
  }
645
650
  function writePackedBoolean(arr, pbf) {
646
- for (var i3 = 0; i3 < arr.length; i3++)
647
- pbf.writeBoolean(arr[i3]);
651
+ for (var i2 = 0; i2 < arr.length; i2++)
652
+ pbf.writeBoolean(arr[i2]);
648
653
  }
649
654
  function writePackedFixed32(arr, pbf) {
650
- for (var i3 = 0; i3 < arr.length; i3++)
651
- pbf.writeFixed32(arr[i3]);
655
+ for (var i2 = 0; i2 < arr.length; i2++)
656
+ pbf.writeFixed32(arr[i2]);
652
657
  }
653
658
  function writePackedSFixed32(arr, pbf) {
654
- for (var i3 = 0; i3 < arr.length; i3++)
655
- pbf.writeSFixed32(arr[i3]);
659
+ for (var i2 = 0; i2 < arr.length; i2++)
660
+ pbf.writeSFixed32(arr[i2]);
656
661
  }
657
662
  function writePackedFixed64(arr, pbf) {
658
- for (var i3 = 0; i3 < arr.length; i3++)
659
- pbf.writeFixed64(arr[i3]);
663
+ for (var i2 = 0; i2 < arr.length; i2++)
664
+ pbf.writeFixed64(arr[i2]);
660
665
  }
661
666
  function writePackedSFixed64(arr, pbf) {
662
- for (var i3 = 0; i3 < arr.length; i3++)
663
- pbf.writeSFixed64(arr[i3]);
667
+ for (var i2 = 0; i2 < arr.length; i2++)
668
+ pbf.writeSFixed64(arr[i2]);
664
669
  }
665
670
  function readUInt32(buf, pos) {
666
671
  return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + buf[pos + 3] * 16777216;
@@ -676,12 +681,12 @@ var __exports__ = (() => {
676
681
  }
677
682
  function readUtf8(buf, pos, end) {
678
683
  var str = "";
679
- var i3 = pos;
680
- while (i3 < end) {
681
- var b0 = buf[i3];
684
+ var i2 = pos;
685
+ while (i2 < end) {
686
+ var b0 = buf[i2];
682
687
  var c = null;
683
688
  var bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
684
- if (i3 + bytesPerSequence > end)
689
+ if (i2 + bytesPerSequence > end)
685
690
  break;
686
691
  var b1, b2, b3;
687
692
  if (bytesPerSequence === 1) {
@@ -689,7 +694,7 @@ var __exports__ = (() => {
689
694
  c = b0;
690
695
  }
691
696
  } else if (bytesPerSequence === 2) {
692
- b1 = buf[i3 + 1];
697
+ b1 = buf[i2 + 1];
693
698
  if ((b1 & 192) === 128) {
694
699
  c = (b0 & 31) << 6 | b1 & 63;
695
700
  if (c <= 127) {
@@ -697,8 +702,8 @@ var __exports__ = (() => {
697
702
  }
698
703
  }
699
704
  } else if (bytesPerSequence === 3) {
700
- b1 = buf[i3 + 1];
701
- b2 = buf[i3 + 2];
705
+ b1 = buf[i2 + 1];
706
+ b2 = buf[i2 + 2];
702
707
  if ((b1 & 192) === 128 && (b2 & 192) === 128) {
703
708
  c = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
704
709
  if (c <= 2047 || c >= 55296 && c <= 57343) {
@@ -706,9 +711,9 @@ var __exports__ = (() => {
706
711
  }
707
712
  }
708
713
  } else if (bytesPerSequence === 4) {
709
- b1 = buf[i3 + 1];
710
- b2 = buf[i3 + 2];
711
- b3 = buf[i3 + 3];
714
+ b1 = buf[i2 + 1];
715
+ b2 = buf[i2 + 2];
716
+ b3 = buf[i2 + 3];
712
717
  if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
713
718
  c = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
714
719
  if (c <= 65535 || c >= 1114112) {
@@ -725,7 +730,7 @@ var __exports__ = (() => {
725
730
  c = 56320 | c & 1023;
726
731
  }
727
732
  str += String.fromCharCode(c);
728
- i3 += bytesPerSequence;
733
+ i2 += bytesPerSequence;
729
734
  }
730
735
  return str;
731
736
  }
@@ -733,8 +738,8 @@ var __exports__ = (() => {
733
738
  return utf8TextDecoder.decode(buf.subarray(pos, end));
734
739
  }
735
740
  function writeUtf8(buf, str, pos) {
736
- for (var i3 = 0, c, lead; i3 < str.length; i3++) {
737
- c = str.charCodeAt(i3);
741
+ for (var i2 = 0, c, lead; i2 < str.length; i2++) {
742
+ c = str.charCodeAt(i2);
738
743
  if (c > 55295 && c < 57344) {
739
744
  if (lead) {
740
745
  if (c < 56320) {
@@ -748,7 +753,7 @@ var __exports__ = (() => {
748
753
  lead = null;
749
754
  }
750
755
  } else {
751
- if (c > 56319 || i3 + 1 === str.length) {
756
+ if (c > 56319 || i2 + 1 === str.length) {
752
757
  buf[pos++] = 239;
753
758
  buf[pos++] = 191;
754
759
  buf[pos++] = 189;
@@ -863,6 +868,548 @@ var __exports__ = (() => {
863
868
  return obj;
864
869
  }
865
870
 
871
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-electron.js
872
+ function isElectron(mockUserAgent) {
873
+ if (typeof window !== "undefined" && typeof window.process === "object" && window.process.type === "renderer") {
874
+ return true;
875
+ }
876
+ if (typeof process !== "undefined" && typeof process.versions === "object" && Boolean(process.versions["electron"])) {
877
+ return true;
878
+ }
879
+ const realUserAgent = typeof navigator === "object" && typeof navigator.userAgent === "string" && navigator.userAgent;
880
+ const userAgent = mockUserAgent || realUserAgent;
881
+ if (userAgent && userAgent.indexOf("Electron") >= 0) {
882
+ return true;
883
+ }
884
+ return false;
885
+ }
886
+
887
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/is-browser.js
888
+ function isBrowser2() {
889
+ const isNode = typeof process === "object" && String(process) === "[object process]" && !process.browser;
890
+ return !isNode || isElectron();
891
+ }
892
+
893
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/lib/globals.js
894
+ var self_2 = globalThis.self || globalThis.window || globalThis.global;
895
+ var window_2 = globalThis.window || globalThis.self || globalThis.global;
896
+ var document_2 = globalThis.document || {};
897
+ var process_ = globalThis.process || {};
898
+ var console_ = globalThis.console;
899
+ var navigator_ = globalThis.navigator || {};
900
+
901
+ // ../../node_modules/@probe.gl/log/node_modules/@probe.gl/env/dist/utils/globals.js
902
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "untranspiled source";
903
+ var isBrowser3 = isBrowser2();
904
+
905
+ // ../../node_modules/@probe.gl/log/dist/utils/local-storage.js
906
+ function getStorage(type) {
907
+ try {
908
+ const storage = window[type];
909
+ const x2 = "__storage_test__";
910
+ storage.setItem(x2, x2);
911
+ storage.removeItem(x2);
912
+ return storage;
913
+ } catch (e) {
914
+ return null;
915
+ }
916
+ }
917
+ var LocalStorage = class {
918
+ constructor(id, defaultConfig) {
919
+ let type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "sessionStorage";
920
+ _defineProperty(this, "storage", void 0);
921
+ _defineProperty(this, "id", void 0);
922
+ _defineProperty(this, "config", void 0);
923
+ this.storage = getStorage(type);
924
+ this.id = id;
925
+ this.config = defaultConfig;
926
+ this._loadConfiguration();
927
+ }
928
+ getConfiguration() {
929
+ return this.config;
930
+ }
931
+ setConfiguration(configuration) {
932
+ Object.assign(this.config, configuration);
933
+ if (this.storage) {
934
+ const serialized = JSON.stringify(this.config);
935
+ this.storage.setItem(this.id, serialized);
936
+ }
937
+ }
938
+ _loadConfiguration() {
939
+ let configuration = {};
940
+ if (this.storage) {
941
+ const serializedConfiguration = this.storage.getItem(this.id);
942
+ configuration = serializedConfiguration ? JSON.parse(serializedConfiguration) : {};
943
+ }
944
+ Object.assign(this.config, configuration);
945
+ return this;
946
+ }
947
+ };
948
+
949
+ // ../../node_modules/@probe.gl/log/dist/utils/formatters.js
950
+ function formatTime(ms) {
951
+ let formatted;
952
+ if (ms < 10) {
953
+ formatted = "".concat(ms.toFixed(2), "ms");
954
+ } else if (ms < 100) {
955
+ formatted = "".concat(ms.toFixed(1), "ms");
956
+ } else if (ms < 1e3) {
957
+ formatted = "".concat(ms.toFixed(0), "ms");
958
+ } else {
959
+ formatted = "".concat((ms / 1e3).toFixed(2), "s");
960
+ }
961
+ return formatted;
962
+ }
963
+ function leftPad(string) {
964
+ let length = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
965
+ const padLength = Math.max(length - string.length, 0);
966
+ return "".concat(" ".repeat(padLength)).concat(string);
967
+ }
968
+ function formatImage(image, message, scale) {
969
+ let maxWidth = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 600;
970
+ const imageUrl = image.src.replace(/\(/g, "%28").replace(/\)/g, "%29");
971
+ if (image.width > maxWidth) {
972
+ scale = Math.min(scale, maxWidth / image.width);
973
+ }
974
+ const width = image.width * scale;
975
+ const height = image.height * scale;
976
+ const style = ["font-size:1px;", "padding:".concat(Math.floor(height / 2), "px ").concat(Math.floor(width / 2), "px;"), "line-height:".concat(height, "px;"), "background:url(".concat(imageUrl, ");"), "background-size:".concat(width, "px ").concat(height, "px;"), "color:transparent;"].join("");
977
+ return ["".concat(message, " %c+"), style];
978
+ }
979
+
980
+ // ../../node_modules/@probe.gl/log/dist/utils/color.js
981
+ var COLOR;
982
+ (function(COLOR2) {
983
+ COLOR2[COLOR2["BLACK"] = 30] = "BLACK";
984
+ COLOR2[COLOR2["RED"] = 31] = "RED";
985
+ COLOR2[COLOR2["GREEN"] = 32] = "GREEN";
986
+ COLOR2[COLOR2["YELLOW"] = 33] = "YELLOW";
987
+ COLOR2[COLOR2["BLUE"] = 34] = "BLUE";
988
+ COLOR2[COLOR2["MAGENTA"] = 35] = "MAGENTA";
989
+ COLOR2[COLOR2["CYAN"] = 36] = "CYAN";
990
+ COLOR2[COLOR2["WHITE"] = 37] = "WHITE";
991
+ COLOR2[COLOR2["BRIGHT_BLACK"] = 90] = "BRIGHT_BLACK";
992
+ COLOR2[COLOR2["BRIGHT_RED"] = 91] = "BRIGHT_RED";
993
+ COLOR2[COLOR2["BRIGHT_GREEN"] = 92] = "BRIGHT_GREEN";
994
+ COLOR2[COLOR2["BRIGHT_YELLOW"] = 93] = "BRIGHT_YELLOW";
995
+ COLOR2[COLOR2["BRIGHT_BLUE"] = 94] = "BRIGHT_BLUE";
996
+ COLOR2[COLOR2["BRIGHT_MAGENTA"] = 95] = "BRIGHT_MAGENTA";
997
+ COLOR2[COLOR2["BRIGHT_CYAN"] = 96] = "BRIGHT_CYAN";
998
+ COLOR2[COLOR2["BRIGHT_WHITE"] = 97] = "BRIGHT_WHITE";
999
+ })(COLOR || (COLOR = {}));
1000
+ var BACKGROUND_INCREMENT = 10;
1001
+ function getColor(color) {
1002
+ if (typeof color !== "string") {
1003
+ return color;
1004
+ }
1005
+ color = color.toUpperCase();
1006
+ return COLOR[color] || COLOR.WHITE;
1007
+ }
1008
+ function addColor(string, color, background) {
1009
+ if (!isBrowser2 && typeof string === "string") {
1010
+ if (color) {
1011
+ const colorCode = getColor(color);
1012
+ string = "\x1B[".concat(colorCode, "m").concat(string, "\x1B[39m");
1013
+ }
1014
+ if (background) {
1015
+ const colorCode = getColor(background);
1016
+ string = "\x1B[".concat(colorCode + BACKGROUND_INCREMENT, "m").concat(string, "\x1B[49m");
1017
+ }
1018
+ }
1019
+ return string;
1020
+ }
1021
+
1022
+ // ../../node_modules/@probe.gl/log/dist/utils/autobind.js
1023
+ function autobind(obj) {
1024
+ let predefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ["constructor"];
1025
+ const proto = Object.getPrototypeOf(obj);
1026
+ const propNames = Object.getOwnPropertyNames(proto);
1027
+ const object = obj;
1028
+ for (const key of propNames) {
1029
+ const value = object[key];
1030
+ if (typeof value === "function") {
1031
+ if (!predefined.find((name) => key === name)) {
1032
+ object[key] = value.bind(obj);
1033
+ }
1034
+ }
1035
+ }
1036
+ }
1037
+
1038
+ // ../../node_modules/@probe.gl/log/dist/utils/assert.js
1039
+ function assert2(condition, message) {
1040
+ if (!condition) {
1041
+ throw new Error(message || "Assertion failed");
1042
+ }
1043
+ }
1044
+
1045
+ // ../../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js
1046
+ function getHiResTimestamp() {
1047
+ let timestamp;
1048
+ if (isBrowser2() && window_2.performance) {
1049
+ var _window$performance, _window$performance$n;
1050
+ timestamp = window_2 === null || window_2 === void 0 ? void 0 : (_window$performance = window_2.performance) === null || _window$performance === void 0 ? void 0 : (_window$performance$n = _window$performance.now) === null || _window$performance$n === void 0 ? void 0 : _window$performance$n.call(_window$performance);
1051
+ } else if ("hrtime" in process_) {
1052
+ var _process$hrtime;
1053
+ const timeParts = process_ === null || process_ === void 0 ? void 0 : (_process$hrtime = process_.hrtime) === null || _process$hrtime === void 0 ? void 0 : _process$hrtime.call(process_);
1054
+ timestamp = timeParts[0] * 1e3 + timeParts[1] / 1e6;
1055
+ } else {
1056
+ timestamp = Date.now();
1057
+ }
1058
+ return timestamp;
1059
+ }
1060
+
1061
+ // ../../node_modules/@probe.gl/log/dist/log.js
1062
+ var originalConsole = {
1063
+ debug: isBrowser2() ? console.debug || console.log : console.log,
1064
+ log: console.log,
1065
+ info: console.info,
1066
+ warn: console.warn,
1067
+ error: console.error
1068
+ };
1069
+ var DEFAULT_LOG_CONFIGURATION = {
1070
+ enabled: true,
1071
+ level: 0
1072
+ };
1073
+ function noop() {
1074
+ }
1075
+ var cache = {};
1076
+ var ONCE = {
1077
+ once: true
1078
+ };
1079
+ var Log = class {
1080
+ constructor() {
1081
+ let {
1082
+ id
1083
+ } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
1084
+ id: ""
1085
+ };
1086
+ _defineProperty(this, "id", void 0);
1087
+ _defineProperty(this, "VERSION", VERSION);
1088
+ _defineProperty(this, "_startTs", getHiResTimestamp());
1089
+ _defineProperty(this, "_deltaTs", getHiResTimestamp());
1090
+ _defineProperty(this, "_storage", void 0);
1091
+ _defineProperty(this, "userData", {});
1092
+ _defineProperty(this, "LOG_THROTTLE_TIMEOUT", 0);
1093
+ this.id = id;
1094
+ this.userData = {};
1095
+ this._storage = new LocalStorage("__probe-".concat(this.id, "__"), DEFAULT_LOG_CONFIGURATION);
1096
+ this.timeStamp("".concat(this.id, " started"));
1097
+ autobind(this);
1098
+ Object.seal(this);
1099
+ }
1100
+ set level(newLevel) {
1101
+ this.setLevel(newLevel);
1102
+ }
1103
+ get level() {
1104
+ return this.getLevel();
1105
+ }
1106
+ isEnabled() {
1107
+ return this._storage.config.enabled;
1108
+ }
1109
+ getLevel() {
1110
+ return this._storage.config.level;
1111
+ }
1112
+ getTotal() {
1113
+ return Number((getHiResTimestamp() - this._startTs).toPrecision(10));
1114
+ }
1115
+ getDelta() {
1116
+ return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));
1117
+ }
1118
+ set priority(newPriority) {
1119
+ this.level = newPriority;
1120
+ }
1121
+ get priority() {
1122
+ return this.level;
1123
+ }
1124
+ getPriority() {
1125
+ return this.level;
1126
+ }
1127
+ enable() {
1128
+ let enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
1129
+ this._storage.setConfiguration({
1130
+ enabled
1131
+ });
1132
+ return this;
1133
+ }
1134
+ setLevel(level) {
1135
+ this._storage.setConfiguration({
1136
+ level
1137
+ });
1138
+ return this;
1139
+ }
1140
+ get(setting) {
1141
+ return this._storage.config[setting];
1142
+ }
1143
+ set(setting, value) {
1144
+ this._storage.setConfiguration({
1145
+ [setting]: value
1146
+ });
1147
+ }
1148
+ settings() {
1149
+ if (console.table) {
1150
+ console.table(this._storage.config);
1151
+ } else {
1152
+ console.log(this._storage.config);
1153
+ }
1154
+ }
1155
+ assert(condition, message) {
1156
+ assert2(condition, message);
1157
+ }
1158
+ warn(message) {
1159
+ return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);
1160
+ }
1161
+ error(message) {
1162
+ return this._getLogFunction(0, message, originalConsole.error, arguments);
1163
+ }
1164
+ deprecated(oldUsage, newUsage) {
1165
+ return this.warn("`".concat(oldUsage, "` is deprecated and will be removed in a later version. Use `").concat(newUsage, "` instead"));
1166
+ }
1167
+ removed(oldUsage, newUsage) {
1168
+ return this.error("`".concat(oldUsage, "` has been removed. Use `").concat(newUsage, "` instead"));
1169
+ }
1170
+ probe(logLevel, message) {
1171
+ return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {
1172
+ time: true,
1173
+ once: true
1174
+ });
1175
+ }
1176
+ log(logLevel, message) {
1177
+ return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);
1178
+ }
1179
+ info(logLevel, message) {
1180
+ return this._getLogFunction(logLevel, message, console.info, arguments);
1181
+ }
1182
+ once(logLevel, message) {
1183
+ return this._getLogFunction(logLevel, message, originalConsole.debug || originalConsole.info, arguments, ONCE);
1184
+ }
1185
+ table(logLevel, table, columns) {
1186
+ if (table) {
1187
+ return this._getLogFunction(logLevel, table, console.table || noop, columns && [columns], {
1188
+ tag: getTableHeader(table)
1189
+ });
1190
+ }
1191
+ return noop;
1192
+ }
1193
+ image(_ref) {
1194
+ let {
1195
+ logLevel,
1196
+ priority,
1197
+ image,
1198
+ message = "",
1199
+ scale = 1
1200
+ } = _ref;
1201
+ if (!this._shouldLog(logLevel || priority)) {
1202
+ return noop;
1203
+ }
1204
+ return isBrowser2() ? logImageInBrowser({
1205
+ image,
1206
+ message,
1207
+ scale
1208
+ }) : logImageInNode({
1209
+ image,
1210
+ message,
1211
+ scale
1212
+ });
1213
+ }
1214
+ time(logLevel, message) {
1215
+ return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);
1216
+ }
1217
+ timeEnd(logLevel, message) {
1218
+ return this._getLogFunction(logLevel, message, console.timeEnd ? console.timeEnd : console.info);
1219
+ }
1220
+ timeStamp(logLevel, message) {
1221
+ return this._getLogFunction(logLevel, message, console.timeStamp || noop);
1222
+ }
1223
+ group(logLevel, message) {
1224
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
1225
+ collapsed: false
1226
+ };
1227
+ const options = normalizeArguments({
1228
+ logLevel,
1229
+ message,
1230
+ opts
1231
+ });
1232
+ const {
1233
+ collapsed
1234
+ } = opts;
1235
+ options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;
1236
+ return this._getLogFunction(options);
1237
+ }
1238
+ groupCollapsed(logLevel, message) {
1239
+ let opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1240
+ return this.group(logLevel, message, Object.assign({}, opts, {
1241
+ collapsed: true
1242
+ }));
1243
+ }
1244
+ groupEnd(logLevel) {
1245
+ return this._getLogFunction(logLevel, "", console.groupEnd || noop);
1246
+ }
1247
+ withGroup(logLevel, message, func) {
1248
+ this.group(logLevel, message)();
1249
+ try {
1250
+ func();
1251
+ } finally {
1252
+ this.groupEnd(logLevel)();
1253
+ }
1254
+ }
1255
+ trace() {
1256
+ if (console.trace) {
1257
+ console.trace();
1258
+ }
1259
+ }
1260
+ _shouldLog(logLevel) {
1261
+ return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);
1262
+ }
1263
+ _getLogFunction(logLevel, message, method, args, opts) {
1264
+ if (this._shouldLog(logLevel)) {
1265
+ opts = normalizeArguments({
1266
+ logLevel,
1267
+ message,
1268
+ args,
1269
+ opts
1270
+ });
1271
+ method = method || opts.method;
1272
+ assert2(method);
1273
+ opts.total = this.getTotal();
1274
+ opts.delta = this.getDelta();
1275
+ this._deltaTs = getHiResTimestamp();
1276
+ const tag = opts.tag || opts.message;
1277
+ if (opts.once && tag) {
1278
+ if (!cache[tag]) {
1279
+ cache[tag] = getHiResTimestamp();
1280
+ } else {
1281
+ return noop;
1282
+ }
1283
+ }
1284
+ message = decorateMessage(this.id, opts.message, opts);
1285
+ return method.bind(console, message, ...opts.args);
1286
+ }
1287
+ return noop;
1288
+ }
1289
+ };
1290
+ _defineProperty(Log, "VERSION", VERSION);
1291
+ function normalizeLogLevel(logLevel) {
1292
+ if (!logLevel) {
1293
+ return 0;
1294
+ }
1295
+ let resolvedLevel;
1296
+ switch (typeof logLevel) {
1297
+ case "number":
1298
+ resolvedLevel = logLevel;
1299
+ break;
1300
+ case "object":
1301
+ resolvedLevel = logLevel.logLevel || logLevel.priority || 0;
1302
+ break;
1303
+ default:
1304
+ return 0;
1305
+ }
1306
+ assert2(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);
1307
+ return resolvedLevel;
1308
+ }
1309
+ function normalizeArguments(opts) {
1310
+ const {
1311
+ logLevel,
1312
+ message
1313
+ } = opts;
1314
+ opts.logLevel = normalizeLogLevel(logLevel);
1315
+ const args = opts.args ? Array.from(opts.args) : [];
1316
+ while (args.length && args.shift() !== message) {
1317
+ }
1318
+ switch (typeof logLevel) {
1319
+ case "string":
1320
+ case "function":
1321
+ if (message !== void 0) {
1322
+ args.unshift(message);
1323
+ }
1324
+ opts.message = logLevel;
1325
+ break;
1326
+ case "object":
1327
+ Object.assign(opts, logLevel);
1328
+ break;
1329
+ default:
1330
+ }
1331
+ if (typeof opts.message === "function") {
1332
+ opts.message = opts.message();
1333
+ }
1334
+ const messageType = typeof opts.message;
1335
+ assert2(messageType === "string" || messageType === "object");
1336
+ return Object.assign(opts, {
1337
+ args
1338
+ }, opts.opts);
1339
+ }
1340
+ function decorateMessage(id, message, opts) {
1341
+ if (typeof message === "string") {
1342
+ const time = opts.time ? leftPad(formatTime(opts.total)) : "";
1343
+ message = opts.time ? "".concat(id, ": ").concat(time, " ").concat(message) : "".concat(id, ": ").concat(message);
1344
+ message = addColor(message, opts.color, opts.background);
1345
+ }
1346
+ return message;
1347
+ }
1348
+ function logImageInNode(_ref2) {
1349
+ let {
1350
+ image,
1351
+ message = "",
1352
+ scale = 1
1353
+ } = _ref2;
1354
+ console.warn("removed");
1355
+ return noop;
1356
+ }
1357
+ function logImageInBrowser(_ref3) {
1358
+ let {
1359
+ image,
1360
+ message = "",
1361
+ scale = 1
1362
+ } = _ref3;
1363
+ if (typeof image === "string") {
1364
+ const img = new Image();
1365
+ img.onload = () => {
1366
+ const args = formatImage(img, message, scale);
1367
+ console.log(...args);
1368
+ };
1369
+ img.src = image;
1370
+ return noop;
1371
+ }
1372
+ const element = image.nodeName || "";
1373
+ if (element.toLowerCase() === "img") {
1374
+ console.log(...formatImage(image, message, scale));
1375
+ return noop;
1376
+ }
1377
+ if (element.toLowerCase() === "canvas") {
1378
+ const img = new Image();
1379
+ img.onload = () => console.log(...formatImage(img, message, scale));
1380
+ img.src = image.toDataURL();
1381
+ return noop;
1382
+ }
1383
+ return noop;
1384
+ }
1385
+ function getTableHeader(table) {
1386
+ for (const key in table) {
1387
+ for (const title in table[key]) {
1388
+ return title || "untitled";
1389
+ }
1390
+ }
1391
+ return "empty";
1392
+ }
1393
+
1394
+ // ../../node_modules/@probe.gl/log/dist/index.js
1395
+ var dist_default = new Log({
1396
+ id: "@probe.gl/log"
1397
+ });
1398
+
1399
+ // ../loader-utils/src/lib/log-utils/log.ts
1400
+ var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1401
+ var version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
1402
+ function createLog() {
1403
+ const log2 = new Log({ id: "loaders.gl" });
1404
+ globalThis.loaders = globalThis.loaders || {};
1405
+ globalThis.loaders.log = log2;
1406
+ globalThis.loaders.version = version;
1407
+ globalThis.probe = globalThis.probe || {};
1408
+ globalThis.probe.loaders = log2;
1409
+ return log2;
1410
+ }
1411
+ var log = createLog();
1412
+
866
1413
  // ../loader-utils/src/lib/path-utils/file-aliases.ts
867
1414
  var pathPrefix = "";
868
1415
  var fileAliases = {};
@@ -925,7 +1472,7 @@ var __exports__ = (() => {
925
1472
  }
926
1473
 
927
1474
  // ../images/src/lib/utils/version.ts
928
- var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1475
+ var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
929
1476
 
930
1477
  // ../images/src/lib/category-api/image-type.ts
931
1478
  var parseImageNode = globalThis.loaders?.parseImageNode;
@@ -1125,8 +1672,8 @@ var __exports__ = (() => {
1125
1672
  }
1126
1673
  function checkString(buffer, header, offset = 0) {
1127
1674
  const headerBytes = stringToBytes(header);
1128
- for (let i3 = 0; i3 < headerBytes.length; ++i3) {
1129
- if (headerBytes[i3] !== buffer[i3 + offset]) {
1675
+ for (let i2 = 0; i2 < headerBytes.length; ++i2) {
1676
+ if (headerBytes[i2] !== buffer[i2 + offset]) {
1130
1677
  return false;
1131
1678
  }
1132
1679
  }
@@ -1196,30 +1743,30 @@ var __exports__ = (() => {
1196
1743
  return null;
1197
1744
  }
1198
1745
  const { tableMarkers, sofMarkers } = getJpegMarkers();
1199
- let i3 = 2;
1200
- while (i3 + 9 < dataView.byteLength) {
1201
- const marker = dataView.getUint16(i3, BIG_ENDIAN);
1746
+ let i2 = 2;
1747
+ while (i2 + 9 < dataView.byteLength) {
1748
+ const marker = dataView.getUint16(i2, BIG_ENDIAN);
1202
1749
  if (sofMarkers.has(marker)) {
1203
1750
  return {
1204
1751
  mimeType: "image/jpeg",
1205
- height: dataView.getUint16(i3 + 5, BIG_ENDIAN),
1752
+ height: dataView.getUint16(i2 + 5, BIG_ENDIAN),
1206
1753
  // Number of lines
1207
- width: dataView.getUint16(i3 + 7, BIG_ENDIAN)
1754
+ width: dataView.getUint16(i2 + 7, BIG_ENDIAN)
1208
1755
  // Number of pixels per line
1209
1756
  };
1210
1757
  }
1211
1758
  if (!tableMarkers.has(marker)) {
1212
1759
  return null;
1213
1760
  }
1214
- i3 += 2;
1215
- i3 += dataView.getUint16(i3, BIG_ENDIAN);
1761
+ i2 += 2;
1762
+ i2 += dataView.getUint16(i2, BIG_ENDIAN);
1216
1763
  }
1217
1764
  return null;
1218
1765
  }
1219
1766
  function getJpegMarkers() {
1220
1767
  const tableMarkers = /* @__PURE__ */ new Set([65499, 65476, 65484, 65501, 65534]);
1221
- for (let i3 = 65504; i3 < 65520; ++i3) {
1222
- tableMarkers.add(i3);
1768
+ for (let i2 = 65504; i2 < 65520; ++i2) {
1769
+ tableMarkers.add(i2);
1223
1770
  }
1224
1771
  const sofMarkers = /* @__PURE__ */ new Set([
1225
1772
  65472,
@@ -1323,7 +1870,7 @@ var __exports__ = (() => {
1323
1870
  id: "image",
1324
1871
  module: "images",
1325
1872
  name: "Images",
1326
- version: VERSION,
1873
+ version: VERSION3,
1327
1874
  mimeTypes: MIME_TYPES,
1328
1875
  extensions: EXTENSIONS,
1329
1876
  parse: parseImage,
@@ -1348,9 +1895,9 @@ var __exports__ = (() => {
1348
1895
  let area2 = 0;
1349
1896
  const i0 = DimIndex[plane[0]];
1350
1897
  const i1 = DimIndex[plane[1]];
1351
- for (let i3 = start, j = end - dim; i3 < end; i3 += dim) {
1352
- area2 += (points[i3 + i0] - points[j + i0]) * (points[i3 + i1] + points[j + i1]);
1353
- j = i3;
1898
+ for (let i2 = start, j = end - dim; i2 < end; i2 += dim) {
1899
+ area2 += (points[i2 + i0] - points[j + i0]) * (points[i2 + i1] + points[j + i1]);
1900
+ j = i2;
1354
1901
  }
1355
1902
  return area2 / 2;
1356
1903
  }
@@ -1368,24 +1915,24 @@ var __exports__ = (() => {
1368
1915
  let maxY;
1369
1916
  let minX;
1370
1917
  let minY;
1371
- let x3;
1372
- let y2;
1918
+ let x2;
1919
+ let y;
1373
1920
  if (hasHoles)
1374
1921
  outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas, plane);
1375
1922
  if (positions.length > 80 * dim) {
1376
1923
  minX = maxX = positions[0];
1377
1924
  minY = maxY = positions[1];
1378
- for (let i3 = dim; i3 < outerLen; i3 += dim) {
1379
- x3 = positions[i3];
1380
- y2 = positions[i3 + 1];
1381
- if (x3 < minX)
1382
- minX = x3;
1383
- if (y2 < minY)
1384
- minY = y2;
1385
- if (x3 > maxX)
1386
- maxX = x3;
1387
- if (y2 > maxY)
1388
- maxY = y2;
1925
+ for (let i2 = dim; i2 < outerLen; i2 += dim) {
1926
+ x2 = positions[i2];
1927
+ y = positions[i2 + 1];
1928
+ if (x2 < minX)
1929
+ minX = x2;
1930
+ if (y < minY)
1931
+ minY = y;
1932
+ if (x2 > maxX)
1933
+ maxX = x2;
1934
+ if (y > maxY)
1935
+ maxY = y;
1389
1936
  }
1390
1937
  invSize = Math.max(maxX - minX, maxY - minY);
1391
1938
  invSize = invSize !== 0 ? 32767 / invSize : 0;
@@ -1394,7 +1941,7 @@ var __exports__ = (() => {
1394
1941
  return triangles;
1395
1942
  }
1396
1943
  function linkedList(data, start, end, dim, clockwise, area2, plane) {
1397
- let i3;
1944
+ let i2;
1398
1945
  let last;
1399
1946
  if (area2 === void 0) {
1400
1947
  area2 = getPolygonSignedArea(data, {
@@ -1407,11 +1954,11 @@ var __exports__ = (() => {
1407
1954
  let i0 = DimIndex[plane[0]];
1408
1955
  let i1 = DimIndex[plane[1]];
1409
1956
  if (clockwise === area2 < 0) {
1410
- for (i3 = start; i3 < end; i3 += dim)
1411
- last = insertNode(i3, data[i3 + i0], data[i3 + i1], last);
1957
+ for (i2 = start; i2 < end; i2 += dim)
1958
+ last = insertNode(i2, data[i2 + i0], data[i2 + i1], last);
1412
1959
  } else {
1413
- for (i3 = end - dim; i3 >= start; i3 -= dim)
1414
- last = insertNode(i3, data[i3 + i0], data[i3 + i1], last);
1960
+ for (i2 = end - dim; i2 >= start; i2 -= dim)
1961
+ last = insertNode(i2, data[i2 + i0], data[i2 + i1], last);
1415
1962
  }
1416
1963
  if (last && equals(last, last.next)) {
1417
1964
  removeNode(last);
@@ -1575,22 +2122,22 @@ var __exports__ = (() => {
1575
2122
  }
1576
2123
  function eliminateHoles(data, holeIndices, outerNode, dim, areas, plane) {
1577
2124
  const queue = [];
1578
- let i3;
2125
+ let i2;
1579
2126
  let len;
1580
2127
  let start;
1581
2128
  let end;
1582
2129
  let list;
1583
- for (i3 = 0, len = holeIndices.length; i3 < len; i3++) {
1584
- start = holeIndices[i3] * dim;
1585
- end = i3 < len - 1 ? holeIndices[i3 + 1] * dim : data.length;
1586
- list = linkedList(data, start, end, dim, false, areas && areas[i3 + 1], plane);
2130
+ for (i2 = 0, len = holeIndices.length; i2 < len; i2++) {
2131
+ start = holeIndices[i2] * dim;
2132
+ end = i2 < len - 1 ? holeIndices[i2 + 1] * dim : data.length;
2133
+ list = linkedList(data, start, end, dim, false, areas && areas[i2 + 1], plane);
1587
2134
  if (list === list.next)
1588
2135
  list.steiner = true;
1589
2136
  queue.push(getLeftmost(list));
1590
2137
  }
1591
2138
  queue.sort(compareX);
1592
- for (i3 = 0; i3 < queue.length; i3++) {
1593
- outerNode = eliminateHole(queue[i3], outerNode);
2139
+ for (i2 = 0; i2 < queue.length; i2++) {
2140
+ outerNode = eliminateHole(queue[i2], outerNode);
1594
2141
  }
1595
2142
  return outerNode;
1596
2143
  }
@@ -1614,11 +2161,11 @@ var __exports__ = (() => {
1614
2161
  let m;
1615
2162
  do {
1616
2163
  if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
1617
- const x3 = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
1618
- if (x3 <= hx && x3 > qx) {
1619
- qx = x3;
2164
+ const x2 = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
2165
+ if (x2 <= hx && x2 > qx) {
2166
+ qx = x2;
1620
2167
  m = p.x < p.next.x ? p : p.next;
1621
- if (x3 === hx)
2168
+ if (x2 === hx)
1622
2169
  return m;
1623
2170
  }
1624
2171
  }
@@ -1662,7 +2209,7 @@ var __exports__ = (() => {
1662
2209
  }
1663
2210
  function sortLinked(list) {
1664
2211
  let e;
1665
- let i3;
2212
+ let i2;
1666
2213
  let inSize = 1;
1667
2214
  let numMerges;
1668
2215
  let p;
@@ -1679,7 +2226,7 @@ var __exports__ = (() => {
1679
2226
  numMerges++;
1680
2227
  q = p;
1681
2228
  pSize = 0;
1682
- for (i3 = 0; i3 < inSize; i3++) {
2229
+ for (i2 = 0; i2 < inSize; i2++) {
1683
2230
  pSize++;
1684
2231
  q = q.nextZ;
1685
2232
  if (!q)
@@ -1710,18 +2257,18 @@ var __exports__ = (() => {
1710
2257
  } while (numMerges > 1);
1711
2258
  return list;
1712
2259
  }
1713
- function zOrder(x3, y2, minX, minY, invSize) {
1714
- x3 = (x3 - minX) * invSize | 0;
1715
- y2 = (y2 - minY) * invSize | 0;
1716
- x3 = (x3 | x3 << 8) & 16711935;
1717
- x3 = (x3 | x3 << 4) & 252645135;
1718
- x3 = (x3 | x3 << 2) & 858993459;
1719
- x3 = (x3 | x3 << 1) & 1431655765;
1720
- y2 = (y2 | y2 << 8) & 16711935;
1721
- y2 = (y2 | y2 << 4) & 252645135;
1722
- y2 = (y2 | y2 << 2) & 858993459;
1723
- y2 = (y2 | y2 << 1) & 1431655765;
1724
- return x3 | y2 << 1;
2260
+ function zOrder(x2, y, minX, minY, invSize) {
2261
+ x2 = (x2 - minX) * invSize | 0;
2262
+ y = (y - minY) * invSize | 0;
2263
+ x2 = (x2 | x2 << 8) & 16711935;
2264
+ x2 = (x2 | x2 << 4) & 252645135;
2265
+ x2 = (x2 | x2 << 2) & 858993459;
2266
+ x2 = (x2 | x2 << 1) & 1431655765;
2267
+ y = (y | y << 8) & 16711935;
2268
+ y = (y | y << 4) & 252645135;
2269
+ y = (y | y << 2) & 858993459;
2270
+ y = (y | y << 1) & 1431655765;
2271
+ return x2 | y << 1;
1725
2272
  }
1726
2273
  function getLeftmost(start) {
1727
2274
  let p = start;
@@ -1807,8 +2354,8 @@ var __exports__ = (() => {
1807
2354
  b2.prev = bp;
1808
2355
  return b2;
1809
2356
  }
1810
- function insertNode(i3, x3, y2, last) {
1811
- const p = new Vertex(i3, x3, y2);
2357
+ function insertNode(i2, x2, y, last) {
2358
+ const p = new Vertex(i2, x2, y);
1812
2359
  if (!last) {
1813
2360
  p.prev = p;
1814
2361
  p.next = p;
@@ -1829,7 +2376,7 @@ var __exports__ = (() => {
1829
2376
  p.nextZ.prevZ = p.prevZ;
1830
2377
  }
1831
2378
  var Vertex = class {
1832
- constructor(i3, x3, y2) {
2379
+ constructor(i2, x2, y) {
1833
2380
  _defineProperty(this, "i", void 0);
1834
2381
  _defineProperty(this, "x", void 0);
1835
2382
  _defineProperty(this, "y", void 0);
@@ -1839,9 +2386,9 @@ var __exports__ = (() => {
1839
2386
  _defineProperty(this, "prevZ", null);
1840
2387
  _defineProperty(this, "nextZ", null);
1841
2388
  _defineProperty(this, "steiner", false);
1842
- this.i = i3;
1843
- this.x = x3;
1844
- this.y = y2;
2389
+ this.i = i2;
2390
+ this.x = x2;
2391
+ this.y = y;
1845
2392
  }
1846
2393
  };
1847
2394
 
@@ -2010,9 +2557,9 @@ var __exports__ = (() => {
2010
2557
  indexMap.linePosition,
2011
2558
  indexMap.linePosition + nPositions
2012
2559
  );
2013
- for (let i3 = 0, il = geometry.indices.length; i3 < il; ++i3) {
2014
- const start = geometry.indices[i3];
2015
- const end = i3 === il - 1 ? geometry.data.length : geometry.indices[i3 + 1];
2560
+ for (let i2 = 0, il = geometry.indices.length; i2 < il; ++i2) {
2561
+ const start = geometry.indices[i2];
2562
+ const end = i2 === il - 1 ? geometry.data.length : geometry.indices[i2 + 1];
2016
2563
  lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
2017
2564
  indexMap.linePosition += (end - start) / coordLength;
2018
2565
  }
@@ -2037,12 +2584,12 @@ var __exports__ = (() => {
2037
2584
  const areas = geometry.areas[l];
2038
2585
  const indices = geometry.indices[l];
2039
2586
  const nextIndices = geometry.indices[l + 1];
2040
- for (let i3 = 0, il = indices.length; i3 < il; ++i3) {
2041
- const start = indices[i3];
2042
- const end = i3 === il - 1 ? (
2587
+ for (let i2 = 0, il = indices.length; i2 < il; ++i2) {
2588
+ const start = indices[i2];
2589
+ const end = i2 === il - 1 ? (
2043
2590
  // last line, so either read to:
2044
2591
  nextIndices === void 0 ? geometry.data.length : nextIndices[0]
2045
- ) : indices[i3 + 1];
2592
+ ) : indices[i2 + 1];
2046
2593
  polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
2047
2594
  indexMap.polygonPosition += (end - start) / coordLength;
2048
2595
  }
@@ -2109,11 +2656,11 @@ var __exports__ = (() => {
2109
2656
  }
2110
2657
  return binaryFeatures;
2111
2658
  }
2112
- function fillNumericProperties(object, properties, index, length2) {
2659
+ function fillNumericProperties(object, properties, index, length) {
2113
2660
  for (const numericPropName in object.numericProps) {
2114
2661
  if (numericPropName in properties) {
2115
2662
  const value = properties[numericPropName];
2116
- object.numericProps[numericPropName].fill(value, index, index + length2);
2663
+ object.numericProps[numericPropName].fill(value, index, index + length);
2117
2664
  }
2118
2665
  }
2119
2666
  }
@@ -2126,17 +2673,70 @@ var __exports__ = (() => {
2126
2673
  }
2127
2674
  return props;
2128
2675
  }
2129
- function deduceArrayType(x3, constructor) {
2130
- if (constructor === Array || !Number.isFinite(x3)) {
2676
+ function deduceArrayType(x2, constructor) {
2677
+ if (constructor === Array || !Number.isFinite(x2)) {
2131
2678
  return Array;
2132
2679
  }
2133
- return constructor === Float64Array || Math.fround(x3) !== x3 ? Float64Array : Float32Array;
2680
+ return constructor === Float64Array || Math.fround(x2) !== x2 ? Float64Array : Float32Array;
2134
2681
  }
2135
2682
 
2136
2683
  // ../mvt/src/lib/parse-mvt.ts
2137
2684
  var import_pbf = __toESM(require_pbf(), 1);
2138
2685
 
2139
- // ../mvt/src/helpers/mapbox-util-functions.ts
2686
+ // ../mvt/src/lib/utils/geometry-utils.ts
2687
+ function signedArea(ring) {
2688
+ let sum = 0;
2689
+ for (let i2 = 0, j = ring.length - 1, p1, p2; i2 < ring.length; j = i2++) {
2690
+ p1 = ring[i2];
2691
+ p2 = ring[j];
2692
+ sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
2693
+ }
2694
+ return sum;
2695
+ }
2696
+ function convertToLocalCoordinates(coordinates, extent) {
2697
+ if (Array.isArray(coordinates[0])) {
2698
+ for (const subcoords of coordinates) {
2699
+ convertToLocalCoordinates(subcoords, extent);
2700
+ }
2701
+ return;
2702
+ }
2703
+ const p = coordinates;
2704
+ p[0] /= extent;
2705
+ p[1] /= extent;
2706
+ }
2707
+ function convertToLocalCoordinatesFlat(data, extent) {
2708
+ for (let i2 = 0, il = data.length; i2 < il; ++i2) {
2709
+ data[i2] /= extent;
2710
+ }
2711
+ }
2712
+ function projectToLngLat(line, tileIndex, extent) {
2713
+ if (typeof line[0][0] !== "number") {
2714
+ for (const point of line) {
2715
+ projectToLngLat(point, tileIndex, extent);
2716
+ }
2717
+ return;
2718
+ }
2719
+ const size = extent * Math.pow(2, tileIndex.z);
2720
+ const x0 = extent * tileIndex.x;
2721
+ const y0 = extent * tileIndex.y;
2722
+ for (let j = 0; j < line.length; j++) {
2723
+ const p = line[j];
2724
+ p[0] = (p[0] + x0) * 360 / size - 180;
2725
+ const y2 = 180 - (p[1] + y0) * 360 / size;
2726
+ p[1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
2727
+ }
2728
+ }
2729
+ function projectToLngLatFlat(data, tileIndex, extent) {
2730
+ const { x: x2, y, z } = tileIndex;
2731
+ const size = extent * Math.pow(2, z);
2732
+ const x0 = extent * x2;
2733
+ const y0 = extent * y;
2734
+ for (let j = 0, jl = data.length; j < jl; j += 2) {
2735
+ data[j] = (data[j] + x0) * 360 / size - 180;
2736
+ const y2 = 180 - (data[j + 1] + y0) * 360 / size;
2737
+ data[j + 1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
2738
+ }
2739
+ }
2140
2740
  function classifyRings(rings) {
2141
2741
  const len = rings.length;
2142
2742
  if (len <= 1)
@@ -2144,8 +2744,8 @@ var __exports__ = (() => {
2144
2744
  const polygons = [];
2145
2745
  let polygon;
2146
2746
  let ccw;
2147
- for (let i3 = 0; i3 < len; i3++) {
2148
- const area2 = signedArea(rings[i3]);
2747
+ for (let i2 = 0; i2 < len; i2++) {
2748
+ const area2 = signedArea(rings[i2]);
2149
2749
  if (area2 === 0)
2150
2750
  continue;
2151
2751
  if (ccw === void 0)
@@ -2153,293 +2753,15 @@ var __exports__ = (() => {
2153
2753
  if (ccw === area2 < 0) {
2154
2754
  if (polygon)
2155
2755
  polygons.push(polygon);
2156
- polygon = [rings[i3]];
2756
+ polygon = [rings[i2]];
2157
2757
  } else if (polygon)
2158
- polygon.push(rings[i3]);
2758
+ polygon.push(rings[i2]);
2159
2759
  }
2160
2760
  if (polygon)
2161
2761
  polygons.push(polygon);
2162
2762
  return polygons;
2163
2763
  }
2164
- function signedArea(ring) {
2165
- let sum = 0;
2166
- for (let i3 = 0, j = ring.length - 1, p1, p2; i3 < ring.length; j = i3++) {
2167
- p1 = ring[i3];
2168
- p2 = ring[j];
2169
- sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
2170
- }
2171
- return sum;
2172
- }
2173
- function readFeature(tag, feature, pbf) {
2174
- if (feature && pbf) {
2175
- if (tag === 1)
2176
- feature.id = pbf.readVarint();
2177
- else if (tag === 2)
2178
- readTag(pbf, feature);
2179
- else if (tag === 3)
2180
- feature.type = pbf.readVarint();
2181
- else if (tag === 4)
2182
- feature._geometry = pbf.pos;
2183
- }
2184
- }
2185
- function readTag(pbf, feature) {
2186
- const end = pbf.readVarint() + pbf.pos;
2187
- while (pbf.pos < end) {
2188
- const key = feature._keys[pbf.readVarint()];
2189
- const value = feature._values[pbf.readVarint()];
2190
- feature.properties[key] = value;
2191
- }
2192
- }
2193
-
2194
- // ../mvt/src/lib/mapbox-vector-tile/vector-tile-feature.ts
2195
- var VectorTileFeature = class {
2196
- properties;
2197
- extent;
2198
- type;
2199
- id;
2200
- _pbf;
2201
- _geometry;
2202
- _keys;
2203
- _values;
2204
- static get types() {
2205
- return ["Unknown", "Point", "LineString", "Polygon"];
2206
- }
2207
- constructor(pbf, end, extent, keys, values) {
2208
- this.properties = {};
2209
- this.extent = extent;
2210
- this.type = 0;
2211
- this.id = null;
2212
- this._pbf = pbf;
2213
- this._geometry = -1;
2214
- this._keys = keys;
2215
- this._values = values;
2216
- pbf.readFields(readFeature, this, end);
2217
- }
2218
- // eslint-disable-next-line complexity, max-statements
2219
- loadGeometry() {
2220
- const pbf = this._pbf;
2221
- pbf.pos = this._geometry;
2222
- const end = pbf.readVarint() + pbf.pos;
2223
- let cmd2 = 1;
2224
- let length2 = 0;
2225
- let x3 = 0;
2226
- let y2 = 0;
2227
- const lines = [];
2228
- let line;
2229
- while (pbf.pos < end) {
2230
- if (length2 <= 0) {
2231
- const cmdLen2 = pbf.readVarint();
2232
- cmd2 = cmdLen2 & 7;
2233
- length2 = cmdLen2 >> 3;
2234
- }
2235
- length2--;
2236
- if (cmd2 === 1 || cmd2 === 2) {
2237
- x3 += pbf.readSVarint();
2238
- y2 += pbf.readSVarint();
2239
- if (cmd2 === 1) {
2240
- if (line)
2241
- lines.push(line);
2242
- line = [];
2243
- }
2244
- if (line)
2245
- line.push([x3, y2]);
2246
- } else if (cmd2 === 7) {
2247
- if (line) {
2248
- line.push(line[0].slice());
2249
- }
2250
- } else {
2251
- throw new Error(`unknown command ${cmd2}`);
2252
- }
2253
- }
2254
- if (line)
2255
- lines.push(line);
2256
- return lines;
2257
- }
2258
- // eslint-disable-next-line max-statements
2259
- bbox() {
2260
- const pbf = this._pbf;
2261
- pbf.pos = this._geometry;
2262
- const end = pbf.readVarint() + pbf.pos;
2263
- let cmd2 = 1;
2264
- let length2 = 0;
2265
- let x3 = 0;
2266
- let y2 = 0;
2267
- let x1 = Infinity;
2268
- let x22 = -Infinity;
2269
- let y1 = Infinity;
2270
- let y22 = -Infinity;
2271
- while (pbf.pos < end) {
2272
- if (length2 <= 0) {
2273
- const cmdLen2 = pbf.readVarint();
2274
- cmd2 = cmdLen2 & 7;
2275
- length2 = cmdLen2 >> 3;
2276
- }
2277
- length2--;
2278
- if (cmd2 === 1 || cmd2 === 2) {
2279
- x3 += pbf.readSVarint();
2280
- y2 += pbf.readSVarint();
2281
- if (x3 < x1)
2282
- x1 = x3;
2283
- if (x3 > x22)
2284
- x22 = x3;
2285
- if (y2 < y1)
2286
- y1 = y2;
2287
- if (y2 > y22)
2288
- y22 = y2;
2289
- } else if (cmd2 !== 7) {
2290
- throw new Error(`unknown command ${cmd2}`);
2291
- }
2292
- }
2293
- return [x1, y1, x22, y22];
2294
- }
2295
- _toGeoJSON(transform) {
2296
- let coords = this.loadGeometry();
2297
- let type = VectorTileFeature.types[this.type];
2298
- let i3;
2299
- let j;
2300
- switch (this.type) {
2301
- case 1:
2302
- const points = [];
2303
- for (i3 = 0; i3 < coords.length; i3++) {
2304
- points[i3] = coords[i3][0];
2305
- }
2306
- coords = points;
2307
- transform(coords, this);
2308
- break;
2309
- case 2:
2310
- for (i3 = 0; i3 < coords.length; i3++) {
2311
- transform(coords[i3], this);
2312
- }
2313
- break;
2314
- case 3:
2315
- coords = classifyRings(coords);
2316
- for (i3 = 0; i3 < coords.length; i3++) {
2317
- for (j = 0; j < coords[i3].length; j++) {
2318
- transform(coords[i3][j], this);
2319
- }
2320
- }
2321
- break;
2322
- }
2323
- if (coords.length === 1) {
2324
- coords = coords[0];
2325
- } else {
2326
- type = `Multi${type}`;
2327
- }
2328
- const result = {
2329
- type: "Feature",
2330
- geometry: {
2331
- type,
2332
- coordinates: coords
2333
- },
2334
- properties: this.properties
2335
- };
2336
- if (this.id !== null) {
2337
- result.id = this.id;
2338
- }
2339
- return result;
2340
- }
2341
- toGeoJSON(options) {
2342
- if (typeof options === "function") {
2343
- return this._toGeoJSON(options);
2344
- }
2345
- const { x: x3, y: y2, z } = options;
2346
- const size = this.extent * Math.pow(2, z);
2347
- const x0 = this.extent * x3;
2348
- const y0 = this.extent * y2;
2349
- function project2(line) {
2350
- for (let j = 0; j < line.length; j++) {
2351
- const p = line[j];
2352
- p[0] = (p[0] + x0) * 360 / size - 180;
2353
- const y22 = 180 - (p[1] + y0) * 360 / size;
2354
- p[1] = 360 / Math.PI * Math.atan(Math.exp(y22 * Math.PI / 180)) - 90;
2355
- }
2356
- }
2357
- return this._toGeoJSON(project2);
2358
- }
2359
- };
2360
-
2361
- // ../mvt/src/lib/mapbox-vector-tile/vector-tile-layer.ts
2362
- var VectorTileLayer = class {
2363
- version;
2364
- name;
2365
- extent;
2366
- length;
2367
- _pbf;
2368
- _keys;
2369
- _values;
2370
- _features;
2371
- constructor(pbf, end) {
2372
- this.version = 1;
2373
- this.name = "";
2374
- this.extent = 4096;
2375
- this.length = 0;
2376
- this._pbf = pbf;
2377
- this._keys = [];
2378
- this._values = [];
2379
- this._features = [];
2380
- pbf.readFields(readLayer, this, end);
2381
- this.length = this._features.length;
2382
- }
2383
- /**
2384
- * return feature `i` from this layer as a `VectorTileFeature`
2385
- * @param index
2386
- * @returns feature
2387
- */
2388
- feature(i3) {
2389
- if (i3 < 0 || i3 >= this._features.length) {
2390
- throw new Error("feature index out of bounds");
2391
- }
2392
- this._pbf.pos = this._features[i3];
2393
- const end = this._pbf.readVarint() + this._pbf.pos;
2394
- return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
2395
- }
2396
- };
2397
- function readLayer(tag, layer, pbf) {
2398
- if (layer && pbf) {
2399
- if (tag === 15)
2400
- layer.version = pbf.readVarint();
2401
- else if (tag === 1)
2402
- layer.name = pbf.readString();
2403
- else if (tag === 5)
2404
- layer.extent = pbf.readVarint();
2405
- else if (tag === 2)
2406
- layer._features.push(pbf.pos);
2407
- else if (tag === 3)
2408
- layer._keys.push(pbf.readString());
2409
- else if (tag === 4)
2410
- layer._values.push(readValueMessage(pbf));
2411
- }
2412
- }
2413
- function readValueMessage(pbf) {
2414
- let value = null;
2415
- const end = pbf.readVarint() + pbf.pos;
2416
- while (pbf.pos < end) {
2417
- const tag = pbf.readVarint() >> 3;
2418
- value = tag === 1 ? pbf.readString() : tag === 2 ? pbf.readFloat() : tag === 3 ? pbf.readDouble() : tag === 4 ? pbf.readVarint64() : tag === 5 ? pbf.readVarint() : tag === 6 ? pbf.readSVarint() : tag === 7 ? pbf.readBoolean() : null;
2419
- }
2420
- return value;
2421
- }
2422
-
2423
- // ../mvt/src/lib/mapbox-vector-tile/vector-tile.ts
2424
- var VectorTile = class {
2425
- layers;
2426
- constructor(pbf, end) {
2427
- this.layers = pbf.readFields(readTile, {}, end);
2428
- }
2429
- };
2430
- function readTile(tag, layers, pbf) {
2431
- if (tag === 3) {
2432
- if (pbf) {
2433
- const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
2434
- if (layer.length && layers) {
2435
- layers[layer.name] = layer;
2436
- }
2437
- }
2438
- }
2439
- }
2440
-
2441
- // ../mvt/src/helpers/binary-util-functions.ts
2442
- function classifyRings2(geom) {
2764
+ function classifyRingsFlat(geom) {
2443
2765
  const len = geom.indices.length;
2444
2766
  const type = "Polygon";
2445
2767
  if (len <= 1) {
@@ -2456,9 +2778,9 @@ var __exports__ = (() => {
2456
2778
  let polygon = [];
2457
2779
  let ccw;
2458
2780
  let offset = 0;
2459
- for (let endIndex, i3 = 0, startIndex; i3 < len; i3++) {
2460
- startIndex = geom.indices[i3] - offset;
2461
- endIndex = geom.indices[i3 + 1] - offset || geom.data.length;
2781
+ for (let endIndex, i2 = 0, startIndex; i2 < len; i2++) {
2782
+ startIndex = geom.indices[i2] - offset;
2783
+ endIndex = geom.indices[i2 + 1] - offset || geom.data.length;
2462
2784
  const shape = geom.data.slice(startIndex, endIndex);
2463
2785
  const area2 = getPolygonSignedArea(shape);
2464
2786
  if (area2 === 0) {
@@ -2488,43 +2810,9 @@ var __exports__ = (() => {
2488
2810
  polygons.push(polygon);
2489
2811
  return { type, areas, indices: polygons, data: geom.data };
2490
2812
  }
2491
- function project(data, x0, y0, size) {
2492
- for (let j = 0, jl = data.length; j < jl; j += 2) {
2493
- data[j] = (data[j] + x0) * 360 / size - 180;
2494
- const y2 = 180 - (data[j + 1] + y0) * 360 / size;
2495
- data[j + 1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
2496
- }
2497
- }
2498
- function readFeature2(tag, feature, pbf) {
2499
- if (feature && pbf) {
2500
- if (tag === 1)
2501
- feature.id = pbf.readVarint();
2502
- else if (tag === 2)
2503
- readTag2(pbf, feature);
2504
- else if (tag === 3)
2505
- feature.type = pbf.readVarint();
2506
- else if (tag === 4)
2507
- feature._geometry = pbf.pos;
2508
- }
2509
- }
2510
- function readTag2(pbf, feature) {
2511
- const end = pbf.readVarint() + pbf.pos;
2512
- while (pbf.pos < end) {
2513
- const key = feature._keys[pbf.readVarint()];
2514
- const value = feature._values[pbf.readVarint()];
2515
- feature.properties[key] = value;
2516
- }
2517
- }
2518
2813
 
2519
- // ../mvt/src/lib/binary-vector-tile/vector-tile-feature.ts
2520
- var endPos;
2521
- var cmd;
2522
- var cmdLen;
2523
- var length;
2524
- var x;
2525
- var y;
2526
- var i;
2527
- var BinaryVectorTileFeature = class {
2814
+ // ../mvt/src/lib/vector-tile/vector-tile-feature.ts
2815
+ var VectorTileFeature = class {
2528
2816
  properties;
2529
2817
  extent;
2530
2818
  type;
@@ -2545,56 +2833,85 @@ var __exports__ = (() => {
2545
2833
  this._keys = keys;
2546
2834
  this._values = values;
2547
2835
  this._geometryInfo = geometryInfo;
2548
- pbf.readFields(readFeature2, this, end);
2836
+ pbf.readFields(readFeature, this, end);
2549
2837
  }
2550
- // eslint-disable-next-line complexity, max-statements
2551
- loadGeometry() {
2838
+ toGeoJSONFeature(coordinates, tileIndex) {
2839
+ const coords = this.loadGeometry();
2840
+ switch (coordinates) {
2841
+ case "wgs84":
2842
+ return _toGeoJSONFeature(
2843
+ this,
2844
+ coords,
2845
+ (line) => projectToLngLat(line, tileIndex, this.extent)
2846
+ );
2847
+ default:
2848
+ return _toGeoJSONFeature(this, coords, convertToLocalCoordinates);
2849
+ }
2850
+ }
2851
+ /**
2852
+ *
2853
+ * @param options
2854
+ * @returns
2855
+ */
2856
+ toBinaryFeature(coordinates, tileIndex) {
2857
+ const geom = this.loadFlatGeometry();
2858
+ switch (coordinates) {
2859
+ case "wgs84":
2860
+ return this._toBinaryCoordinates(
2861
+ geom,
2862
+ (coords) => projectToLngLatFlat(coords, tileIndex, this.extent)
2863
+ );
2864
+ default:
2865
+ return this._toBinaryCoordinates(geom, convertToLocalCoordinatesFlat);
2866
+ }
2867
+ }
2868
+ /** Read a bounding box from the feature */
2869
+ // eslint-disable-next-line max-statements
2870
+ bbox() {
2552
2871
  const pbf = this._pbf;
2553
2872
  pbf.pos = this._geometry;
2554
- endPos = pbf.readVarint() + pbf.pos;
2555
- cmd = 1;
2556
- length = 0;
2557
- x = 0;
2558
- y = 0;
2559
- i = 0;
2560
- const indices = [];
2561
- const data = [];
2562
- while (pbf.pos < endPos) {
2873
+ const end = pbf.readVarint() + pbf.pos;
2874
+ let cmd = 1;
2875
+ let length = 0;
2876
+ let x2 = 0;
2877
+ let y = 0;
2878
+ let x1 = Infinity;
2879
+ let x22 = -Infinity;
2880
+ let y1 = Infinity;
2881
+ let y2 = -Infinity;
2882
+ while (pbf.pos < end) {
2563
2883
  if (length <= 0) {
2564
- cmdLen = pbf.readVarint();
2884
+ const cmdLen = pbf.readVarint();
2565
2885
  cmd = cmdLen & 7;
2566
2886
  length = cmdLen >> 3;
2567
2887
  }
2568
2888
  length--;
2569
2889
  if (cmd === 1 || cmd === 2) {
2570
- x += pbf.readSVarint();
2890
+ x2 += pbf.readSVarint();
2571
2891
  y += pbf.readSVarint();
2572
- if (cmd === 1) {
2573
- indices.push(i);
2574
- }
2575
- data.push(x, y);
2576
- i += 2;
2577
- } else if (cmd === 7) {
2578
- if (i > 0) {
2579
- const start = indices[indices.length - 1];
2580
- data.push(data[start], data[start + 1]);
2581
- i += 2;
2582
- }
2583
- } else {
2892
+ if (x2 < x1)
2893
+ x1 = x2;
2894
+ if (x2 > x22)
2895
+ x22 = x2;
2896
+ if (y < y1)
2897
+ y1 = y;
2898
+ if (y > y2)
2899
+ y2 = y;
2900
+ } else if (cmd !== 7) {
2584
2901
  throw new Error(`unknown command ${cmd}`);
2585
2902
  }
2586
2903
  }
2587
- return { data, indices };
2904
+ return [x1, y1, x22, y2];
2588
2905
  }
2906
+ // BINARY HELPERS
2589
2907
  /**
2590
2908
  *
2591
2909
  * @param transform
2592
2910
  * @returns result
2593
2911
  */
2594
- _toBinaryCoordinates(transform) {
2595
- const geom = this.loadGeometry();
2912
+ _toBinaryCoordinates(geom, transform) {
2596
2913
  let geometry;
2597
- transform(geom.data, this);
2914
+ transform(geom.data, this.extent);
2598
2915
  const coordLength = 2;
2599
2916
  switch (this.type) {
2600
2917
  case 1:
@@ -2609,7 +2926,7 @@ var __exports__ = (() => {
2609
2926
  geometry = { type: "LineString", ...geom };
2610
2927
  break;
2611
2928
  case 3:
2612
- geometry = classifyRings2(geom);
2929
+ geometry = classifyRingsFlat(geom);
2613
2930
  this._geometryInfo.polygonFeaturesCount++;
2614
2931
  this._geometryInfo.polygonObjectsCount += geometry.indices.length;
2615
2932
  for (const indices of geometry.indices) {
@@ -2626,20 +2943,188 @@ var __exports__ = (() => {
2626
2943
  }
2627
2944
  return result;
2628
2945
  }
2629
- toBinaryCoordinates(options) {
2630
- if (typeof options === "function") {
2631
- return this._toBinaryCoordinates(options);
2946
+ // GEOJSON HELPER
2947
+ // eslint-disable-next-line complexity, max-statements
2948
+ loadGeometry() {
2949
+ const pbf = this._pbf;
2950
+ pbf.pos = this._geometry;
2951
+ const end = pbf.readVarint() + pbf.pos;
2952
+ let cmd = 1;
2953
+ let length = 0;
2954
+ let x2 = 0;
2955
+ let y = 0;
2956
+ const lines = [];
2957
+ let line;
2958
+ while (pbf.pos < end) {
2959
+ if (length <= 0) {
2960
+ const cmdLen = pbf.readVarint();
2961
+ cmd = cmdLen & 7;
2962
+ length = cmdLen >> 3;
2963
+ }
2964
+ length--;
2965
+ switch (cmd) {
2966
+ case 1:
2967
+ case 2:
2968
+ x2 += pbf.readSVarint();
2969
+ y += pbf.readSVarint();
2970
+ if (cmd === 1) {
2971
+ if (line)
2972
+ lines.push(line);
2973
+ line = [];
2974
+ }
2975
+ if (line)
2976
+ line.push([x2, y]);
2977
+ break;
2978
+ case 7:
2979
+ if (line) {
2980
+ line.push(line[0].slice());
2981
+ }
2982
+ break;
2983
+ default:
2984
+ throw new Error(`unknown command ${cmd}`);
2985
+ }
2986
+ }
2987
+ if (line)
2988
+ lines.push(line);
2989
+ return lines;
2990
+ }
2991
+ /**
2992
+ * Expands the protobuf data to an intermediate Flat GeoJSON
2993
+ * data format, which maps closely to the binary data buffers.
2994
+ * It is similar to GeoJSON, but rather than storing the coordinates
2995
+ * in multidimensional arrays, we have a 1D `data` with all the
2996
+ * coordinates, and then index into this using the `indices`
2997
+ * parameter, e.g.
2998
+ *
2999
+ * geometry: {
3000
+ * type: 'Point', data: [1,2], indices: [0]
3001
+ * }
3002
+ * geometry: {
3003
+ * type: 'LineString', data: [1,2,3,4,...], indices: [0]
3004
+ * }
3005
+ * geometry: {
3006
+ * type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]
3007
+ * }
3008
+ * Thus the indices member lets us look up the relevant range
3009
+ * from the data array.
3010
+ * The Multi* versions of the above types share the same data
3011
+ * structure, just with multiple elements in the indices array
3012
+ */
3013
+ // eslint-disable-next-line complexity, max-statements
3014
+ loadFlatGeometry() {
3015
+ const pbf = this._pbf;
3016
+ pbf.pos = this._geometry;
3017
+ const endPos = pbf.readVarint() + pbf.pos;
3018
+ let cmd = 1;
3019
+ let cmdLen;
3020
+ let length = 0;
3021
+ let x2 = 0;
3022
+ let y = 0;
3023
+ let i2 = 0;
3024
+ const indices = [];
3025
+ const data = [];
3026
+ while (pbf.pos < endPos) {
3027
+ if (length <= 0) {
3028
+ cmdLen = pbf.readVarint();
3029
+ cmd = cmdLen & 7;
3030
+ length = cmdLen >> 3;
3031
+ }
3032
+ length--;
3033
+ if (cmd === 1 || cmd === 2) {
3034
+ x2 += pbf.readSVarint();
3035
+ y += pbf.readSVarint();
3036
+ if (cmd === 1) {
3037
+ indices.push(i2);
3038
+ }
3039
+ data.push(x2, y);
3040
+ i2 += 2;
3041
+ } else if (cmd === 7) {
3042
+ if (i2 > 0) {
3043
+ const start = indices[indices.length - 1];
3044
+ data.push(data[start], data[start + 1]);
3045
+ i2 += 2;
3046
+ }
3047
+ } else {
3048
+ throw new Error(`unknown command ${cmd}`);
3049
+ }
2632
3050
  }
2633
- const { x: x3, y: y2, z } = options;
2634
- const size = this.extent * Math.pow(2, z);
2635
- const x0 = this.extent * x3;
2636
- const y0 = this.extent * y2;
2637
- return this._toBinaryCoordinates((data) => project(data, x0, y0, size));
3051
+ return { data, indices };
2638
3052
  }
2639
3053
  };
3054
+ __publicField(VectorTileFeature, "types", ["Unknown", "Point", "LineString", "Polygon"]);
3055
+ function _toGeoJSONFeature(vtFeature, coords, transform) {
3056
+ let type = VectorTileFeature.types[vtFeature.type];
3057
+ let i2;
3058
+ let j;
3059
+ let coordinates;
3060
+ switch (vtFeature.type) {
3061
+ case 1:
3062
+ const points = [];
3063
+ for (i2 = 0; i2 < coords.length; i2++) {
3064
+ points[i2] = coords[i2][0];
3065
+ }
3066
+ coordinates = points;
3067
+ transform(coordinates, vtFeature.extent);
3068
+ break;
3069
+ case 2:
3070
+ coordinates = coords;
3071
+ for (i2 = 0; i2 < coordinates.length; i2++) {
3072
+ transform(coordinates[i2], vtFeature.extent);
3073
+ }
3074
+ break;
3075
+ case 3:
3076
+ coordinates = classifyRings(coords);
3077
+ for (i2 = 0; i2 < coordinates.length; i2++) {
3078
+ for (j = 0; j < coordinates[i2].length; j++) {
3079
+ transform(coordinates[i2][j], vtFeature.extent);
3080
+ }
3081
+ }
3082
+ break;
3083
+ default:
3084
+ throw new Error("illegal vector tile type");
3085
+ }
3086
+ if (coordinates.length === 1) {
3087
+ coordinates = coordinates[0];
3088
+ } else {
3089
+ type = `Multi${type}`;
3090
+ }
3091
+ const result = {
3092
+ type: "Feature",
3093
+ geometry: {
3094
+ type,
3095
+ coordinates
3096
+ },
3097
+ properties: vtFeature.properties
3098
+ };
3099
+ if (vtFeature.id !== null) {
3100
+ result.properties ||= {};
3101
+ result.properties.id = vtFeature.id;
3102
+ }
3103
+ return result;
3104
+ }
3105
+ function readFeature(tag, feature, pbf) {
3106
+ if (feature && pbf) {
3107
+ if (tag === 1)
3108
+ feature.id = pbf.readVarint();
3109
+ else if (tag === 2)
3110
+ readTag(pbf, feature);
3111
+ else if (tag === 3)
3112
+ feature.type = pbf.readVarint();
3113
+ else if (tag === 4)
3114
+ feature._geometry = pbf.pos;
3115
+ }
3116
+ }
3117
+ function readTag(pbf, feature) {
3118
+ const end = pbf.readVarint() + pbf.pos;
3119
+ while (pbf.pos < end) {
3120
+ const key = feature._keys[pbf.readVarint()];
3121
+ const value = feature._values[pbf.readVarint()];
3122
+ feature.properties[key] = value;
3123
+ }
3124
+ }
2640
3125
 
2641
- // ../mvt/src/lib/binary-vector-tile/vector-tile-layer.ts
2642
- var BinaryVectorTileLayer = class {
3126
+ // ../mvt/src/lib/vector-tile/vector-tile-layer.ts
3127
+ var VectorTileLayer = class {
2643
3128
  version;
2644
3129
  name;
2645
3130
  extent;
@@ -2657,23 +3142,36 @@ var __exports__ = (() => {
2657
3142
  this._keys = [];
2658
3143
  this._values = [];
2659
3144
  this._features = [];
2660
- pbf.readFields(readLayer2, this, end);
3145
+ pbf.readFields(readLayer, this, end);
2661
3146
  this.length = this._features.length;
2662
3147
  }
2663
3148
  /**
2664
- * return feature `i` from this layer as a `BinaryVectorTileFeature`
3149
+ * return feature `i` from this layer as a `VectorTileFeature`
3150
+ * @param index
3151
+ * @returns feature
3152
+ */
3153
+ getGeoJSONFeature(i2) {
3154
+ if (i2 < 0 || i2 >= this._features.length) {
3155
+ throw new Error("feature index out of bounds");
3156
+ }
3157
+ this._pbf.pos = this._features[i2];
3158
+ const end = this._pbf.readVarint() + this._pbf.pos;
3159
+ return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
3160
+ }
3161
+ /**
3162
+ * return binary feature `i` from this layer as a `VectorTileFeature`
2665
3163
  *
2666
3164
  * @param index
2667
3165
  * @param geometryInfo
2668
- * @returns {BinaryVectorTileFeature}
3166
+ * @returns binary feature
2669
3167
  */
2670
- feature(i3, geometryInfo) {
2671
- if (i3 < 0 || i3 >= this._features.length) {
3168
+ getBinaryFeature(i2, geometryInfo) {
3169
+ if (i2 < 0 || i2 >= this._features.length) {
2672
3170
  throw new Error("feature index out of bounds");
2673
3171
  }
2674
- this._pbf.pos = this._features[i3];
3172
+ this._pbf.pos = this._features[i2];
2675
3173
  const end = this._pbf.readVarint() + this._pbf.pos;
2676
- return new BinaryVectorTileFeature(
3174
+ return new VectorTileFeature(
2677
3175
  this._pbf,
2678
3176
  end,
2679
3177
  this.extent,
@@ -2683,7 +3181,7 @@ var __exports__ = (() => {
2683
3181
  );
2684
3182
  }
2685
3183
  };
2686
- function readLayer2(tag, layer, pbf) {
3184
+ function readLayer(tag, layer, pbf) {
2687
3185
  if (layer && pbf) {
2688
3186
  if (tag === 15)
2689
3187
  layer.version = pbf.readVarint();
@@ -2696,10 +3194,10 @@ var __exports__ = (() => {
2696
3194
  else if (tag === 3)
2697
3195
  layer._keys.push(pbf.readString());
2698
3196
  else if (tag === 4)
2699
- layer._values.push(readValueMessage2(pbf));
3197
+ layer._values.push(readValueMessage(pbf));
2700
3198
  }
2701
3199
  }
2702
- function readValueMessage2(pbf) {
3200
+ function readValueMessage(pbf) {
2703
3201
  let value = null;
2704
3202
  const end = pbf.readVarint() + pbf.pos;
2705
3203
  while (pbf.pos < end) {
@@ -2709,17 +3207,17 @@ var __exports__ = (() => {
2709
3207
  return value;
2710
3208
  }
2711
3209
 
2712
- // ../mvt/src/lib/binary-vector-tile/vector-tile.ts
2713
- var BinaryVectorTile = class {
3210
+ // ../mvt/src/lib/vector-tile/vector-tile.ts
3211
+ var VectorTile = class {
2714
3212
  layers;
2715
3213
  constructor(pbf, end) {
2716
- this.layers = pbf.readFields(readTile2, {}, end);
3214
+ this.layers = pbf.readFields(readTile, {}, end);
2717
3215
  }
2718
3216
  };
2719
- function readTile2(tag, layers, pbf) {
3217
+ function readTile(tag, layers, pbf) {
2720
3218
  if (tag === 3) {
2721
3219
  if (pbf) {
2722
- const layer = new BinaryVectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
3220
+ const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
2723
3221
  if (layer.length && layers) {
2724
3222
  layers[layer.name] = layer;
2725
3223
  }
@@ -2729,7 +3227,7 @@ var __exports__ = (() => {
2729
3227
 
2730
3228
  // ../mvt/src/lib/parse-mvt.ts
2731
3229
  function parseMVT(arrayBuffer, options) {
2732
- const mvtOptions = normalizeOptions(options);
3230
+ const mvtOptions = checkOptions(options);
2733
3231
  const shape = options?.gis?.format || options?.mvt?.shape || options?.shape;
2734
3232
  switch (shape) {
2735
3233
  case "columnar-table":
@@ -2775,15 +3273,15 @@ var __exports__ = (() => {
2775
3273
  if (arrayBuffer.byteLength <= 0) {
2776
3274
  return [features, geometryInfo];
2777
3275
  }
2778
- const tile = new BinaryVectorTile(new import_pbf.default(arrayBuffer));
3276
+ const tile = new VectorTile(new import_pbf.default(arrayBuffer));
2779
3277
  const selectedLayers = options && Array.isArray(options.layers) ? options.layers : Object.keys(tile.layers);
2780
3278
  selectedLayers.forEach((layerName) => {
2781
3279
  const vectorTileLayer = tile.layers[layerName];
2782
3280
  if (!vectorTileLayer) {
2783
3281
  return;
2784
3282
  }
2785
- for (let i3 = 0; i3 < vectorTileLayer.length; i3++) {
2786
- const vectorTileFeature = vectorTileLayer.feature(i3, geometryInfo);
3283
+ for (let i2 = 0; i2 < vectorTileLayer.length; i2++) {
3284
+ const vectorTileFeature = vectorTileLayer.getBinaryFeature(i2, geometryInfo);
2787
3285
  const decodedFeature = getDecodedFeatureBinary(vectorTileFeature, options, layerName);
2788
3286
  features.push(decodedFeature);
2789
3287
  }
@@ -2802,70 +3300,54 @@ var __exports__ = (() => {
2802
3300
  if (!vectorTileLayer) {
2803
3301
  return;
2804
3302
  }
2805
- for (let i3 = 0; i3 < vectorTileLayer.length; i3++) {
2806
- const vectorTileFeature = vectorTileLayer.feature(i3);
3303
+ for (let i2 = 0; i2 < vectorTileLayer.length; i2++) {
3304
+ const vectorTileFeature = vectorTileLayer.getGeoJSONFeature(i2);
2807
3305
  const decodedFeature = getDecodedFeature(vectorTileFeature, options, layerName);
2808
3306
  features.push(decodedFeature);
2809
3307
  }
2810
3308
  });
2811
3309
  return features;
2812
3310
  }
2813
- function normalizeOptions(options) {
3311
+ function checkOptions(options) {
2814
3312
  if (!options?.mvt) {
2815
3313
  throw new Error("mvt options required");
2816
3314
  }
2817
- const wgs84Coordinates = options.mvt?.coordinates === "wgs84";
2818
- const { tileIndex } = options.mvt;
2819
- const hasTileIndex = tileIndex && Number.isFinite(tileIndex.x) && Number.isFinite(tileIndex.y) && Number.isFinite(tileIndex.z);
2820
- if (wgs84Coordinates && !hasTileIndex) {
3315
+ if (options.mvt?.coordinates === "wgs84" && !options.mvt.tileIndex) {
2821
3316
  throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");
2822
3317
  }
3318
+ if (options.gis) {
3319
+ log.warn('MVTLoader: "options.gis" is deprecated, use "options.mvt.shape" instead')();
3320
+ }
2823
3321
  return options.mvt;
2824
3322
  }
2825
3323
  function getDecodedFeature(feature, options, layerName) {
2826
- const decodedFeature = feature.toGeoJSON(
2827
- // @ts-expect-error What is going on here?
2828
- options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinates
3324
+ const decodedFeature = feature.toGeoJSONFeature(
3325
+ options.coordinates || "local",
3326
+ options.tileIndex
2829
3327
  );
2830
3328
  if (options.layerProperty) {
3329
+ decodedFeature.properties ||= {};
2831
3330
  decodedFeature.properties[options.layerProperty] = layerName;
2832
3331
  }
2833
3332
  return decodedFeature;
2834
3333
  }
2835
3334
  function getDecodedFeatureBinary(feature, options, layerName) {
2836
- const decodedFeature = feature.toBinaryCoordinates(
2837
- // @ts-expect-error
2838
- options.coordinates === "wgs84" ? options.tileIndex : transformToLocalCoordinatesBinary
2839
- );
3335
+ const decodedFeature = feature.toBinaryFeature(options.coordinates || "local", options.tileIndex);
2840
3336
  if (options.layerProperty && decodedFeature.properties) {
2841
3337
  decodedFeature.properties[options.layerProperty] = layerName;
2842
3338
  }
2843
3339
  return decodedFeature;
2844
3340
  }
2845
- function transformToLocalCoordinates(line, feature) {
2846
- const { extent } = feature;
2847
- for (let i3 = 0; i3 < line.length; i3++) {
2848
- const p = line[i3];
2849
- p[0] /= extent;
2850
- p[1] /= extent;
2851
- }
2852
- }
2853
- function transformToLocalCoordinatesBinary(data, feature) {
2854
- const { extent } = feature;
2855
- for (let i3 = 0, il = data.length; i3 < il; ++i3) {
2856
- data[i3] /= extent;
2857
- }
2858
- }
2859
3341
 
2860
3342
  // ../mvt/src/mvt-loader.ts
2861
- var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3343
+ var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2862
3344
  var MVTWorkerLoader = {
2863
3345
  dataType: null,
2864
3346
  batchType: null,
2865
3347
  name: "Mapbox Vector Tile",
2866
3348
  id: "mvt",
2867
3349
  module: "mvt",
2868
- version: VERSION2,
3350
+ version: VERSION4,
2869
3351
  // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'
2870
3352
  extensions: ["mvt", "pbf"],
2871
3353
  mimeTypes: [
@@ -2882,7 +3364,7 @@ var __exports__ = (() => {
2882
3364
  coordinates: "local",
2883
3365
  layerProperty: "layerName",
2884
3366
  layers: void 0,
2885
- tileIndex: null
3367
+ tileIndex: void 0
2886
3368
  }
2887
3369
  }
2888
3370
  };
@@ -2894,7 +3376,7 @@ var __exports__ = (() => {
2894
3376
  };
2895
3377
 
2896
3378
  // ../mvt/src/lib/parse-tilejson.ts
2897
- var isObject = (x3) => x3 !== null && typeof x3 === "object";
3379
+ var isObject = (x2) => x2 !== null && typeof x2 === "object";
2898
3380
  function parseTileJSON(jsonMetadata, options) {
2899
3381
  if (!jsonMetadata || !isObject(jsonMetadata)) {
2900
3382
  return null;
@@ -3098,14 +3580,14 @@ var __exports__ = (() => {
3098
3580
  }
3099
3581
 
3100
3582
  // ../mvt/src/tilejson-loader.ts
3101
- var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3583
+ var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3102
3584
  var TileJSONLoader = {
3103
3585
  dataType: null,
3104
3586
  batchType: null,
3105
3587
  name: "TileJSON",
3106
3588
  id: "tilejson",
3107
3589
  module: "pmtiles",
3108
- version: VERSION3,
3590
+ version: VERSION5,
3109
3591
  worker: true,
3110
3592
  extensions: ["json"],
3111
3593
  mimeTypes: ["application/json"],
@@ -3165,7 +3647,7 @@ var __exports__ = (() => {
3165
3647
  reject(e);
3166
3648
  }
3167
3649
  };
3168
- var step = (x3) => x3.done ? resolve(x3.value) : Promise.resolve(x3.value).then(fulfilled, rejected);
3650
+ var step = (x2) => x2.done ? resolve(x2.value) : Promise.resolve(x2.value).then(fulfilled, rejected);
3169
3651
  step((generator = generator.apply(__this, __arguments)).next());
3170
3652
  });
3171
3653
  };
@@ -3246,13 +3728,13 @@ var __exports__ = (() => {
3246
3728
  var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
3247
3729
  var freb = function(eb, start) {
3248
3730
  var b = new u16(31);
3249
- for (var i3 = 0; i3 < 31; ++i3) {
3250
- b[i3] = start += 1 << eb[i3 - 1];
3731
+ for (var i2 = 0; i2 < 31; ++i2) {
3732
+ b[i2] = start += 1 << eb[i2 - 1];
3251
3733
  }
3252
3734
  var r = new i32(b[30]);
3253
- for (var i3 = 1; i3 < 30; ++i3) {
3254
- for (var j = b[i3]; j < b[i3 + 1]; ++j) {
3255
- r[j] = j - b[i3] << 5 | i3;
3735
+ for (var i2 = 1; i2 < 30; ++i2) {
3736
+ for (var j = b[i2]; j < b[i2 + 1]; ++j) {
3737
+ r[j] = j - b[i2] << 5 | i2;
3256
3738
  }
3257
3739
  }
3258
3740
  return { b, r };
@@ -3265,35 +3747,35 @@ var __exports__ = (() => {
3265
3747
  var fd = _b.b;
3266
3748
  var revfd = _b.r;
3267
3749
  var rev = new u16(32768);
3268
- for (i2 = 0; i2 < 32768; ++i2) {
3269
- x2 = (i2 & 43690) >> 1 | (i2 & 21845) << 1;
3270
- x2 = (x2 & 52428) >> 2 | (x2 & 13107) << 2;
3271
- x2 = (x2 & 61680) >> 4 | (x2 & 3855) << 4;
3272
- rev[i2] = ((x2 & 65280) >> 8 | (x2 & 255) << 8) >> 1;
3273
- }
3274
- var x2;
3275
- var i2;
3750
+ for (i = 0; i < 32768; ++i) {
3751
+ x = (i & 43690) >> 1 | (i & 21845) << 1;
3752
+ x = (x & 52428) >> 2 | (x & 13107) << 2;
3753
+ x = (x & 61680) >> 4 | (x & 3855) << 4;
3754
+ rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
3755
+ }
3756
+ var x;
3757
+ var i;
3276
3758
  var hMap = function(cd, mb, r) {
3277
3759
  var s = cd.length;
3278
- var i3 = 0;
3760
+ var i2 = 0;
3279
3761
  var l = new u16(mb);
3280
- for (; i3 < s; ++i3) {
3281
- if (cd[i3])
3282
- ++l[cd[i3] - 1];
3762
+ for (; i2 < s; ++i2) {
3763
+ if (cd[i2])
3764
+ ++l[cd[i2] - 1];
3283
3765
  }
3284
3766
  var le = new u16(mb);
3285
- for (i3 = 1; i3 < mb; ++i3) {
3286
- le[i3] = le[i3 - 1] + l[i3 - 1] << 1;
3767
+ for (i2 = 1; i2 < mb; ++i2) {
3768
+ le[i2] = le[i2 - 1] + l[i2 - 1] << 1;
3287
3769
  }
3288
3770
  var co;
3289
3771
  if (r) {
3290
3772
  co = new u16(1 << mb);
3291
3773
  var rvb = 15 - mb;
3292
- for (i3 = 0; i3 < s; ++i3) {
3293
- if (cd[i3]) {
3294
- var sv = i3 << 4 | cd[i3];
3295
- var r_1 = mb - cd[i3];
3296
- var v = le[cd[i3] - 1]++ << r_1;
3774
+ for (i2 = 0; i2 < s; ++i2) {
3775
+ if (cd[i2]) {
3776
+ var sv = i2 << 4 | cd[i2];
3777
+ var r_1 = mb - cd[i2];
3778
+ var v = le[cd[i2] - 1]++ << r_1;
3297
3779
  for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
3298
3780
  co[rev[v] >> rvb] = sv;
3299
3781
  }
@@ -3301,38 +3783,38 @@ var __exports__ = (() => {
3301
3783
  }
3302
3784
  } else {
3303
3785
  co = new u16(s);
3304
- for (i3 = 0; i3 < s; ++i3) {
3305
- if (cd[i3]) {
3306
- co[i3] = rev[le[cd[i3] - 1]++] >> 15 - cd[i3];
3786
+ for (i2 = 0; i2 < s; ++i2) {
3787
+ if (cd[i2]) {
3788
+ co[i2] = rev[le[cd[i2] - 1]++] >> 15 - cd[i2];
3307
3789
  }
3308
3790
  }
3309
3791
  }
3310
3792
  return co;
3311
3793
  };
3312
3794
  var flt = new u8(288);
3313
- for (i2 = 0; i2 < 144; ++i2)
3314
- flt[i2] = 8;
3315
- var i2;
3316
- for (i2 = 144; i2 < 256; ++i2)
3317
- flt[i2] = 9;
3318
- var i2;
3319
- for (i2 = 256; i2 < 280; ++i2)
3320
- flt[i2] = 7;
3321
- var i2;
3322
- for (i2 = 280; i2 < 288; ++i2)
3323
- flt[i2] = 8;
3324
- var i2;
3795
+ for (i = 0; i < 144; ++i)
3796
+ flt[i] = 8;
3797
+ var i;
3798
+ for (i = 144; i < 256; ++i)
3799
+ flt[i] = 9;
3800
+ var i;
3801
+ for (i = 256; i < 280; ++i)
3802
+ flt[i] = 7;
3803
+ var i;
3804
+ for (i = 280; i < 288; ++i)
3805
+ flt[i] = 8;
3806
+ var i;
3325
3807
  var fdt = new u8(32);
3326
- for (i2 = 0; i2 < 32; ++i2)
3327
- fdt[i2] = 5;
3328
- var i2;
3808
+ for (i = 0; i < 32; ++i)
3809
+ fdt[i] = 5;
3810
+ var i;
3329
3811
  var flrm = /* @__PURE__ */ hMap(flt, 9, 1);
3330
3812
  var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
3331
3813
  var max = function(a) {
3332
3814
  var m = a[0];
3333
- for (var i3 = 1; i3 < a.length; ++i3) {
3334
- if (a[i3] > m)
3335
- m = a[i3];
3815
+ for (var i2 = 1; i2 < a.length; ++i2) {
3816
+ if (a[i2] > m)
3817
+ m = a[i2];
3336
3818
  }
3337
3819
  return m;
3338
3820
  };
@@ -3425,28 +3907,28 @@ var __exports__ = (() => {
3425
3907
  pos += 14;
3426
3908
  var ldt = new u8(tl);
3427
3909
  var clt = new u8(19);
3428
- for (var i3 = 0; i3 < hcLen; ++i3) {
3429
- clt[clim[i3]] = bits(dat, pos + i3 * 3, 7);
3910
+ for (var i2 = 0; i2 < hcLen; ++i2) {
3911
+ clt[clim[i2]] = bits(dat, pos + i2 * 3, 7);
3430
3912
  }
3431
3913
  pos += hcLen * 3;
3432
3914
  var clb = max(clt), clbmsk = (1 << clb) - 1;
3433
3915
  var clm = hMap(clt, clb, 1);
3434
- for (var i3 = 0; i3 < tl; ) {
3916
+ for (var i2 = 0; i2 < tl; ) {
3435
3917
  var r = clm[bits(dat, pos, clbmsk)];
3436
3918
  pos += r & 15;
3437
3919
  var s = r >> 4;
3438
3920
  if (s < 16) {
3439
- ldt[i3++] = s;
3921
+ ldt[i2++] = s;
3440
3922
  } else {
3441
3923
  var c = 0, n = 0;
3442
3924
  if (s == 16)
3443
- n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i3 - 1];
3925
+ n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i2 - 1];
3444
3926
  else if (s == 17)
3445
3927
  n = 3 + bits(dat, pos, 7), pos += 3;
3446
3928
  else if (s == 18)
3447
3929
  n = 11 + bits(dat, pos, 127), pos += 7;
3448
3930
  while (n--)
3449
- ldt[i3++] = c;
3931
+ ldt[i2++] = c;
3450
3932
  }
3451
3933
  }
3452
3934
  var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
@@ -3484,8 +3966,8 @@ var __exports__ = (() => {
3484
3966
  } else {
3485
3967
  var add = sym - 254;
3486
3968
  if (sym > 264) {
3487
- var i3 = sym - 257, b = fleb[i3];
3488
- add = bits(dat, pos, (1 << b) - 1) + fl[i3];
3969
+ var i2 = sym - 257, b = fleb[i2];
3970
+ add = bits(dat, pos, (1 << b) - 1) + fl[i2];
3489
3971
  pos += b;
3490
3972
  }
3491
3973
  var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
@@ -3584,24 +4066,24 @@ var __exports__ = (() => {
3584
4066
  var getUint48 = (view, pos) => {
3585
4067
  return shift(view.getUint32(pos + 2, true), 16) + view.getUint16(pos, true);
3586
4068
  };
3587
- var compare = (tz, tx, ty, view, i3) => {
3588
- if (tz !== view.getUint8(i3))
3589
- return tz - view.getUint8(i3);
3590
- const x3 = getUint24(view, i3 + 1);
3591
- if (tx !== x3)
3592
- return tx - x3;
3593
- const y2 = getUint24(view, i3 + 4);
3594
- if (ty !== y2)
3595
- return ty - y2;
4069
+ var compare = (tz, tx, ty, view, i2) => {
4070
+ if (tz !== view.getUint8(i2))
4071
+ return tz - view.getUint8(i2);
4072
+ const x2 = getUint24(view, i2 + 1);
4073
+ if (tx !== x2)
4074
+ return tx - x2;
4075
+ const y = getUint24(view, i2 + 4);
4076
+ if (ty !== y)
4077
+ return ty - y;
3596
4078
  return 0;
3597
4079
  };
3598
- var queryLeafdir = (view, z, x3, y2) => {
3599
- const offsetLen = queryView(view, z | 128, x3, y2);
4080
+ var queryLeafdir = (view, z, x2, y) => {
4081
+ const offsetLen = queryView(view, z | 128, x2, y);
3600
4082
  if (offsetLen) {
3601
4083
  return {
3602
4084
  z,
3603
- x: x3,
3604
- y: y2,
4085
+ x: x2,
4086
+ y,
3605
4087
  offset: offsetLen[0],
3606
4088
  length: offsetLen[1],
3607
4089
  isDir: true
@@ -3609,13 +4091,13 @@ var __exports__ = (() => {
3609
4091
  }
3610
4092
  return null;
3611
4093
  };
3612
- var queryTile = (view, z, x3, y2) => {
3613
- const offsetLen = queryView(view, z, x3, y2);
4094
+ var queryTile = (view, z, x2, y) => {
4095
+ const offsetLen = queryView(view, z, x2, y);
3614
4096
  if (offsetLen) {
3615
4097
  return {
3616
4098
  z,
3617
- x: x3,
3618
- y: y2,
4099
+ x: x2,
4100
+ y,
3619
4101
  offset: offsetLen[0],
3620
4102
  length: offsetLen[1],
3621
4103
  isDir: false
@@ -3623,12 +4105,12 @@ var __exports__ = (() => {
3623
4105
  }
3624
4106
  return null;
3625
4107
  };
3626
- var queryView = (view, z, x3, y2) => {
4108
+ var queryView = (view, z, x2, y) => {
3627
4109
  let m = 0;
3628
4110
  let n = view.byteLength / 17 - 1;
3629
4111
  while (m <= n) {
3630
4112
  const k = n + m >> 1;
3631
- const cmp = compare(z, x3, y2, view, k * 17);
4113
+ const cmp = compare(z, x2, y, view, k * 17);
3632
4114
  if (cmp > 0) {
3633
4115
  m = k + 1;
3634
4116
  } else if (cmp < 0) {
@@ -3654,23 +4136,23 @@ var __exports__ = (() => {
3654
4136
  }
3655
4137
  return a.y - b.y;
3656
4138
  };
3657
- var parseEntry = (dataview, i3) => {
3658
- const zRaw = dataview.getUint8(i3 * 17);
4139
+ var parseEntry = (dataview, i2) => {
4140
+ const zRaw = dataview.getUint8(i2 * 17);
3659
4141
  const z = zRaw & 127;
3660
4142
  return {
3661
4143
  z,
3662
- x: getUint24(dataview, i3 * 17 + 1),
3663
- y: getUint24(dataview, i3 * 17 + 4),
3664
- offset: getUint48(dataview, i3 * 17 + 7),
3665
- length: dataview.getUint32(i3 * 17 + 13, true),
4144
+ x: getUint24(dataview, i2 * 17 + 1),
4145
+ y: getUint24(dataview, i2 * 17 + 4),
4146
+ offset: getUint48(dataview, i2 * 17 + 7),
4147
+ length: dataview.getUint32(i2 * 17 + 13, true),
3666
4148
  isDir: zRaw >> 7 === 1
3667
4149
  };
3668
4150
  };
3669
4151
  var sortDir = (a) => {
3670
4152
  const entries = [];
3671
4153
  const view = new DataView(a);
3672
- for (let i3 = 0; i3 < view.byteLength / 17; i3++) {
3673
- entries.push(parseEntry(view, i3));
4154
+ for (let i2 = 0; i2 < view.byteLength / 17; i2++) {
4155
+ entries.push(parseEntry(view, i2));
3674
4156
  }
3675
4157
  return createDirectory(entries);
3676
4158
  };
@@ -3678,28 +4160,28 @@ var __exports__ = (() => {
3678
4160
  entries.sort(entrySort);
3679
4161
  const buffer = new ArrayBuffer(17 * entries.length);
3680
4162
  const arr = new Uint8Array(buffer);
3681
- for (let i3 = 0; i3 < entries.length; i3++) {
3682
- const entry = entries[i3];
4163
+ for (let i2 = 0; i2 < entries.length; i2++) {
4164
+ const entry = entries[i2];
3683
4165
  let z = entry.z;
3684
4166
  if (entry.isDir)
3685
4167
  z = z | 128;
3686
- arr[i3 * 17] = z;
3687
- arr[i3 * 17 + 1] = entry.x & 255;
3688
- arr[i3 * 17 + 2] = entry.x >> 8 & 255;
3689
- arr[i3 * 17 + 3] = entry.x >> 16 & 255;
3690
- arr[i3 * 17 + 4] = entry.y & 255;
3691
- arr[i3 * 17 + 5] = entry.y >> 8 & 255;
3692
- arr[i3 * 17 + 6] = entry.y >> 16 & 255;
3693
- arr[i3 * 17 + 7] = entry.offset & 255;
3694
- arr[i3 * 17 + 8] = unshift(entry.offset, 8) & 255;
3695
- arr[i3 * 17 + 9] = unshift(entry.offset, 16) & 255;
3696
- arr[i3 * 17 + 10] = unshift(entry.offset, 24) & 255;
3697
- arr[i3 * 17 + 11] = unshift(entry.offset, 32) & 255;
3698
- arr[i3 * 17 + 12] = unshift(entry.offset, 48) & 255;
3699
- arr[i3 * 17 + 13] = entry.length & 255;
3700
- arr[i3 * 17 + 14] = entry.length >> 8 & 255;
3701
- arr[i3 * 17 + 15] = entry.length >> 16 & 255;
3702
- arr[i3 * 17 + 16] = entry.length >> 24 & 255;
4168
+ arr[i2 * 17] = z;
4169
+ arr[i2 * 17 + 1] = entry.x & 255;
4170
+ arr[i2 * 17 + 2] = entry.x >> 8 & 255;
4171
+ arr[i2 * 17 + 3] = entry.x >> 16 & 255;
4172
+ arr[i2 * 17 + 4] = entry.y & 255;
4173
+ arr[i2 * 17 + 5] = entry.y >> 8 & 255;
4174
+ arr[i2 * 17 + 6] = entry.y >> 16 & 255;
4175
+ arr[i2 * 17 + 7] = entry.offset & 255;
4176
+ arr[i2 * 17 + 8] = unshift(entry.offset, 8) & 255;
4177
+ arr[i2 * 17 + 9] = unshift(entry.offset, 16) & 255;
4178
+ arr[i2 * 17 + 10] = unshift(entry.offset, 24) & 255;
4179
+ arr[i2 * 17 + 11] = unshift(entry.offset, 32) & 255;
4180
+ arr[i2 * 17 + 12] = unshift(entry.offset, 48) & 255;
4181
+ arr[i2 * 17 + 13] = entry.length & 255;
4182
+ arr[i2 * 17 + 14] = entry.length >> 8 & 255;
4183
+ arr[i2 * 17 + 15] = entry.length >> 16 & 255;
4184
+ arr[i2 * 17 + 16] = entry.length >> 24 & 255;
3703
4185
  }
3704
4186
  return buffer;
3705
4187
  };
@@ -3790,9 +4272,9 @@ var __exports__ = (() => {
3790
4272
  return header;
3791
4273
  });
3792
4274
  }
3793
- function getZxy(header, source, cache, z, x3, y2, signal) {
4275
+ function getZxy(header, source, cache2, z, x2, y, signal) {
3794
4276
  return __async(this, null, function* () {
3795
- let rootDir = yield cache.getArrayBuffer(
4277
+ let rootDir = yield cache2.getArrayBuffer(
3796
4278
  source,
3797
4279
  header.rootDirectoryOffset,
3798
4280
  header.rootDirectoryLength,
@@ -3801,7 +4283,7 @@ var __exports__ = (() => {
3801
4283
  if (header.specVersion === 1) {
3802
4284
  rootDir = sortDir(rootDir);
3803
4285
  }
3804
- const entry = queryTile(new DataView(rootDir), z, x3, y2);
4286
+ const entry = queryTile(new DataView(rootDir), z, x2, y);
3805
4287
  if (entry) {
3806
4288
  const resp = yield source.getBytes(entry.offset, entry.length, signal);
3807
4289
  let tileData = resp.data;
@@ -3813,7 +4295,7 @@ var __exports__ = (() => {
3813
4295
  data: tileData
3814
4296
  };
3815
4297
  }
3816
- const leafcoords = deriveLeaf(new DataView(rootDir), { z, x: x3, y: y2 });
4298
+ const leafcoords = deriveLeaf(new DataView(rootDir), { z, x: x2, y });
3817
4299
  if (leafcoords) {
3818
4300
  const leafdirEntry = queryLeafdir(
3819
4301
  new DataView(rootDir),
@@ -3822,7 +4304,7 @@ var __exports__ = (() => {
3822
4304
  leafcoords.y
3823
4305
  );
3824
4306
  if (leafdirEntry) {
3825
- let leafDir = yield cache.getArrayBuffer(
4307
+ let leafDir = yield cache2.getArrayBuffer(
3826
4308
  source,
3827
4309
  leafdirEntry.offset,
3828
4310
  leafdirEntry.length,
@@ -3831,7 +4313,7 @@ var __exports__ = (() => {
3831
4313
  if (header.specVersion === 1) {
3832
4314
  leafDir = sortDir(leafDir);
3833
4315
  }
3834
- const tileEntry = queryTile(new DataView(leafDir), z, x3, y2);
4316
+ const tileEntry = queryTile(new DataView(leafDir), z, x2, y);
3835
4317
  if (tileEntry) {
3836
4318
  const resp = yield source.getBytes(
3837
4319
  tileEntry.offset,
@@ -3974,10 +4456,10 @@ var __exports__ = (() => {
3974
4456
  this.tiles.set(pmtilesUrl, instance);
3975
4457
  }
3976
4458
  const z = result[2];
3977
- const x3 = result[3];
3978
- const y2 = result[4];
4459
+ const x2 = result[3];
4460
+ const y = result[4];
3979
4461
  const header = yield instance.getHeader();
3980
- const resp = yield instance == null ? void 0 : instance.getZxy(+z, +x3, +y2, abortController.signal);
4462
+ const resp = yield instance == null ? void 0 : instance.getZxy(+z, +x2, +y, abortController.signal);
3981
4463
  if (resp) {
3982
4464
  return {
3983
4465
  data: new Uint8Array(resp.data),
@@ -4111,11 +4593,11 @@ var __exports__ = (() => {
4111
4593
  375299968947541,
4112
4594
  1501199875790165
4113
4595
  ];
4114
- function zxyToTileId(z, x3, y2) {
4596
+ function zxyToTileId(z, x2, y) {
4115
4597
  if (z > 26) {
4116
4598
  throw Error("Tile zoom level exceeds max safe number limit (26)");
4117
4599
  }
4118
- if (x3 > __pow(2, z) - 1 || y2 > __pow(2, z) - 1) {
4600
+ if (x2 > __pow(2, z) - 1 || y > __pow(2, z) - 1) {
4119
4601
  throw Error("tile x/y outside zoom level bounds");
4120
4602
  }
4121
4603
  const acc = tzValues[z];
@@ -4123,7 +4605,7 @@ var __exports__ = (() => {
4123
4605
  let rx = 0;
4124
4606
  let ry = 0;
4125
4607
  let d = 0;
4126
- const xy = [x3, y2];
4608
+ const xy = [x2, y];
4127
4609
  let s = n / 2;
4128
4610
  while (s > 0) {
4129
4611
  rx = (xy[0] & s) > 0 ? 1 : 0;
@@ -4134,13 +4616,13 @@ var __exports__ = (() => {
4134
4616
  }
4135
4617
  return acc + d;
4136
4618
  }
4137
- function tileIdToZxy(i3) {
4619
+ function tileIdToZxy(i2) {
4138
4620
  let acc = 0;
4139
4621
  const z = 0;
4140
4622
  for (let z2 = 0; z2 < 27; z2++) {
4141
4623
  const numTiles = (1 << z2) * (1 << z2);
4142
- if (acc + numTiles > i3) {
4143
- return idOnLevel(z2, i3 - acc);
4624
+ if (acc + numTiles > i2) {
4625
+ return idOnLevel(z2, i2 - acc);
4144
4626
  }
4145
4627
  acc += numTiles;
4146
4628
  }
@@ -4217,9 +4699,9 @@ var __exports__ = (() => {
4217
4699
  getKey() {
4218
4700
  return this.file.name;
4219
4701
  }
4220
- getBytes(offset, length2) {
4702
+ getBytes(offset, length) {
4221
4703
  return __async(this, null, function* () {
4222
- const blob = this.file.slice(offset, offset + length2);
4704
+ const blob = this.file.slice(offset, offset + length);
4223
4705
  const a = yield blob.arrayBuffer();
4224
4706
  return { data: a };
4225
4707
  });
@@ -4237,7 +4719,7 @@ var __exports__ = (() => {
4237
4719
  setHeaders(customHeaders) {
4238
4720
  this.customHeaders = customHeaders;
4239
4721
  }
4240
- getBytes(offset, length2, passedSignal, etag) {
4722
+ getBytes(offset, length, passedSignal, etag) {
4241
4723
  return __async(this, null, function* () {
4242
4724
  let controller;
4243
4725
  let signal;
@@ -4248,14 +4730,14 @@ var __exports__ = (() => {
4248
4730
  signal = controller.signal;
4249
4731
  }
4250
4732
  const requestHeaders = new Headers(this.customHeaders);
4251
- requestHeaders.set("range", `bytes=${offset}-${offset + length2 - 1}`);
4252
- let cache;
4733
+ requestHeaders.set("range", `bytes=${offset}-${offset + length - 1}`);
4734
+ let cache2;
4253
4735
  if (this.mustReload) {
4254
- cache = "reload";
4736
+ cache2 = "reload";
4255
4737
  }
4256
4738
  let resp = yield fetch(this.url, {
4257
4739
  signal,
4258
- cache,
4740
+ cache: cache2,
4259
4741
  headers: requestHeaders
4260
4742
  //biome-ignore lint: "cache" is incompatible between cloudflare workers and browser
4261
4743
  });
@@ -4284,7 +4766,7 @@ var __exports__ = (() => {
4284
4766
  throw Error(`Bad response code: ${resp.status}`);
4285
4767
  }
4286
4768
  const contentLength = resp.headers.get("Content-Length");
4287
- if (resp.status === 200 && (!contentLength || +contentLength > length2)) {
4769
+ if (resp.status === 200 && (!contentLength || +contentLength > length)) {
4288
4770
  if (controller)
4289
4771
  controller.abort();
4290
4772
  throw Error(
@@ -4348,23 +4830,23 @@ var __exports__ = (() => {
4348
4830
  const numEntries = readVarint(p);
4349
4831
  const entries = [];
4350
4832
  let lastId = 0;
4351
- for (let i3 = 0; i3 < numEntries; i3++) {
4833
+ for (let i2 = 0; i2 < numEntries; i2++) {
4352
4834
  const v = readVarint(p);
4353
4835
  entries.push({ tileId: lastId + v, offset: 0, length: 0, runLength: 1 });
4354
4836
  lastId += v;
4355
4837
  }
4356
- for (let i3 = 0; i3 < numEntries; i3++) {
4357
- entries[i3].runLength = readVarint(p);
4838
+ for (let i2 = 0; i2 < numEntries; i2++) {
4839
+ entries[i2].runLength = readVarint(p);
4358
4840
  }
4359
- for (let i3 = 0; i3 < numEntries; i3++) {
4360
- entries[i3].length = readVarint(p);
4841
+ for (let i2 = 0; i2 < numEntries; i2++) {
4842
+ entries[i2].length = readVarint(p);
4361
4843
  }
4362
- for (let i3 = 0; i3 < numEntries; i3++) {
4844
+ for (let i2 = 0; i2 < numEntries; i2++) {
4363
4845
  const v = readVarint(p);
4364
- if (v === 0 && i3 > 0) {
4365
- entries[i3].offset = entries[i3 - 1].offset + entries[i3 - 1].length;
4846
+ if (v === 0 && i2 > 0) {
4847
+ entries[i2].offset = entries[i2 - 1].offset + entries[i2 - 1].length;
4366
4848
  } else {
4367
- entries[i3].offset = v - 1;
4849
+ entries[i2].offset = v - 1;
4368
4850
  }
4369
4851
  }
4370
4852
  return entries;
@@ -4410,9 +4892,9 @@ var __exports__ = (() => {
4410
4892
  return [header, [dirKey, rootDir.length, rootDir]];
4411
4893
  });
4412
4894
  }
4413
- function getDirectory(source, decompress, offset, length2, header) {
4895
+ function getDirectory(source, decompress, offset, length, header) {
4414
4896
  return __async(this, null, function* () {
4415
- const resp = yield source.getBytes(offset, length2, void 0, header.etag);
4897
+ const resp = yield source.getBytes(offset, length, void 0, header.etag);
4416
4898
  const data = yield decompress(resp.data, header.internalCompression);
4417
4899
  const directory = deserializeIndex(data);
4418
4900
  if (directory.length === 0) {
@@ -4452,9 +4934,9 @@ var __exports__ = (() => {
4452
4934
  return res[0];
4453
4935
  });
4454
4936
  }
4455
- getDirectory(source, offset, length2, header) {
4937
+ getDirectory(source, offset, length, header) {
4456
4938
  return __async(this, null, function* () {
4457
- const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length2}`;
4939
+ const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`;
4458
4940
  const cacheValue = this.cache.get(cacheKey);
4459
4941
  if (cacheValue) {
4460
4942
  cacheValue.lastUsed = this.counter++;
@@ -4465,7 +4947,7 @@ var __exports__ = (() => {
4465
4947
  source,
4466
4948
  this.decompress,
4467
4949
  offset,
4468
- length2,
4950
+ length,
4469
4951
  header
4470
4952
  );
4471
4953
  this.cache.set(cacheKey, {
@@ -4477,16 +4959,16 @@ var __exports__ = (() => {
4477
4959
  });
4478
4960
  }
4479
4961
  // for v2 backwards compatibility
4480
- getArrayBuffer(source, offset, length2, header) {
4962
+ getArrayBuffer(source, offset, length, header) {
4481
4963
  return __async(this, null, function* () {
4482
- const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length2}`;
4964
+ const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`;
4483
4965
  const cacheValue = this.cache.get(cacheKey);
4484
4966
  if (cacheValue) {
4485
4967
  cacheValue.lastUsed = this.counter++;
4486
4968
  const data = yield cacheValue.data;
4487
4969
  return data;
4488
4970
  }
4489
- const resp = yield source.getBytes(offset, length2, void 0, header.etag);
4971
+ const resp = yield source.getBytes(offset, length, void 0, header.etag);
4490
4972
  this.cache.set(cacheKey, {
4491
4973
  lastUsed: this.counter++,
4492
4974
  data: resp.data
@@ -4551,9 +5033,9 @@ var __exports__ = (() => {
4551
5033
  return p;
4552
5034
  });
4553
5035
  }
4554
- getDirectory(source, offset, length2, header) {
5036
+ getDirectory(source, offset, length, header) {
4555
5037
  return __async(this, null, function* () {
4556
- const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length2}`;
5038
+ const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`;
4557
5039
  const cacheValue = this.cache.get(cacheKey);
4558
5040
  if (cacheValue) {
4559
5041
  cacheValue.lastUsed = this.counter++;
@@ -4561,7 +5043,7 @@ var __exports__ = (() => {
4561
5043
  return data;
4562
5044
  }
4563
5045
  const p = new Promise((resolve, reject) => {
4564
- getDirectory(source, this.decompress, offset, length2, header).then((directory) => {
5046
+ getDirectory(source, this.decompress, offset, length, header).then((directory) => {
4565
5047
  resolve(directory);
4566
5048
  this.prune();
4567
5049
  }).catch((e) => {
@@ -4573,9 +5055,9 @@ var __exports__ = (() => {
4573
5055
  });
4574
5056
  }
4575
5057
  // for v2 backwards compatibility
4576
- getArrayBuffer(source, offset, length2, header) {
5058
+ getArrayBuffer(source, offset, length, header) {
4577
5059
  return __async(this, null, function* () {
4578
- const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length2}`;
5060
+ const cacheKey = `${source.getKey()}|${header.etag || ""}|${offset}|${length}`;
4579
5061
  const cacheValue = this.cache.get(cacheKey);
4580
5062
  if (cacheValue) {
4581
5063
  cacheValue.lastUsed = this.counter++;
@@ -4583,7 +5065,7 @@ var __exports__ = (() => {
4583
5065
  return data;
4584
5066
  }
4585
5067
  const p = new Promise((resolve, reject) => {
4586
- source.getBytes(offset, length2, void 0, header.etag).then((resp) => {
5068
+ source.getBytes(offset, length, void 0, header.etag).then((resp) => {
4587
5069
  resolve(resp.data);
4588
5070
  if (this.cache.has(cacheKey)) {
4589
5071
  }
@@ -4631,7 +5113,7 @@ var __exports__ = (() => {
4631
5113
  }
4632
5114
  };
4633
5115
  var PMTiles = class {
4634
- constructor(source, cache, decompress) {
5116
+ constructor(source, cache2, decompress) {
4635
5117
  if (typeof source === "string") {
4636
5118
  this.source = new FetchSource(source);
4637
5119
  } else {
@@ -4642,8 +5124,8 @@ var __exports__ = (() => {
4642
5124
  } else {
4643
5125
  this.decompress = defaultDecompress;
4644
5126
  }
4645
- if (cache) {
4646
- this.cache = cache;
5127
+ if (cache2) {
5128
+ this.cache = cache2;
4647
5129
  } else {
4648
5130
  this.cache = new SharedPromiseCache();
4649
5131
  }
@@ -4658,12 +5140,12 @@ var __exports__ = (() => {
4658
5140
  });
4659
5141
  }
4660
5142
  /** @hidden */
4661
- getZxyAttempt(z, x3, y2, signal) {
5143
+ getZxyAttempt(z, x2, y, signal) {
4662
5144
  return __async(this, null, function* () {
4663
- const tileId = zxyToTileId(z, x3, y2);
5145
+ const tileId = zxyToTileId(z, x2, y);
4664
5146
  const header = yield this.cache.getHeader(this.source);
4665
5147
  if (header.specVersion < 3) {
4666
- return v2_default.getZxy(header, this.source, this.cache, z, x3, y2, signal);
5148
+ return v2_default.getZxy(header, this.source, this.cache, z, x2, y, signal);
4667
5149
  }
4668
5150
  if (z < header.minZoom || z > header.maxZoom) {
4669
5151
  return void 0;
@@ -4706,14 +5188,14 @@ var __exports__ = (() => {
4706
5188
  *
4707
5189
  * Returns undefined if the tile does not exist in the archive.
4708
5190
  */
4709
- getZxy(z, x3, y2, signal) {
5191
+ getZxy(z, x2, y, signal) {
4710
5192
  return __async(this, null, function* () {
4711
5193
  try {
4712
- return yield this.getZxyAttempt(z, x3, y2, signal);
5194
+ return yield this.getZxyAttempt(z, x2, y, signal);
4713
5195
  } catch (e) {
4714
5196
  if (e instanceof EtagMismatch) {
4715
5197
  this.cache.invalidate(this.source);
4716
- return yield this.getZxyAttempt(z, x3, y2, signal);
5198
+ return yield this.getZxyAttempt(z, x2, y, signal);
4717
5199
  }
4718
5200
  throw e;
4719
5201
  }
@@ -4829,8 +5311,8 @@ var __exports__ = (() => {
4829
5311
  getKey() {
4830
5312
  return this.blob.url || "";
4831
5313
  }
4832
- async getBytes(offset, length2, signal) {
4833
- const slice = this.blob.slice(offset, offset + length2);
5314
+ async getBytes(offset, length, signal) {
5315
+ const slice = this.blob.slice(offset, offset + length);
4834
5316
  const data = await slice.arrayBuffer();
4835
5317
  return {
4836
5318
  data
@@ -4858,6 +5340,9 @@ var __exports__ = (() => {
4858
5340
  this.getTileData = this.getTileData.bind(this);
4859
5341
  this.metadata = this.getMetadata();
4860
5342
  }
5343
+ async getSchema() {
5344
+ return { fields: [], metadata: {} };
5345
+ }
4861
5346
  async getMetadata() {
4862
5347
  const pmtilesHeader = await this.pmtiles.getHeader();
4863
5348
  const pmtilesMetadata = await this.pmtiles.getMetadata();
@@ -4876,8 +5361,8 @@ var __exports__ = (() => {
4876
5361
  return metadata;
4877
5362
  }
4878
5363
  async getTile(tileParams) {
4879
- const { x: x3, y: y2, zoom: z } = tileParams;
4880
- const rangeResponse = await this.pmtiles.getZxy(z, x3, y2);
5364
+ const { x: x2, y, z } = tileParams;
5365
+ const rangeResponse = await this.pmtiles.getZxy(z, x2, y);
4881
5366
  const arrayBuffer = rangeResponse?.data;
4882
5367
  if (!arrayBuffer) {
4883
5368
  return null;
@@ -4887,13 +5372,13 @@ var __exports__ = (() => {
4887
5372
  // Tile Source interface implementation: deck.gl compatible API
4888
5373
  // TODO - currently only handles image tiles, not vector tiles
4889
5374
  async getTileData(tileParams) {
4890
- const { x: x3, y: y2, z } = tileParams.index;
5375
+ const { x: x2, y, z } = tileParams.index;
4891
5376
  const metadata = await this.metadata;
4892
5377
  switch (metadata.tileMIMEType) {
4893
5378
  case "application/vnd.mapbox-vector-tile":
4894
- return await this.getVectorTile({ x: x3, y: y2, zoom: z, layers: [] });
5379
+ return await this.getVectorTile({ x: x2, y, z, layers: [] });
4895
5380
  default:
4896
- return await this.getImageTile({ x: x3, y: y2, zoom: z, layers: [] });
5381
+ return await this.getImageTile({ x: x2, y, z, layers: [] });
4897
5382
  }
4898
5383
  }
4899
5384
  // ImageTileSource interface implementation
@@ -4908,7 +5393,7 @@ var __exports__ = (() => {
4908
5393
  shape: "geojson-table",
4909
5394
  mvt: {
4910
5395
  coordinates: "wgs84",
4911
- tileIndex: { x: tileParams.x, y: tileParams.y, z: tileParams.zoom },
5396
+ tileIndex: { x: tileParams.x, y: tileParams.y, z: tileParams.z },
4912
5397
  ...this.loadOptions?.mvt
4913
5398
  },
4914
5399
  ...this.loadOptions