protomaps-leaflet
Version:
Vector tile rendering and labeling for [Leaflet](https://github.com/Leaflet/Leaflet).
1,463 lines (1,452 loc) • 201 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a2, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a2, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a2, prop, b[prop]);
}
return a2;
};
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __reExport = (target, module, desc) => {
if (module && typeof module === "object" || typeof module === "function") {
for (let key of __getOwnPropNames(module))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
}
return target;
};
var __toModule = (module) => {
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
};
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step2(generator.next(value));
} catch (e2) {
reject(e2);
}
};
var rejected = (value) => {
try {
step2(generator.throw(value));
} catch (e2) {
reject(e2);
}
};
var step2 = (x2) => x2.done ? resolve(x2.value) : Promise.resolve(x2.value).then(fulfilled, rejected);
step2((generator = generator.apply(__this, __arguments)).next());
});
};
// node_modules/@mapbox/point-geometry/index.js
var require_point_geometry = __commonJS({
"node_modules/@mapbox/point-geometry/index.js"(exports, module) {
"use strict";
module.exports = Point9;
function Point9(x2, y) {
this.x = x2;
this.y = y;
}
Point9.prototype = {
clone: function() {
return new Point9(this.x, this.y);
},
add: function(p2) {
return this.clone()._add(p2);
},
sub: function(p2) {
return this.clone()._sub(p2);
},
multByPoint: function(p2) {
return this.clone()._multByPoint(p2);
},
divByPoint: function(p2) {
return this.clone()._divByPoint(p2);
},
mult: function(k) {
return this.clone()._mult(k);
},
div: function(k) {
return this.clone()._div(k);
},
rotate: function(a2) {
return this.clone()._rotate(a2);
},
rotateAround: function(a2, p2) {
return this.clone()._rotateAround(a2, p2);
},
matMult: function(m) {
return this.clone()._matMult(m);
},
unit: function() {
return this.clone()._unit();
},
perp: function() {
return this.clone()._perp();
},
round: function() {
return this.clone()._round();
},
mag: function() {
return Math.sqrt(this.x * this.x + this.y * this.y);
},
equals: function(other) {
return this.x === other.x && this.y === other.y;
},
dist: function(p2) {
return Math.sqrt(this.distSqr(p2));
},
distSqr: function(p2) {
var dx = p2.x - this.x, dy = p2.y - this.y;
return dx * dx + dy * dy;
},
angle: function() {
return Math.atan2(this.y, this.x);
},
angleTo: function(b) {
return Math.atan2(this.y - b.y, this.x - b.x);
},
angleWith: function(b) {
return this.angleWithSep(b.x, b.y);
},
angleWithSep: function(x2, y) {
return Math.atan2(this.x * y - this.y * x2, this.x * x2 + this.y * y);
},
_matMult: function(m) {
var x2 = m[0] * this.x + m[1] * this.y, y = m[2] * this.x + m[3] * this.y;
this.x = x2;
this.y = y;
return this;
},
_add: function(p2) {
this.x += p2.x;
this.y += p2.y;
return this;
},
_sub: function(p2) {
this.x -= p2.x;
this.y -= p2.y;
return this;
},
_mult: function(k) {
this.x *= k;
this.y *= k;
return this;
},
_div: function(k) {
this.x /= k;
this.y /= k;
return this;
},
_multByPoint: function(p2) {
this.x *= p2.x;
this.y *= p2.y;
return this;
},
_divByPoint: function(p2) {
this.x /= p2.x;
this.y /= p2.y;
return this;
},
_unit: function() {
this._div(this.mag());
return this;
},
_perp: function() {
var y = this.y;
this.y = this.x;
this.x = -y;
return this;
},
_rotate: function(angle) {
var cos = Math.cos(angle), sin = Math.sin(angle), x2 = cos * this.x - sin * this.y, y = sin * this.x + cos * this.y;
this.x = x2;
this.y = y;
return this;
},
_rotateAround: function(angle, p2) {
var cos = Math.cos(angle), sin = Math.sin(angle), x2 = p2.x + cos * (this.x - p2.x) - sin * (this.y - p2.y), y = p2.y + sin * (this.x - p2.x) + cos * (this.y - p2.y);
this.x = x2;
this.y = y;
return this;
},
_round: function() {
this.x = Math.round(this.x);
this.y = Math.round(this.y);
return this;
}
};
Point9.convert = function(a2) {
if (a2 instanceof Point9) {
return a2;
}
if (Array.isArray(a2)) {
return new Point9(a2[0], a2[1]);
}
return a2;
};
}
});
// node_modules/@mapbox/vector-tile/lib/vectortilefeature.js
var require_vectortilefeature = __commonJS({
"node_modules/@mapbox/vector-tile/lib/vectortilefeature.js"(exports, module) {
"use strict";
var Point9 = require_point_geometry();
module.exports = VectorTileFeature;
function VectorTileFeature(pbf, end, extent, keys, values) {
this.properties = {};
this.extent = extent;
this.type = 0;
this._pbf = pbf;
this._geometry = -1;
this._keys = keys;
this._values = values;
pbf.readFields(readFeature, this, end);
}
function readFeature(tag, feature, pbf) {
if (tag == 1)
feature.id = pbf.readVarint();
else if (tag == 2)
readTag(pbf, feature);
else if (tag == 3)
feature.type = pbf.readVarint();
else if (tag == 4)
feature._geometry = pbf.pos;
}
function readTag(pbf, feature) {
var end = pbf.readVarint() + pbf.pos;
while (pbf.pos < end) {
var key = feature._keys[pbf.readVarint()], value = feature._values[pbf.readVarint()];
feature.properties[key] = value;
}
}
VectorTileFeature.types = ["Unknown", "Point", "LineString", "Polygon"];
VectorTileFeature.prototype.loadGeometry = function() {
var pbf = this._pbf;
pbf.pos = this._geometry;
var end = pbf.readVarint() + pbf.pos, cmd = 1, length = 0, x2 = 0, y = 0, lines = [], line;
while (pbf.pos < end) {
if (length <= 0) {
var cmdLen = pbf.readVarint();
cmd = cmdLen & 7;
length = cmdLen >> 3;
}
length--;
if (cmd === 1 || cmd === 2) {
x2 += pbf.readSVarint();
y += pbf.readSVarint();
if (cmd === 1) {
if (line)
lines.push(line);
line = [];
}
line.push(new Point9(x2, y));
} else if (cmd === 7) {
if (line) {
line.push(line[0].clone());
}
} else {
throw new Error("unknown command " + cmd);
}
}
if (line)
lines.push(line);
return lines;
};
VectorTileFeature.prototype.bbox = function() {
var pbf = this._pbf;
pbf.pos = this._geometry;
var end = pbf.readVarint() + pbf.pos, cmd = 1, length = 0, x2 = 0, y = 0, x1 = Infinity, x22 = -Infinity, y1 = Infinity, y2 = -Infinity;
while (pbf.pos < end) {
if (length <= 0) {
var cmdLen = pbf.readVarint();
cmd = cmdLen & 7;
length = cmdLen >> 3;
}
length--;
if (cmd === 1 || cmd === 2) {
x2 += pbf.readSVarint();
y += pbf.readSVarint();
if (x2 < x1)
x1 = x2;
if (x2 > x22)
x22 = x2;
if (y < y1)
y1 = y;
if (y > y2)
y2 = y;
} else if (cmd !== 7) {
throw new Error("unknown command " + cmd);
}
}
return [x1, y1, x22, y2];
};
VectorTileFeature.prototype.toGeoJSON = function(x2, y, z2) {
var size = this.extent * Math.pow(2, z2), x0 = this.extent * x2, y0 = this.extent * y, coords = this.loadGeometry(), type = VectorTileFeature.types[this.type], i3, j;
function project3(line) {
for (var j2 = 0; j2 < line.length; j2++) {
var p2 = line[j2], y2 = 180 - (p2.y + y0) * 360 / size;
line[j2] = [
(p2.x + x0) * 360 / size - 180,
360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90
];
}
}
switch (this.type) {
case 1:
var points = [];
for (i3 = 0; i3 < coords.length; i3++) {
points[i3] = coords[i3][0];
}
coords = points;
project3(coords);
break;
case 2:
for (i3 = 0; i3 < coords.length; i3++) {
project3(coords[i3]);
}
break;
case 3:
coords = classifyRings(coords);
for (i3 = 0; i3 < coords.length; i3++) {
for (j = 0; j < coords[i3].length; j++) {
project3(coords[i3][j]);
}
}
break;
}
if (coords.length === 1) {
coords = coords[0];
} else {
type = "Multi" + type;
}
var result = {
type: "Feature",
geometry: {
type,
coordinates: coords
},
properties: this.properties
};
if ("id" in this) {
result.id = this.id;
}
return result;
};
function classifyRings(rings) {
var len = rings.length;
if (len <= 1)
return [rings];
var polygons = [], polygon, ccw;
for (var i3 = 0; i3 < len; i3++) {
var area = signedArea(rings[i3]);
if (area === 0)
continue;
if (ccw === void 0)
ccw = area < 0;
if (ccw === area < 0) {
if (polygon)
polygons.push(polygon);
polygon = [rings[i3]];
} else {
polygon.push(rings[i3]);
}
}
if (polygon)
polygons.push(polygon);
return polygons;
}
function signedArea(ring) {
var sum = 0;
for (var i3 = 0, len = ring.length, j = len - 1, p1, p2; i3 < len; j = i3++) {
p1 = ring[i3];
p2 = ring[j];
sum += (p2.x - p1.x) * (p1.y + p2.y);
}
return sum;
}
}
});
// node_modules/@mapbox/vector-tile/lib/vectortilelayer.js
var require_vectortilelayer = __commonJS({
"node_modules/@mapbox/vector-tile/lib/vectortilelayer.js"(exports, module) {
"use strict";
var VectorTileFeature = require_vectortilefeature();
module.exports = VectorTileLayer;
function VectorTileLayer(pbf, end) {
this.version = 1;
this.name = null;
this.extent = 4096;
this.length = 0;
this._pbf = pbf;
this._keys = [];
this._values = [];
this._features = [];
pbf.readFields(readLayer, this, end);
this.length = this._features.length;
}
function readLayer(tag, layer, pbf) {
if (tag === 15)
layer.version = pbf.readVarint();
else if (tag === 1)
layer.name = pbf.readString();
else if (tag === 5)
layer.extent = pbf.readVarint();
else if (tag === 2)
layer._features.push(pbf.pos);
else if (tag === 3)
layer._keys.push(pbf.readString());
else if (tag === 4)
layer._values.push(readValueMessage(pbf));
}
function readValueMessage(pbf) {
var value = null, end = pbf.readVarint() + pbf.pos;
while (pbf.pos < end) {
var tag = pbf.readVarint() >> 3;
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;
}
return value;
}
VectorTileLayer.prototype.feature = function(i3) {
if (i3 < 0 || i3 >= this._features.length)
throw new Error("feature index out of bounds");
this._pbf.pos = this._features[i3];
var end = this._pbf.readVarint() + this._pbf.pos;
return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
};
}
});
// node_modules/@mapbox/vector-tile/lib/vectortile.js
var require_vectortile = __commonJS({
"node_modules/@mapbox/vector-tile/lib/vectortile.js"(exports, module) {
"use strict";
var VectorTileLayer = require_vectortilelayer();
module.exports = VectorTile2;
function VectorTile2(pbf, end) {
this.layers = pbf.readFields(readTile, {}, end);
}
function readTile(tag, layers, pbf) {
if (tag === 3) {
var layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
if (layer.length)
layers[layer.name] = layer;
}
}
}
});
// node_modules/@mapbox/vector-tile/index.js
var require_vector_tile = __commonJS({
"node_modules/@mapbox/vector-tile/index.js"(exports, module) {
module.exports.VectorTile = require_vectortile();
module.exports.VectorTileFeature = require_vectortilefeature();
module.exports.VectorTileLayer = require_vectortilelayer();
}
});
// node_modules/ieee754/index.js
var require_ieee754 = __commonJS({
"node_modules/ieee754/index.js"(exports) {
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
var e2, m;
var eLen = nBytes * 8 - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var nBits = -7;
var i3 = isLE ? nBytes - 1 : 0;
var d = isLE ? -1 : 1;
var s2 = buffer[offset + i3];
i3 += d;
e2 = s2 & (1 << -nBits) - 1;
s2 >>= -nBits;
nBits += eLen;
for (; nBits > 0; e2 = e2 * 256 + buffer[offset + i3], i3 += d, nBits -= 8) {
}
m = e2 & (1 << -nBits) - 1;
e2 >>= -nBits;
nBits += mLen;
for (; nBits > 0; m = m * 256 + buffer[offset + i3], i3 += d, nBits -= 8) {
}
if (e2 === 0) {
e2 = 1 - eBias;
} else if (e2 === eMax) {
return m ? NaN : (s2 ? -1 : 1) * Infinity;
} else {
m = m + Math.pow(2, mLen);
e2 = e2 - eBias;
}
return (s2 ? -1 : 1) * m * Math.pow(2, e2 - mLen);
};
exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
var e2, m, c2;
var eLen = nBytes * 8 - mLen - 1;
var eMax = (1 << eLen) - 1;
var eBias = eMax >> 1;
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
var i3 = isLE ? 0 : nBytes - 1;
var d = isLE ? 1 : -1;
var s2 = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
value = Math.abs(value);
if (isNaN(value) || value === Infinity) {
m = isNaN(value) ? 1 : 0;
e2 = eMax;
} else {
e2 = Math.floor(Math.log(value) / Math.LN2);
if (value * (c2 = Math.pow(2, -e2)) < 1) {
e2--;
c2 *= 2;
}
if (e2 + eBias >= 1) {
value += rt / c2;
} else {
value += rt * Math.pow(2, 1 - eBias);
}
if (value * c2 >= 2) {
e2++;
c2 /= 2;
}
if (e2 + eBias >= eMax) {
m = 0;
e2 = eMax;
} else if (e2 + eBias >= 1) {
m = (value * c2 - 1) * Math.pow(2, mLen);
e2 = e2 + eBias;
} else {
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
e2 = 0;
}
}
for (; mLen >= 8; buffer[offset + i3] = m & 255, i3 += d, m /= 256, mLen -= 8) {
}
e2 = e2 << mLen | m;
eLen += mLen;
for (; eLen > 0; buffer[offset + i3] = e2 & 255, i3 += d, e2 /= 256, eLen -= 8) {
}
buffer[offset + i3 - d] |= s2 * 128;
};
}
});
// node_modules/pbf/index.js
var require_pbf = __commonJS({
"node_modules/pbf/index.js"(exports, module) {
"use strict";
module.exports = Pbf;
var ieee754 = require_ieee754();
function Pbf(buf) {
this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);
this.pos = 0;
this.type = 0;
this.length = this.buf.length;
}
Pbf.Varint = 0;
Pbf.Fixed64 = 1;
Pbf.Bytes = 2;
Pbf.Fixed32 = 5;
var SHIFT_LEFT_32 = (1 << 16) * (1 << 16);
var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
var TEXT_DECODER_MIN_LENGTH = 12;
var utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf8");
Pbf.prototype = {
destroy: function() {
this.buf = null;
},
readFields: function(readField, result, end) {
end = end || this.length;
while (this.pos < end) {
var val = this.readVarint(), tag = val >> 3, startPos = this.pos;
this.type = val & 7;
readField(tag, result, this);
if (this.pos === startPos)
this.skip(val);
}
return result;
},
readMessage: function(readField, result) {
return this.readFields(readField, result, this.readVarint() + this.pos);
},
readFixed32: function() {
var val = readUInt32(this.buf, this.pos);
this.pos += 4;
return val;
},
readSFixed32: function() {
var val = readInt32(this.buf, this.pos);
this.pos += 4;
return val;
},
readFixed64: function() {
var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
this.pos += 8;
return val;
},
readSFixed64: function() {
var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
this.pos += 8;
return val;
},
readFloat: function() {
var val = ieee754.read(this.buf, this.pos, true, 23, 4);
this.pos += 4;
return val;
},
readDouble: function() {
var val = ieee754.read(this.buf, this.pos, true, 52, 8);
this.pos += 8;
return val;
},
readVarint: function(isSigned) {
var buf = this.buf, val, b;
b = buf[this.pos++];
val = b & 127;
if (b < 128)
return val;
b = buf[this.pos++];
val |= (b & 127) << 7;
if (b < 128)
return val;
b = buf[this.pos++];
val |= (b & 127) << 14;
if (b < 128)
return val;
b = buf[this.pos++];
val |= (b & 127) << 21;
if (b < 128)
return val;
b = buf[this.pos];
val |= (b & 15) << 28;
return readVarintRemainder2(val, isSigned, this);
},
readVarint64: function() {
return this.readVarint(true);
},
readSVarint: function() {
var num = this.readVarint();
return num % 2 === 1 ? (num + 1) / -2 : num / 2;
},
readBoolean: function() {
return Boolean(this.readVarint());
},
readString: function() {
var end = this.readVarint() + this.pos;
var pos = this.pos;
this.pos = end;
if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {
return readUtf8TextDecoder(this.buf, pos, end);
}
return readUtf8(this.buf, pos, end);
},
readBytes: function() {
var end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end);
this.pos = end;
return buffer;
},
readPackedVarint: function(arr2, isSigned) {
if (this.type !== Pbf.Bytes)
return arr2.push(this.readVarint(isSigned));
var end = readPackedEnd(this);
arr2 = arr2 || [];
while (this.pos < end)
arr2.push(this.readVarint(isSigned));
return arr2;
},
readPackedSVarint: function(arr2) {
if (this.type !== Pbf.Bytes)
return arr2.push(this.readSVarint());
var end = readPackedEnd(this);
arr2 = arr2 || [];
while (this.pos < end)
arr2.push(this.readSVarint());
return arr2;
},
readPackedBoolean: function(arr2) {
if (this.type !== Pbf.Bytes)
return arr2.push(this.readBoolean());
var end = readPackedEnd(this);
arr2 = arr2 || [];
while (this.pos < end)
arr2.push(this.readBoolean());
return arr2;
},
readPackedFloat: function(arr2) {
if (this.type !== Pbf.Bytes)
return arr2.push(this.readFloat());
var end = readPackedEnd(this);
arr2 = arr2 || [];
while (this.pos < end)
arr2.push(this.readFloat());
return arr2;
},
readPackedDouble: function(arr2) {
if (this.type !== Pbf.Bytes)
return arr2.push(this.readDouble());
var end = readPackedEnd(this);
arr2 = arr2 || [];
while (this.pos < end)
arr2.push(this.readDouble());
return arr2;
},
readPackedFixed32: function(arr2) {
if (this.type !== Pbf.Bytes)
return arr2.push(this.readFixed32());
var end = readPackedEnd(this);
arr2 = arr2 || [];
while (this.pos < end)
arr2.push(this.readFixed32());
return arr2;
},
readPackedSFixed32: function(arr2) {
if (this.type !== Pbf.Bytes)
return arr2.push(this.readSFixed32());
var end = readPackedEnd(this);
arr2 = arr2 || [];
while (this.pos < end)
arr2.push(this.readSFixed32());
return arr2;
},
readPackedFixed64: function(arr2) {
if (this.type !== Pbf.Bytes)
return arr2.push(this.readFixed64());
var end = readPackedEnd(this);
arr2 = arr2 || [];
while (this.pos < end)
arr2.push(this.readFixed64());
return arr2;
},
readPackedSFixed64: function(arr2) {
if (this.type !== Pbf.Bytes)
return arr2.push(this.readSFixed64());
var end = readPackedEnd(this);
arr2 = arr2 || [];
while (this.pos < end)
arr2.push(this.readSFixed64());
return arr2;
},
skip: function(val) {
var type = val & 7;
if (type === Pbf.Varint)
while (this.buf[this.pos++] > 127) {
}
else if (type === Pbf.Bytes)
this.pos = this.readVarint() + this.pos;
else if (type === Pbf.Fixed32)
this.pos += 4;
else if (type === Pbf.Fixed64)
this.pos += 8;
else
throw new Error("Unimplemented type: " + type);
},
writeTag: function(tag, type) {
this.writeVarint(tag << 3 | type);
},
realloc: function(min) {
var length = this.length || 16;
while (length < this.pos + min)
length *= 2;
if (length !== this.length) {
var buf = new Uint8Array(length);
buf.set(this.buf);
this.buf = buf;
this.length = length;
}
},
finish: function() {
this.length = this.pos;
this.pos = 0;
return this.buf.subarray(0, this.length);
},
writeFixed32: function(val) {
this.realloc(4);
writeInt32(this.buf, val, this.pos);
this.pos += 4;
},
writeSFixed32: function(val) {
this.realloc(4);
writeInt32(this.buf, val, this.pos);
this.pos += 4;
},
writeFixed64: function(val) {
this.realloc(8);
writeInt32(this.buf, val & -1, this.pos);
writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
this.pos += 8;
},
writeSFixed64: function(val) {
this.realloc(8);
writeInt32(this.buf, val & -1, this.pos);
writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
this.pos += 8;
},
writeVarint: function(val) {
val = +val || 0;
if (val > 268435455 || val < 0) {
writeBigVarint(val, this);
return;
}
this.realloc(4);
this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0);
if (val <= 127)
return;
this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
if (val <= 127)
return;
this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
if (val <= 127)
return;
this.buf[this.pos++] = val >>> 7 & 127;
},
writeSVarint: function(val) {
this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
},
writeBoolean: function(val) {
this.writeVarint(Boolean(val));
},
writeString: function(str) {
str = String(str);
this.realloc(str.length * 4);
this.pos++;
var startPos = this.pos;
this.pos = writeUtf8(this.buf, str, this.pos);
var len = this.pos - startPos;
if (len >= 128)
makeRoomForExtraLength(startPos, len, this);
this.pos = startPos - 1;
this.writeVarint(len);
this.pos += len;
},
writeFloat: function(val) {
this.realloc(4);
ieee754.write(this.buf, val, this.pos, true, 23, 4);
this.pos += 4;
},
writeDouble: function(val) {
this.realloc(8);
ieee754.write(this.buf, val, this.pos, true, 52, 8);
this.pos += 8;
},
writeBytes: function(buffer) {
var len = buffer.length;
this.writeVarint(len);
this.realloc(len);
for (var i3 = 0; i3 < len; i3++)
this.buf[this.pos++] = buffer[i3];
},
writeRawMessage: function(fn, obj) {
this.pos++;
var startPos = this.pos;
fn(obj, this);
var len = this.pos - startPos;
if (len >= 128)
makeRoomForExtraLength(startPos, len, this);
this.pos = startPos - 1;
this.writeVarint(len);
this.pos += len;
},
writeMessage: function(tag, fn, obj) {
this.writeTag(tag, Pbf.Bytes);
this.writeRawMessage(fn, obj);
},
writePackedVarint: function(tag, arr2) {
if (arr2.length)
this.writeMessage(tag, writePackedVarint, arr2);
},
writePackedSVarint: function(tag, arr2) {
if (arr2.length)
this.writeMessage(tag, writePackedSVarint, arr2);
},
writePackedBoolean: function(tag, arr2) {
if (arr2.length)
this.writeMessage(tag, writePackedBoolean, arr2);
},
writePackedFloat: function(tag, arr2) {
if (arr2.length)
this.writeMessage(tag, writePackedFloat, arr2);
},
writePackedDouble: function(tag, arr2) {
if (arr2.length)
this.writeMessage(tag, writePackedDouble, arr2);
},
writePackedFixed32: function(tag, arr2) {
if (arr2.length)
this.writeMessage(tag, writePackedFixed32, arr2);
},
writePackedSFixed32: function(tag, arr2) {
if (arr2.length)
this.writeMessage(tag, writePackedSFixed32, arr2);
},
writePackedFixed64: function(tag, arr2) {
if (arr2.length)
this.writeMessage(tag, writePackedFixed64, arr2);
},
writePackedSFixed64: function(tag, arr2) {
if (arr2.length)
this.writeMessage(tag, writePackedSFixed64, arr2);
},
writeBytesField: function(tag, buffer) {
this.writeTag(tag, Pbf.Bytes);
this.writeBytes(buffer);
},
writeFixed32Field: function(tag, val) {
this.writeTag(tag, Pbf.Fixed32);
this.writeFixed32(val);
},
writeSFixed32Field: function(tag, val) {
this.writeTag(tag, Pbf.Fixed32);
this.writeSFixed32(val);
},
writeFixed64Field: function(tag, val) {
this.writeTag(tag, Pbf.Fixed64);
this.writeFixed64(val);
},
writeSFixed64Field: function(tag, val) {
this.writeTag(tag, Pbf.Fixed64);
this.writeSFixed64(val);
},
writeVarintField: function(tag, val) {
this.writeTag(tag, Pbf.Varint);
this.writeVarint(val);
},
writeSVarintField: function(tag, val) {
this.writeTag(tag, Pbf.Varint);
this.writeSVarint(val);
},
writeStringField: function(tag, str) {
this.writeTag(tag, Pbf.Bytes);
this.writeString(str);
},
writeFloatField: function(tag, val) {
this.writeTag(tag, Pbf.Fixed32);
this.writeFloat(val);
},
writeDoubleField: function(tag, val) {
this.writeTag(tag, Pbf.Fixed64);
this.writeDouble(val);
},
writeBooleanField: function(tag, val) {
this.writeVarintField(tag, Boolean(val));
}
};
function readVarintRemainder2(l2, s2, p2) {
var buf = p2.buf, h, b;
b = buf[p2.pos++];
h = (b & 112) >> 4;
if (b < 128)
return toNum2(l2, h, s2);
b = buf[p2.pos++];
h |= (b & 127) << 3;
if (b < 128)
return toNum2(l2, h, s2);
b = buf[p2.pos++];
h |= (b & 127) << 10;
if (b < 128)
return toNum2(l2, h, s2);
b = buf[p2.pos++];
h |= (b & 127) << 17;
if (b < 128)
return toNum2(l2, h, s2);
b = buf[p2.pos++];
h |= (b & 127) << 24;
if (b < 128)
return toNum2(l2, h, s2);
b = buf[p2.pos++];
h |= (b & 1) << 31;
if (b < 128)
return toNum2(l2, h, s2);
throw new Error("Expected varint not more than 10 bytes");
}
function readPackedEnd(pbf) {
return pbf.type === Pbf.Bytes ? pbf.readVarint() + pbf.pos : pbf.pos + 1;
}
function toNum2(low, high, isSigned) {
if (isSigned) {
return high * 4294967296 + (low >>> 0);
}
return (high >>> 0) * 4294967296 + (low >>> 0);
}
function writeBigVarint(val, pbf) {
var low, high;
if (val >= 0) {
low = val % 4294967296 | 0;
high = val / 4294967296 | 0;
} else {
low = ~(-val % 4294967296);
high = ~(-val / 4294967296);
if (low ^ 4294967295) {
low = low + 1 | 0;
} else {
low = 0;
high = high + 1 | 0;
}
}
if (val >= 18446744073709552e3 || val < -18446744073709552e3) {
throw new Error("Given varint doesn't fit into 10 bytes");
}
pbf.realloc(10);
writeBigVarintLow(low, high, pbf);
writeBigVarintHigh(high, pbf);
}
function writeBigVarintLow(low, high, pbf) {
pbf.buf[pbf.pos++] = low & 127 | 128;
low >>>= 7;
pbf.buf[pbf.pos++] = low & 127 | 128;
low >>>= 7;
pbf.buf[pbf.pos++] = low & 127 | 128;
low >>>= 7;
pbf.buf[pbf.pos++] = low & 127 | 128;
low >>>= 7;
pbf.buf[pbf.pos] = low & 127;
}
function writeBigVarintHigh(high, pbf) {
var lsb = (high & 7) << 4;
pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 128 : 0);
if (!high)
return;
pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
if (!high)
return;
pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
if (!high)
return;
pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
if (!high)
return;
pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
if (!high)
return;
pbf.buf[pbf.pos++] = high & 127;
}
function makeRoomForExtraLength(startPos, len, pbf) {
var extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
pbf.realloc(extraLen);
for (var i3 = pbf.pos - 1; i3 >= startPos; i3--)
pbf.buf[i3 + extraLen] = pbf.buf[i3];
}
function writePackedVarint(arr2, pbf) {
for (var i3 = 0; i3 < arr2.length; i3++)
pbf.writeVarint(arr2[i3]);
}
function writePackedSVarint(arr2, pbf) {
for (var i3 = 0; i3 < arr2.length; i3++)
pbf.writeSVarint(arr2[i3]);
}
function writePackedFloat(arr2, pbf) {
for (var i3 = 0; i3 < arr2.length; i3++)
pbf.writeFloat(arr2[i3]);
}
function writePackedDouble(arr2, pbf) {
for (var i3 = 0; i3 < arr2.length; i3++)
pbf.writeDouble(arr2[i3]);
}
function writePackedBoolean(arr2, pbf) {
for (var i3 = 0; i3 < arr2.length; i3++)
pbf.writeBoolean(arr2[i3]);
}
function writePackedFixed32(arr2, pbf) {
for (var i3 = 0; i3 < arr2.length; i3++)
pbf.writeFixed32(arr2[i3]);
}
function writePackedSFixed32(arr2, pbf) {
for (var i3 = 0; i3 < arr2.length; i3++)
pbf.writeSFixed32(arr2[i3]);
}
function writePackedFixed64(arr2, pbf) {
for (var i3 = 0; i3 < arr2.length; i3++)
pbf.writeFixed64(arr2[i3]);
}
function writePackedSFixed64(arr2, pbf) {
for (var i3 = 0; i3 < arr2.length; i3++)
pbf.writeSFixed64(arr2[i3]);
}
function readUInt32(buf, pos) {
return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + buf[pos + 3] * 16777216;
}
function writeInt32(buf, val, pos) {
buf[pos] = val;
buf[pos + 1] = val >>> 8;
buf[pos + 2] = val >>> 16;
buf[pos + 3] = val >>> 24;
}
function readInt32(buf, pos) {
return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + (buf[pos + 3] << 24);
}
function readUtf8(buf, pos, end) {
var str = "";
var i3 = pos;
while (i3 < end) {
var b0 = buf[i3];
var c2 = null;
var bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
if (i3 + bytesPerSequence > end)
break;
var b1, b2, b3;
if (bytesPerSequence === 1) {
if (b0 < 128) {
c2 = b0;
}
} else if (bytesPerSequence === 2) {
b1 = buf[i3 + 1];
if ((b1 & 192) === 128) {
c2 = (b0 & 31) << 6 | b1 & 63;
if (c2 <= 127) {
c2 = null;
}
}
} else if (bytesPerSequence === 3) {
b1 = buf[i3 + 1];
b2 = buf[i3 + 2];
if ((b1 & 192) === 128 && (b2 & 192) === 128) {
c2 = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
if (c2 <= 2047 || c2 >= 55296 && c2 <= 57343) {
c2 = null;
}
}
} else if (bytesPerSequence === 4) {
b1 = buf[i3 + 1];
b2 = buf[i3 + 2];
b3 = buf[i3 + 3];
if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
c2 = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
if (c2 <= 65535 || c2 >= 1114112) {
c2 = null;
}
}
}
if (c2 === null) {
c2 = 65533;
bytesPerSequence = 1;
} else if (c2 > 65535) {
c2 -= 65536;
str += String.fromCharCode(c2 >>> 10 & 1023 | 55296);
c2 = 56320 | c2 & 1023;
}
str += String.fromCharCode(c2);
i3 += bytesPerSequence;
}
return str;
}
function readUtf8TextDecoder(buf, pos, end) {
return utf8TextDecoder.decode(buf.subarray(pos, end));
}
function writeUtf8(buf, str, pos) {
for (var i3 = 0, c2, lead; i3 < str.length; i3++) {
c2 = str.charCodeAt(i3);
if (c2 > 55295 && c2 < 57344) {
if (lead) {
if (c2 < 56320) {
buf[pos++] = 239;
buf[pos++] = 191;
buf[pos++] = 189;
lead = c2;
continue;
} else {
c2 = lead - 55296 << 10 | c2 - 56320 | 65536;
lead = null;
}
} else {
if (c2 > 56319 || i3 + 1 === str.length) {
buf[pos++] = 239;
buf[pos++] = 191;
buf[pos++] = 189;
} else {
lead = c2;
}
continue;
}
} else if (lead) {
buf[pos++] = 239;
buf[pos++] = 191;
buf[pos++] = 189;
lead = null;
}
if (c2 < 128) {
buf[pos++] = c2;
} else {
if (c2 < 2048) {
buf[pos++] = c2 >> 6 | 192;
} else {
if (c2 < 65536) {
buf[pos++] = c2 >> 12 | 224;
} else {
buf[pos++] = c2 >> 18 | 240;
buf[pos++] = c2 >> 12 & 63 | 128;
}
buf[pos++] = c2 >> 6 & 63 | 128;
}
buf[pos++] = c2 & 63 | 128;
}
}
return pos;
}
}
});
// node_modules/rbush/rbush.min.js
var require_rbush_min = __commonJS({
"node_modules/rbush/rbush.min.js"(exports, module) {
!function(t2, i3) {
typeof exports == "object" && typeof module != "undefined" ? module.exports = i3() : typeof define == "function" && define.amd ? define(i3) : (t2 = t2 || self).RBush = i3();
}(exports, function() {
"use strict";
function t2(t3, r3, e3, a3, h2) {
!function t4(n3, r4, e4, a4, h3) {
for (; a4 > e4; ) {
if (a4 - e4 > 600) {
var o3 = a4 - e4 + 1, s3 = r4 - e4 + 1, l3 = Math.log(o3), f3 = 0.5 * Math.exp(2 * l3 / 3), u3 = 0.5 * Math.sqrt(l3 * f3 * (o3 - f3) / o3) * (s3 - o3 / 2 < 0 ? -1 : 1), m2 = Math.max(e4, Math.floor(r4 - s3 * f3 / o3 + u3)), c3 = Math.min(a4, Math.floor(r4 + (o3 - s3) * f3 / o3 + u3));
t4(n3, r4, m2, c3, h3);
}
var p3 = n3[r4], d2 = e4, x2 = a4;
for (i3(n3, e4, r4), h3(n3[a4], p3) > 0 && i3(n3, e4, a4); d2 < x2; ) {
for (i3(n3, d2, x2), d2++, x2--; h3(n3[d2], p3) < 0; )
d2++;
for (; h3(n3[x2], p3) > 0; )
x2--;
}
h3(n3[e4], p3) === 0 ? i3(n3, e4, x2) : i3(n3, ++x2, a4), x2 <= r4 && (e4 = x2 + 1), r4 <= x2 && (a4 = x2 - 1);
}
}(t3, r3, e3 || 0, a3 || t3.length - 1, h2 || n2);
}
function i3(t3, i4, n3) {
var r3 = t3[i4];
t3[i4] = t3[n3], t3[n3] = r3;
}
function n2(t3, i4) {
return t3 < i4 ? -1 : t3 > i4 ? 1 : 0;
}
var r2 = function(t3) {
t3 === void 0 && (t3 = 9), this._maxEntries = Math.max(4, t3), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
};
function e2(t3, i4, n3) {
if (!n3)
return i4.indexOf(t3);
for (var r3 = 0; r3 < i4.length; r3++)
if (n3(t3, i4[r3]))
return r3;
return -1;
}
function a2(t3, i4) {
h(t3, 0, t3.children.length, i4, t3);
}
function h(t3, i4, n3, r3, e3) {
e3 || (e3 = p2(null)), e3.minX = 1 / 0, e3.minY = 1 / 0, e3.maxX = -1 / 0, e3.maxY = -1 / 0;
for (var a3 = i4; a3 < n3; a3++) {
var h2 = t3.children[a3];
o2(e3, t3.leaf ? r3(h2) : h2);
}
return e3;
}
function o2(t3, i4) {
return t3.minX = Math.min(t3.minX, i4.minX), t3.minY = Math.min(t3.minY, i4.minY), t3.maxX = Math.max(t3.maxX, i4.maxX), t3.maxY = Math.max(t3.maxY, i4.maxY), t3;
}
function s2(t3, i4) {
return t3.minX - i4.minX;
}
function l2(t3, i4) {
return t3.minY - i4.minY;
}
function f2(t3) {
return (t3.maxX - t3.minX) * (t3.maxY - t3.minY);
}
function u2(t3) {
return t3.maxX - t3.minX + (t3.maxY - t3.minY);
}
function m(t3, i4) {
return t3.minX <= i4.minX && t3.minY <= i4.minY && i4.maxX <= t3.maxX && i4.maxY <= t3.maxY;
}
function c2(t3, i4) {
return i4.minX <= t3.maxX && i4.minY <= t3.maxY && i4.maxX >= t3.minX && i4.maxY >= t3.minY;
}
function p2(t3) {
return { children: t3, height: 1, leaf: true, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
}
function d(i4, n3, r3, e3, a3) {
for (var h2 = [n3, r3]; h2.length; )
if (!((r3 = h2.pop()) - (n3 = h2.pop()) <= e3)) {
var o3 = n3 + Math.ceil((r3 - n3) / e3 / 2) * e3;
t2(i4, o3, n3, r3, a3), h2.push(n3, o3, o3, r3);
}
}
return r2.prototype.all = function() {
return this._all(this.data, []);
}, r2.prototype.search = function(t3) {
var i4 = this.data, n3 = [];
if (!c2(t3, i4))
return n3;
for (var r3 = this.toBBox, e3 = []; i4; ) {
for (var a3 = 0; a3 < i4.children.length; a3++) {
var h2 = i4.children[a3], o3 = i4.leaf ? r3(h2) : h2;
c2(t3, o3) && (i4.leaf ? n3.push(h2) : m(t3, o3) ? this._all(h2, n3) : e3.push(h2));
}
i4 = e3.pop();
}
return n3;
}, r2.prototype.collides = function(t3) {
var i4 = this.data;
if (!c2(t3, i4))
return false;
for (var n3 = []; i4; ) {
for (var r3 = 0; r3 < i4.children.length; r3++) {
var e3 = i4.children[r3], a3 = i4.leaf ? this.toBBox(e3) : e3;
if (c2(t3, a3)) {
if (i4.leaf || m(t3, a3))
return true;
n3.push(e3);
}
}
i4 = n3.pop();
}
return false;
}, r2.prototype.load = function(t3) {
if (!t3 || !t3.length)
return this;
if (t3.length < this._minEntries) {
for (var i4 = 0; i4 < t3.length; i4++)
this.insert(t3[i4]);
return this;
}
var n3 = this._build(t3.slice(), 0, t3.length - 1, 0);
if (this.data.children.length)
if (this.data.height === n3.height)
this._splitRoot(this.data, n3);
else {
if (this.data.height < n3.height) {
var r3 = this.data;
this.data = n3, n3 = r3;
}
this._insert(n3, this.data.height - n3.height - 1, true);
}
else
this.data = n3;
return this;
}, r2.prototype.insert = function(t3) {
return t3 && this._insert(t3, this.data.height - 1), this;
}, r2.prototype.clear = function() {
return this.data = p2([]), this;
}, r2.prototype.remove = function(t3, i4) {
if (!t3)
return this;
for (var n3, r3, a3, h2 = this.data, o3 = this.toBBox(t3), s3 = [], l3 = []; h2 || s3.length; ) {
if (h2 || (h2 = s3.pop(), r3 = s3[s3.length - 1], n3 = l3.pop(), a3 = true), h2.leaf) {
var f3 = e2(t3, h2.children, i4);
if (f3 !== -1)
return h2.children.splice(f3, 1), s3.push(h2), this._condense(s3), this;
}
a3 || h2.leaf || !m(h2, o3) ? r3 ? (n3++, h2 = r3.children[n3], a3 = false) : h2 = null : (s3.push(h2), l3.push(n3), n3 = 0, r3 = h2, h2 = h2.children[0]);
}
return this;
}, r2.prototype.toBBox = function(t3) {
return t3;
}, r2.prototype.compareMinX = function(t3, i4) {
return t3.minX - i4.minX;
}, r2.prototype.compareMinY = function(t3, i4) {
return t3.minY - i4.minY;
}, r2.prototype.toJSON = function() {
return this.data;
}, r2.prototype.fromJSON = function(t3) {
return this.data = t3, this;
}, r2.prototype._all = function(t3, i4) {
for (var n3 = []; t3; )
t3.leaf ? i4.push.apply(i4, t3.children) : n3.push.apply(n3, t3.children), t3 = n3.pop();
return i4;
}, r2.prototype._build = function(t3, i4, n3, r3) {
var e3, h2 = n3 - i4 + 1, o3 = this._maxEntries;
if (h2 <= o3)
return a2(e3 = p2(t3.slice(i4, n3 + 1)), this.toBBox), e3;
r3 || (r3 = Math.ceil(Math.log(h2) / Math.log(o3)), o3 = Math.ceil(h2 / Math.pow(o3, r3 - 1))), (e3 = p2([])).leaf = false, e3.height = r3;
var s3 = Math.ceil(h2 / o3), l3 = s3 * Math.ceil(Math.sqrt(o3));
d(t3, i4, n3, l3, this.compareMinX);
for (var f3 = i4; f3 <= n3; f3 += l3) {
var u3 = Math.min(f3 + l3 - 1, n3);
d(t3, f3, u3, s3, this.compareMinY);
for (var m2 = f3; m2 <= u3; m2 += s3) {
var c3 = Math.min(m2 + s3 - 1, u3);
e3.children.push(this._build(t3, m2, c3, r3 - 1));
}
}
return a2(e3, this.toBBox), e3;
}, r2.prototype._chooseSubtree = function(t3, i4, n3, r3) {
for (; r3.push(i4), !i4.leaf && r3.length - 1 !== n3; ) {
for (var e3 = 1 / 0, a3 = 1 / 0, h2 = void 0, o3 = 0; o3 < i4.children.length; o3++) {
var s3 = i4.children[o3], l3 = f2(s3), u3 = (m2 = t3, c3 = s3, (Math.max(c3.maxX, m2.maxX) - Math.min(c3.minX, m2.minX)) * (Math.max(c3.maxY, m2.maxY) - Math.min(c3.minY, m2.minY)) - l3);
u3 < a3 ? (a3 = u3, e3 = l3 < e3 ? l3 : e3, h2 = s3) : u3 === a3 && l3 < e3 && (e3 = l3, h2 = s3);
}
i4 = h2 || i4.children[0];
}
var m2, c3;
return i4;
}, r2.prototype._insert = function(t3, i4, n3) {
var r3 = n3 ? t3 : this.toBBox(t3), e3 = [], a3 = this._chooseSubtree(r3, this.data, i4, e3);
for (a3.children.push(t3), o2(a3, r3); i4 >= 0 && e3[i4].children.length > this._maxEntries; )
this._split(e3, i4), i4--;
this._adjustParentBBoxes(r3, e3, i4);
}, r2.prototype._split = function(t3, i4) {
var n3 = t3[i4], r3 = n3.children.length, e3 = this._minEntries;
this._chooseSplitAxis(n3, e3, r3);
var h2 = this._chooseSplitIndex(n3, e3, r3), o3 = p2(n3.children.splice(h2, n3.children.length - h2));
o3.height = n3.height, o3.leaf = n3.leaf, a2(n3, this.toBBox), a2(o3, this.toBBox), i4 ? t3[i4 - 1].children.push(o3) : this._splitRoot(n3, o3);
}, r2.prototype._splitRoot = function(t3, i4) {
this.data = p2([t3, i4]), this.data.height = t3.height + 1, this.data.leaf = false, a2(this.data, this.toBBox);
}, r2.prototype._chooseSplitIndex = function(t3, i4, n3) {
for (var r3, e3, a3, o3, s3, l3, u3, m2 = 1 / 0, c3 = 1 / 0, p3 = i4; p3 <= n3 - i4; p3++) {
var d2 = h(t3, 0, p3, this.toBBox), x2 = h(t3, p3, n3, this.toBBox), v = (e3 = d2, a3 = x2, o3 = void 0, s3 = void 0, l3 = void 0, u3 = void 0, o3 = Math.max(e3.minX, a3.minX), s3 = Math.max(e3.minY, a3.minY), l3 = Math.min(e3.maxX, a3.maxX), u3 = Math.min(e3.maxY, a3.maxY), Math.max(0, l3 - o3) * Math.max(0, u3 - s3)), M = f2(d2) + f2(x2);
v < m2 ? (m2 = v, r3 = p3, c3 = M < c3 ? M : c3) : v === m2 && M < c3 && (c3 = M, r3 = p3);
}
return r3 || n3 - i4;
}, r2.prototype._chooseSplitAxis = function(t3, i4, n3) {
var r3 = t3.leaf ? this.compareMinX : s2, e3 = t3.leaf ? this.compareMinY : l2;
this._allDistMargin(t3, i4, n3, r3) < this._allDistMargin(t3, i4, n3, e3) && t3.children.sort(r3);
}, r2.prototype._allDistMargin = function(t3, i4, n3, r3) {
t3.children.sort(r3);
for (var e3 = this.toBBox, a3 = h(t3, 0, i4, e3), s3 = h(t3, n3 - i4, n3, e3), l3 = u2(a3) + u2(s3), f3 = i4; f3 < n3 - i4; f3++) {
var m2 = t3.children[f3];
o2(a3, t3.leaf ? e3(m2) : m2), l3 += u2(a3);
}
for (var c3 = n3 - i4 - 1; c3 >= i4; c3--) {
var p3 = t3.children[c3];
o2(s3, t3.leaf ? e3(p3) : p3), l3 += u2(s3);
}
return l3;
}, r2.prototype._adjustParentBBoxes = function(t3, i4, n3) {
for (var r3 = n3; r3 >= 0; r3--)
o2(i4[r3], t3);
}, r2.prototype._condense = function(t3) {
for (var i4 = t3.length - 1, n3 = void 0; i4 >= 0; i4--)
t3[i4].children.length === 0 ? i4 > 0 ? (n3 = t3[i4 - 1].children).splice(n3.indexOf(t3[i4]), 1) : this.clear() : a2(t3[i4], this.toBBox);
}, r2;
});
}
});
// src/types/unitbezier.d.ts
var require_unitbezier_d = __commonJS({
"src/types/unitbezier.d.ts"() {
}
});
// node_modules/tinyqueue/tinyqueue.js
var require_tinyqueue = __commonJS({
"node_modules/tinyqueue/tinyqueue.js"(exports, module) {
(function(global, factory) {
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = global || self, global.TinyQueue = factory());
})(exports, function() {
"use strict";
var TinyQueue = function TinyQueue2(data, compare2) {
if (data === void 0)
data = [];
if (compare2 === void 0)
compare2 = defaultCompare;
this.data = data;
this.length = this.data.length;
this.compare = compare2;
if (this.length > 0) {
for (var i3 = (this.length >> 1) - 1; i3 >= 0; i3--) {
this._down(i3);
}