@mesh3d/cesium-vectortile-gl 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +120 -0
- package/Source/Cesium.d.ts +2692 -0
- package/Source/VectorTileLOD.js +494 -0
- package/Source/VectorTileRenderList.js +65 -0
- package/Source/VectorTileset.js +309 -0
- package/Source/layers/BackgroundRenderLayer.js +82 -0
- package/Source/layers/FillRenderLayer.js +18 -0
- package/Source/layers/IRenderLayer.js +128 -0
- package/Source/layers/LineRenderLayer.js +94 -0
- package/Source/layers/SymbolRenderLayer.js +31 -0
- package/Source/layers/index.js +16 -0
- package/Source/layers/registerRenderLayer.js +24 -0
- package/Source/layers/visualizers/FillLayerVisualizer.js +420 -0
- package/Source/layers/visualizers/ILayerVisualizer.js +73 -0
- package/Source/layers/visualizers/LineLayerVisualizer.js +565 -0
- package/Source/layers/visualizers/SymbolLayerVisualizer.js +179 -0
- package/Source/sources/GeoJSONSource.js +46 -0
- package/Source/sources/ISource.js +39 -0
- package/Source/sources/VectorSource.js +45 -0
- package/Source/sources/granularitySettings.js +20 -0
- package/Source/sources/index.js +11 -0
- package/Source/sources/registerSource.js +19 -0
- package/Source/style/StyleLayer.js +43 -0
- package/Source/style/StyleLayerProperties.js +43 -0
- package/Source/style/index.js +2 -0
- package/dist/cvt-gl.js +10642 -0
- package/dist/cvt-gl.js.map +1 -0
- package/dist/cvt-gl.min.js +135 -0
- package/dist/cvt-gl.min.js.map +1 -0
- package/index.js +6 -0
- package/logo.svg +47 -0
- package/package.json +36 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cvt-gl.js","sources":["../node_modules/@mapbox/point-geometry/index.js","../node_modules/@mapbox/vector-tile/index.js","../Source/sources/ISource.js","../Source/sources/registerSource.js","../node_modules/pbf/index.js","../Source/sources/VectorSource.js","../node_modules/geojson-vt/src/simplify.js","../node_modules/geojson-vt/src/feature.js","../node_modules/geojson-vt/src/convert.js","../node_modules/geojson-vt/src/clip.js","../node_modules/geojson-vt/src/wrap.js","../node_modules/geojson-vt/src/transform.js","../node_modules/geojson-vt/src/tile.js","../node_modules/geojson-vt/src/index.js","../node_modules/@maplibre/vt-pbf/dist/index.es.js","../node_modules/maplibre-gl/src/data/extent.ts","../Source/sources/GeoJSONSource.js","../node_modules/@maplibre/maplibre-gl-style-spec/dist/index.mjs","../Source/style/StyleLayerProperties.js","../Source/style/StyleLayer.js","../Source/VectorTileRenderList.js","../node_modules/earcut/src/earcut.js","../node_modules/maplibre-gl/src/render/subdivision_granularity_settings.ts","../node_modules/maplibre-gl/src/util/transferable_grid_index.ts","../node_modules/@mapbox/unitbezier/index.js","../node_modules/maplibre-gl/src/util/util.ts","../node_modules/maplibre-gl/src/util/ajax.ts","../node_modules/maplibre-gl/src/util/web_worker_transfer.ts","../node_modules/maplibre-gl/src/render/subdivision.ts","../Source/sources/granularitySettings.js","../Source/VectorTileLOD.js","../Source/VectorTileset.js","../Source/layers/IRenderLayer.js","../Source/layers/visualizers/ILayerVisualizer.js","../Source/layers/registerRenderLayer.js","../Source/layers/BackgroundRenderLayer.js","../node_modules/maplibre-gl/src/data/load_geometry.ts","../Source/layers/visualizers/FillLayerVisualizer.js","../Source/layers/FillRenderLayer.js","../Source/layers/visualizers/LineLayerVisualizer.js","../Source/layers/LineRenderLayer.js","../Source/layers/visualizers/SymbolLayerVisualizer.js","../Source/layers/SymbolRenderLayer.js"],"sourcesContent":["/**\n * A standalone point geometry with useful accessor, comparison, and\n * modification methods.\n *\n * @class\n * @param {number} x the x-coordinate. This could be longitude or screen pixels, or any other sort of unit.\n * @param {number} y the y-coordinate. This could be latitude or screen pixels, or any other sort of unit.\n *\n * @example\n * const point = new Point(-77, 38);\n */\nexport default function Point(x, y) {\n this.x = x;\n this.y = y;\n}\n\nPoint.prototype = {\n /**\n * Clone this point, returning a new point that can be modified\n * without affecting the old one.\n * @return {Point} the clone\n */\n clone() { return new Point(this.x, this.y); },\n\n /**\n * Add this point's x & y coordinates to another point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n add(p) { return this.clone()._add(p); },\n\n /**\n * Subtract this point's x & y coordinates to from point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n sub(p) { return this.clone()._sub(p); },\n\n /**\n * Multiply this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n multByPoint(p) { return this.clone()._multByPoint(p); },\n\n /**\n * Divide this point's x & y coordinates by point,\n * yielding a new point.\n * @param {Point} p the other point\n * @return {Point} output point\n */\n divByPoint(p) { return this.clone()._divByPoint(p); },\n\n /**\n * Multiply this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {number} k factor\n * @return {Point} output point\n */\n mult(k) { return this.clone()._mult(k); },\n\n /**\n * Divide this point's x & y coordinates by a factor,\n * yielding a new point.\n * @param {number} k factor\n * @return {Point} output point\n */\n div(k) { return this.clone()._div(k); },\n\n /**\n * Rotate this point around the 0, 0 origin by an angle a,\n * given in radians\n * @param {number} a angle to rotate around, in radians\n * @return {Point} output point\n */\n rotate(a) { return this.clone()._rotate(a); },\n\n /**\n * Rotate this point around p point by an angle a,\n * given in radians\n * @param {number} a angle to rotate around, in radians\n * @param {Point} p Point to rotate around\n * @return {Point} output point\n */\n rotateAround(a, p) { return this.clone()._rotateAround(a, p); },\n\n /**\n * Multiply this point by a 4x1 transformation matrix\n * @param {[number, number, number, number]} m transformation matrix\n * @return {Point} output point\n */\n matMult(m) { return this.clone()._matMult(m); },\n\n /**\n * Calculate this point but as a unit vector from 0, 0, meaning\n * that the distance from the resulting point to the 0, 0\n * coordinate will be equal to 1 and the angle from the resulting\n * point to the 0, 0 coordinate will be the same as before.\n * @return {Point} unit vector point\n */\n unit() { return this.clone()._unit(); },\n\n /**\n * Compute a perpendicular point, where the new y coordinate\n * is the old x coordinate and the new x coordinate is the old y\n * coordinate multiplied by -1\n * @return {Point} perpendicular point\n */\n perp() { return this.clone()._perp(); },\n\n /**\n * Return a version of this point with the x & y coordinates\n * rounded to integers.\n * @return {Point} rounded point\n */\n round() { return this.clone()._round(); },\n\n /**\n * Return the magnitude of this point: this is the Euclidean\n * distance from the 0, 0 coordinate to this point's x and y\n * coordinates.\n * @return {number} magnitude\n */\n mag() {\n return Math.sqrt(this.x * this.x + this.y * this.y);\n },\n\n /**\n * Judge whether this point is equal to another point, returning\n * true or false.\n * @param {Point} other the other point\n * @return {boolean} whether the points are equal\n */\n equals(other) {\n return this.x === other.x &&\n this.y === other.y;\n },\n\n /**\n * Calculate the distance from this point to another point\n * @param {Point} p the other point\n * @return {number} distance\n */\n dist(p) {\n return Math.sqrt(this.distSqr(p));\n },\n\n /**\n * Calculate the distance from this point to another point,\n * without the square root step. Useful if you're comparing\n * relative distances.\n * @param {Point} p the other point\n * @return {number} distance\n */\n distSqr(p) {\n const dx = p.x - this.x,\n dy = p.y - this.y;\n return dx * dx + dy * dy;\n },\n\n /**\n * Get the angle from the 0, 0 coordinate to this point, in radians\n * coordinates.\n * @return {number} angle\n */\n angle() {\n return Math.atan2(this.y, this.x);\n },\n\n /**\n * Get the angle from this point to another point, in radians\n * @param {Point} b the other point\n * @return {number} angle\n */\n angleTo(b) {\n return Math.atan2(this.y - b.y, this.x - b.x);\n },\n\n /**\n * Get the angle between this point and another point, in radians\n * @param {Point} b the other point\n * @return {number} angle\n */\n angleWith(b) {\n return this.angleWithSep(b.x, b.y);\n },\n\n /**\n * Find the angle of the two vectors, solving the formula for\n * the cross product a x b = |a||b|sin(θ) for θ.\n * @param {number} x the x-coordinate\n * @param {number} y the y-coordinate\n * @return {number} the angle in radians\n */\n angleWithSep(x, y) {\n return Math.atan2(\n this.x * y - this.y * x,\n this.x * x + this.y * y);\n },\n\n /** @param {[number, number, number, number]} m */\n _matMult(m) {\n const x = m[0] * this.x + m[1] * this.y,\n y = m[2] * this.x + m[3] * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n\n /** @param {Point} p */\n _add(p) {\n this.x += p.x;\n this.y += p.y;\n return this;\n },\n\n /** @param {Point} p */\n _sub(p) {\n this.x -= p.x;\n this.y -= p.y;\n return this;\n },\n\n /** @param {number} k */\n _mult(k) {\n this.x *= k;\n this.y *= k;\n return this;\n },\n\n /** @param {number} k */\n _div(k) {\n this.x /= k;\n this.y /= k;\n return this;\n },\n\n /** @param {Point} p */\n _multByPoint(p) {\n this.x *= p.x;\n this.y *= p.y;\n return this;\n },\n\n /** @param {Point} p */\n _divByPoint(p) {\n this.x /= p.x;\n this.y /= p.y;\n return this;\n },\n\n _unit() {\n this._div(this.mag());\n return this;\n },\n\n _perp() {\n const y = this.y;\n this.y = this.x;\n this.x = -y;\n return this;\n },\n\n /** @param {number} angle */\n _rotate(angle) {\n const cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = cos * this.x - sin * this.y,\n y = sin * this.x + cos * this.y;\n this.x = x;\n this.y = y;\n return this;\n },\n\n /**\n * @param {number} angle\n * @param {Point} p\n */\n _rotateAround(angle, p) {\n const cos = Math.cos(angle),\n sin = Math.sin(angle),\n x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y),\n y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);\n this.x = x;\n this.y = y;\n return this;\n },\n\n _round() {\n this.x = Math.round(this.x);\n this.y = Math.round(this.y);\n return this;\n },\n\n constructor: Point\n};\n\n/**\n * Construct a point from an array if necessary, otherwise if the input\n * is already a Point, return it unchanged.\n * @param {Point | [number, number] | {x: number, y: number}} p input value\n * @return {Point} constructed point.\n * @example\n * // this\n * var point = Point.convert([0, 1]);\n * // is equivalent to\n * var point = new Point(0, 1);\n */\nPoint.convert = function (p) {\n if (p instanceof Point) {\n return /** @type {Point} */ (p);\n }\n if (Array.isArray(p)) {\n return new Point(+p[0], +p[1]);\n }\n if (p.x !== undefined && p.y !== undefined) {\n return new Point(+p.x, +p.y);\n }\n throw new Error('Expected [x, y] or {x, y} point format');\n};\n","\nimport Point from '@mapbox/point-geometry';\n\n/** @import Pbf from 'pbf' */\n/** @import {Feature} from 'geojson' */\n\nexport class VectorTileFeature {\n /**\n * @param {Pbf} pbf\n * @param {number} end\n * @param {number} extent\n * @param {string[]} keys\n * @param {(number | string | boolean)[]} values\n */\n constructor(pbf, end, extent, keys, values) {\n // Public\n\n /** @type {Record<string, number | string | boolean>} */\n this.properties = {};\n\n this.extent = extent;\n /** @type {0 | 1 | 2 | 3} */\n this.type = 0;\n\n /** @type {number | undefined} */\n this.id = undefined;\n\n /** @private */\n this._pbf = pbf;\n /** @private */\n this._geometry = -1;\n /** @private */\n this._keys = keys;\n /** @private */\n this._values = values;\n\n pbf.readFields(readFeature, this, end);\n }\n\n loadGeometry() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n\n const end = pbf.readVarint() + pbf.pos;\n\n /** @type Point[][] */\n const lines = [];\n\n /** @type Point[] | undefined */\n let line;\n\n let cmd = 1;\n let length = 0;\n let x = 0;\n let y = 0;\n\n while (pbf.pos < end) {\n if (length <= 0) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n\n if (cmd === 1) { // moveTo\n if (line) lines.push(line);\n line = [];\n }\n\n if (line) line.push(new Point(x, y));\n\n } else if (cmd === 7) {\n\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (line) {\n line.push(line[0].clone()); // closePolygon\n }\n\n } else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n\n if (line) lines.push(line);\n\n return lines;\n }\n\n bbox() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n\n const end = pbf.readVarint() + pbf.pos;\n let cmd = 1,\n length = 0,\n x = 0,\n y = 0,\n x1 = Infinity,\n x2 = -Infinity,\n y1 = Infinity,\n y2 = -Infinity;\n\n while (pbf.pos < end) {\n if (length <= 0) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (x < x1) x1 = x;\n if (x > x2) x2 = x;\n if (y < y1) y1 = y;\n if (y > y2) y2 = y;\n\n } else if (cmd !== 7) {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n\n return [x1, y1, x2, y2];\n }\n\n /**\n * @param {number} x\n * @param {number} y\n * @param {number} z\n * @return {Feature}\n */\n toGeoJSON(x, y, z) {\n const size = this.extent * Math.pow(2, z),\n x0 = this.extent * x,\n y0 = this.extent * y,\n vtCoords = this.loadGeometry();\n\n /** @param {Point} p */\n function projectPoint(p) {\n return [\n (p.x + x0) * 360 / size - 180,\n 360 / Math.PI * Math.atan(Math.exp((1 - (p.y + y0) * 2 / size) * Math.PI)) - 90\n ];\n }\n\n /** @param {Point[]} line */\n function projectLine(line) {\n return line.map(projectPoint);\n }\n\n /** @type {Feature[\"geometry\"]} */\n let geometry;\n\n if (this.type === 1) {\n const points = [];\n for (const line of vtCoords) {\n points.push(line[0]);\n }\n const coordinates = projectLine(points);\n geometry = points.length === 1 ?\n {type: 'Point', coordinates: coordinates[0]} :\n {type: 'MultiPoint', coordinates};\n\n } else if (this.type === 2) {\n\n const coordinates = vtCoords.map(projectLine);\n geometry = coordinates.length === 1 ?\n {type: 'LineString', coordinates: coordinates[0]} :\n {type: 'MultiLineString', coordinates};\n\n } else if (this.type === 3) {\n const polygons = classifyRings(vtCoords);\n const coordinates = [];\n for (const polygon of polygons) {\n coordinates.push(polygon.map(projectLine));\n }\n geometry = coordinates.length === 1 ?\n {type: 'Polygon', coordinates: coordinates[0]} :\n {type: 'MultiPolygon', coordinates};\n } else {\n\n throw new Error('unknown feature type');\n }\n\n /** @type {Feature} */\n const result = {\n type: 'Feature',\n geometry,\n properties: this.properties\n };\n\n if (this.id != null) {\n result.id = this.id;\n }\n\n return result;\n }\n}\n\n/** @type {['Unknown', 'Point', 'LineString', 'Polygon']} */\nVectorTileFeature.types = ['Unknown', 'Point', 'LineString', 'Polygon'];\n\n/**\n * @param {number} tag\n * @param {VectorTileFeature} feature\n * @param {Pbf} pbf\n */\nfunction readFeature(tag, feature, pbf) {\n if (tag === 1) feature.id = pbf.readVarint();\n else if (tag === 2) readTag(pbf, feature);\n else if (tag === 3) feature.type = /** @type {0 | 1 | 2 | 3} */ (pbf.readVarint());\n // @ts-expect-error TS2341 deliberately accessing a private property\n else if (tag === 4) feature._geometry = pbf.pos;\n}\n\n/**\n * @param {Pbf} pbf\n * @param {VectorTileFeature} feature\n */\nfunction readTag(pbf, feature) {\n const end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n // @ts-expect-error TS2341 deliberately accessing a private property\n const key = feature._keys[pbf.readVarint()];\n // @ts-expect-error TS2341 deliberately accessing a private property\n const value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n}\n\n/** classifies an array of rings into polygons with outer rings and holes\n * @param {Point[][]} rings\n */\nexport function classifyRings(rings) {\n const len = rings.length;\n\n if (len <= 1) return [rings];\n\n const polygons = [];\n let polygon, ccw;\n\n for (let i = 0; i < len; i++) {\n const area = signedArea(rings[i]);\n if (area === 0) continue;\n\n if (ccw === undefined) ccw = area < 0;\n\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n\n } else if (polygon) {\n polygon.push(rings[i]);\n }\n }\n if (polygon) polygons.push(polygon);\n\n return polygons;\n}\n\n/** @param {Point[]} ring */\nfunction signedArea(ring) {\n let sum = 0;\n for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n}\n\nexport class VectorTileLayer {\n /**\n * @param {Pbf} pbf\n * @param {number} [end]\n */\n constructor(pbf, end) {\n // Public\n this.version = 1;\n this.name = '';\n this.extent = 4096;\n this.length = 0;\n\n /** @private */\n this._pbf = pbf;\n\n /** @private\n * @type {string[]} */\n this._keys = [];\n\n /** @private\n * @type {(number | string | boolean)[]} */\n this._values = [];\n\n /** @private\n * @type {number[]} */\n this._features = [];\n\n pbf.readFields(readLayer, this, end);\n\n this.length = this._features.length;\n }\n\n /** return feature `i` from this layer as a `VectorTileFeature`\n * @param {number} i\n */\n feature(i) {\n if (i < 0 || i >= this._features.length) throw new Error('feature index out of bounds');\n\n this._pbf.pos = this._features[i];\n\n const end = this._pbf.readVarint() + this._pbf.pos;\n return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);\n }\n}\n\n/**\n * @param {number} tag\n * @param {VectorTileLayer} layer\n * @param {Pbf} pbf\n */\nfunction readLayer(tag, layer, pbf) {\n if (tag === 15) layer.version = pbf.readVarint();\n else if (tag === 1) layer.name = pbf.readString();\n else if (tag === 5) layer.extent = pbf.readVarint();\n // @ts-expect-error TS2341 deliberately accessing a private property\n else if (tag === 2) layer._features.push(pbf.pos);\n // @ts-expect-error TS2341 deliberately accessing a private property\n else if (tag === 3) layer._keys.push(pbf.readString());\n // @ts-expect-error TS2341 deliberately accessing a private property\n else if (tag === 4) layer._values.push(readValueMessage(pbf));\n}\n\n/**\n * @param {Pbf} pbf\n */\nfunction readValueMessage(pbf) {\n let value = null;\n const end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n const tag = pbf.readVarint() >> 3;\n\n value = tag === 1 ? pbf.readString() :\n tag === 2 ? pbf.readFloat() :\n tag === 3 ? pbf.readDouble() :\n tag === 4 ? pbf.readVarint64() :\n tag === 5 ? pbf.readVarint() :\n tag === 6 ? pbf.readSVarint() :\n tag === 7 ? pbf.readBoolean() : null;\n }\n if (value == null) {\n throw new Error('unknown feature value');\n }\n\n return value;\n}\n\nexport class VectorTile {\n /**\n * @param {Pbf} pbf\n * @param {number} [end]\n */\n constructor(pbf, end) {\n /** @type {Record<string, VectorTileLayer>} */\n this.layers = pbf.readFields(readTile, {}, end);\n }\n}\n\n/**\n * @param {number} tag\n * @param {Record<string, VectorTileLayer>} layers\n * @param {Pbf} pbf\n */\nfunction readTile(tag, layers, pbf) {\n if (tag === 3) {\n const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length) layers[layer.name] = layer;\n }\n}\n","import { VectorTile } from '@mapbox/vector-tile'\r\n\r\n/**\r\n * 数据源基类,定义通用属性和必须实现的方法(init、requestTile)\r\n * @see VectorSource\r\n * @see GeoJSONSource\r\n */\r\nexport class ISource {\r\n /**\r\n * 构造数据源实例。注意:该构造函数由VectorTileset调用,请勿在其他模块直接调用\r\n * @param {import('@maplibre/maplibre-gl-style-spec').SourceSpecification} styleSource \r\n * @param {string} [path] \r\n * @see VectorSource\r\n * @see GeoJSONSource\r\n */\r\n constructor(styleSource, path = '') {\r\n /**@type {\"vector\"|\"geojson\"} */\r\n this.type = styleSource.type\r\n /**@type {import('@maplibre/maplibre-gl-style-spec').SourceSpecification} */\r\n this.styleSource = styleSource\r\n this.path = path\r\n this.errorEvent = new Cesium.Event()\r\n }\r\n\r\n async init() { }\r\n\r\n /**\r\n * @param {number} x \r\n * @param {number} y \r\n * @param {number} z \r\n * @returns {Promise<VectorTile>}\r\n */\r\n requestTile(x, y, z) { }\r\n\r\n destroy() {\r\n this.styleSource = null\r\n this.errorEvent = null\r\n }\r\n}","import { ISource } from \"./ISource\"\r\n\r\n/**\r\n * @type {{[sourceType:string]:typeof ISource}}\r\n */\r\nconst Sources = {}\r\n\r\n/**\r\n * 注册数据源类型,设置数据源类\r\n * @param {*} type \r\n * @param {*} sourceCls \r\n */\r\nfunction registerSource(type, sourceCls) {\r\n Sources[type] = sourceCls\r\n}\r\n\r\nexport {\r\n Sources, registerSource\r\n}","\nconst SHIFT_LEFT_32 = (1 << 16) * (1 << 16);\nconst SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;\n\n// Threshold chosen based on both benchmarking and knowledge about browser string\n// data structures (which currently switch structure types at 12 bytes or more)\nconst TEXT_DECODER_MIN_LENGTH = 12;\nconst utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf-8');\n\nconst PBF_VARINT = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum\nconst PBF_FIXED64 = 1; // 64-bit: double, fixed64, sfixed64\nconst PBF_BYTES = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields\nconst PBF_FIXED32 = 5; // 32-bit: float, fixed32, sfixed32\n\nexport default class Pbf {\n /**\n * @param {Uint8Array | ArrayBuffer} [buf]\n */\n constructor(buf = new Uint8Array(16)) {\n this.buf = ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf);\n this.dataView = new DataView(this.buf.buffer);\n this.pos = 0;\n this.type = 0;\n this.length = this.buf.length;\n }\n\n // === READING =================================================================\n\n /**\n * @template T\n * @param {(tag: number, result: T, pbf: Pbf) => void} readField\n * @param {T} result\n * @param {number} [end]\n */\n readFields(readField, result, end = this.length) {\n while (this.pos < end) {\n const val = this.readVarint(),\n tag = val >> 3,\n startPos = this.pos;\n\n this.type = val & 0x7;\n readField(tag, result, this);\n\n if (this.pos === startPos) this.skip(val);\n }\n return result;\n }\n\n /**\n * @template T\n * @param {(tag: number, result: T, pbf: Pbf) => void} readField\n * @param {T} result\n */\n readMessage(readField, result) {\n return this.readFields(readField, result, this.readVarint() + this.pos);\n }\n\n readFixed32() {\n const val = this.dataView.getUint32(this.pos, true);\n this.pos += 4;\n return val;\n }\n\n readSFixed32() {\n const val = this.dataView.getInt32(this.pos, true);\n this.pos += 4;\n return val;\n }\n\n // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)\n\n readFixed64() {\n const val = this.dataView.getUint32(this.pos, true) + this.dataView.getUint32(this.pos + 4, true) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n }\n\n readSFixed64() {\n const val = this.dataView.getUint32(this.pos, true) + this.dataView.getInt32(this.pos + 4, true) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n }\n\n readFloat() {\n const val = this.dataView.getFloat32(this.pos, true);\n this.pos += 4;\n return val;\n }\n\n readDouble() {\n const val = this.dataView.getFloat64(this.pos, true);\n this.pos += 8;\n return val;\n }\n\n /**\n * @param {boolean} [isSigned]\n */\n readVarint(isSigned) {\n const buf = this.buf;\n let val, b;\n\n b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val;\n b = buf[this.pos]; val |= (b & 0x0f) << 28;\n\n return readVarintRemainder(val, isSigned, this);\n }\n\n readVarint64() { // for compatibility with v2.0.1\n return this.readVarint(true);\n }\n\n readSVarint() {\n const num = this.readVarint();\n return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding\n }\n\n readBoolean() {\n return Boolean(this.readVarint());\n }\n\n readString() {\n const end = this.readVarint() + this.pos;\n const pos = this.pos;\n this.pos = end;\n\n if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {\n // longer strings are fast with the built-in browser TextDecoder API\n return utf8TextDecoder.decode(this.buf.subarray(pos, end));\n }\n // short strings are fast with our custom implementation\n return readUtf8(this.buf, pos, end);\n }\n\n readBytes() {\n const end = this.readVarint() + this.pos,\n buffer = this.buf.subarray(this.pos, end);\n this.pos = end;\n return buffer;\n }\n\n // verbose for performance reasons; doesn't affect gzipped size\n\n /**\n * @param {number[]} [arr]\n * @param {boolean} [isSigned]\n */\n readPackedVarint(arr = [], isSigned) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readVarint(isSigned));\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedSVarint(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readSVarint());\n return arr;\n }\n /** @param {boolean[]} [arr] */\n readPackedBoolean(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readBoolean());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedFloat(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readFloat());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedDouble(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readDouble());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedFixed32(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readFixed32());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedSFixed32(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readSFixed32());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedFixed64(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readFixed64());\n return arr;\n }\n /** @param {number[]} [arr] */\n readPackedSFixed64(arr = []) {\n const end = this.readPackedEnd();\n while (this.pos < end) arr.push(this.readSFixed64());\n return arr;\n }\n readPackedEnd() {\n return this.type === PBF_BYTES ? this.readVarint() + this.pos : this.pos + 1;\n }\n\n /** @param {number} val */\n skip(val) {\n const type = val & 0x7;\n if (type === PBF_VARINT) while (this.buf[this.pos++] > 0x7f) {}\n else if (type === PBF_BYTES) this.pos = this.readVarint() + this.pos;\n else if (type === PBF_FIXED32) this.pos += 4;\n else if (type === PBF_FIXED64) this.pos += 8;\n else throw new Error(`Unimplemented type: ${type}`);\n }\n\n // === WRITING =================================================================\n\n /**\n * @param {number} tag\n * @param {number} type\n */\n writeTag(tag, type) {\n this.writeVarint((tag << 3) | type);\n }\n\n /** @param {number} min */\n realloc(min) {\n let length = this.length || 16;\n\n while (length < this.pos + min) length *= 2;\n\n if (length !== this.length) {\n const buf = new Uint8Array(length);\n buf.set(this.buf);\n this.buf = buf;\n this.dataView = new DataView(buf.buffer);\n this.length = length;\n }\n }\n\n finish() {\n this.length = this.pos;\n this.pos = 0;\n return this.buf.subarray(0, this.length);\n }\n\n /** @param {number} val */\n writeFixed32(val) {\n this.realloc(4);\n this.dataView.setInt32(this.pos, val, true);\n this.pos += 4;\n }\n\n /** @param {number} val */\n writeSFixed32(val) {\n this.realloc(4);\n this.dataView.setInt32(this.pos, val, true);\n this.pos += 4;\n }\n\n /** @param {number} val */\n writeFixed64(val) {\n this.realloc(8);\n this.dataView.setInt32(this.pos, val & -1, true);\n this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true);\n this.pos += 8;\n }\n\n /** @param {number} val */\n writeSFixed64(val) {\n this.realloc(8);\n this.dataView.setInt32(this.pos, val & -1, true);\n this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true);\n this.pos += 8;\n }\n\n /** @param {number} val */\n writeVarint(val) {\n val = +val || 0;\n\n if (val > 0xfffffff || val < 0) {\n writeBigVarint(val, this);\n return;\n }\n\n this.realloc(4);\n\n this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = (val >>> 7) & 0x7f;\n }\n\n /** @param {number} val */\n writeSVarint(val) {\n this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);\n }\n\n /** @param {boolean} val */\n writeBoolean(val) {\n this.writeVarint(+val);\n }\n\n /** @param {string} str */\n writeString(str) {\n str = String(str);\n this.realloc(str.length * 4);\n\n this.pos++; // reserve 1 byte for short string length\n\n const startPos = this.pos;\n // write the string directly to the buffer and see how much was written\n this.pos = writeUtf8(this.buf, str, this.pos);\n const len = this.pos - startPos;\n\n if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);\n\n // finally, write the message length in the reserved place and restore the position\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n }\n\n /** @param {number} val */\n writeFloat(val) {\n this.realloc(4);\n this.dataView.setFloat32(this.pos, val, true);\n this.pos += 4;\n }\n\n /** @param {number} val */\n writeDouble(val) {\n this.realloc(8);\n this.dataView.setFloat64(this.pos, val, true);\n this.pos += 8;\n }\n\n /** @param {Uint8Array} buffer */\n writeBytes(buffer) {\n const len = buffer.length;\n this.writeVarint(len);\n this.realloc(len);\n for (let i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];\n }\n\n /**\n * @template T\n * @param {(obj: T, pbf: Pbf) => void} fn\n * @param {T} obj\n */\n writeRawMessage(fn, obj) {\n this.pos++; // reserve 1 byte for short message length\n\n // write the message directly to the buffer and see how much was written\n const startPos = this.pos;\n fn(obj, this);\n const len = this.pos - startPos;\n\n if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);\n\n // finally, write the message length in the reserved place and restore the position\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n }\n\n /**\n * @template T\n * @param {number} tag\n * @param {(obj: T, pbf: Pbf) => void} fn\n * @param {T} obj\n */\n writeMessage(tag, fn, obj) {\n this.writeTag(tag, PBF_BYTES);\n this.writeRawMessage(fn, obj);\n }\n\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedVarint(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedVarint, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedSVarint(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedSVarint, arr);\n }\n /**\n * @param {number} tag\n * @param {boolean[]} arr\n */\n writePackedBoolean(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedBoolean, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedFloat(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedFloat, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedDouble(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedDouble, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedFixed32(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedFixed32, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedSFixed32(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedFixed64(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedFixed64, arr);\n }\n /**\n * @param {number} tag\n * @param {number[]} arr\n */\n writePackedSFixed64(tag, arr) {\n if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr);\n }\n\n /**\n * @param {number} tag\n * @param {Uint8Array} buffer\n */\n writeBytesField(tag, buffer) {\n this.writeTag(tag, PBF_BYTES);\n this.writeBytes(buffer);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeFixed32Field(tag, val) {\n this.writeTag(tag, PBF_FIXED32);\n this.writeFixed32(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeSFixed32Field(tag, val) {\n this.writeTag(tag, PBF_FIXED32);\n this.writeSFixed32(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeFixed64Field(tag, val) {\n this.writeTag(tag, PBF_FIXED64);\n this.writeFixed64(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeSFixed64Field(tag, val) {\n this.writeTag(tag, PBF_FIXED64);\n this.writeSFixed64(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeVarintField(tag, val) {\n this.writeTag(tag, PBF_VARINT);\n this.writeVarint(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeSVarintField(tag, val) {\n this.writeTag(tag, PBF_VARINT);\n this.writeSVarint(val);\n }\n /**\n * @param {number} tag\n * @param {string} str\n */\n writeStringField(tag, str) {\n this.writeTag(tag, PBF_BYTES);\n this.writeString(str);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeFloatField(tag, val) {\n this.writeTag(tag, PBF_FIXED32);\n this.writeFloat(val);\n }\n /**\n * @param {number} tag\n * @param {number} val\n */\n writeDoubleField(tag, val) {\n this.writeTag(tag, PBF_FIXED64);\n this.writeDouble(val);\n }\n /**\n * @param {number} tag\n * @param {boolean} val\n */\n writeBooleanField(tag, val) {\n this.writeVarintField(tag, +val);\n }\n};\n\n/**\n * @param {number} l\n * @param {boolean | undefined} s\n * @param {Pbf} p\n */\nfunction readVarintRemainder(l, s, p) {\n const buf = p.buf;\n let h, b;\n\n b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s);\n\n throw new Error('Expected varint not more than 10 bytes');\n}\n\n/**\n * @param {number} low\n * @param {number} high\n * @param {boolean} [isSigned]\n */\nfunction toNum(low, high, isSigned) {\n return isSigned ? high * 0x100000000 + (low >>> 0) : ((high >>> 0) * 0x100000000) + (low >>> 0);\n}\n\n/**\n * @param {number} val\n * @param {Pbf} pbf\n */\nfunction writeBigVarint(val, pbf) {\n let low, high;\n\n if (val >= 0) {\n low = (val % 0x100000000) | 0;\n high = (val / 0x100000000) | 0;\n } else {\n low = ~(-val % 0x100000000);\n high = ~(-val / 0x100000000);\n\n if (low ^ 0xffffffff) {\n low = (low + 1) | 0;\n } else {\n low = 0;\n high = (high + 1) | 0;\n }\n }\n\n if (val >= 0x10000000000000000 || val < -0x10000000000000000) {\n throw new Error('Given varint doesn\\'t fit into 10 bytes');\n }\n\n pbf.realloc(10);\n\n writeBigVarintLow(low, high, pbf);\n writeBigVarintHigh(high, pbf);\n}\n\n/**\n * @param {number} high\n * @param {number} low\n * @param {Pbf} pbf\n */\nfunction writeBigVarintLow(low, high, pbf) {\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos] = low & 0x7f;\n}\n\n/**\n * @param {number} high\n * @param {Pbf} pbf\n */\nfunction writeBigVarintHigh(high, pbf) {\n const lsb = (high & 0x07) << 4;\n\n pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f;\n}\n\n/**\n * @param {number} startPos\n * @param {number} len\n * @param {Pbf} pbf\n */\nfunction makeRoomForExtraLength(startPos, len, pbf) {\n const extraLen =\n len <= 0x3fff ? 1 :\n len <= 0x1fffff ? 2 :\n len <= 0xfffffff ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));\n\n // if 1 byte isn't enough for encoding message length, shift the data to the right\n pbf.realloc(extraLen);\n for (let i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];\n}\n\n/**\n * @param {number[]} arr\n * @param {Pbf} pbf\n */\nfunction writePackedVarint(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]);\n}\n/**\n * @param {number[]} arr\n * @param {Pbf} pbf\n */\nfunction writePackedSVarint(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]);\n}\n/**\n * @param {number[]} arr\n * @param {Pbf} pbf\n */\nfunction writePackedFloat(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]);\n}\n/**\n * @param {number[]} arr\n * @param {Pbf} pbf\n */\nfunction writePackedDouble(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]);\n}\n/**\n * @param {boolean[]} arr\n * @param {Pbf} pbf\n */\nfunction writePackedBoolean(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]);\n}\n/**\n * @param {number[]} arr\n * @param {Pbf} pbf\n */\nfunction writePackedFixed32(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]);\n}\n/**\n * @param {number[]} arr\n * @param {Pbf} pbf\n */\nfunction writePackedSFixed32(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]);\n}\n/**\n * @param {number[]} arr\n * @param {Pbf} pbf\n */\nfunction writePackedFixed64(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]);\n}\n/**\n * @param {number[]} arr\n * @param {Pbf} pbf\n */\nfunction writePackedSFixed64(arr, pbf) {\n for (let i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]);\n}\n\n// Buffer code below from https://github.com/feross/buffer, MIT-licensed\n\n/**\n * @param {Uint8Array} buf\n * @param {number} pos\n * @param {number} end\n */\nfunction readUtf8(buf, pos, end) {\n let str = '';\n let i = pos;\n\n while (i < end) {\n const b0 = buf[i];\n let c = null; // codepoint\n let bytesPerSequence =\n b0 > 0xEF ? 4 :\n b0 > 0xDF ? 3 :\n b0 > 0xBF ? 2 : 1;\n\n if (i + bytesPerSequence > end) break;\n\n let b1, b2, b3;\n\n if (bytesPerSequence === 1) {\n if (b0 < 0x80) {\n c = b0;\n }\n } else if (bytesPerSequence === 2) {\n b1 = buf[i + 1];\n if ((b1 & 0xC0) === 0x80) {\n c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);\n if (c <= 0x7F) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 3) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {\n c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);\n if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 4) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n b3 = buf[i + 3];\n if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {\n c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);\n if (c <= 0xFFFF || c >= 0x110000) {\n c = null;\n }\n }\n }\n\n if (c === null) {\n c = 0xFFFD;\n bytesPerSequence = 1;\n\n } else if (c > 0xFFFF) {\n c -= 0x10000;\n str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);\n c = 0xDC00 | c & 0x3FF;\n }\n\n str += String.fromCharCode(c);\n i += bytesPerSequence;\n }\n\n return str;\n}\n\n/**\n * @param {Uint8Array} buf\n * @param {string} str\n * @param {number} pos\n */\nfunction writeUtf8(buf, str, pos) {\n for (let i = 0, c, lead; i < str.length; i++) {\n c = str.charCodeAt(i); // code point\n\n if (c > 0xD7FF && c < 0xE000) {\n if (lead) {\n if (c < 0xDC00) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n lead = c;\n continue;\n } else {\n c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;\n lead = null;\n }\n } else {\n if (c > 0xDBFF || (i + 1 === str.length)) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n } else {\n lead = c;\n }\n continue;\n }\n } else if (lead) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n lead = null;\n }\n\n if (c < 0x80) {\n buf[pos++] = c;\n } else {\n if (c < 0x800) {\n buf[pos++] = c >> 0x6 | 0xC0;\n } else {\n if (c < 0x10000) {\n buf[pos++] = c >> 0xC | 0xE0;\n } else {\n buf[pos++] = c >> 0x12 | 0xF0;\n buf[pos++] = c >> 0xC & 0x3F | 0x80;\n }\n buf[pos++] = c >> 0x6 & 0x3F | 0x80;\n }\n buf[pos++] = c & 0x3F | 0x80;\n }\n }\n return pos;\n}\n","import { ISource } from \"./ISource\";\r\nimport { registerSource } from \"./registerSource\";\r\nimport { VectorTile } from '@mapbox/vector-tile'\r\nimport Pbf from 'pbf'\r\n\r\nexport class VectorSource extends ISource {\r\n constructor(styleSource, path) {\r\n super(styleSource, path)\r\n }\r\n\r\n async init() {\r\n const sourceParams = this.styleSource\r\n let url = sourceParams.url\r\n if (url && !sourceParams.tiles) {\r\n url = /^((http)|(https)|(data:)|\\/)/.test(url) ? url : this.path + sourceParams.url\r\n try {\r\n const metadata = await Cesium.Resource.fetchJson(url)\r\n for (const key in metadata) {\r\n if (!sourceParams[key]) {\r\n sourceParams[key] = metadata[key]\r\n }\r\n }\r\n } catch (err) {\r\n this.errorEvent.raiseEvent(err)\r\n }\r\n }\r\n }\r\n\r\n async requestTile(x, y, z) {\r\n const sourceParams = this.styleSource\r\n if (!sourceParams.tiles || !sourceParams.tiles.length) return\r\n let tileUrl = sourceParams.tiles[0].replace('{x}', x).replace('{y}', y).replace('{z}', z)\r\n tileUrl = /^((http)|(https)|(data:)|\\/)/.test(tileUrl) ? tileUrl : this.path + tileUrl\r\n\r\n try {\r\n const tileBuf = await (fetch(tileUrl).then(res => res.arrayBuffer()));\r\n const tileData = new VectorTile(new Pbf(tileBuf))\r\n return tileData\r\n } catch (err) {\r\n this.errorEvent.raiseEvent(err)\r\n }\r\n }\r\n}\r\n\r\nregisterSource('vector', VectorSource)","\n// calculate simplification data using optimized Douglas-Peucker algorithm\n\nexport default function simplify(coords, first, last, sqTolerance) {\n let maxSqDist = sqTolerance;\n const mid = first + ((last - first) >> 1);\n let minPosToMid = last - first;\n let index;\n\n const ax = coords[first];\n const ay = coords[first + 1];\n const bx = coords[last];\n const by = coords[last + 1];\n\n for (let i = first + 3; i < last; i += 3) {\n const d = getSqSegDist(coords[i], coords[i + 1], ax, ay, bx, by);\n\n if (d > maxSqDist) {\n index = i;\n maxSqDist = d;\n\n } else if (d === maxSqDist) {\n // a workaround to ensure we choose a pivot close to the middle of the list,\n // reducing recursion depth, for certain degenerate inputs\n // https://github.com/mapbox/geojson-vt/issues/104\n const posToMid = Math.abs(i - mid);\n if (posToMid < minPosToMid) {\n index = i;\n minPosToMid = posToMid;\n }\n }\n }\n\n if (maxSqDist > sqTolerance) {\n if (index - first > 3) simplify(coords, first, index, sqTolerance);\n coords[index + 2] = maxSqDist;\n if (last - index > 3) simplify(coords, index, last, sqTolerance);\n }\n}\n\n// square distance from a point to a segment\nfunction getSqSegDist(px, py, x, y, bx, by) {\n\n let dx = bx - x;\n let dy = by - y;\n\n if (dx !== 0 || dy !== 0) {\n\n const t = ((px - x) * dx + (py - y) * dy) / (dx * dx + dy * dy);\n\n if (t > 1) {\n x = bx;\n y = by;\n\n } else if (t > 0) {\n x += dx * t;\n y += dy * t;\n }\n }\n\n dx = px - x;\n dy = py - y;\n\n return dx * dx + dy * dy;\n}\n","\nexport default function createFeature(id, type, geom, tags) {\n const feature = {\n id: id == null ? null : id,\n type,\n geometry: geom,\n tags,\n minX: Infinity,\n minY: Infinity,\n maxX: -Infinity,\n maxY: -Infinity\n };\n\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n calcLineBBox(feature, geom);\n\n } else if (type === 'Polygon') {\n // the outer ring (ie [0]) contains all inner rings\n calcLineBBox(feature, geom[0]);\n\n } else if (type === 'MultiLineString') {\n for (const line of geom) {\n calcLineBBox(feature, line);\n }\n\n } else if (type === 'MultiPolygon') {\n for (const polygon of geom) {\n // the outer ring (ie [0]) contains all inner rings\n calcLineBBox(feature, polygon[0]);\n }\n }\n\n return feature;\n}\n\nfunction calcLineBBox(feature, geom) {\n for (let i = 0; i < geom.length; i += 3) {\n feature.minX = Math.min(feature.minX, geom[i]);\n feature.minY = Math.min(feature.minY, geom[i + 1]);\n feature.maxX = Math.max(feature.maxX, geom[i]);\n feature.maxY = Math.max(feature.maxY, geom[i + 1]);\n }\n}\n","\nimport simplify from './simplify.js';\nimport createFeature from './feature.js';\n\n// converts GeoJSON feature into an intermediate projected JSON vector format with simplification data\n\nexport default function convert(data, options) {\n const features = [];\n if (data.type === 'FeatureCollection') {\n for (let i = 0; i < data.features.length; i++) {\n convertFeature(features, data.features[i], options, i);\n }\n\n } else if (data.type === 'Feature') {\n convertFeature(features, data, options);\n\n } else {\n // single geometry or a geometry collection\n convertFeature(features, {geometry: data}, options);\n }\n\n return features;\n}\n\nfunction convertFeature(features, geojson, options, index) {\n if (!geojson.geometry) return;\n\n const coords = geojson.geometry.coordinates;\n if (coords && coords.length === 0) return;\n\n const type = geojson.geometry.type;\n const tolerance = Math.pow(options.tolerance / ((1 << options.maxZoom) * options.extent), 2);\n let geometry = [];\n let id = geojson.id;\n if (options.promoteId) {\n id = geojson.properties[options.promoteId];\n } else if (options.generateId) {\n id = index || 0;\n }\n if (type === 'Point') {\n convertPoint(coords, geometry);\n\n } else if (type === 'MultiPoint') {\n for (const p of coords) {\n convertPoint(p, geometry);\n }\n\n } else if (type === 'LineString') {\n convertLine(coords, geometry, tolerance, false);\n\n } else if (type === 'MultiLineString') {\n if (options.lineMetrics) {\n // explode into linestrings to be able to track metrics\n for (const line of coords) {\n geometry = [];\n convertLine(line, geometry, tolerance, false);\n features.push(createFeature(id, 'LineString', geometry, geojson.properties));\n }\n return;\n } else {\n convertLines(coords, geometry, tolerance, false);\n }\n\n } else if (type === 'Polygon') {\n convertLines(coords, geometry, tolerance, true);\n\n } else if (type === 'MultiPolygon') {\n for (const polygon of coords) {\n const newPolygon = [];\n convertLines(polygon, newPolygon, tolerance, true);\n geometry.push(newPolygon);\n }\n } else if (type === 'GeometryCollection') {\n for (const singleGeometry of geojson.geometry.geometries) {\n convertFeature(features, {\n id,\n geometry: singleGeometry,\n properties: geojson.properties\n }, options, index);\n }\n return;\n } else {\n throw new Error('Input data is not a valid GeoJSON object.');\n }\n\n features.push(createFeature(id, type, geometry, geojson.properties));\n}\n\nfunction convertPoint(coords, out) {\n out.push(projectX(coords[0]), projectY(coords[1]), 0);\n}\n\nfunction convertLine(ring, out, tolerance, isPolygon) {\n let x0, y0;\n let size = 0;\n\n for (let j = 0; j < ring.length; j++) {\n const x = projectX(ring[j][0]);\n const y = projectY(ring[j][1]);\n\n out.push(x, y, 0);\n\n if (j > 0) {\n if (isPolygon) {\n size += (x0 * y - x * y0) / 2; // area\n } else {\n size += Math.sqrt(Math.pow(x - x0, 2) + Math.pow(y - y0, 2)); // length\n }\n }\n x0 = x;\n y0 = y;\n }\n\n const last = out.length - 3;\n out[2] = 1;\n simplify(out, 0, last, tolerance);\n out[last + 2] = 1;\n\n out.size = Math.abs(size);\n out.start = 0;\n out.end = out.size;\n}\n\nfunction convertLines(rings, out, tolerance, isPolygon) {\n for (let i = 0; i < rings.length; i++) {\n const geom = [];\n convertLine(rings[i], geom, tolerance, isPolygon);\n out.push(geom);\n }\n}\n\nfunction projectX(x) {\n return x / 360 + 0.5;\n}\n\nfunction projectY(y) {\n const sin = Math.sin(y * Math.PI / 180);\n const y2 = 0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI;\n return y2 < 0 ? 0 : y2 > 1 ? 1 : y2;\n}\n","\nimport createFeature from './feature.js';\n\n/* clip features between two vertical or horizontal axis-parallel lines:\n * | |\n * ___|___ | /\n * / | \\____|____/\n * | |\n *\n * k1 and k2 are the line coordinates\n * axis: 0 for x, 1 for y\n * minAll and maxAll: minimum and maximum coordinate value for all features\n */\nexport default function clip(features, scale, k1, k2, axis, minAll, maxAll, options) {\n k1 /= scale;\n k2 /= scale;\n\n if (minAll >= k1 && maxAll < k2) return features; // trivial accept\n else if (maxAll < k1 || minAll >= k2) return null; // trivial reject\n\n const clipped = [];\n\n for (const feature of features) {\n const geometry = feature.geometry;\n let type = feature.type;\n\n const min = axis === 0 ? feature.minX : feature.minY;\n const max = axis === 0 ? feature.maxX : feature.maxY;\n\n if (min >= k1 && max < k2) { // trivial accept\n clipped.push(feature);\n continue;\n } else if (max < k1 || min >= k2) { // trivial reject\n continue;\n }\n\n let newGeometry = [];\n\n if (type === 'Point' || type === 'MultiPoint') {\n clipPoints(geometry, newGeometry, k1, k2, axis);\n\n } else if (type === 'LineString') {\n clipLine(geometry, newGeometry, k1, k2, axis, false, options.lineMetrics);\n\n } else if (type === 'MultiLineString') {\n clipLines(geometry, newGeometry, k1, k2, axis, false);\n\n } else if (type === 'Polygon') {\n clipLines(geometry, newGeometry, k1, k2, axis, true);\n\n } else if (type === 'MultiPolygon') {\n for (const polygon of geometry) {\n const newPolygon = [];\n clipLines(polygon, newPolygon, k1, k2, axis, true);\n if (newPolygon.length) {\n newGeometry.push(newPolygon);\n }\n }\n }\n\n if (newGeometry.length) {\n if (options.lineMetrics && type === 'LineString') {\n for (const line of newGeometry) {\n clipped.push(createFeature(feature.id, type, line, feature.tags));\n }\n continue;\n }\n\n if (type === 'LineString' || type === 'MultiLineString') {\n if (newGeometry.length === 1) {\n type = 'LineString';\n newGeometry = newGeometry[0];\n } else {\n type = 'MultiLineString';\n }\n }\n if (type === 'Point' || type === 'MultiPoint') {\n type = newGeometry.length === 3 ? 'Point' : 'MultiPoint';\n }\n\n clipped.push(createFeature(feature.id, type, newGeometry, feature.tags));\n }\n }\n\n return clipped.length ? clipped : null;\n}\n\nfunction clipPoints(geom, newGeom, k1, k2, axis) {\n for (let i = 0; i < geom.length; i += 3) {\n const a = geom[i + axis];\n\n if (a >= k1 && a <= k2) {\n addPoint(newGeom, geom[i], geom[i + 1], geom[i + 2]);\n }\n }\n}\n\nfunction clipLine(geom, newGeom, k1, k2, axis, isPolygon, trackMetrics) {\n\n let slice = newSlice(geom);\n const intersect = axis === 0 ? intersectX : intersectY;\n let len = geom.start;\n let segLen, t;\n\n for (let i = 0; i < geom.length - 3; i += 3) {\n const ax = geom[i];\n const ay = geom[i + 1];\n const az = geom[i + 2];\n const bx = geom[i + 3];\n const by = geom[i + 4];\n const a = axis === 0 ? ax : ay;\n const b = axis === 0 ? bx : by;\n let exited = false;\n\n if (trackMetrics) segLen = Math.sqrt(Math.pow(ax - bx, 2) + Math.pow(ay - by, 2));\n\n if (a < k1) {\n // ---|--> | (line enters the clip region from the left)\n if (b > k1) {\n t = intersect(slice, ax, ay, bx, by, k1);\n if (trackMetrics) slice.start = len + segLen * t;\n }\n } else if (a > k2) {\n // | <--|--- (line enters the clip region from the right)\n if (b < k2) {\n t = intersect(slice, ax, ay, bx, by, k2);\n if (trackMetrics) slice.start = len + segLen * t;\n }\n } else {\n addPoint(slice, ax, ay, az);\n }\n if (b < k1 && a >= k1) {\n // <--|--- | or <--|-----|--- (line exits the clip region on the left)\n t = intersect(slice, ax, ay, bx, by, k1);\n exited = true;\n }\n if (b > k2 && a <= k2) {\n // | ---|--> or ---|-----|--> (line exits the clip region on the right)\n t = intersect(slice, ax, ay, bx, by, k2);\n exited = true;\n }\n\n if (!isPolygon && exited) {\n if (trackMetrics) slice.end = len + segLen * t;\n newGeom.push(slice);\n slice = newSlice(geom);\n }\n\n if (trackMetrics) len += segLen;\n }\n\n // add the last point\n let last = geom.length - 3;\n const ax = geom[last];\n const ay = geom[last + 1];\n const az = geom[last + 2];\n const a = axis === 0 ? ax : ay;\n if (a >= k1 && a <= k2) addPoint(slice, ax, ay, az);\n\n // close the polygon if its endpoints are not the same after clipping\n last = slice.length - 3;\n if (isPolygon && last >= 3 && (slice[last] !== slice[0] || slice[last + 1] !== slice[1])) {\n addPoint(slice, slice[0], slice[1], slice[2]);\n }\n\n // add the final slice\n if (slice.length) {\n newGeom.push(slice);\n }\n}\n\nfunction newSlice(line) {\n const slice = [];\n slice.size = line.size;\n slice.start = line.start;\n slice.end = line.end;\n return slice;\n}\n\nfunction clipLines(geom, newGeom, k1, k2, axis, isPolygon) {\n for (const line of geom) {\n clipLine(line, newGeom, k1, k2, axis, isPolygon, false);\n }\n}\n\nfunction addPoint(out, x, y, z) {\n out.push(x, y, z);\n}\n\nfunction intersectX(out, ax, ay, bx, by, x) {\n const t = (x - ax) / (bx - ax);\n addPoint(out, x, ay + (by - ay) * t, 1);\n return t;\n}\n\nfunction intersectY(out, ax, ay, bx, by, y) {\n const t = (y - ay) / (by - ay);\n addPoint(out, ax + (bx - ax) * t, y, 1);\n return t;\n}\n","\nimport clip from './clip.js';\nimport createFeature from './feature.js';\n\nexport default function wrap(features, options) {\n const buffer = options.buffer / options.extent;\n let merged = features;\n const left = clip(features, 1, -1 - buffer, buffer, 0, -1, 2, options); // left world copy\n const right = clip(features, 1, 1 - buffer, 2 + buffer, 0, -1, 2, options); // right world copy\n\n if (left || right) {\n merged = clip(features, 1, -buffer, 1 + buffer, 0, -1, 2, options) || []; // center world copy\n\n if (left) merged = shiftFeatureCoords(left, 1).concat(merged); // merge left into center\n if (right) merged = merged.concat(shiftFeatureCoords(right, -1)); // merge right into center\n }\n\n return merged;\n}\n\nfunction shiftFeatureCoords(features, offset) {\n const newFeatures = [];\n\n for (let i = 0; i < features.length; i++) {\n const feature = features[i];\n const type = feature.type;\n\n let newGeometry;\n\n if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {\n newGeometry = shiftCoords(feature.geometry, offset);\n\n } else if (type === 'MultiLineString' || type === 'Polygon') {\n newGeometry = [];\n for (const line of feature.geometry) {\n newGeometry.push(shiftCoords(line, offset));\n }\n } else if (type === 'MultiPolygon') {\n newGeometry = [];\n for (const polygon of feature.geometry) {\n const newPolygon = [];\n for (const line of polygon) {\n newPolygon.push(shiftCoords(line, offset));\n }\n newGeometry.push(newPolygon);\n }\n }\n\n newFeatures.push(createFeature(feature.id, type, newGeometry, feature.tags));\n }\n\n return newFeatures;\n}\n\nfunction shiftCoords(points, offset) {\n const newPoints = [];\n newPoints.size = points.size;\n\n if (points.start !== undefined) {\n newPoints.start = points.start;\n newPoints.end = points.end;\n }\n\n for (let i = 0; i < points.length; i += 3) {\n newPoints.push(points[i] + offset, points[i + 1], points[i + 2]);\n }\n return newPoints;\n}\n","\n// Transforms the coordinates of each feature in the given tile from\n// mercator-projected space into (extent x extent) tile space.\nexport default function transformTile(tile, extent) {\n if (tile.transformed) return tile;\n\n const z2 = 1 << tile.z;\n const tx = tile.x;\n const ty = tile.y;\n\n for (const feature of tile.features) {\n const geom = feature.geometry;\n const type = feature.type;\n\n feature.geometry = [];\n\n if (type === 1) {\n for (let j = 0; j < geom.length; j += 2) {\n feature.geometry.push(transformPoint(geom[j], geom[j + 1], extent, z2, tx, ty));\n }\n } else {\n for (let j = 0; j < geom.length; j++) {\n const ring = [];\n for (let k = 0; k < geom[j].length; k += 2) {\n ring.push(transformPoint(geom[j][k], geom[j][k + 1], extent, z2, tx, ty));\n }\n feature.geometry.push(ring);\n }\n }\n }\n\n tile.transformed = true;\n\n return tile;\n}\n\nfunction transformPoint(x, y, extent, z2, tx, ty) {\n return [\n Math.round(extent * (x * z2 - tx)),\n Math.round(extent * (y * z2 - ty))];\n}\n","\nexport default function createTile(features, z, tx, ty, options) {\n const tolerance = z === options.maxZoom ? 0 : options.tolerance / ((1 << z) * options.extent);\n const tile = {\n features: [],\n numPoints: 0,\n numSimplified: 0,\n numFeatures: features.length,\n source: null,\n x: tx,\n y: ty,\n z,\n transformed: false,\n minX: 2,\n minY: 1,\n maxX: -1,\n maxY: 0\n };\n for (const feature of features) {\n addFeature(tile, feature, tolerance, options);\n }\n return tile;\n}\n\nfunction addFeature(tile, feature, tolerance, options) {\n const geom = feature.geometry;\n const type = feature.type;\n const simplified = [];\n\n tile.minX = Math.min(tile.minX, feature.minX);\n tile.minY = Math.min(tile.minY, feature.minY);\n tile.maxX = Math.max(tile.maxX, feature.maxX);\n tile.maxY = Math.max(tile.maxY, feature.maxY);\n\n if (type === 'Point' || type === 'MultiPoint') {\n for (let i = 0; i < geom.length; i += 3) {\n simplified.push(geom[i], geom[i + 1]);\n tile.numPoints++;\n tile.numSimplified++;\n }\n\n } else if (type === 'LineString') {\n addLine(simplified, geom, tile, tolerance, false, false);\n\n } else if (type === 'MultiLineString' || type === 'Polygon') {\n for (let i = 0; i < geom.length; i++) {\n addLine(simplified, geom[i], tile, tolerance, type === 'Polygon', i === 0);\n }\n\n } else if (type === 'MultiPolygon') {\n\n for (let k = 0; k < geom.length; k++) {\n const polygon = geom[k];\n for (let i = 0; i < polygon.length; i++) {\n addLine(simplified, polygon[i], tile, tolerance, true, i === 0);\n }\n }\n }\n\n if (simplified.length) {\n let tags = feature.tags || null;\n\n if (type === 'LineString' && options.lineMetrics) {\n tags = {};\n for (const key in feature.tags) tags[key] = feature.tags[key];\n tags['mapbox_clip_start'] = geom.start / geom.size;\n tags['mapbox_clip_end'] = geom.end / geom.size;\n }\n\n const tileFeature = {\n geometry: simplified,\n type: type === 'Polygon' || type === 'MultiPolygon' ? 3 :\n (type === 'LineString' || type === 'MultiLineString' ? 2 : 1),\n tags\n };\n if (feature.id !== null) {\n tileFeature.id = feature.id;\n }\n tile.features.push(tileFeature);\n }\n}\n\nfunction addLine(result, geom, tile, tolerance, isPolygon, isOuter) {\n const sqTolerance = tolerance * tolerance;\n\n if (tolerance > 0 && (geom.size < (isPolygon ? sqTolerance : tolerance))) {\n tile.numPoints += geom.length / 3;\n return;\n }\n\n const ring = [];\n\n for (let i = 0; i < geom.length; i += 3) {\n if (tolerance === 0 || geom[i + 2] > sqTolerance) {\n tile.numSimplified++;\n ring.push(geom[i], geom[i + 1]);\n }\n tile.numPoints++;\n }\n\n if (isPolygon) rewind(ring, isOuter);\n\n result.push(ring);\n}\n\nfunction rewind(ring, clockwise) {\n let area = 0;\n for (let i = 0, len = ring.length, j = len - 2; i < len; j = i, i += 2) {\n area += (ring[i] - ring[j]) * (ring[i + 1] + ring[j + 1]);\n }\n if (area > 0 === clockwise) {\n for (let i = 0, len = ring.length; i < len / 2; i += 2) {\n const x = ring[i];\n const y = ring[i + 1];\n ring[i] = ring[len - 2 - i];\n ring[i + 1] = ring[len - 1 - i];\n ring[len - 2 - i] = x;\n ring[len - 1 - i] = y;\n }\n }\n}\n","\nimport convert from './convert.js'; // GeoJSON conversion and preprocessing\nimport clip from './clip.js'; // stripe clipping algorithm\nimport wrap from './wrap.js'; // date line processing\nimport transform from './transform.js'; // coordinate transformation\nimport createTile from './tile.js'; // final simplified tile generation\n\nconst defaultOptions = {\n maxZoom: 14, // max zoom to preserve detail on\n indexMaxZoom: 5, // max zoom in the tile index\n indexMaxPoints: 100000, // max number of points per tile in the tile index\n tolerance: 3, // simplification tolerance (higher means simpler)\n extent: 4096, // tile extent\n buffer: 64, // tile buffer on each side\n lineMetrics: false, // whether to calculate line metrics\n promoteId: null, // name of a feature property to be promoted to feature.id\n generateId: false, // whether to generate feature ids. Cannot be used with promoteId\n debug: 0 // logging level (0, 1 or 2)\n};\n\nclass GeoJSONVT {\n constructor(data, options) {\n options = this.options = extend(Object.create(defaultOptions), options);\n\n const debug = options.debug;\n\n if (debug) console.time('preprocess data');\n\n if (options.maxZoom < 0 || options.maxZoom > 24) throw new Error('maxZoom should be in the 0-24 range');\n if (options.promoteId && options.generateId) throw new Error('promoteId and generateId cannot be used together.');\n\n // projects and adds simplification info\n let features = convert(data, options);\n\n // tiles and tileCoords are part of the public API\n this.tiles = {};\n this.tileCoords = [];\n\n if (debug) {\n console.timeEnd('preprocess data');\n console.log('index: maxZoom: %d, maxPoints: %d', options.indexMaxZoom, options.indexMaxPoints);\n console.time('generate tiles');\n this.stats = {};\n this.total = 0;\n }\n\n // wraps features (ie extreme west and extreme east)\n features = wrap(features, options);\n\n // start slicing from the top tile down\n if (features.length) this.splitTile(features, 0, 0, 0);\n\n if (debug) {\n if (features.length) console.log('features: %d, points: %d', this.tiles[0].numFeatures, this.tiles[0].numPoints);\n console.timeEnd('generate tiles');\n console.log('tiles generated:', this.total, JSON.stringify(this.stats));\n }\n }\n\n // splits features from a parent tile to sub-tiles.\n // z, x, and y are the coordinates of the parent tile\n // cz, cx, and cy are the coordinates of the target tile\n //\n // If no target tile is specified, splitting stops when we reach the maximum\n // zoom or the number of points is low as specified in the options.\n splitTile(features, z, x, y, cz, cx, cy) {\n\n const stack = [features, z, x, y];\n const options = this.options;\n const debug = options.debug;\n\n // avoid recursion by using a processing queue\n while (stack.length) {\n y = stack.pop();\n x = stack.pop();\n z = stack.pop();\n features = stack.pop();\n\n const z2 = 1 << z;\n const id = toID(z, x, y);\n let tile = this.tiles[id];\n\n if (!tile) {\n if (debug > 1) console.time('creation');\n\n tile = this.tiles[id] = createTile(features, z, x, y, options);\n this.tileCoords.push({z, x, y});\n\n if (debug) {\n if (debug > 1) {\n console.log('tile z%d-%d-%d (features: %d, points: %d, simplified: %d)',\n z, x, y, tile.numFeatures, tile.numPoints, tile.numSimplified);\n console.timeEnd('creation');\n }\n const key = `z${ z}`;\n this.stats[key] = (this.stats[key] || 0) + 1;\n this.total++;\n }\n }\n\n // save reference to original geometry in tile so that we can drill down later if we stop now\n tile.source = features;\n\n // if it's the first-pass tiling\n if (cz == null) {\n // stop tiling if we reached max zoom, or if the tile is too simple\n if (z === options.indexMaxZoom || tile.numPoints <= options.indexMaxPoints) continue;\n // if a drilldown to a specific tile\n } else if (z === options.maxZoom || z === cz) {\n // stop tiling if we reached base zoom or our target tile zoom\n continue;\n } else if (cz != null) {\n // stop tiling if it's not an ancestor of the target tile\n const zoomSteps = cz - z;\n if (x !== cx >> zoomSteps || y !== cy >> zoomSteps) continue;\n }\n\n // if we slice further down, no need to keep source geometry\n tile.source = null;\n\n if (features.length === 0) continue;\n\n if (debug > 1) console.time('clipping');\n\n // values we'll use for clipping\n const k1 = 0.5 * options.buffer / options.extent;\n const k2 = 0.5 - k1;\n const k3 = 0.5 + k1;\n const k4 = 1 + k1;\n\n let tl = null;\n let bl = null;\n let tr = null;\n let br = null;\n\n let left = clip(features, z2, x - k1, x + k3, 0, tile.minX, tile.maxX, options);\n let right = clip(features, z2, x + k2, x + k4, 0, tile.minX, tile.maxX, options);\n features = null;\n\n if (left) {\n tl = clip(left, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);\n bl = clip(left, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);\n left = null;\n }\n\n if (right) {\n tr = clip(right, z2, y - k1, y + k3, 1, tile.minY, tile.maxY, options);\n br = clip(right, z2, y + k2, y + k4, 1, tile.minY, tile.maxY, options);\n right = null;\n }\n\n if (debug > 1) console.timeEnd('clipping');\n\n stack.push(tl || [], z + 1, x * 2, y * 2);\n stack.push(bl || [], z + 1, x * 2, y * 2 + 1);\n stack.push(tr || [], z + 1, x * 2 + 1, y * 2);\n stack.push(br || [], z + 1, x * 2 + 1, y * 2 + 1);\n }\n }\n\n getTile(z, x, y) {\n z = +z;\n x = +x;\n y = +y;\n\n const options = this.options;\n const {extent, debug} = options;\n\n if (z < 0 || z > 24) return null;\n\n const z2 = 1 << z;\n x = (x + z2) & (z2 - 1); // wrap tile x coordinate\n\n const id = toID(z, x, y);\n if (this.tiles[id]) return transform(this.tiles[id], extent);\n\n if (debug > 1) console.log('drilling down to z%d-%d-%d', z, x, y);\n\n let z0 = z;\n let x0 = x;\n let y0 = y;\n let parent;\n\n while (!parent && z0 > 0) {\n z0--;\n x0 = x0 >> 1;\n y0 = y0 >> 1;\n parent = this.tiles[toID(z0, x0, y0)];\n }\n\n if (!parent || !parent.source) return null;\n\n // if we found a parent tile containing the original geometry, we can drill down from it\n if (debug > 1) {\n console.log('found parent tile z%d-%d-%d', z0, x0, y0);\n console.time('drilling down');\n }\n this.splitTile(parent.source, z0, x0, y0, z, x, y);\n if (debug > 1) console.timeEnd('drilling down');\n\n return this.tiles[id] ? transform(this.tiles[id], extent) : null;\n }\n}\n\nfunction toID(z, x, y) {\n return (((1 << z) * y + x) * 32) + z;\n}\n\nfunction extend(dest, src) {\n for (const i in src) dest[i] = src[i];\n return dest;\n}\n\nexport default function geojsonvt(data, options) {\n return new GeoJSONVT(data, options);\n}\n","import e from\"pbf\";import t from\"@mapbox/point-geometry\";class i{constructor(e,t){this.feature=e,this.type=e.type,this.properties=e.tags?e.tags:{},this.extent=t,\"id\"in e&&(\"string\"==typeof e.id?this.id=parseInt(e.id,10):\"number\"!=typeof e.id||isNaN(e.id)||(this.id=e.id))}loadGeometry(){const e=[],i=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const n of i){const i=[];for(const e of n)i.push(new t(e[0],e[1]));e.push(i)}return e}}const n=\"_geojsonTileLayer\";class r{constructor(e,t){this.layers={[n]:this},this.name=n,this.version=t?t.version:1,this.extent=t?t.extent:4096,this.length=e.length,this.features=e}feature(e){return new i(this.features[e],this.extent)}}function o(t){const i=new e;return function(e,t){for(const i in e.layers)t.writeMessage(3,a,e.layers[i])}(t,i),i.finish()}function s(e,t){const i={};for(const n in e)i[n]=new r(e[n].features,t),i[n].name=n,i[n].version=t?t.version:1,i[n].extent=t?t.extent:4096;return o({layers:i})}function a(e,t){t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||\"\"),t.writeVarintField(5,e.extent||4096);const i={keys:[],values:[],keycache:{},valuecache:{}};for(let n=0;n<e.length;n++)i.feature=e.feature(n),t.writeMessage(2,f,i);const n=i.keys;for(const e of n)t.writeStringField(3,e);const r=i.values;for(const e of r)t.writeMessage(4,y,e)}function f(e,t){if(!e.feature)return;const i=e.feature;void 0!==i.id&&t.writeVarintField(1,i.id),t.writeMessage(2,c,e),t.writeVarintField(3,i.type),t.writeMessage(4,h,i)}function c(e,t){for(const i in e.feature?.properties){let n=e.feature.properties[i],r=e.keycache[i];if(null==n)continue;void 0===r&&(e.keys.push(i),r=e.keys.length-1,e.keycache[i]=r),t.writeVarint(r),\"string\"!=typeof n&&\"boolean\"!=typeof n&&\"number\"!=typeof n&&(n=JSON.stringify(n));const o=typeof n+\":\"+n;let s=e.valuecache[o];void 0===s&&(e.values.push(n),s=e.values.length-1,e.valuecache[o]=s),t.writeVarint(s)}}function u(e,t){return(t<<3)+(7&e)}function l(e){return e<<1^e>>31}function h(e,t){const i=e.loadGeometry(),n=e.type;let r=0,o=0;for(const s of i){let i=1;1===n&&(i=s.length),t.writeVarint(u(1,i));const a=3===n?s.length-1:s.length;for(let e=0;e<a;e++){1===e&&1!==n&&t.writeVarint(u(2,a-1));const i=s[e].x-r,f=s[e].y-o;t.writeVarint(l(i)),t.writeVarint(l(f)),r+=i,o+=f}3===e.type&&t.writeVarint(u(7,1))}}function y(e,t){const i=typeof e;\"string\"===i?t.writeStringField(1,e):\"boolean\"===i?t.writeBooleanField(7,e):\"number\"===i&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e))}export{n as GEOJSON_TILE_LAYER_NAME,r as GeoJSONWrapper,s as fromGeojsonVt,o as fromVectorTileJs};\n//# sourceMappingURL=index.es.js.map\n","/**\n * The maximum value of a coordinate in the internal tile coordinate system. Coordinates of\n * all source features normalized to this extent upon load.\n *\n * The value is a consequence of the following:\n *\n * * Vertex buffer store positions as signed 16 bit integers.\n * * One bit is lost for signedness to support tile buffers.\n * * One bit is lost because the line vertex buffer used to pack 1 bit of other data into the int.\n * * One bit is lost to support features extending past the extent on the right edge of the tile.\n * * This leaves us with 2^13 = 8192\n */\nexport const EXTENT = 8192;","import { ISource } from \"./ISource\";\r\nimport { registerSource } from \"./registerSource\";\r\nimport geojsonvt from \"geojson-vt\";\r\nimport { GeoJSONWrapper } from '@maplibre/vt-pbf'\r\nimport { EXTENT } from 'maplibre-gl/src/data/extent';\r\n\r\nexport class GeoJSONSource extends ISource {\r\n constructor(styleSource, path) {\r\n super(styleSource, path)\r\n }\r\n\r\n async init() {\r\n /**@type {import(\"@maplibre/maplibre-gl-style-spec\").GeoJSONSourceSpecification} */\r\n const sourceParams = this.styleSource\r\n let data = sourceParams.data\r\n if (typeof data === 'string') {\r\n const url = /^((http)|(https)|(data:)|\\/)/.test(data) ? data : this.path + data\r\n try {\r\n data = await Cesium.Resource.fetchJson(url)\r\n } catch (err) {\r\n this.errorEvent.raiseEvent(err)\r\n }\r\n }\r\n if (data && data.features?.length) {\r\n this.tileIndex = new geojsonvt(data, {\r\n extent: EXTENT,\r\n buffer: sourceParams.buffer === undefined ? 128 : sourceParams.buffer,\r\n tolerance: sourceParams.tolerance === sourceParams.tolerance ? 0.375 : sourceParams.tolerance\r\n })\r\n }\r\n }\r\n\r\n async requestTile(x, y, z) {\r\n if (!this.tileIndex) return\r\n try {\r\n const geoJSONTile = this.tileIndex.getTile(z, x, y)\r\n if (!geoJSONTile) return\r\n const geojsonWrapper = new GeoJSONWrapper(geoJSONTile.features, { extent: EXTENT });\r\n return geojsonWrapper\r\n } catch (err) {\r\n this.errorEvent.raiseEvent(err)\r\n }\r\n }\r\n}\r\n\r\nregisterSource('geojson', GeoJSONSource)","var $version = 8;\nvar $root = {\n\tversion: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: [\n\t\t\t8\n\t\t]\n\t},\n\tname: {\n\t\ttype: \"string\"\n\t},\n\tmetadata: {\n\t\ttype: \"*\"\n\t},\n\tcenter: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2\n\t},\n\tcenterAltitude: {\n\t\ttype: \"number\"\n\t},\n\tzoom: {\n\t\ttype: \"number\"\n\t},\n\tbearing: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\"\n\t},\n\tpitch: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tunits: \"degrees\"\n\t},\n\troll: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tunits: \"degrees\"\n\t},\n\tstate: {\n\t\ttype: \"state\",\n\t\t\"default\": {\n\t\t}\n\t},\n\tlight: {\n\t\ttype: \"light\"\n\t},\n\tsky: {\n\t\ttype: \"sky\"\n\t},\n\tprojection: {\n\t\ttype: \"projection\"\n\t},\n\tterrain: {\n\t\ttype: \"terrain\"\n\t},\n\tsources: {\n\t\trequired: true,\n\t\ttype: \"sources\"\n\t},\n\tsprite: {\n\t\ttype: \"sprite\"\n\t},\n\tglyphs: {\n\t\ttype: \"string\"\n\t},\n\t\"font-faces\": {\n\t\ttype: \"fontFaces\"\n\t},\n\ttransition: {\n\t\ttype: \"transition\"\n\t},\n\tlayers: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tvalue: \"layer\"\n\t}\n};\nvar sources = {\n\t\"*\": {\n\t\ttype: \"source\"\n\t}\n};\nvar source = [\n\t\"source_vector\",\n\t\"source_raster\",\n\t\"source_raster_dem\",\n\t\"source_geojson\",\n\t\"source_video\",\n\t\"source_image\"\n];\nvar source_vector = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvector: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tscheme: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\txyz: {\n\t\t\t},\n\t\t\ttms: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"xyz\"\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tpromoteId: {\n\t\ttype: \"promoteId\"\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tencoding: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmvt: {\n\t\t\t},\n\t\t\tmlt: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"mvt\"\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_raster = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\traster: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\ttileSize: {\n\t\ttype: \"number\",\n\t\t\"default\": 512,\n\t\tunits: \"pixels\"\n\t},\n\tscheme: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\txyz: {\n\t\t\t},\n\t\t\ttms: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"xyz\"\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_raster_dem = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\t\"raster-dem\": {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\ttype: \"string\"\n\t},\n\ttiles: {\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tbounds: {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t-180,\n\t\t\t-85.051129,\n\t\t\t180,\n\t\t\t85.051129\n\t\t]\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 22\n\t},\n\ttileSize: {\n\t\ttype: \"number\",\n\t\t\"default\": 512,\n\t\tunits: \"pixels\"\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tencoding: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tterrarium: {\n\t\t\t},\n\t\t\tmapbox: {\n\t\t\t},\n\t\t\tcustom: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"mapbox\"\n\t},\n\tredFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tblueFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tgreenFactor: {\n\t\ttype: \"number\",\n\t\t\"default\": 1\n\t},\n\tbaseShift: {\n\t\ttype: \"number\",\n\t\t\"default\": 0\n\t},\n\tvolatile: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\t\"*\": {\n\t\ttype: \"*\"\n\t}\n};\nvar source_geojson = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tgeojson: {\n\t\t\t}\n\t\t}\n\t},\n\tdata: {\n\t\trequired: true,\n\t\ttype: \"*\"\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\t\"default\": 18\n\t},\n\tattribution: {\n\t\ttype: \"string\"\n\t},\n\tbuffer: {\n\t\ttype: \"number\",\n\t\t\"default\": 128,\n\t\tmaximum: 512,\n\t\tminimum: 0\n\t},\n\tfilter: {\n\t\ttype: \"filter\"\n\t},\n\ttolerance: {\n\t\ttype: \"number\",\n\t\t\"default\": 0.375\n\t},\n\tcluster: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tclusterRadius: {\n\t\ttype: \"number\",\n\t\t\"default\": 50,\n\t\tminimum: 0\n\t},\n\tclusterMaxZoom: {\n\t\ttype: \"number\"\n\t},\n\tclusterMinPoints: {\n\t\ttype: \"number\"\n\t},\n\tclusterProperties: {\n\t\ttype: \"*\"\n\t},\n\tlineMetrics: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tgenerateId: {\n\t\ttype: \"boolean\",\n\t\t\"default\": false\n\t},\n\tpromoteId: {\n\t\ttype: \"promoteId\"\n\t}\n};\nvar source_video = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvideo: {\n\t\t\t}\n\t\t}\n\t},\n\turls: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tvalue: \"string\"\n\t},\n\tcoordinates: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tlength: 4,\n\t\tvalue: {\n\t\t\ttype: \"array\",\n\t\t\tlength: 2,\n\t\t\tvalue: \"number\"\n\t\t}\n\t}\n};\nvar source_image = {\n\ttype: {\n\t\trequired: true,\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\timage: {\n\t\t\t}\n\t\t}\n\t},\n\turl: {\n\t\trequired: true,\n\t\ttype: \"string\"\n\t},\n\tcoordinates: {\n\t\trequired: true,\n\t\ttype: \"array\",\n\t\tlength: 4,\n\t\tvalue: {\n\t\t\ttype: \"array\",\n\t\t\tlength: 2,\n\t\t\tvalue: \"number\"\n\t\t}\n\t}\n};\nvar layer = {\n\tid: {\n\t\ttype: \"string\",\n\t\trequired: true\n\t},\n\ttype: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tfill: {\n\t\t\t},\n\t\t\tline: {\n\t\t\t},\n\t\t\tsymbol: {\n\t\t\t},\n\t\t\tcircle: {\n\t\t\t},\n\t\t\theatmap: {\n\t\t\t},\n\t\t\t\"fill-extrusion\": {\n\t\t\t},\n\t\t\traster: {\n\t\t\t},\n\t\t\thillshade: {\n\t\t\t},\n\t\t\t\"color-relief\": {\n\t\t\t},\n\t\t\tbackground: {\n\t\t\t}\n\t\t},\n\t\trequired: true\n\t},\n\tmetadata: {\n\t\ttype: \"*\"\n\t},\n\tsource: {\n\t\ttype: \"string\"\n\t},\n\t\"source-layer\": {\n\t\ttype: \"string\"\n\t},\n\tminzoom: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\tmaximum: 24\n\t},\n\tmaxzoom: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\tmaximum: 24\n\t},\n\tfilter: {\n\t\ttype: \"filter\"\n\t},\n\tlayout: {\n\t\ttype: \"layout\"\n\t},\n\tpaint: {\n\t\ttype: \"paint\"\n\t}\n};\nvar layout = [\n\t\"layout_fill\",\n\t\"layout_line\",\n\t\"layout_circle\",\n\t\"layout_heatmap\",\n\t\"layout_fill-extrusion\",\n\t\"layout_symbol\",\n\t\"layout_raster\",\n\t\"layout_hillshade\",\n\t\"layout_color-relief\",\n\t\"layout_background\"\n];\nvar layout_background = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"global-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar layout_fill = {\n\t\"fill-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"global-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar layout_circle = {\n\t\"circle-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"global-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar layout_heatmap = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"global-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar layout_line = {\n\t\"line-cap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tbutt: {\n\t\t\t},\n\t\t\tround: {\n\t\t\t},\n\t\t\tsquare: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"butt\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-join\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tbevel: {\n\t\t\t},\n\t\t\tround: {\n\t\t\t},\n\t\t\tmiter: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"miter\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-miter-limit\": {\n\t\ttype: \"number\",\n\t\t\"default\": 2,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"line-join\": \"miter\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-round-limit\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1.05,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"line-join\": \"round\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"global-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar layout_symbol = {\n\t\"symbol-placement\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tpoint: {\n\t\t\t},\n\t\t\tline: {\n\t\t\t},\n\t\t\t\"line-center\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"point\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-spacing\": {\n\t\ttype: \"number\",\n\t\t\"default\": 250,\n\t\tminimum: 1,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"symbol-placement\": \"line\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-avoid-edges\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"symbol-sort-key\": {\n\t\ttype: \"number\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"symbol-z-order\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tauto: {\n\t\t\t},\n\t\t\t\"viewport-y\": {\n\t\t\t},\n\t\t\tsource: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-allow-overlap\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t{\n\t\t\t\t\"!\": \"icon-overlap\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-overlap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnever: {\n\t\t\t},\n\t\t\talways: {\n\t\t\t},\n\t\t\tcooperative: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-ignore-placement\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-optional\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-rotation-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-size\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tunits: \"factor of the original icon size\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-text-fit\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnone: {\n\t\t\t},\n\t\t\twidth: {\n\t\t\t},\n\t\t\theight: {\n\t\t\t},\n\t\t\tboth: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"none\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-text-fit-padding\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 4,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0,\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"icon-text-fit\": [\n\t\t\t\t\t\"both\",\n\t\t\t\t\t\"width\",\n\t\t\t\t\t\"height\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-image\": {\n\t\ttype: \"resolvedImage\",\n\t\ttokens: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-padding\": {\n\t\ttype: \"padding\",\n\t\t\"default\": [\n\t\t\t2\n\t\t],\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-keep-upright\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t{\n\t\t\t\t\"icon-rotation-alignment\": \"map\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-offset\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-rotation-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t},\n\t\t\t\"viewport-glyph\": {\n\t\t\t},\n\t\t\tauto: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"auto\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-field\": {\n\t\ttype: \"formatted\",\n\t\t\"default\": \"\",\n\t\ttokens: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-font\": {\n\t\ttype: \"array\",\n\t\tvalue: \"string\",\n\t\t\"default\": [\n\t\t\t\"Open Sans Regular\",\n\t\t\t\"Arial Unicode MS Regular\"\n\t\t],\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-size\": {\n\t\ttype: \"number\",\n\t\t\"default\": 16,\n\t\tminimum: 0,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-max-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 10,\n\t\tminimum: 0,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-line-height\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1.2,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-letter-spacing\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tunits: \"ems\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-justify\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tauto: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-radial-offset\": {\n\t\ttype: \"number\",\n\t\tunits: \"ems\",\n\t\t\"default\": 0,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\t\"property-type\": \"data-driven\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t}\n\t},\n\t\"text-variable-anchor\": {\n\t\ttype: \"array\",\n\t\tvalue: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-variable-anchor-offset\": {\n\t\ttype: \"variableAnchorOffsetCollection\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tcenter: {\n\t\t\t},\n\t\t\tleft: {\n\t\t\t},\n\t\t\tright: {\n\t\t\t},\n\t\t\ttop: {\n\t\t\t},\n\t\t\tbottom: {\n\t\t\t},\n\t\t\t\"top-left\": {\n\t\t\t},\n\t\t\t\"top-right\": {\n\t\t\t},\n\t\t\t\"bottom-left\": {\n\t\t\t},\n\t\t\t\"bottom-right\": {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"center\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-variable-anchor\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-max-angle\": {\n\t\ttype: \"number\",\n\t\t\"default\": 45,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-writing-mode\": {\n\t\ttype: \"array\",\n\t\tvalue: \"enum\",\n\t\tvalues: {\n\t\t\thorizontal: {\n\t\t\t},\n\t\t\tvertical: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"point\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\tunits: \"degrees\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-padding\": {\n\t\ttype: \"number\",\n\t\t\"default\": 2,\n\t\tminimum: 0,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-keep-upright\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"text-rotation-alignment\": \"map\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"symbol-placement\": [\n\t\t\t\t\t\"line\",\n\t\t\t\t\t\"line-center\"\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-transform\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnone: {\n\t\t\t},\n\t\t\tuppercase: {\n\t\t\t},\n\t\t\tlowercase: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"none\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-offset\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tunits: \"ems\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-radial-offset\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-allow-overlap\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t{\n\t\t\t\t\"!\": \"text-overlap\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-overlap\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tnever: {\n\t\t\t},\n\t\t\talways: {\n\t\t\t},\n\t\t\tcooperative: {\n\t\t\t}\n\t\t},\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-ignore-placement\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-optional\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": false,\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"global-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar layout_raster = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"global-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar layout_hillshade = {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"global-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar filter = {\n\ttype: \"boolean\",\n\texpression: {\n\t\tinterpolated: false,\n\t\tparameters: [\n\t\t\t\"zoom\",\n\t\t\t\"feature\"\n\t\t]\n\t},\n\t\"property-type\": \"data-driven\"\n};\nvar filter_operator = {\n\ttype: \"enum\",\n\tvalues: {\n\t\t\"==\": {\n\t\t},\n\t\t\"!=\": {\n\t\t},\n\t\t\">\": {\n\t\t},\n\t\t\">=\": {\n\t\t},\n\t\t\"<\": {\n\t\t},\n\t\t\"<=\": {\n\t\t},\n\t\t\"in\": {\n\t\t},\n\t\t\"!in\": {\n\t\t},\n\t\tall: {\n\t\t},\n\t\tany: {\n\t\t},\n\t\tnone: {\n\t\t},\n\t\thas: {\n\t\t},\n\t\t\"!has\": {\n\t\t}\n\t}\n};\nvar geometry_type = {\n\ttype: \"enum\",\n\tvalues: {\n\t\tPoint: {\n\t\t},\n\t\tLineString: {\n\t\t},\n\t\tPolygon: {\n\t\t}\n\t}\n};\nvar function_stop = {\n\ttype: \"array\",\n\tminimum: 0,\n\tmaximum: 24,\n\tvalue: [\n\t\t\"number\",\n\t\t\"color\"\n\t],\n\tlength: 2\n};\nvar expression$1 = {\n\ttype: \"array\",\n\tvalue: \"expression_name\",\n\tminimum: 1\n};\nvar light = {\n\tanchor: {\n\t\ttype: \"enum\",\n\t\t\"default\": \"viewport\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t},\n\tposition: {\n\t\ttype: \"array\",\n\t\t\"default\": [\n\t\t\t1.15,\n\t\t\t210,\n\t\t\t30\n\t\t],\n\t\tlength: 3,\n\t\tvalue: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t},\n\tcolor: {\n\t\ttype: \"color\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": \"#ffffff\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\tintensity: {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t}\n};\nvar sky = {\n\t\"sky-color\": {\n\t\ttype: \"color\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": \"#88C6FC\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\t\"horizon-color\": {\n\t\ttype: \"color\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": \"#ffffff\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\t\"fog-color\": {\n\t\ttype: \"color\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": \"#ffffff\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\t\"fog-ground-blend\": {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\t\"horizon-fog-blend\": {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.8,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\t\"sky-horizon-blend\": {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.8,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t},\n\t\"atmosphere-blend\": {\n\t\ttype: \"number\",\n\t\t\"property-type\": \"data-constant\",\n\t\t\"default\": 0.8,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\ttransition: true\n\t}\n};\nvar terrain = {\n\tsource: {\n\t\ttype: \"string\",\n\t\trequired: true\n\t},\n\texaggeration: {\n\t\ttype: \"number\",\n\t\tminimum: 0,\n\t\t\"default\": 1\n\t}\n};\nvar projection = {\n\ttype: {\n\t\ttype: \"projectionDefinition\",\n\t\t\"default\": \"mercator\",\n\t\t\"property-type\": \"data-constant\",\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t}\n\t}\n};\nvar paint = [\n\t\"paint_fill\",\n\t\"paint_line\",\n\t\"paint_circle\",\n\t\"paint_heatmap\",\n\t\"paint_fill-extrusion\",\n\t\"paint_symbol\",\n\t\"paint_raster\",\n\t\"paint_hillshade\",\n\t\"paint_color-relief\",\n\t\"paint_background\"\n];\nvar paint_fill = {\n\t\"fill-antialias\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-outline-color\": {\n\t\ttype: \"color\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-pattern\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"fill-antialias\": true\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"fill-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t}\n};\nvar paint_line = {\n\t\"line-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"line-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"line-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-gap-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-offset\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"line-dasharray\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"line widths\",\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"line-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"line-gradient\": {\n\t\ttype: \"color\",\n\t\ttransition: false,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"line-dasharray\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"!\": \"line-pattern\"\n\t\t\t},\n\t\t\t{\n\t\t\t\tsource: \"geojson\",\n\t\t\t\thas: {\n\t\t\t\t\tlineMetrics: true\n\t\t\t\t}\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"line-progress\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t}\n};\nvar paint_circle = {\n\t\"circle-radius\": {\n\t\ttype: \"number\",\n\t\t\"default\": 5,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"circle-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-pitch-scale\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-pitch-alignment\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"viewport\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"circle-stroke-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-stroke-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"circle-stroke-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t}\n};\nvar paint_heatmap = {\n\t\"heatmap-radius\": {\n\t\ttype: \"number\",\n\t\t\"default\": 30,\n\t\tminimum: 1,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"heatmap-weight\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"heatmap-intensity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"heatmap-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": [\n\t\t\t\"interpolate\",\n\t\t\t[\n\t\t\t\t\"linear\"\n\t\t\t],\n\t\t\t[\n\t\t\t\t\"heatmap-density\"\n\t\t\t],\n\t\t\t0,\n\t\t\t\"rgba(0, 0, 255, 0)\",\n\t\t\t0.1,\n\t\t\t\"royalblue\",\n\t\t\t0.3,\n\t\t\t\"cyan\",\n\t\t\t0.5,\n\t\t\t\"lime\",\n\t\t\t0.7,\n\t\t\t\"yellow\",\n\t\t\t1,\n\t\t\t\"red\"\n\t\t],\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"heatmap-density\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t},\n\t\"heatmap-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_symbol = {\n\t\"icon-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"rgba(0, 0, 0, 0)\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-halo-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"icon-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"icon-image\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"icon-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"icon-image\",\n\t\t\t\"icon-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\toverridable: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"rgba(0, 0, 0, 0)\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-width\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-halo-blur\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"text-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\trequires: [\n\t\t\t\"text-field\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"text-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"text-field\",\n\t\t\t\"text-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_raster = {\n\t\"raster-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-hue-rotate\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tperiod: 360,\n\t\ttransition: true,\n\t\tunits: \"degrees\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-brightness-min\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-brightness-max\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-saturation\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: -1,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-contrast\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: -1,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-resampling\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tlinear: {\n\t\t\t},\n\t\t\tnearest: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"linear\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"raster-fade-duration\": {\n\t\ttype: \"number\",\n\t\t\"default\": 300,\n\t\tminimum: 0,\n\t\ttransition: false,\n\t\tunits: \"milliseconds\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_hillshade = {\n\t\"hillshade-illumination-direction\": {\n\t\ttype: \"numberArray\",\n\t\t\"default\": 335,\n\t\tminimum: 0,\n\t\tmaximum: 359,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-illumination-altitude\": {\n\t\ttype: \"numberArray\",\n\t\t\"default\": 45,\n\t\tminimum: 0,\n\t\tmaximum: 90,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-illumination-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"viewport\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-exaggeration\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0.5,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-shadow-color\": {\n\t\ttype: \"colorArray\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-highlight-color\": {\n\t\ttype: \"colorArray\",\n\t\t\"default\": \"#FFFFFF\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-accent-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"hillshade-method\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tstandard: {\n\t\t\t},\n\t\t\tbasic: {\n\t\t\t},\n\t\t\tcombined: {\n\t\t\t},\n\t\t\tigor: {\n\t\t\t},\n\t\t\tmultidirectional: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"standard\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar paint_background = {\n\t\"background-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"background-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"background-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded\"\n\t},\n\t\"background-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n};\nvar transition = {\n\tduration: {\n\t\ttype: \"number\",\n\t\t\"default\": 300,\n\t\tminimum: 0,\n\t\tunits: \"milliseconds\"\n\t},\n\tdelay: {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"milliseconds\"\n\t}\n};\nvar promoteId = {\n\t\"*\": {\n\t\ttype: \"string\"\n\t}\n};\nvar interpolation = {\n\ttype: \"array\",\n\tvalue: \"interpolation_name\",\n\tminimum: 1\n};\nvar interpolation_name = {\n\ttype: \"enum\",\n\tvalues: {\n\t\tlinear: {\n\t\t\tsyntax: {\n\t\t\t\toverloads: [\n\t\t\t\t\t{\n\t\t\t\t\t\tparameters: [\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"output-type\": \"interpolation\"\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tparameters: [\n\t\t\t\t]\n\t\t\t}\n\t\t},\n\t\texponential: {\n\t\t\tsyntax: {\n\t\t\t\toverloads: [\n\t\t\t\t\t{\n\t\t\t\t\t\tparameters: [\n\t\t\t\t\t\t\t\"base\"\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"output-type\": \"interpolation\"\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tparameters: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"base\",\n\t\t\t\t\t\ttype: \"number literal\"\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t},\n\t\t\"cubic-bezier\": {\n\t\t\tsyntax: {\n\t\t\t\toverloads: [\n\t\t\t\t\t{\n\t\t\t\t\t\tparameters: [\n\t\t\t\t\t\t\t\"x1\",\n\t\t\t\t\t\t\t\"y1\",\n\t\t\t\t\t\t\t\"x2\",\n\t\t\t\t\t\t\t\"y2\"\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"output-type\": \"interpolation\"\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\tparameters: [\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"x1\",\n\t\t\t\t\t\ttype: \"number literal\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"y1\",\n\t\t\t\t\t\ttype: \"number literal\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"x2\",\n\t\t\t\t\t\ttype: \"number literal\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tname: \"y2\",\n\t\t\t\t\t\ttype: \"number literal\"\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t}\n};\nvar v8Spec = {\n\t$version: $version,\n\t$root: $root,\n\tsources: sources,\n\tsource: source,\n\tsource_vector: source_vector,\n\tsource_raster: source_raster,\n\tsource_raster_dem: source_raster_dem,\n\tsource_geojson: source_geojson,\n\tsource_video: source_video,\n\tsource_image: source_image,\n\tlayer: layer,\n\tlayout: layout,\n\tlayout_background: layout_background,\n\tlayout_fill: layout_fill,\n\tlayout_circle: layout_circle,\n\tlayout_heatmap: layout_heatmap,\n\t\"layout_fill-extrusion\": {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"global-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n},\n\tlayout_line: layout_line,\n\tlayout_symbol: layout_symbol,\n\tlayout_raster: layout_raster,\n\tlayout_hillshade: layout_hillshade,\n\t\"layout_color-relief\": {\n\tvisibility: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tvisible: {\n\t\t\t},\n\t\t\tnone: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"visible\",\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"global-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n},\n\tfilter: filter,\n\tfilter_operator: filter_operator,\n\tgeometry_type: geometry_type,\n\t\"function\": {\n\texpression: {\n\t\ttype: \"expression\"\n\t},\n\tstops: {\n\t\ttype: \"array\",\n\t\tvalue: \"function_stop\"\n\t},\n\tbase: {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0\n\t},\n\tproperty: {\n\t\ttype: \"string\",\n\t\t\"default\": \"$zoom\"\n\t},\n\ttype: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tidentity: {\n\t\t\t},\n\t\t\texponential: {\n\t\t\t},\n\t\t\tinterval: {\n\t\t\t},\n\t\t\tcategorical: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"exponential\"\n\t},\n\tcolorSpace: {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\trgb: {\n\t\t\t},\n\t\t\tlab: {\n\t\t\t},\n\t\t\thcl: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"rgb\"\n\t},\n\t\"default\": {\n\t\ttype: \"*\",\n\t\trequired: false\n\t}\n},\n\tfunction_stop: function_stop,\n\texpression: expression$1,\n\tlight: light,\n\tsky: sky,\n\tterrain: terrain,\n\tprojection: projection,\n\tpaint: paint,\n\tpaint_fill: paint_fill,\n\t\"paint_fill-extrusion\": {\n\t\"fill-extrusion-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-color\": {\n\t\ttype: \"color\",\n\t\t\"default\": \"#000000\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t{\n\t\t\t\t\"!\": \"fill-extrusion-pattern\"\n\t\t\t}\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-translate\": {\n\t\ttype: \"array\",\n\t\tvalue: \"number\",\n\t\tlength: 2,\n\t\t\"default\": [\n\t\t\t0,\n\t\t\t0\n\t\t],\n\t\ttransition: true,\n\t\tunits: \"pixels\",\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-translate-anchor\": {\n\t\ttype: \"enum\",\n\t\tvalues: {\n\t\t\tmap: {\n\t\t\t},\n\t\t\tviewport: {\n\t\t\t}\n\t\t},\n\t\t\"default\": \"map\",\n\t\trequires: [\n\t\t\t\"fill-extrusion-translate\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"fill-extrusion-pattern\": {\n\t\ttype: \"resolvedImage\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"cross-faded-data-driven\"\n\t},\n\t\"fill-extrusion-height\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"meters\",\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-base\": {\n\t\ttype: \"number\",\n\t\t\"default\": 0,\n\t\tminimum: 0,\n\t\tunits: \"meters\",\n\t\ttransition: true,\n\t\trequires: [\n\t\t\t\"fill-extrusion-height\"\n\t\t],\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\",\n\t\t\t\t\"feature\",\n\t\t\t\t\"feature-state\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-driven\"\n\t},\n\t\"fill-extrusion-vertical-gradient\": {\n\t\ttype: \"boolean\",\n\t\t\"default\": true,\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: false,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t}\n},\n\tpaint_line: paint_line,\n\tpaint_circle: paint_circle,\n\tpaint_heatmap: paint_heatmap,\n\tpaint_symbol: paint_symbol,\n\tpaint_raster: paint_raster,\n\tpaint_hillshade: paint_hillshade,\n\t\"paint_color-relief\": {\n\t\"color-relief-opacity\": {\n\t\ttype: \"number\",\n\t\t\"default\": 1,\n\t\tminimum: 0,\n\t\tmaximum: 1,\n\t\ttransition: true,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"zoom\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"data-constant\"\n\t},\n\t\"color-relief-color\": {\n\t\ttype: \"color\",\n\t\ttransition: false,\n\t\texpression: {\n\t\t\tinterpolated: true,\n\t\t\tparameters: [\n\t\t\t\t\"elevation\"\n\t\t\t]\n\t\t},\n\t\t\"property-type\": \"color-ramp\"\n\t}\n},\n\tpaint_background: paint_background,\n\ttransition: transition,\n\t\"property-type\": {\n\t\"data-driven\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"cross-faded\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"cross-faded-data-driven\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"color-ramp\": {\n\t\ttype: \"property-type\"\n\t},\n\t\"data-constant\": {\n\t\ttype: \"property-type\"\n\t},\n\tconstant: {\n\t\ttype: \"property-type\"\n\t}\n},\n\tpromoteId: promoteId,\n\tinterpolation: interpolation,\n\tinterpolation_name: interpolation_name\n};\n\nconst refProperties = [\n 'type',\n 'source',\n 'source-layer',\n 'minzoom',\n 'maxzoom',\n 'filter',\n 'layout'\n];\n\nfunction deref(layer, parent) {\n const result = {};\n for (const k in layer) {\n if (k !== 'ref') {\n result[k] = layer[k];\n }\n }\n refProperties.forEach((k) => {\n if (k in parent) {\n result[k] = parent[k];\n }\n });\n return result;\n}\n/**\n *\n * The input is not modified. The output may contain references to portions\n * of the input.\n *\n * @param layers - array of layers, some of which may contain `ref` properties\n * whose value is the `id` of another property\n * @returns a new array where such layers have been augmented with the 'type', 'source', etc. properties\n * from the parent layer, and the `ref` property has been removed.\n */\nfunction derefLayers(layers) {\n layers = layers.slice();\n const map = Object.create(null);\n for (let i = 0; i < layers.length; i++) {\n map[layers[i].id] = layers[i];\n }\n for (let i = 0; i < layers.length; i++) {\n if ('ref' in layers[i]) {\n layers[i] = deref(layers[i], map[layers[i].ref]);\n }\n }\n return layers;\n}\n\n/**\n * Deeply compares two object literals.\n *\n * @private\n */\nfunction deepEqual(a, b) {\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i]))\n return false;\n }\n return true;\n }\n if (typeof a === 'object' && a !== null && b !== null) {\n if (!(typeof b === 'object'))\n return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length)\n return false;\n for (const key in a) {\n if (!deepEqual(a[key], b[key]))\n return false;\n }\n return true;\n }\n return a === b;\n}\n\n/**\n * The main reason for this method is to allow type check when adding a command to the array.\n * @param commands - The commands array to add to\n * @param command - The command to add\n */\nfunction addCommand(commands, command) {\n commands.push(command);\n}\nfunction addSource(sourceId, after, commands) {\n addCommand(commands, { command: 'addSource', args: [sourceId, after[sourceId]] });\n}\nfunction removeSource(sourceId, commands, sourcesRemoved) {\n addCommand(commands, { command: 'removeSource', args: [sourceId] });\n sourcesRemoved[sourceId] = true;\n}\nfunction updateSource(sourceId, after, commands, sourcesRemoved) {\n removeSource(sourceId, commands, sourcesRemoved);\n addSource(sourceId, after, commands);\n}\nfunction canUpdateGeoJSON(before, after, sourceId) {\n let prop;\n for (prop in before[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(before[sourceId], prop))\n continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n for (prop in after[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(after[sourceId], prop))\n continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n return true;\n}\nfunction diffSources(before, after, commands, sourcesRemoved) {\n before = before || {};\n after = after || {};\n let sourceId;\n // look for sources to remove\n for (sourceId in before) {\n if (!Object.prototype.hasOwnProperty.call(before, sourceId))\n continue;\n if (!Object.prototype.hasOwnProperty.call(after, sourceId)) {\n removeSource(sourceId, commands, sourcesRemoved);\n }\n }\n // look for sources to add/update\n for (sourceId in after) {\n if (!Object.prototype.hasOwnProperty.call(after, sourceId))\n continue;\n if (!Object.prototype.hasOwnProperty.call(before, sourceId)) {\n addSource(sourceId, after, commands);\n }\n else if (!deepEqual(before[sourceId], after[sourceId])) {\n if (before[sourceId].type === 'geojson' &&\n after[sourceId].type === 'geojson' &&\n canUpdateGeoJSON(before, after, sourceId)) {\n addCommand(commands, {\n command: 'setGeoJSONSourceData',\n args: [sourceId, after[sourceId].data]\n });\n }\n else {\n // no update command, must remove then add\n updateSource(sourceId, after, commands, sourcesRemoved);\n }\n }\n }\n}\nfunction diffLayerPropertyChanges(before, after, commands, layerId, klass, command) {\n before = before || {};\n after = after || {};\n for (const prop in before) {\n if (!Object.prototype.hasOwnProperty.call(before, prop))\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({ command, args: [layerId, prop, after[prop], klass] });\n }\n }\n for (const prop in after) {\n if (!Object.prototype.hasOwnProperty.call(after, prop) ||\n Object.prototype.hasOwnProperty.call(before, prop))\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({ command, args: [layerId, prop, after[prop], klass] });\n }\n }\n}\nfunction pluckId(layer) {\n return layer.id;\n}\nfunction indexById(group, layer) {\n group[layer.id] = layer;\n return group;\n}\nfunction diffLayers(before, after, commands) {\n before = before || [];\n after = after || [];\n // order of layers by id\n const beforeOrder = before.map(pluckId);\n const afterOrder = after.map(pluckId);\n // index of layer by id\n const beforeIndex = before.reduce(indexById, {});\n const afterIndex = after.reduce(indexById, {});\n // track order of layers as if they have been mutated\n const tracker = beforeOrder.slice();\n // layers that have been added do not need to be diffed\n const clean = Object.create(null);\n let layerId;\n let beforeLayer;\n let afterLayer;\n let insertBeforeLayerId;\n let prop;\n // remove layers\n for (let i = 0, d = 0; i < beforeOrder.length; i++) {\n layerId = beforeOrder[i];\n if (!Object.prototype.hasOwnProperty.call(afterIndex, layerId)) {\n addCommand(commands, { command: 'removeLayer', args: [layerId] });\n tracker.splice(tracker.indexOf(layerId, d), 1);\n }\n else {\n // limit where in tracker we need to look for a match\n d++;\n }\n }\n // add/reorder layers\n for (let i = 0, d = 0; i < afterOrder.length; i++) {\n // work backwards as insert is before an existing layer\n layerId = afterOrder[afterOrder.length - 1 - i];\n if (tracker[tracker.length - 1 - i] === layerId)\n continue;\n if (Object.prototype.hasOwnProperty.call(beforeIndex, layerId)) {\n // remove the layer before we insert at the correct position\n addCommand(commands, { command: 'removeLayer', args: [layerId] });\n tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1);\n }\n else {\n // limit where in tracker we need to look for a match\n d++;\n }\n // add layer at correct position\n insertBeforeLayerId = tracker[tracker.length - i];\n addCommand(commands, {\n command: 'addLayer',\n args: [afterIndex[layerId], insertBeforeLayerId]\n });\n tracker.splice(tracker.length - i, 0, layerId);\n clean[layerId] = true;\n }\n // update layers\n for (let i = 0; i < afterOrder.length; i++) {\n layerId = afterOrder[i];\n beforeLayer = beforeIndex[layerId];\n afterLayer = afterIndex[layerId];\n // no need to update if previously added (new or moved)\n if (clean[layerId] || deepEqual(beforeLayer, afterLayer))\n continue;\n // If source, source-layer, or type have changes, then remove the layer\n // and add it back 'from scratch'.\n if (!deepEqual(beforeLayer.source, afterLayer.source) ||\n !deepEqual(beforeLayer['source-layer'], afterLayer['source-layer']) ||\n !deepEqual(beforeLayer.type, afterLayer.type)) {\n addCommand(commands, { command: 'removeLayer', args: [layerId] });\n // we add the layer back at the same position it was already in, so\n // there's no need to update the `tracker`\n insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1];\n addCommand(commands, { command: 'addLayer', args: [afterLayer, insertBeforeLayerId] });\n continue;\n }\n // layout, paint, filter, minzoom, maxzoom\n diffLayerPropertyChanges(beforeLayer.layout, afterLayer.layout, commands, layerId, null, 'setLayoutProperty');\n diffLayerPropertyChanges(beforeLayer.paint, afterLayer.paint, commands, layerId, null, 'setPaintProperty');\n if (!deepEqual(beforeLayer.filter, afterLayer.filter)) {\n addCommand(commands, { command: 'setFilter', args: [layerId, afterLayer.filter] });\n }\n if (!deepEqual(beforeLayer.minzoom, afterLayer.minzoom) ||\n !deepEqual(beforeLayer.maxzoom, afterLayer.maxzoom)) {\n addCommand(commands, {\n command: 'setLayerZoomRange',\n args: [layerId, afterLayer.minzoom, afterLayer.maxzoom]\n });\n }\n // handle all other layer props, including paint.*\n for (prop in beforeLayer) {\n if (!Object.prototype.hasOwnProperty.call(beforeLayer, prop))\n continue;\n if (prop === 'layout' ||\n prop === 'paint' ||\n prop === 'filter' ||\n prop === 'metadata' ||\n prop === 'minzoom' ||\n prop === 'maxzoom')\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), 'setPaintProperty');\n }\n else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n addCommand(commands, {\n command: 'setLayerProperty',\n args: [layerId, prop, afterLayer[prop]]\n });\n }\n }\n for (prop in afterLayer) {\n if (!Object.prototype.hasOwnProperty.call(afterLayer, prop) ||\n Object.prototype.hasOwnProperty.call(beforeLayer, prop))\n continue;\n if (prop === 'layout' ||\n prop === 'paint' ||\n prop === 'filter' ||\n prop === 'metadata' ||\n prop === 'minzoom' ||\n prop === 'maxzoom')\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(beforeLayer[prop], afterLayer[prop], commands, layerId, prop.slice(6), 'setPaintProperty');\n }\n else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n addCommand(commands, {\n command: 'setLayerProperty',\n args: [layerId, prop, afterLayer[prop]]\n });\n }\n }\n }\n}\n/**\n * Diff two stylesheet\n *\n * Creates semanticly aware diffs that can easily be applied at runtime.\n * Operations produced by the diff closely resemble the maplibre-gl-js API. Any\n * error creating the diff will fall back to the 'setStyle' operation.\n *\n * Example diff:\n * [\n * { command: 'setConstant', args: ['@water', '#0000FF'] },\n * { command: 'setPaintProperty', args: ['background', 'background-color', 'black'] }\n * ]\n *\n * @private\n * @param {*} [before] stylesheet to compare from\n * @param {*} after stylesheet to compare to\n * @returns Array list of changes\n */\nfunction diff(before, after) {\n if (!before)\n return [{ command: 'setStyle', args: [after] }];\n let commands = [];\n try {\n // Handle changes to top-level properties\n if (!deepEqual(before.version, after.version)) {\n return [{ command: 'setStyle', args: [after] }];\n }\n if (!deepEqual(before.center, after.center)) {\n commands.push({ command: 'setCenter', args: [after.center] });\n }\n if (!deepEqual(before.state, after.state)) {\n commands.push({ command: 'setGlobalState', args: [after.state] });\n }\n if (!deepEqual(before.centerAltitude, after.centerAltitude)) {\n commands.push({ command: 'setCenterAltitude', args: [after.centerAltitude] });\n }\n if (!deepEqual(before.zoom, after.zoom)) {\n commands.push({ command: 'setZoom', args: [after.zoom] });\n }\n if (!deepEqual(before.bearing, after.bearing)) {\n commands.push({ command: 'setBearing', args: [after.bearing] });\n }\n if (!deepEqual(before.pitch, after.pitch)) {\n commands.push({ command: 'setPitch', args: [after.pitch] });\n }\n if (!deepEqual(before.roll, after.roll)) {\n commands.push({ command: 'setRoll', args: [after.roll] });\n }\n if (!deepEqual(before.sprite, after.sprite)) {\n commands.push({ command: 'setSprite', args: [after.sprite] });\n }\n if (!deepEqual(before.glyphs, after.glyphs)) {\n commands.push({ command: 'setGlyphs', args: [after.glyphs] });\n }\n if (!deepEqual(before.transition, after.transition)) {\n commands.push({ command: 'setTransition', args: [after.transition] });\n }\n if (!deepEqual(before.light, after.light)) {\n commands.push({ command: 'setLight', args: [after.light] });\n }\n if (!deepEqual(before.terrain, after.terrain)) {\n commands.push({ command: 'setTerrain', args: [after.terrain] });\n }\n if (!deepEqual(before.sky, after.sky)) {\n commands.push({ command: 'setSky', args: [after.sky] });\n }\n if (!deepEqual(before.projection, after.projection)) {\n commands.push({ command: 'setProjection', args: [after.projection] });\n }\n // Handle changes to `sources`\n // If a source is to be removed, we also--before the removeSource\n // command--need to remove all the style layers that depend on it.\n const sourcesRemoved = {};\n // First collect the {add,remove}Source commands\n const removeOrAddSourceCommands = [];\n diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved);\n // Push a removeLayer command for each style layer that depends on a\n // source that's being removed.\n // Also, exclude any such layers them from the input to `diffLayers`\n // below, so that diffLayers produces the appropriate `addLayers`\n // command\n const beforeLayers = [];\n if (before.layers) {\n before.layers.forEach((layer) => {\n if ('source' in layer && sourcesRemoved[layer.source]) {\n commands.push({ command: 'removeLayer', args: [layer.id] });\n }\n else {\n beforeLayers.push(layer);\n }\n });\n }\n commands = commands.concat(removeOrAddSourceCommands);\n // Handle changes to `layers`\n diffLayers(beforeLayers, after.layers, commands);\n }\n catch (e) {\n // fall back to setStyle\n console.warn('Unable to compute style diff:', e);\n commands = [{ command: 'setStyle', args: [after] }];\n }\n return commands;\n}\n\n// Note: Do not inherit from Error. It breaks when transpiling to ES5.\nclass ValidationError {\n constructor(key, value, message, identifier) {\n this.message = (key ? `${key}: ` : '') + message;\n if (identifier)\n this.identifier = identifier;\n if (value !== null && value !== undefined && value.__line__) {\n this.line = value.__line__;\n }\n }\n}\n\n// Note: Do not inherit from Error. It breaks when transpiling to ES5.\nclass ParsingError {\n constructor(error) {\n this.error = error;\n this.message = error.message;\n const match = error.message.match(/line (\\d+)/);\n this.line = match ? parseInt(match[1], 10) : 0;\n }\n}\n\nfunction extendBy(output, ...inputs) {\n for (const input of inputs) {\n for (const k in input) {\n output[k] = input[k];\n }\n }\n return output;\n}\n\nclass ExpressionParsingError extends Error {\n constructor(key, message) {\n super(message);\n this.message = message;\n this.key = key;\n }\n}\n\n/**\n * Tracks `let` bindings during expression parsing.\n * @private\n */\nclass Scope {\n constructor(parent, bindings = []) {\n this.parent = parent;\n this.bindings = {};\n for (const [name, expression] of bindings) {\n this.bindings[name] = expression;\n }\n }\n concat(bindings) {\n return new Scope(this, bindings);\n }\n get(name) {\n if (this.bindings[name]) {\n return this.bindings[name];\n }\n if (this.parent) {\n return this.parent.get(name);\n }\n throw new Error(`${name} not found in scope.`);\n }\n has(name) {\n if (this.bindings[name])\n return true;\n return this.parent ? this.parent.has(name) : false;\n }\n}\n\nconst NullType = { kind: 'null' };\nconst NumberType = { kind: 'number' };\nconst StringType = { kind: 'string' };\nconst BooleanType = { kind: 'boolean' };\nconst ColorType = { kind: 'color' };\nconst ProjectionDefinitionType = {\n kind: 'projectionDefinition'\n};\nconst ObjectType = { kind: 'object' };\nconst ValueType = { kind: 'value' };\nconst ErrorType = { kind: 'error' };\nconst CollatorType = { kind: 'collator' };\nconst FormattedType = { kind: 'formatted' };\nconst PaddingType = { kind: 'padding' };\nconst ColorArrayType = { kind: 'colorArray' };\nconst NumberArrayType = { kind: 'numberArray' };\nconst ResolvedImageType = { kind: 'resolvedImage' };\nconst VariableAnchorOffsetCollectionType = {\n kind: 'variableAnchorOffsetCollection'\n};\nfunction array(itemType, N) {\n return {\n kind: 'array',\n itemType,\n N\n };\n}\nfunction typeToString(type) {\n if (type.kind === 'array') {\n const itemType = typeToString(type.itemType);\n return typeof type.N === 'number'\n ? `array<${itemType}, ${type.N}>`\n : type.itemType.kind === 'value'\n ? 'array'\n : `array<${itemType}>`;\n }\n else {\n return type.kind;\n }\n}\nconst valueMemberTypes = [\n NullType,\n NumberType,\n StringType,\n BooleanType,\n ColorType,\n ProjectionDefinitionType,\n FormattedType,\n ObjectType,\n array(ValueType),\n PaddingType,\n NumberArrayType,\n ColorArrayType,\n ResolvedImageType,\n VariableAnchorOffsetCollectionType\n];\n/**\n * Returns null if `t` is a subtype of `expected`; otherwise returns an\n * error message.\n * @private\n */\nfunction checkSubtype(expected, t) {\n if (t.kind === 'error') {\n // Error is a subtype of every type\n return null;\n }\n else if (expected.kind === 'array') {\n if (t.kind === 'array' &&\n ((t.N === 0 && t.itemType.kind === 'value') ||\n !checkSubtype(expected.itemType, t.itemType)) &&\n (typeof expected.N !== 'number' || expected.N === t.N)) {\n return null;\n }\n }\n else if (expected.kind === t.kind) {\n return null;\n }\n else if (expected.kind === 'value') {\n for (const memberType of valueMemberTypes) {\n if (!checkSubtype(memberType, t)) {\n return null;\n }\n }\n }\n return `Expected ${typeToString(expected)} but found ${typeToString(t)} instead.`;\n}\nfunction isValidType(provided, allowedTypes) {\n return allowedTypes.some((t) => t.kind === provided.kind);\n}\nfunction isValidNativeType(provided, allowedTypes) {\n return allowedTypes.some((t) => {\n if (t === 'null') {\n return provided === null;\n }\n else if (t === 'array') {\n return Array.isArray(provided);\n }\n else if (t === 'object') {\n return provided && !Array.isArray(provided) && typeof provided === 'object';\n }\n else {\n return t === typeof provided;\n }\n });\n}\n/**\n * Verify whether the specified type is of the same type as the specified sample.\n *\n * @param provided Type to verify\n * @param sample Sample type to reference\n * @returns `true` if both objects are of the same type, `false` otherwise\n * @example basic types\n * if (verifyType(outputType, ValueType)) {\n * // type narrowed to:\n * outputType.kind; // 'value'\n * }\n * @example array types\n * if (verifyType(outputType, array(NumberType))) {\n * // type narrowed to:\n * outputType.kind; // 'array'\n * outputType.itemType; // NumberTypeT\n * outputType.itemType.kind; // 'number'\n * }\n */\nfunction verifyType(provided, sample) {\n if (provided.kind === 'array' && sample.kind === 'array') {\n return provided.itemType.kind === sample.itemType.kind && typeof provided.N === 'number';\n }\n return provided.kind === sample.kind;\n}\n\n// See https://observablehq.com/@mbostock/lab-and-rgb\nconst Xn = 0.96422, Yn = 1, Zn = 0.82521, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI;\nfunction constrainAngle(angle) {\n angle = angle % 360;\n if (angle < 0) {\n angle += 360;\n }\n return angle;\n}\nfunction rgbToLab([r, g, b, alpha]) {\n r = rgb2xyz(r);\n g = rgb2xyz(g);\n b = rgb2xyz(b);\n let x, z;\n const y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn);\n if (r === g && g === b) {\n x = z = y;\n }\n else {\n x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);\n z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);\n }\n const l = 116 * y - 16;\n return [l < 0 ? 0 : l, 500 * (x - y), 200 * (y - z), alpha];\n}\nfunction rgb2xyz(x) {\n return x <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);\n}\nfunction xyz2lab(t) {\n return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;\n}\nfunction labToRgb([l, a, b, alpha]) {\n let y = (l + 16) / 116, x = isNaN(a) ? y : y + a / 500, z = isNaN(b) ? y : y - b / 200;\n y = Yn * lab2xyz(y);\n x = Xn * lab2xyz(x);\n z = Zn * lab2xyz(z);\n return [\n xyz2rgb(3.1338561 * x - 1.6168667 * y - 0.4906146 * z), // D50 -> sRGB\n xyz2rgb(-0.9787684 * x + 1.9161415 * y + 0.033454 * z),\n xyz2rgb(0.0719453 * x - 0.2289914 * y + 1.4052427 * z),\n alpha\n ];\n}\nfunction xyz2rgb(x) {\n x = x <= 0.00304 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055;\n return x < 0 ? 0 : x > 1 ? 1 : x; // clip to 0..1 range\n}\nfunction lab2xyz(t) {\n return t > t1 ? t * t * t : t2 * (t - t0);\n}\nfunction rgbToHcl(rgbColor) {\n const [l, a, b, alpha] = rgbToLab(rgbColor);\n const c = Math.sqrt(a * a + b * b);\n const h = Math.round(c * 10000) ? constrainAngle(Math.atan2(b, a) * rad2deg) : NaN;\n return [h, c, l, alpha];\n}\nfunction hclToRgb([h, c, l, alpha]) {\n h = isNaN(h) ? 0 : h * deg2rad;\n return labToRgb([l, Math.cos(h) * c, Math.sin(h) * c, alpha]);\n}\n// https://drafts.csswg.org/css-color-4/#hsl-to-rgb\nfunction hslToRgb([h, s, l, alpha]) {\n h = constrainAngle(h);\n s /= 100;\n l /= 100;\n function f(n) {\n const k = (n + h / 30) % 12;\n const a = s * Math.min(l, 1 - l);\n return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n }\n return [f(0), f(8), f(4), alpha];\n}\n\n// polyfill for Object.hasOwn\nconst hasOwnProperty = Object.hasOwn ||\n function hasOwnProperty(object, key) {\n return Object.prototype.hasOwnProperty.call(object, key);\n };\nfunction getOwn(object, key) {\n return hasOwnProperty(object, key) ? object[key] : undefined;\n}\n\n/**\n * CSS color parser compliant with CSS Color 4 Specification.\n * Supports: named colors, `transparent` keyword, all rgb hex notations,\n * rgb(), rgba(), hsl() and hsla() functions.\n * Does not round the parsed values to integers from the range 0..255.\n *\n * Syntax:\n *\n * <alpha-value> = <number> | <percentage>\n * <hue> = <number> | <angle>\n *\n * rgb() = rgb( <percentage>{3} [ / <alpha-value> ]? ) | rgb( <number>{3} [ / <alpha-value> ]? )\n * rgb() = rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? )\n *\n * hsl() = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? )\n * hsl() = hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )\n *\n * Caveats:\n * - <angle> - <number> with optional `deg` suffix; `grad`, `rad`, `turn` are not supported\n * - `none` keyword is not supported\n * - comments inside rgb()/hsl() are not supported\n * - legacy color syntax rgba() is supported with an identical grammar and behavior to rgb()\n * - legacy color syntax hsla() is supported with an identical grammar and behavior to hsl()\n *\n * @param input CSS color string to parse.\n * @returns Color in sRGB color space, with `red`, `green`, `blue`\n * and `alpha` channels normalized to the range 0..1,\n * or `undefined` if the input is not a valid color string.\n */\nfunction parseCssColor(input) {\n input = input.toLowerCase().trim();\n if (input === 'transparent') {\n return [0, 0, 0, 0];\n }\n // 'white', 'black', 'blue'\n const namedColorsMatch = getOwn(namedColors, input);\n if (namedColorsMatch) {\n const [r, g, b] = namedColorsMatch;\n return [r / 255, g / 255, b / 255, 1];\n }\n // #f0c, #f0cf, #ff00cc, #ff00ccff\n if (input.startsWith('#')) {\n const hexRegexp = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/;\n if (hexRegexp.test(input)) {\n const step = input.length < 6 ? 1 : 2;\n let i = 1;\n return [\n parseHex(input.slice(i, (i += step))),\n parseHex(input.slice(i, (i += step))),\n parseHex(input.slice(i, (i += step))),\n parseHex(input.slice(i, i + step) || 'ff')\n ];\n }\n }\n // rgb(128 0 0), rgb(50% 0% 0%), rgba(255,0,255,0.6), rgb(255 0 255 / 60%), rgb(100% 0% 100% /.6)\n if (input.startsWith('rgb')) {\n const rgbRegExp = /^rgba?\\(\\s*([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)(%)?(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/;\n const rgbMatch = input.match(rgbRegExp);\n if (rgbMatch) {\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n r, // <numeric>\n rp, // % (optional)\n f1, // , (optional)\n g, // <numeric>\n gp, // % (optional)\n f2, // , (optional)\n b, // <numeric>\n bp, // % (optional)\n f3, // ,|/ (optional)\n a, // <numeric> (optional)\n ap // % (optional)\n ] = rgbMatch;\n const argFormat = [f1 || ' ', f2 || ' ', f3].join('');\n if (argFormat === ' ' ||\n argFormat === ' /' ||\n argFormat === ',,' ||\n argFormat === ',,,') {\n const valFormat = [rp, gp, bp].join('');\n const maxValue = valFormat === '%%%' ? 100 : valFormat === '' ? 255 : 0;\n if (maxValue) {\n const rgba = [\n clamp(+r / maxValue, 0, 1),\n clamp(+g / maxValue, 0, 1),\n clamp(+b / maxValue, 0, 1),\n a ? parseAlpha(+a, ap) : 1\n ];\n if (validateNumbers(rgba)) {\n return rgba;\n }\n // invalid numbers\n }\n // values must be all numbers or all percentages\n }\n return; // comma optional syntax requires no commas at all\n }\n }\n // hsl(120 50% 80%), hsla(120deg,50%,80%,.9), hsl(12e1 50% 80% / 90%)\n const hslRegExp = /^hsla?\\(\\s*([\\de.+-]+)(?:deg)?(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s+|\\s*(,)\\s*)([\\de.+-]+)%(?:\\s*([,\\/])\\s*([\\de.+-]+)(%)?)?\\s*\\)$/;\n const hslMatch = input.match(hslRegExp);\n if (hslMatch) {\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n h, // <numeric>\n f1, // , (optional)\n s, // <numeric>\n f2, // , (optional)\n l, // <numeric>\n f3, // ,|/ (optional)\n a, // <numeric> (optional)\n ap // % (optional)\n ] = hslMatch;\n const argFormat = [f1 || ' ', f2 || ' ', f3].join('');\n if (argFormat === ' ' ||\n argFormat === ' /' ||\n argFormat === ',,' ||\n argFormat === ',,,') {\n const hsla = [\n +h,\n clamp(+s, 0, 100),\n clamp(+l, 0, 100),\n a ? parseAlpha(+a, ap) : 1\n ];\n if (validateNumbers(hsla)) {\n return hslToRgb(hsla);\n }\n // invalid numbers\n }\n // comma optional syntax requires no commas at all\n }\n}\nfunction parseHex(hex) {\n return parseInt(hex.padEnd(2, hex), 16) / 255;\n}\nfunction parseAlpha(a, asPercentage) {\n return clamp(asPercentage ? a / 100 : a, 0, 1);\n}\nfunction clamp(n, min, max) {\n return Math.min(Math.max(min, n), max);\n}\n/**\n * The regular expression for numeric values is not super specific, and it may\n * happen that it will accept a value that is not a valid number. In order to\n * detect and eliminate such values this function exists.\n *\n * @param array Array of uncertain numbers.\n * @returns `true` if the specified array contains only valid numbers, `false` otherwise.\n */\nfunction validateNumbers(array) {\n return !array.some(Number.isNaN);\n}\n/**\n * To generate:\n * - visit {@link https://www.w3.org/TR/css-color-4/#named-colors}\n * - run in the console:\n * @example\n * copy(`{\\n${[...document.querySelector('.named-color-table tbody').children].map((tr) => `${tr.cells[2].textContent.trim()}: [${tr.cells[4].textContent.trim().split(/\\s+/).join(', ')}],`).join('\\n')}\\n}`);\n */\nconst namedColors = {\n aliceblue: [240, 248, 255],\n antiquewhite: [250, 235, 215],\n aqua: [0, 255, 255],\n aquamarine: [127, 255, 212],\n azure: [240, 255, 255],\n beige: [245, 245, 220],\n bisque: [255, 228, 196],\n black: [0, 0, 0],\n blanchedalmond: [255, 235, 205],\n blue: [0, 0, 255],\n blueviolet: [138, 43, 226],\n brown: [165, 42, 42],\n burlywood: [222, 184, 135],\n cadetblue: [95, 158, 160],\n chartreuse: [127, 255, 0],\n chocolate: [210, 105, 30],\n coral: [255, 127, 80],\n cornflowerblue: [100, 149, 237],\n cornsilk: [255, 248, 220],\n crimson: [220, 20, 60],\n cyan: [0, 255, 255],\n darkblue: [0, 0, 139],\n darkcyan: [0, 139, 139],\n darkgoldenrod: [184, 134, 11],\n darkgray: [169, 169, 169],\n darkgreen: [0, 100, 0],\n darkgrey: [169, 169, 169],\n darkkhaki: [189, 183, 107],\n darkmagenta: [139, 0, 139],\n darkolivegreen: [85, 107, 47],\n darkorange: [255, 140, 0],\n darkorchid: [153, 50, 204],\n darkred: [139, 0, 0],\n darksalmon: [233, 150, 122],\n darkseagreen: [143, 188, 143],\n darkslateblue: [72, 61, 139],\n darkslategray: [47, 79, 79],\n darkslategrey: [47, 79, 79],\n darkturquoise: [0, 206, 209],\n darkviolet: [148, 0, 211],\n deeppink: [255, 20, 147],\n deepskyblue: [0, 191, 255],\n dimgray: [105, 105, 105],\n dimgrey: [105, 105, 105],\n dodgerblue: [30, 144, 255],\n firebrick: [178, 34, 34],\n floralwhite: [255, 250, 240],\n forestgreen: [34, 139, 34],\n fuchsia: [255, 0, 255],\n gainsboro: [220, 220, 220],\n ghostwhite: [248, 248, 255],\n gold: [255, 215, 0],\n goldenrod: [218, 165, 32],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenyellow: [173, 255, 47],\n grey: [128, 128, 128],\n honeydew: [240, 255, 240],\n hotpink: [255, 105, 180],\n indianred: [205, 92, 92],\n indigo: [75, 0, 130],\n ivory: [255, 255, 240],\n khaki: [240, 230, 140],\n lavender: [230, 230, 250],\n lavenderblush: [255, 240, 245],\n lawngreen: [124, 252, 0],\n lemonchiffon: [255, 250, 205],\n lightblue: [173, 216, 230],\n lightcoral: [240, 128, 128],\n lightcyan: [224, 255, 255],\n lightgoldenrodyellow: [250, 250, 210],\n lightgray: [211, 211, 211],\n lightgreen: [144, 238, 144],\n lightgrey: [211, 211, 211],\n lightpink: [255, 182, 193],\n lightsalmon: [255, 160, 122],\n lightseagreen: [32, 178, 170],\n lightskyblue: [135, 206, 250],\n lightslategray: [119, 136, 153],\n lightslategrey: [119, 136, 153],\n lightsteelblue: [176, 196, 222],\n lightyellow: [255, 255, 224],\n lime: [0, 255, 0],\n limegreen: [50, 205, 50],\n linen: [250, 240, 230],\n magenta: [255, 0, 255],\n maroon: [128, 0, 0],\n mediumaquamarine: [102, 205, 170],\n mediumblue: [0, 0, 205],\n mediumorchid: [186, 85, 211],\n mediumpurple: [147, 112, 219],\n mediumseagreen: [60, 179, 113],\n mediumslateblue: [123, 104, 238],\n mediumspringgreen: [0, 250, 154],\n mediumturquoise: [72, 209, 204],\n mediumvioletred: [199, 21, 133],\n midnightblue: [25, 25, 112],\n mintcream: [245, 255, 250],\n mistyrose: [255, 228, 225],\n moccasin: [255, 228, 181],\n navajowhite: [255, 222, 173],\n navy: [0, 0, 128],\n oldlace: [253, 245, 230],\n olive: [128, 128, 0],\n olivedrab: [107, 142, 35],\n orange: [255, 165, 0],\n orangered: [255, 69, 0],\n orchid: [218, 112, 214],\n palegoldenrod: [238, 232, 170],\n palegreen: [152, 251, 152],\n paleturquoise: [175, 238, 238],\n palevioletred: [219, 112, 147],\n papayawhip: [255, 239, 213],\n peachpuff: [255, 218, 185],\n peru: [205, 133, 63],\n pink: [255, 192, 203],\n plum: [221, 160, 221],\n powderblue: [176, 224, 230],\n purple: [128, 0, 128],\n rebeccapurple: [102, 51, 153],\n red: [255, 0, 0],\n rosybrown: [188, 143, 143],\n royalblue: [65, 105, 225],\n saddlebrown: [139, 69, 19],\n salmon: [250, 128, 114],\n sandybrown: [244, 164, 96],\n seagreen: [46, 139, 87],\n seashell: [255, 245, 238],\n sienna: [160, 82, 45],\n silver: [192, 192, 192],\n skyblue: [135, 206, 235],\n slateblue: [106, 90, 205],\n slategray: [112, 128, 144],\n slategrey: [112, 128, 144],\n snow: [255, 250, 250],\n springgreen: [0, 255, 127],\n steelblue: [70, 130, 180],\n tan: [210, 180, 140],\n teal: [0, 128, 128],\n thistle: [216, 191, 216],\n tomato: [255, 99, 71],\n turquoise: [64, 224, 208],\n violet: [238, 130, 238],\n wheat: [245, 222, 179],\n white: [255, 255, 255],\n whitesmoke: [245, 245, 245],\n yellow: [255, 255, 0],\n yellowgreen: [154, 205, 50]\n};\n\nfunction interpolateNumber(from, to, t) {\n return from + t * (to - from);\n}\nfunction interpolateArray(from, to, t) {\n return from.map((d, i) => {\n return interpolateNumber(d, to[i], t);\n });\n}\n\n/**\n * Checks whether the specified color space is one of the supported interpolation color spaces.\n *\n * @param colorSpace Color space key to verify.\n * @returns `true` if the specified color space is one of the supported\n * interpolation color spaces, `false` otherwise\n */\nfunction isSupportedInterpolationColorSpace(colorSpace) {\n return colorSpace === 'rgb' || colorSpace === 'hcl' || colorSpace === 'lab';\n}\n/**\n * Color representation used by WebGL.\n * Defined in sRGB color space and pre-blended with alpha.\n * @private\n */\nclass Color {\n /**\n * @param r Red component premultiplied by `alpha` 0..1\n * @param g Green component premultiplied by `alpha` 0..1\n * @param b Blue component premultiplied by `alpha` 0..1\n * @param [alpha=1] Alpha component 0..1\n * @param [premultiplied=true] Whether the `r`, `g` and `b` values have already\n * been multiplied by alpha. If `true` nothing happens if `false` then they will\n * be multiplied automatically.\n */\n constructor(r, g, b, alpha = 1, premultiplied = true) {\n this.r = r;\n this.g = g;\n this.b = b;\n this.a = alpha;\n if (!premultiplied) {\n this.r *= alpha;\n this.g *= alpha;\n this.b *= alpha;\n if (!alpha) {\n // alpha = 0 erases completely rgb channels. This behavior is not desirable\n // if this particular color is later used in color interpolation.\n // Because of that, a reference to original color is saved.\n this.overwriteGetter('rgb', [r, g, b, alpha]);\n }\n }\n }\n /**\n * Parses CSS color strings and converts colors to sRGB color space if needed.\n * Officially supported color formats:\n * - keyword, e.g. 'aquamarine' or 'steelblue'\n * - hex (with 3, 4, 6 or 8 digits), e.g. '#f0f' or '#e9bebea9'\n * - rgb and rgba, e.g. 'rgb(0,240,120)' or 'rgba(0%,94%,47%,0.1)' or 'rgb(0 240 120 / .3)'\n * - hsl and hsla, e.g. 'hsl(0,0%,83%)' or 'hsla(0,0%,83%,.5)' or 'hsl(0 0% 83% / 20%)'\n *\n * @param input CSS color string to parse.\n * @returns A `Color` instance, or `undefined` if the input is not a valid color string.\n */\n static parse(input) {\n // in zoom-and-property function input could be an instance of Color class\n if (input instanceof Color) {\n return input;\n }\n if (typeof input !== 'string') {\n return;\n }\n const rgba = parseCssColor(input);\n if (rgba) {\n return new Color(...rgba, false);\n }\n }\n /**\n * Used in color interpolation and by 'to-rgba' expression.\n *\n * @returns Gien color, with reversed alpha blending, in sRGB color space.\n */\n get rgb() {\n const { r, g, b, a } = this;\n const f = a || Infinity; // reverse alpha blending factor\n return this.overwriteGetter('rgb', [r / f, g / f, b / f, a]);\n }\n /**\n * Used in color interpolation.\n *\n * @returns Gien color, with reversed alpha blending, in HCL color space.\n */\n get hcl() {\n return this.overwriteGetter('hcl', rgbToHcl(this.rgb));\n }\n /**\n * Used in color interpolation.\n *\n * @returns Gien color, with reversed alpha blending, in LAB color space.\n */\n get lab() {\n return this.overwriteGetter('lab', rgbToLab(this.rgb));\n }\n /**\n * Lazy getter pattern. When getter is called for the first time lazy value\n * is calculated and then overwrites getter function in given object instance.\n *\n * @example:\n * const redColor = Color.parse('red');\n * let x = redColor.hcl; // this will invoke `get hcl()`, which will calculate\n * // the value of red in HCL space and invoke this `overwriteGetter` function\n * // which in turn will set a field with a key 'hcl' in the `redColor` object.\n * // In other words it will override `get hcl()` from its `Color` prototype\n * // with its own property: hcl = [calculated red value in hcl].\n * let y = redColor.hcl; // next call will no longer invoke getter but simply\n * // return the previously calculated value\n * x === y; // true - `x` is exactly the same object as `y`\n *\n * @param getterKey Getter key\n * @param lazyValue Lazily calculated value to be memoized by current instance\n * @private\n */\n overwriteGetter(getterKey, lazyValue) {\n Object.defineProperty(this, getterKey, { value: lazyValue });\n return lazyValue;\n }\n /**\n * Used by 'to-string' expression.\n *\n * @returns Serialized color in format `rgba(r,g,b,a)`\n * where r,g,b are numbers within 0..255 and alpha is number within 1..0\n *\n * @example\n * var purple = new Color.parse('purple');\n * purple.toString; // = \"rgba(128,0,128,1)\"\n * var translucentGreen = new Color.parse('rgba(26, 207, 26, .73)');\n * translucentGreen.toString(); // = \"rgba(26,207,26,0.73)\"\n */\n toString() {\n const [r, g, b, a] = this.rgb;\n return `rgba(${[r, g, b].map((n) => Math.round(n * 255)).join(',')},${a})`;\n }\n static interpolate(from, to, t, spaceKey = 'rgb') {\n switch (spaceKey) {\n case 'rgb': {\n const [r, g, b, alpha] = interpolateArray(from.rgb, to.rgb, t);\n return new Color(r, g, b, alpha, false);\n }\n case 'hcl': {\n const [hue0, chroma0, light0, alphaF] = from.hcl;\n const [hue1, chroma1, light1, alphaT] = to.hcl;\n // https://github.com/gka/chroma.js/blob/cd1b3c0926c7a85cbdc3b1453b3a94006de91a92/src/interpolator/_hsx.js\n let hue, chroma;\n if (!isNaN(hue0) && !isNaN(hue1)) {\n let dh = hue1 - hue0;\n if (hue1 > hue0 && dh > 180) {\n dh -= 360;\n }\n else if (hue1 < hue0 && hue0 - hue1 > 180) {\n dh += 360;\n }\n hue = hue0 + t * dh;\n }\n else if (!isNaN(hue0)) {\n hue = hue0;\n if (light1 === 1 || light1 === 0)\n chroma = chroma0;\n }\n else if (!isNaN(hue1)) {\n hue = hue1;\n if (light0 === 1 || light0 === 0)\n chroma = chroma1;\n }\n else {\n hue = NaN;\n }\n const [r, g, b, alpha] = hclToRgb([\n hue,\n chroma !== null && chroma !== void 0 ? chroma : interpolateNumber(chroma0, chroma1, t),\n interpolateNumber(light0, light1, t),\n interpolateNumber(alphaF, alphaT, t)\n ]);\n return new Color(r, g, b, alpha, false);\n }\n case 'lab': {\n const [r, g, b, alpha] = labToRgb(interpolateArray(from.lab, to.lab, t));\n return new Color(r, g, b, alpha, false);\n }\n }\n }\n}\nColor.black = new Color(0, 0, 0, 1);\nColor.white = new Color(1, 1, 1, 1);\nColor.transparent = new Color(0, 0, 0, 0);\nColor.red = new Color(1, 0, 0, 1);\n\nclass Collator {\n constructor(caseSensitive, diacriticSensitive, locale) {\n if (caseSensitive)\n this.sensitivity = diacriticSensitive ? 'variant' : 'case';\n else\n this.sensitivity = diacriticSensitive ? 'accent' : 'base';\n this.locale = locale;\n this.collator = new Intl.Collator(this.locale ? this.locale : [], {\n sensitivity: this.sensitivity,\n usage: 'search'\n });\n }\n compare(lhs, rhs) {\n return this.collator.compare(lhs, rhs);\n }\n resolvedLocale() {\n // We create a Collator without \"usage: search\" because we don't want\n // the search options encoded in our result (e.g. \"en-u-co-search\")\n return new Intl.Collator(this.locale ? this.locale : []).resolvedOptions().locale;\n }\n}\n\nconst VERTICAL_ALIGN_OPTIONS = ['bottom', 'center', 'top'];\nclass FormattedSection {\n constructor(text, image, scale, fontStack, textColor, verticalAlign) {\n this.text = text;\n this.image = image;\n this.scale = scale;\n this.fontStack = fontStack;\n this.textColor = textColor;\n this.verticalAlign = verticalAlign;\n }\n}\nclass Formatted {\n constructor(sections) {\n this.sections = sections;\n }\n static fromString(unformatted) {\n return new Formatted([new FormattedSection(unformatted, null, null, null, null, null)]);\n }\n isEmpty() {\n if (this.sections.length === 0)\n return true;\n return !this.sections.some((section) => section.text.length !== 0 || (section.image && section.image.name.length !== 0));\n }\n static factory(text) {\n if (text instanceof Formatted) {\n return text;\n }\n else {\n return Formatted.fromString(text);\n }\n }\n toString() {\n if (this.sections.length === 0)\n return '';\n return this.sections.map((section) => section.text).join('');\n }\n}\n\n/**\n * A set of four numbers representing padding around a box. Create instances from\n * bare arrays or numeric values using the static method `Padding.parse`.\n * @private\n */\nclass Padding {\n constructor(values) {\n this.values = values.slice();\n }\n /**\n * Numeric padding values\n * @param input A padding value\n * @returns A `Padding` instance, or `undefined` if the input is not a valid padding value.\n */\n static parse(input) {\n if (input instanceof Padding) {\n return input;\n }\n // Backwards compatibility: bare number is treated the same as array with single value.\n // Padding applies to all four sides.\n if (typeof input === 'number') {\n return new Padding([input, input, input, input]);\n }\n if (!Array.isArray(input)) {\n return undefined;\n }\n if (input.length < 1 || input.length > 4) {\n return undefined;\n }\n for (const val of input) {\n if (typeof val !== 'number') {\n return undefined;\n }\n }\n // Expand shortcut properties into explicit 4-sided values\n switch (input.length) {\n case 1:\n input = [input[0], input[0], input[0], input[0]];\n break;\n case 2:\n input = [input[0], input[1], input[0], input[1]];\n break;\n case 3:\n input = [input[0], input[1], input[2], input[1]];\n break;\n }\n return new Padding(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n static interpolate(from, to, t) {\n return new Padding(interpolateArray(from.values, to.values, t));\n }\n}\n\n/**\n * An array of numbers. Create instances from\n * bare arrays or numeric values using the static method `NumberArray.parse`.\n * @private\n */\nclass NumberArray {\n constructor(values) {\n this.values = values.slice();\n }\n /**\n * Numeric NumberArray values\n * @param input A NumberArray value\n * @returns A `NumberArray` instance, or `undefined` if the input is not a valid NumberArray value.\n */\n static parse(input) {\n if (input instanceof NumberArray) {\n return input;\n }\n // Backwards compatibility (e.g. hillshade-illumination-direction): bare number is treated the same as array with single value.\n if (typeof input === 'number') {\n return new NumberArray([input]);\n }\n if (!Array.isArray(input)) {\n return undefined;\n }\n for (const val of input) {\n if (typeof val !== 'number') {\n return undefined;\n }\n }\n return new NumberArray(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n static interpolate(from, to, t) {\n return new NumberArray(interpolateArray(from.values, to.values, t));\n }\n}\n\n/**\n * An array of colors. Create instances from\n * bare arrays or strings using the static method `ColorArray.parse`.\n * @private\n */\nclass ColorArray {\n constructor(values) {\n this.values = values.slice();\n }\n /**\n * ColorArray values\n * @param input A ColorArray value\n * @returns A `ColorArray` instance, or `undefined` if the input is not a valid ColorArray value.\n */\n static parse(input) {\n if (input instanceof ColorArray) {\n return input;\n }\n // Backwards compatibility (e.g. hillshade-shadow-color): bare Color is treated the same as array with single value.\n if (typeof input === 'string') {\n const parsed_val = Color.parse(input);\n if (!parsed_val) {\n return undefined;\n }\n return new ColorArray([parsed_val]);\n }\n if (!Array.isArray(input)) {\n return undefined;\n }\n const colors = [];\n for (const val of input) {\n if (typeof val !== 'string') {\n return undefined;\n }\n const parsed_val = Color.parse(val);\n if (!parsed_val) {\n return undefined;\n }\n colors.push(parsed_val);\n }\n return new ColorArray(colors);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n static interpolate(from, to, t, spaceKey = 'rgb') {\n const colors = [];\n if (from.values.length != to.values.length) {\n throw new Error(`colorArray: Arrays have mismatched length (${from.values.length} vs. ${to.values.length}), cannot interpolate.`);\n }\n for (let i = 0; i < from.values.length; i++) {\n colors.push(Color.interpolate(from.values[i], to.values[i], t, spaceKey));\n }\n return new ColorArray(colors);\n }\n}\n\nclass RuntimeError extends Error {\n constructor(message) {\n super(message);\n this.name = 'RuntimeError';\n }\n toJSON() {\n return this.message;\n }\n}\n\n/** Set of valid anchor positions, as a set for validation */\nconst anchors = new Set([\n 'center',\n 'left',\n 'right',\n 'top',\n 'bottom',\n 'top-left',\n 'top-right',\n 'bottom-left',\n 'bottom-right'\n]);\n/**\n * Utility class to assist managing values for text-variable-anchor-offset property. Create instances from\n * bare arrays using the static method `VariableAnchorOffsetCollection.parse`.\n * @private\n */\nclass VariableAnchorOffsetCollection {\n constructor(values) {\n this.values = values.slice();\n }\n static parse(input) {\n if (input instanceof VariableAnchorOffsetCollection) {\n return input;\n }\n if (!Array.isArray(input) || input.length < 1 || input.length % 2 !== 0) {\n return undefined;\n }\n for (let i = 0; i < input.length; i += 2) {\n // Elements in even positions should be anchor positions; Elements in odd positions should be offset values\n const anchorValue = input[i];\n const offsetValue = input[i + 1];\n if (typeof anchorValue !== 'string' || !anchors.has(anchorValue)) {\n return undefined;\n }\n if (!Array.isArray(offsetValue) ||\n offsetValue.length !== 2 ||\n typeof offsetValue[0] !== 'number' ||\n typeof offsetValue[1] !== 'number') {\n return undefined;\n }\n }\n return new VariableAnchorOffsetCollection(input);\n }\n toString() {\n return JSON.stringify(this.values);\n }\n static interpolate(from, to, t) {\n const fromValues = from.values;\n const toValues = to.values;\n if (fromValues.length !== toValues.length) {\n throw new RuntimeError(`Cannot interpolate values of different length. from: ${from.toString()}, to: ${to.toString()}`);\n }\n const output = [];\n for (let i = 0; i < fromValues.length; i += 2) {\n // Anchor entries must match\n if (fromValues[i] !== toValues[i]) {\n throw new RuntimeError(`Cannot interpolate values containing mismatched anchors. from[${i}]: ${fromValues[i]}, to[${i}]: ${toValues[i]}`);\n }\n output.push(fromValues[i]);\n // Interpolate the offset values for each anchor\n const [fx, fy] = fromValues[i + 1];\n const [tx, ty] = toValues[i + 1];\n output.push([interpolateNumber(fx, tx, t), interpolateNumber(fy, ty, t)]);\n }\n return new VariableAnchorOffsetCollection(output);\n }\n}\n\nclass ResolvedImage {\n constructor(options) {\n this.name = options.name;\n this.available = options.available;\n }\n toString() {\n return this.name;\n }\n static fromString(name) {\n if (!name)\n return null; // treat empty values as no image\n return new ResolvedImage({ name, available: false });\n }\n}\n\nclass ProjectionDefinition {\n constructor(from, to, transition) {\n this.from = from;\n this.to = to;\n this.transition = transition;\n }\n static interpolate(from, to, t) {\n return new ProjectionDefinition(from, to, t);\n }\n static parse(input) {\n if (input instanceof ProjectionDefinition) {\n return input;\n }\n if (Array.isArray(input) &&\n input.length === 3 &&\n typeof input[0] === 'string' &&\n typeof input[1] === 'string' &&\n typeof input[2] === 'number') {\n return new ProjectionDefinition(input[0], input[1], input[2]);\n }\n if (typeof input === 'object' &&\n typeof input.from === 'string' &&\n typeof input.to === 'string' &&\n typeof input.transition === 'number') {\n return new ProjectionDefinition(input.from, input.to, input.transition);\n }\n if (typeof input === 'string') {\n return new ProjectionDefinition(input, input, 1);\n }\n return undefined;\n }\n}\n\nfunction validateRGBA(r, g, b, a) {\n if (!(typeof r === 'number' &&\n r >= 0 &&\n r <= 255 &&\n typeof g === 'number' &&\n g >= 0 &&\n g <= 255 &&\n typeof b === 'number' &&\n b >= 0 &&\n b <= 255)) {\n const value = typeof a === 'number' ? [r, g, b, a] : [r, g, b];\n return `Invalid rgba value [${value.join(', ')}]: 'r', 'g', and 'b' must be between 0 and 255.`;\n }\n if (!(typeof a === 'undefined' || (typeof a === 'number' && a >= 0 && a <= 1))) {\n return `Invalid rgba value [${[r, g, b, a].join(', ')}]: 'a' must be between 0 and 1.`;\n }\n return null;\n}\nfunction isValue(mixed) {\n if (mixed === null ||\n typeof mixed === 'string' ||\n typeof mixed === 'boolean' ||\n typeof mixed === 'number' ||\n mixed instanceof ProjectionDefinition ||\n mixed instanceof Color ||\n mixed instanceof Collator ||\n mixed instanceof Formatted ||\n mixed instanceof Padding ||\n mixed instanceof NumberArray ||\n mixed instanceof ColorArray ||\n mixed instanceof VariableAnchorOffsetCollection ||\n mixed instanceof ResolvedImage) {\n return true;\n }\n else if (Array.isArray(mixed)) {\n for (const item of mixed) {\n if (!isValue(item)) {\n return false;\n }\n }\n return true;\n }\n else if (typeof mixed === 'object') {\n for (const key in mixed) {\n if (!isValue(mixed[key])) {\n return false;\n }\n }\n return true;\n }\n else {\n return false;\n }\n}\nfunction typeOf(value) {\n if (value === null) {\n return NullType;\n }\n else if (typeof value === 'string') {\n return StringType;\n }\n else if (typeof value === 'boolean') {\n return BooleanType;\n }\n else if (typeof value === 'number') {\n return NumberType;\n }\n else if (value instanceof Color) {\n return ColorType;\n }\n else if (value instanceof ProjectionDefinition) {\n return ProjectionDefinitionType;\n }\n else if (value instanceof Collator) {\n return CollatorType;\n }\n else if (value instanceof Formatted) {\n return FormattedType;\n }\n else if (value instanceof Padding) {\n return PaddingType;\n }\n else if (value instanceof NumberArray) {\n return NumberArrayType;\n }\n else if (value instanceof ColorArray) {\n return ColorArrayType;\n }\n else if (value instanceof VariableAnchorOffsetCollection) {\n return VariableAnchorOffsetCollectionType;\n }\n else if (value instanceof ResolvedImage) {\n return ResolvedImageType;\n }\n else if (Array.isArray(value)) {\n const length = value.length;\n let itemType;\n for (const item of value) {\n const t = typeOf(item);\n if (!itemType) {\n itemType = t;\n }\n else if (itemType === t) {\n continue;\n }\n else {\n itemType = ValueType;\n break;\n }\n }\n return array(itemType || ValueType, length);\n }\n else {\n return ObjectType;\n }\n}\nfunction valueToString(value) {\n const type = typeof value;\n if (value === null) {\n return '';\n }\n else if (type === 'string' || type === 'number' || type === 'boolean') {\n return String(value);\n }\n else if (value instanceof Color ||\n value instanceof ProjectionDefinition ||\n value instanceof Formatted ||\n value instanceof Padding ||\n value instanceof NumberArray ||\n value instanceof ColorArray ||\n value instanceof VariableAnchorOffsetCollection ||\n value instanceof ResolvedImage) {\n return value.toString();\n }\n else {\n return JSON.stringify(value);\n }\n}\n\nclass Literal {\n constructor(type, value) {\n this.type = type;\n this.value = value;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'literal' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (!isValue(args[1]))\n return context.error('invalid value');\n const value = args[1];\n let type = typeOf(value);\n // special case: infer the item type if possible for zero-length arrays\n const expected = context.expectedType;\n if (type.kind === 'array' &&\n type.N === 0 &&\n expected &&\n expected.kind === 'array' &&\n (typeof expected.N !== 'number' || expected.N === 0)) {\n type = expected;\n }\n return new Literal(type, value);\n }\n evaluate() {\n return this.value;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nconst types$1 = {\n string: StringType,\n number: NumberType,\n boolean: BooleanType,\n object: ObjectType\n};\nclass Assertion {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2)\n return context.error('Expected at least one argument.');\n let i = 1;\n let type;\n const name = args[0];\n if (name === 'array') {\n let itemType;\n if (args.length > 2) {\n const type = args[1];\n if (typeof type !== 'string' || !(type in types$1) || type === 'object')\n return context.error('The item type argument of \"array\" must be one of string, number, boolean', 1);\n itemType = types$1[type];\n i++;\n }\n else {\n itemType = ValueType;\n }\n let N;\n if (args.length > 3) {\n if (args[2] !== null &&\n (typeof args[2] !== 'number' || args[2] < 0 || args[2] !== Math.floor(args[2]))) {\n return context.error('The length argument to \"array\" must be a positive integer literal', 2);\n }\n N = args[2];\n i++;\n }\n type = array(itemType, N);\n }\n else {\n if (!types$1[name])\n throw new Error(`Types doesn't contain name = ${name}`);\n type = types$1[name];\n }\n const parsed = [];\n for (; i < args.length; i++) {\n const input = context.parse(args[i], i, ValueType);\n if (!input)\n return null;\n parsed.push(input);\n }\n return new Assertion(type, parsed);\n }\n evaluate(ctx) {\n for (let i = 0; i < this.args.length; i++) {\n const value = this.args[i].evaluate(ctx);\n const error = checkSubtype(this.type, typeOf(value));\n if (!error) {\n return value;\n }\n else if (i === this.args.length - 1) {\n throw new RuntimeError(`Expected value to be of type ${typeToString(this.type)}, but found ${typeToString(typeOf(value))} instead.`);\n }\n }\n throw new Error();\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every((arg) => arg.outputDefined());\n }\n}\n\nconst types = {\n 'to-boolean': BooleanType,\n 'to-color': ColorType,\n 'to-number': NumberType,\n 'to-string': StringType\n};\n/**\n * Special form for error-coalescing coercion expressions \"to-number\",\n * \"to-color\". Since these coercions can fail at runtime, they accept multiple\n * arguments, only evaluating one at a time until one succeeds.\n *\n * @private\n */\nclass Coercion {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2)\n return context.error('Expected at least one argument.');\n const name = args[0];\n if (!types[name])\n throw new Error(`Can't parse ${name} as it is not part of the known types`);\n if ((name === 'to-boolean' || name === 'to-string') && args.length !== 2)\n return context.error('Expected one argument.');\n const type = types[name];\n const parsed = [];\n for (let i = 1; i < args.length; i++) {\n const input = context.parse(args[i], i, ValueType);\n if (!input)\n return null;\n parsed.push(input);\n }\n return new Coercion(type, parsed);\n }\n evaluate(ctx) {\n switch (this.type.kind) {\n case 'boolean':\n return Boolean(this.args[0].evaluate(ctx));\n case 'color': {\n let input;\n let error;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n error = null;\n if (input instanceof Color) {\n return input;\n }\n else if (typeof input === 'string') {\n const c = ctx.parseColor(input);\n if (c)\n return c;\n }\n else if (Array.isArray(input)) {\n if (input.length < 3 || input.length > 4) {\n error = `Invalid rgba value ${JSON.stringify(input)}: expected an array containing either three or four numeric values.`;\n }\n else {\n error = validateRGBA(input[0], input[1], input[2], input[3]);\n }\n if (!error) {\n return new Color(input[0] / 255, input[1] / 255, input[2] / 255, input[3]);\n }\n }\n }\n throw new RuntimeError(error ||\n `Could not parse color from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'padding': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const pad = Padding.parse(input);\n if (pad) {\n return pad;\n }\n }\n throw new RuntimeError(`Could not parse padding from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'numberArray': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const val = NumberArray.parse(input);\n if (val) {\n return val;\n }\n }\n throw new RuntimeError(`Could not parse numberArray from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'colorArray': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const val = ColorArray.parse(input);\n if (val) {\n return val;\n }\n }\n throw new RuntimeError(`Could not parse colorArray from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'variableAnchorOffsetCollection': {\n let input;\n for (const arg of this.args) {\n input = arg.evaluate(ctx);\n const coll = VariableAnchorOffsetCollection.parse(input);\n if (coll) {\n return coll;\n }\n }\n throw new RuntimeError(`Could not parse variableAnchorOffsetCollection from value '${typeof input === 'string' ? input : JSON.stringify(input)}'`);\n }\n case 'number': {\n let value = null;\n for (const arg of this.args) {\n value = arg.evaluate(ctx);\n if (value === null)\n return 0;\n const num = Number(value);\n if (isNaN(num))\n continue;\n return num;\n }\n throw new RuntimeError(`Could not convert ${JSON.stringify(value)} to number.`);\n }\n case 'formatted':\n // There is no explicit 'to-formatted' but this coercion can be implicitly\n // created by properties that expect the 'formatted' type.\n return Formatted.fromString(valueToString(this.args[0].evaluate(ctx)));\n case 'resolvedImage':\n return ResolvedImage.fromString(valueToString(this.args[0].evaluate(ctx)));\n case 'projectionDefinition':\n return this.args[0].evaluate(ctx);\n default:\n return valueToString(this.args[0].evaluate(ctx));\n }\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every((arg) => arg.outputDefined());\n }\n}\n\nconst geometryTypes = ['Unknown', 'Point', 'LineString', 'Polygon'];\nclass EvaluationContext {\n constructor() {\n this.globals = null;\n this.feature = null;\n this.featureState = null;\n this.formattedSection = null;\n this._parseColorCache = new Map();\n this.availableImages = null;\n this.canonical = null;\n }\n id() {\n return this.feature && 'id' in this.feature ? this.feature.id : null;\n }\n geometryType() {\n return this.feature\n ? typeof this.feature.type === 'number'\n ? geometryTypes[this.feature.type]\n : this.feature.type\n : null;\n }\n geometry() {\n return this.feature && 'geometry' in this.feature ? this.feature.geometry : null;\n }\n canonicalID() {\n return this.canonical;\n }\n properties() {\n return (this.feature && this.feature.properties) || {};\n }\n parseColor(input) {\n let cached = this._parseColorCache.get(input);\n if (!cached) {\n cached = Color.parse(input);\n this._parseColorCache.set(input, cached);\n }\n return cached;\n }\n}\n\n/**\n * State associated parsing at a given point in an expression tree.\n * @private\n */\nclass ParsingContext {\n constructor(registry, isConstantFunc, path = [], expectedType, scope = new Scope(), errors = []) {\n this.registry = registry;\n this.path = path;\n this.key = path.map((part) => `[${part}]`).join('');\n this.scope = scope;\n this.errors = errors;\n this.expectedType = expectedType;\n this._isConstant = isConstantFunc;\n }\n /**\n * @param expr the JSON expression to parse\n * @param index the optional argument index if this expression is an argument of a parent expression that's being parsed\n * @param options\n * @param options.omitTypeAnnotations set true to omit inferred type annotations. Caller beware: with this option set, the parsed expression's type will NOT satisfy `expectedType` if it would normally be wrapped in an inferred annotation.\n * @private\n */\n parse(expr, index, expectedType, bindings, options = {}) {\n if (index) {\n return this.concat(index, expectedType, bindings)._parse(expr, options);\n }\n return this._parse(expr, options);\n }\n _parse(expr, options) {\n if (expr === null ||\n typeof expr === 'string' ||\n typeof expr === 'boolean' ||\n typeof expr === 'number') {\n expr = ['literal', expr];\n }\n function annotate(parsed, type, typeAnnotation) {\n if (typeAnnotation === 'assert') {\n return new Assertion(type, [parsed]);\n }\n else if (typeAnnotation === 'coerce') {\n return new Coercion(type, [parsed]);\n }\n else {\n return parsed;\n }\n }\n if (Array.isArray(expr)) {\n if (expr.length === 0) {\n return this.error('Expected an array with at least one element. If you wanted a literal array, use [\"literal\", []].');\n }\n const op = expr[0];\n if (typeof op !== 'string') {\n this.error(`Expression name must be a string, but found ${typeof op} instead. If you wanted a literal array, use [\"literal\", [...]].`, 0);\n return null;\n }\n const Expr = this.registry[op];\n if (Expr) {\n let parsed = Expr.parse(expr, this);\n if (!parsed)\n return null;\n if (this.expectedType) {\n const expected = this.expectedType;\n const actual = parsed.type;\n // When we expect a number, string, boolean, or array but have a value, wrap it in an assertion.\n // When we expect a color or formatted string, but have a string or value, wrap it in a coercion.\n // Otherwise, we do static type-checking.\n //\n // These behaviors are overridable for:\n // * The \"coalesce\" operator, which needs to omit type annotations.\n // * String-valued properties (e.g. `text-field`), where coercion is more convenient than assertion.\n //\n if ((expected.kind === 'string' ||\n expected.kind === 'number' ||\n expected.kind === 'boolean' ||\n expected.kind === 'object' ||\n expected.kind === 'array') &&\n actual.kind === 'value') {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'assert');\n }\n else if (('projectionDefinition' === expected.kind &&\n ['string', 'array'].includes(actual.kind)) ||\n (['color', 'formatted', 'resolvedImage'].includes(expected.kind) &&\n ['value', 'string'].includes(actual.kind)) ||\n (['padding', 'numberArray'].includes(expected.kind) &&\n ['value', 'number', 'array'].includes(actual.kind)) ||\n ('colorArray' === expected.kind &&\n ['value', 'string', 'array'].includes(actual.kind)) ||\n ('variableAnchorOffsetCollection' === expected.kind &&\n ['value', 'array'].includes(actual.kind))) {\n parsed = annotate(parsed, expected, options.typeAnnotation || 'coerce');\n }\n else if (this.checkSubtype(expected, actual)) {\n return null;\n }\n }\n // If an expression's arguments are all literals, we can evaluate\n // it immediately and replace it with a literal value in the\n // parsed/compiled result. Expressions that expect an image should\n // not be resolved here so we can later get the available images.\n if (!(parsed instanceof Literal) &&\n parsed.type.kind !== 'resolvedImage' &&\n this._isConstant(parsed)) {\n const ec = new EvaluationContext();\n try {\n parsed = new Literal(parsed.type, parsed.evaluate(ec));\n }\n catch (e) {\n this.error(e.message);\n return null;\n }\n }\n return parsed;\n }\n return this.error(`Unknown expression \"${op}\". If you wanted a literal array, use [\"literal\", [...]].`, 0);\n }\n else if (typeof expr === 'undefined') {\n return this.error(\"'undefined' value invalid. Use null instead.\");\n }\n else if (typeof expr === 'object') {\n return this.error('Bare objects invalid. Use [\"literal\", {...}] instead.');\n }\n else {\n return this.error(`Expected an array, but found ${typeof expr} instead.`);\n }\n }\n /**\n * Returns a copy of this context suitable for parsing the subexpression at\n * index `index`, optionally appending to 'let' binding map.\n *\n * Note that `errors` property, intended for collecting errors while\n * parsing, is copied by reference rather than cloned.\n * @private\n */\n concat(index, expectedType, bindings) {\n const path = typeof index === 'number' ? this.path.concat(index) : this.path;\n const scope = bindings ? this.scope.concat(bindings) : this.scope;\n return new ParsingContext(this.registry, this._isConstant, path, expectedType || null, scope, this.errors);\n }\n /**\n * Push a parsing (or type checking) error into the `this.errors`\n * @param error The message\n * @param keys Optionally specify the source of the error at a child\n * of the current expression at `this.key`.\n * @private\n */\n error(error, ...keys) {\n const key = `${this.key}${keys.map((k) => `[${k}]`).join('')}`;\n this.errors.push(new ExpressionParsingError(key, error));\n }\n /**\n * Returns null if `t` is a subtype of `expected`; otherwise returns an\n * error message and also pushes it to `this.errors`.\n * @param expected The expected type\n * @param t The actual type\n * @returns null if `t` is a subtype of `expected`; otherwise returns an error message\n */\n checkSubtype(expected, t) {\n const error = checkSubtype(expected, t);\n if (error)\n this.error(error);\n return error;\n }\n}\n\nclass Let {\n constructor(bindings, result) {\n this.type = result.type;\n this.bindings = [].concat(bindings);\n this.result = result;\n }\n evaluate(ctx) {\n return this.result.evaluate(ctx);\n }\n eachChild(fn) {\n for (const binding of this.bindings) {\n fn(binding[1]);\n }\n fn(this.result);\n }\n static parse(args, context) {\n if (args.length < 4)\n return context.error(`Expected at least 3 arguments, but found ${args.length - 1} instead.`);\n const bindings = [];\n for (let i = 1; i < args.length - 1; i += 2) {\n const name = args[i];\n if (typeof name !== 'string') {\n return context.error(`Expected string, but found ${typeof name} instead.`, i);\n }\n if (/[^a-zA-Z0-9_]/.test(name)) {\n return context.error(\"Variable names must contain only alphanumeric characters or '_'.\", i);\n }\n const value = context.parse(args[i + 1], i + 1);\n if (!value)\n return null;\n bindings.push([name, value]);\n }\n const result = context.parse(args[args.length - 1], args.length - 1, context.expectedType, bindings);\n if (!result)\n return null;\n return new Let(bindings, result);\n }\n outputDefined() {\n return this.result.outputDefined();\n }\n}\n\nclass Var {\n constructor(name, boundExpression) {\n this.type = boundExpression.type;\n this.name = name;\n this.boundExpression = boundExpression;\n }\n static parse(args, context) {\n if (args.length !== 2 || typeof args[1] !== 'string')\n return context.error(\"'var' expression requires exactly one string literal argument.\");\n const name = args[1];\n if (!context.scope.has(name)) {\n return context.error(`Unknown variable \"${name}\". Make sure \"${name}\" has been bound in an enclosing \"let\" expression before using it.`, 1);\n }\n return new Var(name, context.scope.get(name));\n }\n evaluate(ctx) {\n return this.boundExpression.evaluate(ctx);\n }\n eachChild() { }\n outputDefined() {\n return false;\n }\n}\n\nclass At {\n constructor(type, index, input) {\n this.type = type;\n this.index = index;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 3)\n return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);\n const index = context.parse(args[1], 1, NumberType);\n const input = context.parse(args[2], 2, array(context.expectedType || ValueType));\n if (!index || !input)\n return null;\n const t = input.type;\n return new At(t.itemType, index, input);\n }\n evaluate(ctx) {\n const index = this.index.evaluate(ctx);\n const array = this.input.evaluate(ctx);\n if (index < 0) {\n throw new RuntimeError(`Array index out of bounds: ${index} < 0.`);\n }\n if (index >= array.length) {\n throw new RuntimeError(`Array index out of bounds: ${index} > ${array.length - 1}.`);\n }\n if (index !== Math.floor(index)) {\n throw new RuntimeError(`Array index must be an integer, but found ${index} instead.`);\n }\n return array[index];\n }\n eachChild(fn) {\n fn(this.index);\n fn(this.input);\n }\n outputDefined() {\n return false;\n }\n}\n\nclass In {\n constructor(needle, haystack) {\n this.type = BooleanType;\n this.needle = needle;\n this.haystack = haystack;\n }\n static parse(args, context) {\n if (args.length !== 3) {\n return context.error(`Expected 2 arguments, but found ${args.length - 1} instead.`);\n }\n const needle = context.parse(args[1], 1, ValueType);\n const haystack = context.parse(args[2], 2, ValueType);\n if (!needle || !haystack)\n return null;\n if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {\n return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${typeToString(needle.type)} instead`);\n }\n return new In(needle, haystack);\n }\n evaluate(ctx) {\n const needle = this.needle.evaluate(ctx);\n const haystack = this.haystack.evaluate(ctx);\n if (!haystack)\n return false;\n if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {\n throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${typeToString(typeOf(needle))} instead.`);\n }\n if (!isValidNativeType(haystack, ['string', 'array'])) {\n throw new RuntimeError(`Expected second argument to be of type array or string, but found ${typeToString(typeOf(haystack))} instead.`);\n }\n return haystack.indexOf(needle) >= 0;\n }\n eachChild(fn) {\n fn(this.needle);\n fn(this.haystack);\n }\n outputDefined() {\n return true;\n }\n}\n\nclass IndexOf {\n constructor(needle, haystack, fromIndex) {\n this.type = NumberType;\n this.needle = needle;\n this.haystack = haystack;\n this.fromIndex = fromIndex;\n }\n static parse(args, context) {\n if (args.length <= 2 || args.length >= 5) {\n return context.error(`Expected 2 or 3 arguments, but found ${args.length - 1} instead.`);\n }\n const needle = context.parse(args[1], 1, ValueType);\n const haystack = context.parse(args[2], 2, ValueType);\n if (!needle || !haystack)\n return null;\n if (!isValidType(needle.type, [BooleanType, StringType, NumberType, NullType, ValueType])) {\n return context.error(`Expected first argument to be of type boolean, string, number or null, but found ${typeToString(needle.type)} instead`);\n }\n if (args.length === 4) {\n const fromIndex = context.parse(args[3], 3, NumberType);\n if (!fromIndex)\n return null;\n return new IndexOf(needle, haystack, fromIndex);\n }\n else {\n return new IndexOf(needle, haystack);\n }\n }\n evaluate(ctx) {\n const needle = this.needle.evaluate(ctx);\n const haystack = this.haystack.evaluate(ctx);\n if (!isValidNativeType(needle, ['boolean', 'string', 'number', 'null'])) {\n throw new RuntimeError(`Expected first argument to be of type boolean, string, number or null, but found ${typeToString(typeOf(needle))} instead.`);\n }\n let fromIndex;\n if (this.fromIndex) {\n fromIndex = this.fromIndex.evaluate(ctx);\n }\n if (isValidNativeType(haystack, ['string'])) {\n const rawIndex = haystack.indexOf(needle, fromIndex);\n if (rawIndex === -1) {\n return -1;\n }\n else {\n // The index may be affected by surrogate pairs, so get the length of the preceding substring.\n return [...haystack.slice(0, rawIndex)].length;\n }\n }\n else if (isValidNativeType(haystack, ['array'])) {\n return haystack.indexOf(needle, fromIndex);\n }\n else {\n throw new RuntimeError(`Expected second argument to be of type array or string, but found ${typeToString(typeOf(haystack))} instead.`);\n }\n }\n eachChild(fn) {\n fn(this.needle);\n fn(this.haystack);\n if (this.fromIndex) {\n fn(this.fromIndex);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nclass Match {\n constructor(inputType, outputType, input, cases, outputs, otherwise) {\n this.inputType = inputType;\n this.type = outputType;\n this.input = input;\n this.cases = cases;\n this.outputs = outputs;\n this.otherwise = otherwise;\n }\n static parse(args, context) {\n if (args.length < 5)\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n if (args.length % 2 !== 1)\n return context.error('Expected an even number of arguments.');\n let inputType;\n let outputType;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n const cases = {};\n const outputs = [];\n for (let i = 2; i < args.length - 1; i += 2) {\n let labels = args[i];\n const value = args[i + 1];\n if (!Array.isArray(labels)) {\n labels = [labels];\n }\n const labelContext = context.concat(i);\n if (labels.length === 0) {\n return labelContext.error('Expected at least one branch label.');\n }\n for (const label of labels) {\n if (typeof label !== 'number' && typeof label !== 'string') {\n return labelContext.error('Branch labels must be numbers or strings.');\n }\n else if (typeof label === 'number' && Math.abs(label) > Number.MAX_SAFE_INTEGER) {\n return labelContext.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);\n }\n else if (typeof label === 'number' && Math.floor(label) !== label) {\n return labelContext.error('Numeric branch labels must be integer values.');\n }\n else if (!inputType) {\n inputType = typeOf(label);\n }\n else if (labelContext.checkSubtype(inputType, typeOf(label))) {\n return null;\n }\n if (typeof cases[String(label)] !== 'undefined') {\n return labelContext.error('Branch labels must be unique.');\n }\n cases[String(label)] = outputs.length;\n }\n const result = context.parse(value, i, outputType);\n if (!result)\n return null;\n outputType = outputType || result.type;\n outputs.push(result);\n }\n const input = context.parse(args[1], 1, ValueType);\n if (!input)\n return null;\n const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);\n if (!otherwise)\n return null;\n if (input.type.kind !== 'value' &&\n context.concat(1).checkSubtype(inputType, input.type)) {\n return null;\n }\n return new Match(inputType, outputType, input, cases, outputs, otherwise);\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n const output = (typeOf(input) === this.inputType && this.outputs[this.cases[input]]) || this.otherwise;\n return output.evaluate(ctx);\n }\n eachChild(fn) {\n fn(this.input);\n this.outputs.forEach(fn);\n fn(this.otherwise);\n }\n outputDefined() {\n return this.outputs.every((out) => out.outputDefined()) && this.otherwise.outputDefined();\n }\n}\n\nclass Case {\n constructor(type, branches, otherwise) {\n this.type = type;\n this.branches = branches;\n this.otherwise = otherwise;\n }\n static parse(args, context) {\n if (args.length < 4)\n return context.error(`Expected at least 3 arguments, but found only ${args.length - 1}.`);\n if (args.length % 2 !== 0)\n return context.error('Expected an odd number of arguments.');\n let outputType;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n const branches = [];\n for (let i = 1; i < args.length - 1; i += 2) {\n const test = context.parse(args[i], i, BooleanType);\n if (!test)\n return null;\n const result = context.parse(args[i + 1], i + 1, outputType);\n if (!result)\n return null;\n branches.push([test, result]);\n outputType = outputType || result.type;\n }\n const otherwise = context.parse(args[args.length - 1], args.length - 1, outputType);\n if (!otherwise)\n return null;\n if (!outputType)\n throw new Error(\"Can't infer output type\");\n return new Case(outputType, branches, otherwise);\n }\n evaluate(ctx) {\n for (const [test, expression] of this.branches) {\n if (test.evaluate(ctx)) {\n return expression.evaluate(ctx);\n }\n }\n return this.otherwise.evaluate(ctx);\n }\n eachChild(fn) {\n for (const [test, expression] of this.branches) {\n fn(test);\n fn(expression);\n }\n fn(this.otherwise);\n }\n outputDefined() {\n return (this.branches.every(([_, out]) => out.outputDefined()) && this.otherwise.outputDefined());\n }\n}\n\nclass Slice {\n constructor(type, input, beginIndex, endIndex) {\n this.type = type;\n this.input = input;\n this.beginIndex = beginIndex;\n this.endIndex = endIndex;\n }\n static parse(args, context) {\n if (args.length <= 2 || args.length >= 5) {\n return context.error(`Expected 2 or 3 arguments, but found ${args.length - 1} instead.`);\n }\n const input = context.parse(args[1], 1, ValueType);\n const beginIndex = context.parse(args[2], 2, NumberType);\n if (!input || !beginIndex)\n return null;\n if (!isValidType(input.type, [array(ValueType), StringType, ValueType])) {\n return context.error(`Expected first argument to be of type array or string, but found ${typeToString(input.type)} instead`);\n }\n if (args.length === 4) {\n const endIndex = context.parse(args[3], 3, NumberType);\n if (!endIndex)\n return null;\n return new Slice(input.type, input, beginIndex, endIndex);\n }\n else {\n return new Slice(input.type, input, beginIndex);\n }\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n const beginIndex = this.beginIndex.evaluate(ctx);\n let endIndex;\n if (this.endIndex) {\n endIndex = this.endIndex.evaluate(ctx);\n }\n if (isValidNativeType(input, ['string'])) {\n // Indices may be affected by surrogate pairs.\n return [...input].slice(beginIndex, endIndex).join('');\n }\n else if (isValidNativeType(input, ['array'])) {\n return input.slice(beginIndex, endIndex);\n }\n else {\n throw new RuntimeError(`Expected first argument to be of type array or string, but found ${typeToString(typeOf(input))} instead.`);\n }\n }\n eachChild(fn) {\n fn(this.input);\n fn(this.beginIndex);\n if (this.endIndex) {\n fn(this.endIndex);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\n/**\n * Returns the index of the last stop <= input, or 0 if it doesn't exist.\n * @private\n */\nfunction findStopLessThanOrEqualTo(stops, input) {\n const lastIndex = stops.length - 1;\n let lowerIndex = 0;\n let upperIndex = lastIndex;\n let currentIndex = 0;\n let currentValue, nextValue;\n while (lowerIndex <= upperIndex) {\n currentIndex = Math.floor((lowerIndex + upperIndex) / 2);\n currentValue = stops[currentIndex];\n nextValue = stops[currentIndex + 1];\n if (currentValue <= input) {\n if (currentIndex === lastIndex || input < nextValue) {\n // Search complete\n return currentIndex;\n }\n lowerIndex = currentIndex + 1;\n }\n else if (currentValue > input) {\n upperIndex = currentIndex - 1;\n }\n else {\n throw new RuntimeError('Input is not a number.');\n }\n }\n return 0;\n}\n\nclass Step {\n constructor(type, input, stops) {\n this.type = type;\n this.input = input;\n this.labels = [];\n this.outputs = [];\n for (const [label, expression] of stops) {\n this.labels.push(label);\n this.outputs.push(expression);\n }\n }\n static parse(args, context) {\n if (args.length - 1 < 4) {\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n }\n if ((args.length - 1) % 2 !== 0) {\n return context.error('Expected an even number of arguments.');\n }\n const input = context.parse(args[1], 1, NumberType);\n if (!input)\n return null;\n const stops = [];\n let outputType = null;\n if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n for (let i = 1; i < args.length; i += 2) {\n const label = i === 1 ? -Infinity : args[i];\n const value = args[i + 1];\n const labelKey = i;\n const valueKey = i + 1;\n if (typeof label !== 'number') {\n return context.error('Input/output pairs for \"step\" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);\n }\n if (stops.length && stops[stops.length - 1][0] >= label) {\n return context.error('Input/output pairs for \"step\" expressions must be arranged with input values in strictly ascending order.', labelKey);\n }\n const parsed = context.parse(value, valueKey, outputType);\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n stops.push([label, parsed]);\n }\n return new Step(outputType, input, stops);\n }\n evaluate(ctx) {\n const labels = this.labels;\n const outputs = this.outputs;\n if (labels.length === 1) {\n return outputs[0].evaluate(ctx);\n }\n const value = this.input.evaluate(ctx);\n if (value <= labels[0]) {\n return outputs[0].evaluate(ctx);\n }\n const stopCount = labels.length;\n if (value >= labels[stopCount - 1]) {\n return outputs[stopCount - 1].evaluate(ctx);\n }\n const index = findStopLessThanOrEqualTo(labels, value);\n return outputs[index].evaluate(ctx);\n }\n eachChild(fn) {\n fn(this.input);\n for (const expression of this.outputs) {\n fn(expression);\n }\n }\n outputDefined() {\n return this.outputs.every((out) => out.outputDefined());\n }\n}\n\nfunction getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\nvar unitbezier;\nvar hasRequiredUnitbezier;\n\nfunction requireUnitbezier () {\n\tif (hasRequiredUnitbezier) return unitbezier;\n\thasRequiredUnitbezier = 1;\n\n\tunitbezier = UnitBezier;\n\n\tfunction UnitBezier(p1x, p1y, p2x, p2y) {\n\t // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).\n\t this.cx = 3.0 * p1x;\n\t this.bx = 3.0 * (p2x - p1x) - this.cx;\n\t this.ax = 1.0 - this.cx - this.bx;\n\n\t this.cy = 3.0 * p1y;\n\t this.by = 3.0 * (p2y - p1y) - this.cy;\n\t this.ay = 1.0 - this.cy - this.by;\n\n\t this.p1x = p1x;\n\t this.p1y = p1y;\n\t this.p2x = p2x;\n\t this.p2y = p2y;\n\t}\n\n\tUnitBezier.prototype = {\n\t sampleCurveX: function (t) {\n\t // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.\n\t return ((this.ax * t + this.bx) * t + this.cx) * t;\n\t },\n\n\t sampleCurveY: function (t) {\n\t return ((this.ay * t + this.by) * t + this.cy) * t;\n\t },\n\n\t sampleCurveDerivativeX: function (t) {\n\t return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx;\n\t },\n\n\t solveCurveX: function (x, epsilon) {\n\t if (epsilon === undefined) epsilon = 1e-6;\n\n\t if (x < 0.0) return 0.0;\n\t if (x > 1.0) return 1.0;\n\n\t var t = x;\n\n\t // First try a few iterations of Newton's method - normally very fast.\n\t for (var i = 0; i < 8; i++) {\n\t var x2 = this.sampleCurveX(t) - x;\n\t if (Math.abs(x2) < epsilon) return t;\n\n\t var d2 = this.sampleCurveDerivativeX(t);\n\t if (Math.abs(d2) < 1e-6) break;\n\n\t t = t - x2 / d2;\n\t }\n\n\t // Fall back to the bisection method for reliability.\n\t var t0 = 0.0;\n\t var t1 = 1.0;\n\t t = x;\n\n\t for (i = 0; i < 20; i++) {\n\t x2 = this.sampleCurveX(t);\n\t if (Math.abs(x2 - x) < epsilon) break;\n\n\t if (x > x2) {\n\t t0 = t;\n\t } else {\n\t t1 = t;\n\t }\n\n\t t = (t1 - t0) * 0.5 + t0;\n\t }\n\n\t return t;\n\t },\n\n\t solve: function (x, epsilon) {\n\t return this.sampleCurveY(this.solveCurveX(x, epsilon));\n\t }\n\t};\n\treturn unitbezier;\n}\n\nvar unitbezierExports = requireUnitbezier();\nvar UnitBezier = /*@__PURE__*/getDefaultExportFromCjs(unitbezierExports);\n\nclass Interpolate {\n constructor(type, operator, interpolation, input, stops) {\n this.type = type;\n this.operator = operator;\n this.interpolation = interpolation;\n this.input = input;\n this.labels = [];\n this.outputs = [];\n for (const [label, expression] of stops) {\n this.labels.push(label);\n this.outputs.push(expression);\n }\n }\n static interpolationFactor(interpolation, input, lower, upper) {\n let t = 0;\n if (interpolation.name === 'exponential') {\n t = exponentialInterpolation(input, interpolation.base, lower, upper);\n }\n else if (interpolation.name === 'linear') {\n t = exponentialInterpolation(input, 1, lower, upper);\n }\n else if (interpolation.name === 'cubic-bezier') {\n const c = interpolation.controlPoints;\n const ub = new UnitBezier(c[0], c[1], c[2], c[3]);\n t = ub.solve(exponentialInterpolation(input, 1, lower, upper));\n }\n return t;\n }\n static parse(args, context) {\n let [operator, interpolation, input, ...rest] = args;\n if (!Array.isArray(interpolation) || interpolation.length === 0) {\n return context.error('Expected an interpolation type expression.', 1);\n }\n if (interpolation[0] === 'linear') {\n interpolation = { name: 'linear' };\n }\n else if (interpolation[0] === 'exponential') {\n const base = interpolation[1];\n if (typeof base !== 'number')\n return context.error('Exponential interpolation requires a numeric base.', 1, 1);\n interpolation = {\n name: 'exponential',\n base\n };\n }\n else if (interpolation[0] === 'cubic-bezier') {\n const controlPoints = interpolation.slice(1);\n if (controlPoints.length !== 4 ||\n controlPoints.some((t) => typeof t !== 'number' || t < 0 || t > 1)) {\n return context.error('Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.', 1);\n }\n interpolation = {\n name: 'cubic-bezier',\n controlPoints: controlPoints\n };\n }\n else {\n return context.error(`Unknown interpolation type ${String(interpolation[0])}`, 1, 0);\n }\n if (args.length - 1 < 4) {\n return context.error(`Expected at least 4 arguments, but found only ${args.length - 1}.`);\n }\n if ((args.length - 1) % 2 !== 0) {\n return context.error('Expected an even number of arguments.');\n }\n input = context.parse(input, 2, NumberType);\n if (!input)\n return null;\n const stops = [];\n let outputType = null;\n if ((operator === 'interpolate-hcl' || operator === 'interpolate-lab') &&\n context.expectedType != ColorArrayType) {\n outputType = ColorType;\n }\n else if (context.expectedType && context.expectedType.kind !== 'value') {\n outputType = context.expectedType;\n }\n for (let i = 0; i < rest.length; i += 2) {\n const label = rest[i];\n const value = rest[i + 1];\n const labelKey = i + 3;\n const valueKey = i + 4;\n if (typeof label !== 'number') {\n return context.error('Input/output pairs for \"interpolate\" expressions must be defined using literal numeric values (not computed expressions) for the input values.', labelKey);\n }\n if (stops.length && stops[stops.length - 1][0] >= label) {\n return context.error('Input/output pairs for \"interpolate\" expressions must be arranged with input values in strictly ascending order.', labelKey);\n }\n const parsed = context.parse(value, valueKey, outputType);\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n stops.push([label, parsed]);\n }\n if (!verifyType(outputType, NumberType) &&\n !verifyType(outputType, ProjectionDefinitionType) &&\n !verifyType(outputType, ColorType) &&\n !verifyType(outputType, PaddingType) &&\n !verifyType(outputType, NumberArrayType) &&\n !verifyType(outputType, ColorArrayType) &&\n !verifyType(outputType, VariableAnchorOffsetCollectionType) &&\n !verifyType(outputType, array(NumberType))) {\n return context.error(`Type ${typeToString(outputType)} is not interpolatable.`);\n }\n return new Interpolate(outputType, operator, interpolation, input, stops);\n }\n evaluate(ctx) {\n const labels = this.labels;\n const outputs = this.outputs;\n if (labels.length === 1) {\n return outputs[0].evaluate(ctx);\n }\n const value = this.input.evaluate(ctx);\n if (value <= labels[0]) {\n return outputs[0].evaluate(ctx);\n }\n const stopCount = labels.length;\n if (value >= labels[stopCount - 1]) {\n return outputs[stopCount - 1].evaluate(ctx);\n }\n const index = findStopLessThanOrEqualTo(labels, value);\n const lower = labels[index];\n const upper = labels[index + 1];\n const t = Interpolate.interpolationFactor(this.interpolation, value, lower, upper);\n const outputLower = outputs[index].evaluate(ctx);\n const outputUpper = outputs[index + 1].evaluate(ctx);\n switch (this.operator) {\n case 'interpolate':\n switch (this.type.kind) {\n case 'number':\n return interpolateNumber(outputLower, outputUpper, t);\n case 'color':\n return Color.interpolate(outputLower, outputUpper, t);\n case 'padding':\n return Padding.interpolate(outputLower, outputUpper, t);\n case 'colorArray':\n return ColorArray.interpolate(outputLower, outputUpper, t);\n case 'numberArray':\n return NumberArray.interpolate(outputLower, outputUpper, t);\n case 'variableAnchorOffsetCollection':\n return VariableAnchorOffsetCollection.interpolate(outputLower, outputUpper, t);\n case 'array':\n return interpolateArray(outputLower, outputUpper, t);\n case 'projectionDefinition':\n return ProjectionDefinition.interpolate(outputLower, outputUpper, t);\n }\n case 'interpolate-hcl':\n switch (this.type.kind) {\n case 'color':\n return Color.interpolate(outputLower, outputUpper, t, 'hcl');\n case 'colorArray':\n return ColorArray.interpolate(outputLower, outputUpper, t, 'hcl');\n }\n case 'interpolate-lab':\n switch (this.type.kind) {\n case 'color':\n return Color.interpolate(outputLower, outputUpper, t, 'lab');\n case 'colorArray':\n return ColorArray.interpolate(outputLower, outputUpper, t, 'lab');\n }\n }\n }\n eachChild(fn) {\n fn(this.input);\n for (const expression of this.outputs) {\n fn(expression);\n }\n }\n outputDefined() {\n return this.outputs.every((out) => out.outputDefined());\n }\n}\n/**\n * Returns a ratio that can be used to interpolate between exponential function\n * stops.\n * How it works: Two consecutive stop values define a (scaled and shifted) exponential function `f(x) = a * base^x + b`, where `base` is the user-specified base,\n * and `a` and `b` are constants affording sufficient degrees of freedom to fit\n * the function to the given stops.\n *\n * Here's a bit of algebra that lets us compute `f(x)` directly from the stop\n * values without explicitly solving for `a` and `b`:\n *\n * First stop value: `f(x0) = y0 = a * base^x0 + b`\n * Second stop value: `f(x1) = y1 = a * base^x1 + b`\n * => `y1 - y0 = a(base^x1 - base^x0)`\n * => `a = (y1 - y0)/(base^x1 - base^x0)`\n *\n * Desired value: `f(x) = y = a * base^x + b`\n * => `f(x) = y0 + a * (base^x - base^x0)`\n *\n * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a\n * little algebra:\n * ```\n * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)\n * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)\n * ```\n *\n * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have\n * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as\n * an interpolation factor between the two stops' output values.\n *\n * (Note: a slightly different form for `ratio`,\n * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer\n * expensive `Math.pow()` operations.)\n *\n * @private\n */\nfunction exponentialInterpolation(input, base, lowerValue, upperValue) {\n const difference = upperValue - lowerValue;\n const progress = input - lowerValue;\n if (difference === 0) {\n return 0;\n }\n else if (base === 1) {\n return progress / difference;\n }\n else {\n return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);\n }\n}\nconst interpolateFactory = {\n color: Color.interpolate,\n number: interpolateNumber,\n padding: Padding.interpolate,\n numberArray: NumberArray.interpolate,\n colorArray: ColorArray.interpolate,\n variableAnchorOffsetCollection: VariableAnchorOffsetCollection.interpolate,\n array: interpolateArray\n};\n\nclass Coalesce {\n constructor(type, args) {\n this.type = type;\n this.args = args;\n }\n static parse(args, context) {\n if (args.length < 2) {\n return context.error('Expected at least one argument.');\n }\n let outputType = null;\n const expectedType = context.expectedType;\n if (expectedType && expectedType.kind !== 'value') {\n outputType = expectedType;\n }\n const parsedArgs = [];\n for (const arg of args.slice(1)) {\n const parsed = context.parse(arg, 1 + parsedArgs.length, outputType, undefined, {\n typeAnnotation: 'omit'\n });\n if (!parsed)\n return null;\n outputType = outputType || parsed.type;\n parsedArgs.push(parsed);\n }\n if (!outputType)\n throw new Error('No output type');\n // Above, we parse arguments without inferred type annotation so that\n // they don't produce a runtime error for `null` input, which would\n // preempt the desired null-coalescing behavior.\n // Thus, if any of our arguments would have needed an annotation, we\n // need to wrap the enclosing coalesce expression with it instead.\n const needsAnnotation = expectedType && parsedArgs.some((arg) => checkSubtype(expectedType, arg.type));\n return needsAnnotation\n ? new Coalesce(ValueType, parsedArgs)\n : new Coalesce(outputType, parsedArgs);\n }\n evaluate(ctx) {\n let result = null;\n let argCount = 0;\n let requestedImageName;\n for (const arg of this.args) {\n argCount++;\n result = arg.evaluate(ctx);\n // we need to keep track of the first requested image in a coalesce statement\n // if coalesce can't find a valid image, we return the first image name so styleimagemissing can fire\n if (result && result instanceof ResolvedImage && !result.available) {\n if (!requestedImageName) {\n requestedImageName = result.name;\n }\n result = null;\n if (argCount === this.args.length) {\n result = requestedImageName;\n }\n }\n if (result !== null)\n break;\n }\n return result;\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return this.args.every((arg) => arg.outputDefined());\n }\n}\n\nfunction isComparableType(op, type) {\n if (op === '==' || op === '!=') {\n // equality operator\n return (type.kind === 'boolean' ||\n type.kind === 'string' ||\n type.kind === 'number' ||\n type.kind === 'null' ||\n type.kind === 'value');\n }\n else {\n // ordering operator\n return type.kind === 'string' || type.kind === 'number' || type.kind === 'value';\n }\n}\nfunction eq(ctx, a, b) {\n return a === b;\n}\nfunction neq(ctx, a, b) {\n return a !== b;\n}\nfunction lt(ctx, a, b) {\n return a < b;\n}\nfunction gt(ctx, a, b) {\n return a > b;\n}\nfunction lteq(ctx, a, b) {\n return a <= b;\n}\nfunction gteq(ctx, a, b) {\n return a >= b;\n}\nfunction eqCollate(ctx, a, b, c) {\n return c.compare(a, b) === 0;\n}\nfunction neqCollate(ctx, a, b, c) {\n return !eqCollate(ctx, a, b, c);\n}\nfunction ltCollate(ctx, a, b, c) {\n return c.compare(a, b) < 0;\n}\nfunction gtCollate(ctx, a, b, c) {\n return c.compare(a, b) > 0;\n}\nfunction lteqCollate(ctx, a, b, c) {\n return c.compare(a, b) <= 0;\n}\nfunction gteqCollate(ctx, a, b, c) {\n return c.compare(a, b) >= 0;\n}\n/**\n * Special form for comparison operators, implementing the signatures:\n * - (T, T, ?Collator) => boolean\n * - (T, value, ?Collator) => boolean\n * - (value, T, ?Collator) => boolean\n *\n * For inequalities, T must be either value, string, or number. For ==/!=, it\n * can also be boolean or null.\n *\n * Equality semantics are equivalent to Javascript's strict equality (===/!==)\n * -- i.e., when the arguments' types don't match, == evaluates to false, != to\n * true.\n *\n * When types don't match in an ordering comparison, a runtime error is thrown.\n *\n * @private\n */\nfunction makeComparison(op, compareBasic, compareWithCollator) {\n const isOrderComparison = op !== '==' && op !== '!=';\n return class Comparison {\n constructor(lhs, rhs, collator) {\n this.type = BooleanType;\n this.lhs = lhs;\n this.rhs = rhs;\n this.collator = collator;\n this.hasUntypedArgument = lhs.type.kind === 'value' || rhs.type.kind === 'value';\n }\n static parse(args, context) {\n if (args.length !== 3 && args.length !== 4)\n return context.error('Expected two or three arguments.');\n const op = args[0];\n let lhs = context.parse(args[1], 1, ValueType);\n if (!lhs)\n return null;\n if (!isComparableType(op, lhs.type)) {\n return context\n .concat(1)\n .error(`\"${op}\" comparisons are not supported for type '${typeToString(lhs.type)}'.`);\n }\n let rhs = context.parse(args[2], 2, ValueType);\n if (!rhs)\n return null;\n if (!isComparableType(op, rhs.type)) {\n return context\n .concat(2)\n .error(`\"${op}\" comparisons are not supported for type '${typeToString(rhs.type)}'.`);\n }\n if (lhs.type.kind !== rhs.type.kind &&\n lhs.type.kind !== 'value' &&\n rhs.type.kind !== 'value') {\n return context.error(`Cannot compare types '${typeToString(lhs.type)}' and '${typeToString(rhs.type)}'.`);\n }\n if (isOrderComparison) {\n // typing rules specific to less/greater than operators\n if (lhs.type.kind === 'value' && rhs.type.kind !== 'value') {\n // (value, T)\n lhs = new Assertion(rhs.type, [lhs]);\n }\n else if (lhs.type.kind !== 'value' && rhs.type.kind === 'value') {\n // (T, value)\n rhs = new Assertion(lhs.type, [rhs]);\n }\n }\n let collator = null;\n if (args.length === 4) {\n if (lhs.type.kind !== 'string' &&\n rhs.type.kind !== 'string' &&\n lhs.type.kind !== 'value' &&\n rhs.type.kind !== 'value') {\n return context.error('Cannot use collator to compare non-string types.');\n }\n collator = context.parse(args[3], 3, CollatorType);\n if (!collator)\n return null;\n }\n return new Comparison(lhs, rhs, collator);\n }\n evaluate(ctx) {\n const lhs = this.lhs.evaluate(ctx);\n const rhs = this.rhs.evaluate(ctx);\n if (isOrderComparison && this.hasUntypedArgument) {\n const lt = typeOf(lhs);\n const rt = typeOf(rhs);\n // check that type is string or number, and equal\n if (lt.kind !== rt.kind || !(lt.kind === 'string' || lt.kind === 'number')) {\n throw new RuntimeError(`Expected arguments for \"${op}\" to be (string, string) or (number, number), but found (${lt.kind}, ${rt.kind}) instead.`);\n }\n }\n if (this.collator && !isOrderComparison && this.hasUntypedArgument) {\n const lt = typeOf(lhs);\n const rt = typeOf(rhs);\n if (lt.kind !== 'string' || rt.kind !== 'string') {\n return compareBasic(ctx, lhs, rhs);\n }\n }\n return this.collator\n ? compareWithCollator(ctx, lhs, rhs, this.collator.evaluate(ctx))\n : compareBasic(ctx, lhs, rhs);\n }\n eachChild(fn) {\n fn(this.lhs);\n fn(this.rhs);\n if (this.collator) {\n fn(this.collator);\n }\n }\n outputDefined() {\n return true;\n }\n };\n}\nconst Equals = makeComparison('==', eq, eqCollate);\nconst NotEquals = makeComparison('!=', neq, neqCollate);\nconst LessThan = makeComparison('<', lt, ltCollate);\nconst GreaterThan = makeComparison('>', gt, gtCollate);\nconst LessThanOrEqual = makeComparison('<=', lteq, lteqCollate);\nconst GreaterThanOrEqual = makeComparison('>=', gteq, gteqCollate);\n\nclass CollatorExpression {\n constructor(caseSensitive, diacriticSensitive, locale) {\n this.type = CollatorType;\n this.locale = locale;\n this.caseSensitive = caseSensitive;\n this.diacriticSensitive = diacriticSensitive;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error('Expected one argument.');\n const options = args[1];\n if (typeof options !== 'object' || Array.isArray(options))\n return context.error('Collator options argument must be an object.');\n const caseSensitive = context.parse(options['case-sensitive'] === undefined ? false : options['case-sensitive'], 1, BooleanType);\n if (!caseSensitive)\n return null;\n const diacriticSensitive = context.parse(options['diacritic-sensitive'] === undefined ? false : options['diacritic-sensitive'], 1, BooleanType);\n if (!diacriticSensitive)\n return null;\n let locale = null;\n if (options['locale']) {\n locale = context.parse(options['locale'], 1, StringType);\n if (!locale)\n return null;\n }\n return new CollatorExpression(caseSensitive, diacriticSensitive, locale);\n }\n evaluate(ctx) {\n return new Collator(this.caseSensitive.evaluate(ctx), this.diacriticSensitive.evaluate(ctx), this.locale ? this.locale.evaluate(ctx) : null);\n }\n eachChild(fn) {\n fn(this.caseSensitive);\n fn(this.diacriticSensitive);\n if (this.locale) {\n fn(this.locale);\n }\n }\n outputDefined() {\n // Technically the set of possible outputs is the combinatoric set of Collators produced\n // by all possible outputs of locale/caseSensitive/diacriticSensitive\n // But for the primary use of Collators in comparison operators, we ignore the Collator's\n // possible outputs anyway, so we can get away with leaving this false for now.\n return false;\n }\n}\n\nclass NumberFormat {\n constructor(number, locale, currency, minFractionDigits, maxFractionDigits) {\n this.type = StringType;\n this.number = number;\n this.locale = locale;\n this.currency = currency;\n this.minFractionDigits = minFractionDigits;\n this.maxFractionDigits = maxFractionDigits;\n }\n static parse(args, context) {\n if (args.length !== 3)\n return context.error('Expected two arguments.');\n const number = context.parse(args[1], 1, NumberType);\n if (!number)\n return null;\n const options = args[2];\n if (typeof options !== 'object' || Array.isArray(options))\n return context.error('NumberFormat options argument must be an object.');\n let locale = null;\n if (options['locale']) {\n locale = context.parse(options['locale'], 1, StringType);\n if (!locale)\n return null;\n }\n let currency = null;\n if (options['currency']) {\n currency = context.parse(options['currency'], 1, StringType);\n if (!currency)\n return null;\n }\n let minFractionDigits = null;\n if (options['min-fraction-digits']) {\n minFractionDigits = context.parse(options['min-fraction-digits'], 1, NumberType);\n if (!minFractionDigits)\n return null;\n }\n let maxFractionDigits = null;\n if (options['max-fraction-digits']) {\n maxFractionDigits = context.parse(options['max-fraction-digits'], 1, NumberType);\n if (!maxFractionDigits)\n return null;\n }\n return new NumberFormat(number, locale, currency, minFractionDigits, maxFractionDigits);\n }\n evaluate(ctx) {\n return new Intl.NumberFormat(this.locale ? this.locale.evaluate(ctx) : [], {\n style: this.currency ? 'currency' : 'decimal',\n currency: this.currency ? this.currency.evaluate(ctx) : undefined,\n minimumFractionDigits: this.minFractionDigits\n ? this.minFractionDigits.evaluate(ctx)\n : undefined,\n maximumFractionDigits: this.maxFractionDigits\n ? this.maxFractionDigits.evaluate(ctx)\n : undefined\n }).format(this.number.evaluate(ctx));\n }\n eachChild(fn) {\n fn(this.number);\n if (this.locale) {\n fn(this.locale);\n }\n if (this.currency) {\n fn(this.currency);\n }\n if (this.minFractionDigits) {\n fn(this.minFractionDigits);\n }\n if (this.maxFractionDigits) {\n fn(this.maxFractionDigits);\n }\n }\n outputDefined() {\n return false;\n }\n}\n\nclass FormatExpression {\n constructor(sections) {\n this.type = FormattedType;\n this.sections = sections;\n }\n static parse(args, context) {\n if (args.length < 2) {\n return context.error('Expected at least one argument.');\n }\n const firstArg = args[1];\n if (!Array.isArray(firstArg) && typeof firstArg === 'object') {\n return context.error('First argument must be an image or text section.');\n }\n const sections = [];\n let nextTokenMayBeObject = false;\n for (let i = 1; i <= args.length - 1; ++i) {\n const arg = args[i];\n if (nextTokenMayBeObject && typeof arg === 'object' && !Array.isArray(arg)) {\n nextTokenMayBeObject = false;\n let scale = null;\n if (arg['font-scale']) {\n scale = context.parse(arg['font-scale'], 1, NumberType);\n if (!scale)\n return null;\n }\n let font = null;\n if (arg['text-font']) {\n font = context.parse(arg['text-font'], 1, array(StringType));\n if (!font)\n return null;\n }\n let textColor = null;\n if (arg['text-color']) {\n textColor = context.parse(arg['text-color'], 1, ColorType);\n if (!textColor)\n return null;\n }\n let verticalAlign = null;\n if (arg['vertical-align']) {\n if (typeof arg['vertical-align'] === 'string' &&\n !VERTICAL_ALIGN_OPTIONS.includes(arg['vertical-align'])) {\n return context.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${arg['vertical-align']}' instead.`);\n }\n verticalAlign = context.parse(arg['vertical-align'], 1, StringType);\n if (!verticalAlign)\n return null;\n }\n const lastExpression = sections[sections.length - 1];\n lastExpression.scale = scale;\n lastExpression.font = font;\n lastExpression.textColor = textColor;\n lastExpression.verticalAlign = verticalAlign;\n }\n else {\n const content = context.parse(args[i], 1, ValueType);\n if (!content)\n return null;\n const kind = content.type.kind;\n if (kind !== 'string' &&\n kind !== 'value' &&\n kind !== 'null' &&\n kind !== 'resolvedImage')\n return context.error(\"Formatted text type must be 'string', 'value', 'image' or 'null'.\");\n nextTokenMayBeObject = true;\n sections.push({\n content,\n scale: null,\n font: null,\n textColor: null,\n verticalAlign: null\n });\n }\n }\n return new FormatExpression(sections);\n }\n evaluate(ctx) {\n const evaluateSection = (section) => {\n const evaluatedContent = section.content.evaluate(ctx);\n if (typeOf(evaluatedContent) === ResolvedImageType) {\n return new FormattedSection('', evaluatedContent, null, null, null, section.verticalAlign ? section.verticalAlign.evaluate(ctx) : null);\n }\n return new FormattedSection(valueToString(evaluatedContent), null, section.scale ? section.scale.evaluate(ctx) : null, section.font ? section.font.evaluate(ctx).join(',') : null, section.textColor ? section.textColor.evaluate(ctx) : null, section.verticalAlign ? section.verticalAlign.evaluate(ctx) : null);\n };\n return new Formatted(this.sections.map(evaluateSection));\n }\n eachChild(fn) {\n for (const section of this.sections) {\n fn(section.content);\n if (section.scale) {\n fn(section.scale);\n }\n if (section.font) {\n fn(section.font);\n }\n if (section.textColor) {\n fn(section.textColor);\n }\n if (section.verticalAlign) {\n fn(section.verticalAlign);\n }\n }\n }\n outputDefined() {\n // Technically the combinatoric set of all children\n // Usually, this.text will be undefined anyway\n return false;\n }\n}\n\nclass ImageExpression {\n constructor(input) {\n this.type = ResolvedImageType;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 2) {\n return context.error('Expected two arguments.');\n }\n const name = context.parse(args[1], 1, StringType);\n if (!name)\n return context.error('No image name provided.');\n return new ImageExpression(name);\n }\n evaluate(ctx) {\n const evaluatedImageName = this.input.evaluate(ctx);\n const value = ResolvedImage.fromString(evaluatedImageName);\n if (value && ctx.availableImages)\n value.available = ctx.availableImages.indexOf(evaluatedImageName) > -1;\n return value;\n }\n eachChild(fn) {\n fn(this.input);\n }\n outputDefined() {\n // The output of image is determined by the list of available images in the evaluation context\n return false;\n }\n}\n\nclass Length {\n constructor(input) {\n this.type = NumberType;\n this.input = input;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`Expected 1 argument, but found ${args.length - 1} instead.`);\n const input = context.parse(args[1], 1);\n if (!input)\n return null;\n if (input.type.kind !== 'array' &&\n input.type.kind !== 'string' &&\n input.type.kind !== 'value')\n return context.error(`Expected argument of type string or array, but found ${typeToString(input.type)} instead.`);\n return new Length(input);\n }\n evaluate(ctx) {\n const input = this.input.evaluate(ctx);\n if (typeof input === 'string') {\n // The length may be affected by surrogate pairs.\n return [...input].length;\n }\n else if (Array.isArray(input)) {\n return input.length;\n }\n else {\n throw new RuntimeError(`Expected value to be of type string or array, but found ${typeToString(typeOf(input))} instead.`);\n }\n }\n eachChild(fn) {\n fn(this.input);\n }\n outputDefined() {\n return false;\n }\n}\n\nconst EXTENT = 8192;\nfunction getTileCoordinates(p, canonical) {\n const x = mercatorXfromLng(p[0]);\n const y = mercatorYfromLat(p[1]);\n const tilesAtZoom = Math.pow(2, canonical.z);\n return [Math.round(x * tilesAtZoom * EXTENT), Math.round(y * tilesAtZoom * EXTENT)];\n}\nfunction getLngLatFromTileCoord(coord, canonical) {\n const tilesAtZoom = Math.pow(2, canonical.z);\n const x = (coord[0] / EXTENT + canonical.x) / tilesAtZoom;\n const y = (coord[1] / EXTENT + canonical.y) / tilesAtZoom;\n return [lngFromMercatorXfromLng(x), latFromMercatorY(y)];\n}\nfunction mercatorXfromLng(lng) {\n return (180 + lng) / 360;\n}\nfunction lngFromMercatorXfromLng(mercatorX) {\n return mercatorX * 360 - 180;\n}\nfunction mercatorYfromLat(lat) {\n return (180 - (180 / Math.PI) * Math.log(Math.tan(Math.PI / 4 + (lat * Math.PI) / 360))) / 360;\n}\nfunction latFromMercatorY(mercatorY) {\n return (360 / Math.PI) * Math.atan(Math.exp(((180 - mercatorY * 360) * Math.PI) / 180)) - 90;\n}\nfunction updateBBox(bbox, coord) {\n bbox[0] = Math.min(bbox[0], coord[0]);\n bbox[1] = Math.min(bbox[1], coord[1]);\n bbox[2] = Math.max(bbox[2], coord[0]);\n bbox[3] = Math.max(bbox[3], coord[1]);\n}\nfunction boxWithinBox(bbox1, bbox2) {\n if (bbox1[0] <= bbox2[0])\n return false;\n if (bbox1[2] >= bbox2[2])\n return false;\n if (bbox1[1] <= bbox2[1])\n return false;\n if (bbox1[3] >= bbox2[3])\n return false;\n return true;\n}\nfunction rayIntersect(p, p1, p2) {\n return (p1[1] > p[1] !== p2[1] > p[1] &&\n p[0] < ((p2[0] - p1[0]) * (p[1] - p1[1])) / (p2[1] - p1[1]) + p1[0]);\n}\nfunction pointOnBoundary(p, p1, p2) {\n const x1 = p[0] - p1[0];\n const y1 = p[1] - p1[1];\n const x2 = p[0] - p2[0];\n const y2 = p[1] - p2[1];\n return x1 * y2 - x2 * y1 === 0 && x1 * x2 <= 0 && y1 * y2 <= 0;\n}\n// a, b are end points for line segment1, c and d are end points for line segment2\nfunction segmentIntersectSegment(a, b, c, d) {\n // check if two segments are parallel or not\n // precondition is end point a, b is inside polygon, if line a->b is\n // parallel to polygon edge c->d, then a->b won't intersect with c->d\n const vectorP = [b[0] - a[0], b[1] - a[1]];\n const vectorQ = [d[0] - c[0], d[1] - c[1]];\n if (perp(vectorQ, vectorP) === 0)\n return false;\n // If lines are intersecting with each other, the relative location should be:\n // a and b lie in different sides of segment c->d\n // c and d lie in different sides of segment a->b\n if (twoSided(a, b, c, d) && twoSided(c, d, a, b))\n return true;\n return false;\n}\nfunction lineIntersectPolygon(p1, p2, polygon) {\n for (const ring of polygon) {\n // loop through every edge of the ring\n for (let j = 0; j < ring.length - 1; ++j) {\n if (segmentIntersectSegment(p1, p2, ring[j], ring[j + 1])) {\n return true;\n }\n }\n }\n return false;\n}\n// ray casting algorithm for detecting if point is in polygon\nfunction pointWithinPolygon(point, rings, trueIfOnBoundary = false) {\n let inside = false;\n for (const ring of rings) {\n for (let j = 0; j < ring.length - 1; j++) {\n if (pointOnBoundary(point, ring[j], ring[j + 1]))\n return trueIfOnBoundary;\n if (rayIntersect(point, ring[j], ring[j + 1]))\n inside = !inside;\n }\n }\n return inside;\n}\nfunction pointWithinPolygons(point, polygons) {\n for (const polygon of polygons) {\n if (pointWithinPolygon(point, polygon))\n return true;\n }\n return false;\n}\nfunction lineStringWithinPolygon(line, polygon) {\n // First, check if geometry points of line segments are all inside polygon\n for (const point of line) {\n if (!pointWithinPolygon(point, polygon)) {\n return false;\n }\n }\n // Second, check if there is line segment intersecting polygon edge\n for (let i = 0; i < line.length - 1; ++i) {\n if (lineIntersectPolygon(line[i], line[i + 1], polygon)) {\n return false;\n }\n }\n return true;\n}\nfunction lineStringWithinPolygons(line, polygons) {\n for (const polygon of polygons) {\n if (lineStringWithinPolygon(line, polygon))\n return true;\n }\n return false;\n}\nfunction perp(v1, v2) {\n return v1[0] * v2[1] - v1[1] * v2[0];\n}\n// check if p1 and p2 are in different sides of line segment q1->q2\nfunction twoSided(p1, p2, q1, q2) {\n // q1->p1 (x1, y1), q1->p2 (x2, y2), q1->q2 (x3, y3)\n const x1 = p1[0] - q1[0];\n const y1 = p1[1] - q1[1];\n const x2 = p2[0] - q1[0];\n const y2 = p2[1] - q1[1];\n const x3 = q2[0] - q1[0];\n const y3 = q2[1] - q1[1];\n const det1 = x1 * y3 - x3 * y1;\n const det2 = x2 * y3 - x3 * y2;\n if ((det1 > 0 && det2 < 0) || (det1 < 0 && det2 > 0))\n return true;\n return false;\n}\n\nfunction getTilePolygon(coordinates, bbox, canonical) {\n const polygon = [];\n for (let i = 0; i < coordinates.length; i++) {\n const ring = [];\n for (let j = 0; j < coordinates[i].length; j++) {\n const coord = getTileCoordinates(coordinates[i][j], canonical);\n updateBBox(bbox, coord);\n ring.push(coord);\n }\n polygon.push(ring);\n }\n return polygon;\n}\nfunction getTilePolygons(coordinates, bbox, canonical) {\n const polygons = [];\n for (let i = 0; i < coordinates.length; i++) {\n const polygon = getTilePolygon(coordinates[i], bbox, canonical);\n polygons.push(polygon);\n }\n return polygons;\n}\nfunction updatePoint(p, bbox, polyBBox, worldSize) {\n if (p[0] < polyBBox[0] || p[0] > polyBBox[2]) {\n const halfWorldSize = worldSize * 0.5;\n let shift = p[0] - polyBBox[0] > halfWorldSize\n ? -worldSize\n : polyBBox[0] - p[0] > halfWorldSize\n ? worldSize\n : 0;\n if (shift === 0) {\n shift =\n p[0] - polyBBox[2] > halfWorldSize\n ? -worldSize\n : polyBBox[2] - p[0] > halfWorldSize\n ? worldSize\n : 0;\n }\n p[0] += shift;\n }\n updateBBox(bbox, p);\n}\nfunction resetBBox(bbox) {\n bbox[0] = bbox[1] = Infinity;\n bbox[2] = bbox[3] = -Infinity;\n}\nfunction getTilePoints(geometry, pointBBox, polyBBox, canonical) {\n const worldSize = Math.pow(2, canonical.z) * EXTENT;\n const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];\n const tilePoints = [];\n for (const points of geometry) {\n for (const point of points) {\n const p = [point.x + shifts[0], point.y + shifts[1]];\n updatePoint(p, pointBBox, polyBBox, worldSize);\n tilePoints.push(p);\n }\n }\n return tilePoints;\n}\nfunction getTileLines(geometry, lineBBox, polyBBox, canonical) {\n const worldSize = Math.pow(2, canonical.z) * EXTENT;\n const shifts = [canonical.x * EXTENT, canonical.y * EXTENT];\n const tileLines = [];\n for (const line of geometry) {\n const tileLine = [];\n for (const point of line) {\n const p = [point.x + shifts[0], point.y + shifts[1]];\n updateBBox(lineBBox, p);\n tileLine.push(p);\n }\n tileLines.push(tileLine);\n }\n if (lineBBox[2] - lineBBox[0] <= worldSize / 2) {\n resetBBox(lineBBox);\n for (const line of tileLines) {\n for (const p of line) {\n updatePoint(p, lineBBox, polyBBox, worldSize);\n }\n }\n }\n return tileLines;\n}\nfunction pointsWithinPolygons(ctx, polygonGeometry) {\n const pointBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const canonical = ctx.canonicalID();\n if (polygonGeometry.type === 'Polygon') {\n const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);\n const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);\n if (!boxWithinBox(pointBBox, polyBBox))\n return false;\n for (const point of tilePoints) {\n if (!pointWithinPolygon(point, tilePolygon))\n return false;\n }\n }\n if (polygonGeometry.type === 'MultiPolygon') {\n const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);\n const tilePoints = getTilePoints(ctx.geometry(), pointBBox, polyBBox, canonical);\n if (!boxWithinBox(pointBBox, polyBBox))\n return false;\n for (const point of tilePoints) {\n if (!pointWithinPolygons(point, tilePolygons))\n return false;\n }\n }\n return true;\n}\nfunction linesWithinPolygons(ctx, polygonGeometry) {\n const lineBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const polyBBox = [Infinity, Infinity, -Infinity, -Infinity];\n const canonical = ctx.canonicalID();\n if (polygonGeometry.type === 'Polygon') {\n const tilePolygon = getTilePolygon(polygonGeometry.coordinates, polyBBox, canonical);\n const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);\n if (!boxWithinBox(lineBBox, polyBBox))\n return false;\n for (const line of tileLines) {\n if (!lineStringWithinPolygon(line, tilePolygon))\n return false;\n }\n }\n if (polygonGeometry.type === 'MultiPolygon') {\n const tilePolygons = getTilePolygons(polygonGeometry.coordinates, polyBBox, canonical);\n const tileLines = getTileLines(ctx.geometry(), lineBBox, polyBBox, canonical);\n if (!boxWithinBox(lineBBox, polyBBox))\n return false;\n for (const line of tileLines) {\n if (!lineStringWithinPolygons(line, tilePolygons))\n return false;\n }\n }\n return true;\n}\nclass Within {\n constructor(geojson, geometries) {\n this.type = BooleanType;\n this.geojson = geojson;\n this.geometries = geometries;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'within' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (isValue(args[1])) {\n const geojson = args[1];\n if (geojson.type === 'FeatureCollection') {\n const polygonsCoords = [];\n for (const polygon of geojson.features) {\n const { type, coordinates } = polygon.geometry;\n if (type === 'Polygon') {\n polygonsCoords.push(coordinates);\n }\n if (type === 'MultiPolygon') {\n polygonsCoords.push(...coordinates);\n }\n }\n if (polygonsCoords.length) {\n const multipolygonWrapper = {\n type: 'MultiPolygon',\n coordinates: polygonsCoords\n };\n return new Within(geojson, multipolygonWrapper);\n }\n }\n else if (geojson.type === 'Feature') {\n const type = geojson.geometry.type;\n if (type === 'Polygon' || type === 'MultiPolygon') {\n return new Within(geojson, geojson.geometry);\n }\n }\n else if (geojson.type === 'Polygon' || geojson.type === 'MultiPolygon') {\n return new Within(geojson, geojson);\n }\n }\n return context.error(\"'within' expression requires valid geojson object that contains polygon geometry type.\");\n }\n evaluate(ctx) {\n if (ctx.geometry() != null && ctx.canonicalID() != null) {\n if (ctx.geometryType() === 'Point') {\n return pointsWithinPolygons(ctx, this.geometries);\n }\n else if (ctx.geometryType() === 'LineString') {\n return linesWithinPolygons(ctx, this.geometries);\n }\n }\n return false;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nclass TinyQueue {\n constructor(data = [], compare = (a, b) => (a < b ? -1 : a > b ? 1 : 0)) {\n this.data = data;\n this.length = this.data.length;\n this.compare = compare;\n\n if (this.length > 0) {\n for (let i = (this.length >> 1) - 1; i >= 0; i--) this._down(i);\n }\n }\n\n push(item) {\n this.data.push(item);\n this._up(this.length++);\n }\n\n pop() {\n if (this.length === 0) return undefined;\n\n const top = this.data[0];\n const bottom = this.data.pop();\n\n if (--this.length > 0) {\n this.data[0] = bottom;\n this._down(0);\n }\n\n return top;\n }\n\n peek() {\n return this.data[0];\n }\n\n _up(pos) {\n const {data, compare} = this;\n const item = data[pos];\n\n while (pos > 0) {\n const parent = (pos - 1) >> 1;\n const current = data[parent];\n if (compare(item, current) >= 0) break;\n data[pos] = current;\n pos = parent;\n }\n\n data[pos] = item;\n }\n\n _down(pos) {\n const {data, compare} = this;\n const halfLength = this.length >> 1;\n const item = data[pos];\n\n while (pos < halfLength) {\n let bestChild = (pos << 1) + 1; // initially it is the left child\n const right = bestChild + 1;\n\n if (right < this.length && compare(data[right], data[bestChild]) < 0) {\n bestChild = right;\n }\n if (compare(data[bestChild], item) >= 0) break;\n\n data[pos] = data[bestChild];\n pos = bestChild;\n }\n\n data[pos] = item;\n }\n}\n\n/**\n * Rearranges items so that all items in the [left, k] are the smallest.\n * The k-th element will have the (k - left + 1)-th smallest value in [left, right].\n *\n * @template T\n * @param {T[]} arr the array to partially sort (in place)\n * @param {number} k middle index for partial sorting (as defined above)\n * @param {number} [left=0] left index of the range to sort\n * @param {number} [right=arr.length-1] right index\n * @param {(a: T, b: T) => number} [compare = (a, b) => a - b] compare function\n */\nfunction quickselect(arr, k, left = 0, right = arr.length - 1, compare = defaultCompare) {\n\n while (right > left) {\n if (right - left > 600) {\n const n = right - left + 1;\n const m = k - left + 1;\n const z = Math.log(n);\n const s = 0.5 * Math.exp(2 * z / 3);\n const sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);\n const newLeft = Math.max(left, Math.floor(k - m * s / n + sd));\n const newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));\n quickselect(arr, k, newLeft, newRight, compare);\n }\n\n const t = arr[k];\n let i = left;\n /** @type {number} */\n let j = right;\n\n swap(arr, left, k);\n if (compare(arr[right], t) > 0) swap(arr, left, right);\n\n while (i < j) {\n swap(arr, i, j);\n i++;\n j--;\n while (compare(arr[i], t) < 0) i++;\n while (compare(arr[j], t) > 0) j--;\n }\n\n if (compare(arr[left], t) === 0) swap(arr, left, j);\n else {\n j++;\n swap(arr, j, right);\n }\n\n if (j <= k) left = j + 1;\n if (k <= j) right = j - 1;\n }\n}\n\n/**\n * @template T\n * @param {T[]} arr\n * @param {number} i\n * @param {number} j\n */\nfunction swap(arr, i, j) {\n const tmp = arr[i];\n arr[i] = arr[j];\n arr[j] = tmp;\n}\n\n/**\n * @template T\n * @param {T} a\n * @param {T} b\n * @returns {number}\n */\nfunction defaultCompare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\n/**\n * Classifies an array of rings into polygons with outer rings and holes\n * @param rings - the rings to classify\n * @param maxRings - the maximum number of rings to include in a polygon, use 0 to include all rings\n * @returns an array of polygons with internal rings as holes\n */\nfunction classifyRings(rings, maxRings) {\n const len = rings.length;\n if (len <= 1)\n return [rings];\n const polygons = [];\n let polygon;\n let ccw;\n for (const ring of rings) {\n const area = calculateSignedArea(ring);\n if (area === 0)\n continue;\n ring.area = Math.abs(area);\n if (ccw === undefined)\n ccw = area < 0;\n if (ccw === area < 0) {\n if (polygon)\n polygons.push(polygon);\n polygon = [ring];\n }\n else {\n polygon.push(ring);\n }\n }\n if (polygon)\n polygons.push(polygon);\n // Earcut performance degrades with the # of rings in a polygon. For this\n // reason, we limit strip out all but the `maxRings` largest rings.\n if (maxRings > 1) {\n for (let j = 0; j < polygons.length; j++) {\n if (polygons[j].length <= maxRings)\n continue;\n quickselect(polygons[j], maxRings, 1, polygons[j].length - 1, compareAreas);\n polygons[j] = polygons[j].slice(0, maxRings);\n }\n }\n return polygons;\n}\nfunction compareAreas(a, b) {\n return b.area - a.area;\n}\n/**\n * Returns the signed area for the polygon ring. Positive areas are exterior rings and\n * have a clockwise winding. Negative areas are interior rings and have a counter clockwise\n * ordering.\n *\n * @param ring - Exterior or interior ring\n * @returns Signed area\n */\nfunction calculateSignedArea(ring) {\n let sum = 0;\n for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2.x - p1.x) * (p1.y + p2.y);\n }\n return sum;\n}\n\n// This is taken from https://github.com/mapbox/cheap-ruler/ in order to take only the relevant parts\n// Values that define WGS84 ellipsoid model of the Earth\nconst RE = 6378.137; // equatorial radius\nconst FE = 1 / 298.257223563; // flattening\nconst E2 = FE * (2 - FE);\nconst RAD = Math.PI / 180;\nclass CheapRuler {\n constructor(lat) {\n // Curvature formulas from https://en.wikipedia.org/wiki/Earth_radius#Meridional\n const m = RAD * RE * 1000;\n const coslat = Math.cos(lat * RAD);\n const w2 = 1 / (1 - E2 * (1 - coslat * coslat));\n const w = Math.sqrt(w2);\n // multipliers for converting longitude and latitude degrees into distance\n this.kx = m * w * coslat; // based on normal radius of curvature\n this.ky = m * w * w2 * (1 - E2); // based on meridional radius of curvature\n }\n /**\n * Given two points of the form [longitude, latitude], returns the distance.\n *\n * @param a - point [longitude, latitude]\n * @param b - point [longitude, latitude]\n * @returns distance\n * @example\n * const distance = ruler.distance([30.5, 50.5], [30.51, 50.49]);\n * //=distance\n */\n distance(a, b) {\n const dx = this.wrap(a[0] - b[0]) * this.kx;\n const dy = (a[1] - b[1]) * this.ky;\n return Math.sqrt(dx * dx + dy * dy);\n }\n /**\n * Returns an object of the form {point, index, t}, where point is closest point on the line\n * from the given point, index is the start index of the segment with the closest point,\n * and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.\n *\n * @param line - an array of points that form the line\n * @param p - point [longitude, latitude]\n * @returns the nearest point, its index in the array and the proportion along the line\n * @example\n * const point = ruler.pointOnLine(line, [-67.04, 50.5]).point;\n * //=point\n */\n pointOnLine(line, p) {\n let minDist = Infinity;\n let minX, minY, minI, minT;\n for (let i = 0; i < line.length - 1; i++) {\n let x = line[i][0];\n let y = line[i][1];\n let dx = this.wrap(line[i + 1][0] - x) * this.kx;\n let dy = (line[i + 1][1] - y) * this.ky;\n let t = 0;\n if (dx !== 0 || dy !== 0) {\n t =\n (this.wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) /\n (dx * dx + dy * dy);\n if (t > 1) {\n x = line[i + 1][0];\n y = line[i + 1][1];\n }\n else if (t > 0) {\n x += (dx / this.kx) * t;\n y += (dy / this.ky) * t;\n }\n }\n dx = this.wrap(p[0] - x) * this.kx;\n dy = (p[1] - y) * this.ky;\n const sqDist = dx * dx + dy * dy;\n if (sqDist < minDist) {\n minDist = sqDist;\n minX = x;\n minY = y;\n minI = i;\n minT = t;\n }\n }\n return {\n point: [minX, minY],\n index: minI,\n t: Math.max(0, Math.min(1, minT))\n };\n }\n wrap(deg) {\n while (deg < -180)\n deg += 360;\n while (deg > 180)\n deg -= 360;\n return deg;\n }\n}\n\nconst MinPointsSize = 100;\nconst MinLinePointsSize = 50;\nfunction compareDistPair(a, b) {\n return b[0] - a[0];\n}\nfunction getRangeSize(range) {\n return range[1] - range[0] + 1;\n}\nfunction isRangeSafe(range, threshold) {\n return range[1] >= range[0] && range[1] < threshold;\n}\nfunction splitRange(range, isLine) {\n if (range[0] > range[1]) {\n return [null, null];\n }\n const size = getRangeSize(range);\n if (isLine) {\n if (size === 2) {\n return [range, null];\n }\n const size1 = Math.floor(size / 2);\n return [\n [range[0], range[0] + size1],\n [range[0] + size1, range[1]]\n ];\n }\n if (size === 1) {\n return [range, null];\n }\n const size1 = Math.floor(size / 2) - 1;\n return [\n [range[0], range[0] + size1],\n [range[0] + size1 + 1, range[1]]\n ];\n}\nfunction getBBox(coords, range) {\n if (!isRangeSafe(range, coords.length)) {\n return [Infinity, Infinity, -Infinity, -Infinity];\n }\n const bbox = [Infinity, Infinity, -Infinity, -Infinity];\n for (let i = range[0]; i <= range[1]; ++i) {\n updateBBox(bbox, coords[i]);\n }\n return bbox;\n}\nfunction getPolygonBBox(polygon) {\n const bbox = [Infinity, Infinity, -Infinity, -Infinity];\n for (const ring of polygon) {\n for (const coord of ring) {\n updateBBox(bbox, coord);\n }\n }\n return bbox;\n}\nfunction isValidBBox(bbox) {\n return (bbox[0] !== -Infinity &&\n bbox[1] !== -Infinity &&\n bbox[2] !== Infinity &&\n bbox[3] !== Infinity);\n}\n// Calculate the distance between two bounding boxes.\n// Calculate the delta in x and y direction, and use two fake points {0.0, 0.0}\n// and {dx, dy} to calculate the distance. Distance will be 0.0 if bounding box are overlapping.\nfunction bboxToBBoxDistance(bbox1, bbox2, ruler) {\n if (!isValidBBox(bbox1) || !isValidBBox(bbox2)) {\n return NaN;\n }\n let dx = 0.0;\n let dy = 0.0;\n // bbox1 in left side\n if (bbox1[2] < bbox2[0]) {\n dx = bbox2[0] - bbox1[2];\n }\n // bbox1 in right side\n if (bbox1[0] > bbox2[2]) {\n dx = bbox1[0] - bbox2[2];\n }\n // bbox1 in above side\n if (bbox1[1] > bbox2[3]) {\n dy = bbox1[1] - bbox2[3];\n }\n // bbox1 in down side\n if (bbox1[3] < bbox2[1]) {\n dy = bbox2[1] - bbox1[3];\n }\n return ruler.distance([0.0, 0.0], [dx, dy]);\n}\nfunction pointToLineDistance(point, line, ruler) {\n const nearestPoint = ruler.pointOnLine(line, point);\n return ruler.distance(point, nearestPoint.point);\n}\nfunction segmentToSegmentDistance(p1, p2, q1, q2, ruler) {\n const dist1 = Math.min(pointToLineDistance(p1, [q1, q2], ruler), pointToLineDistance(p2, [q1, q2], ruler));\n const dist2 = Math.min(pointToLineDistance(q1, [p1, p2], ruler), pointToLineDistance(q2, [p1, p2], ruler));\n return Math.min(dist1, dist2);\n}\nfunction lineToLineDistance(line1, range1, line2, range2, ruler) {\n const rangeSafe = isRangeSafe(range1, line1.length) && isRangeSafe(range2, line2.length);\n if (!rangeSafe) {\n return Infinity;\n }\n let dist = Infinity;\n for (let i = range1[0]; i < range1[1]; ++i) {\n const p1 = line1[i];\n const p2 = line1[i + 1];\n for (let j = range2[0]; j < range2[1]; ++j) {\n const q1 = line2[j];\n const q2 = line2[j + 1];\n if (segmentIntersectSegment(p1, p2, q1, q2)) {\n return 0.0;\n }\n dist = Math.min(dist, segmentToSegmentDistance(p1, p2, q1, q2, ruler));\n }\n }\n return dist;\n}\nfunction pointsToPointsDistance(points1, range1, points2, range2, ruler) {\n const rangeSafe = isRangeSafe(range1, points1.length) && isRangeSafe(range2, points2.length);\n if (!rangeSafe) {\n return NaN;\n }\n let dist = Infinity;\n for (let i = range1[0]; i <= range1[1]; ++i) {\n for (let j = range2[0]; j <= range2[1]; ++j) {\n dist = Math.min(dist, ruler.distance(points1[i], points2[j]));\n if (dist === 0.0) {\n return dist;\n }\n }\n }\n return dist;\n}\nfunction pointToPolygonDistance(point, polygon, ruler) {\n if (pointWithinPolygon(point, polygon, true)) {\n return 0.0;\n }\n let dist = Infinity;\n for (const ring of polygon) {\n const front = ring[0];\n const back = ring[ring.length - 1];\n if (front !== back) {\n dist = Math.min(dist, pointToLineDistance(point, [back, front], ruler));\n if (dist === 0.0) {\n return dist;\n }\n }\n const nearestPoint = ruler.pointOnLine(ring, point);\n dist = Math.min(dist, ruler.distance(point, nearestPoint.point));\n if (dist === 0.0) {\n return dist;\n }\n }\n return dist;\n}\nfunction lineToPolygonDistance(line, range, polygon, ruler) {\n if (!isRangeSafe(range, line.length)) {\n return NaN;\n }\n for (let i = range[0]; i <= range[1]; ++i) {\n if (pointWithinPolygon(line[i], polygon, true)) {\n return 0.0;\n }\n }\n let dist = Infinity;\n for (let i = range[0]; i < range[1]; ++i) {\n const p1 = line[i];\n const p2 = line[i + 1];\n for (const ring of polygon) {\n for (let j = 0, len = ring.length, k = len - 1; j < len; k = j++) {\n const q1 = ring[k];\n const q2 = ring[j];\n if (segmentIntersectSegment(p1, p2, q1, q2)) {\n return 0.0;\n }\n dist = Math.min(dist, segmentToSegmentDistance(p1, p2, q1, q2, ruler));\n }\n }\n }\n return dist;\n}\nfunction polygonIntersect(poly1, poly2) {\n for (const ring of poly1) {\n for (const point of ring) {\n if (pointWithinPolygon(point, poly2, true)) {\n return true;\n }\n }\n }\n return false;\n}\nfunction polygonToPolygonDistance(polygon1, polygon2, ruler, currentMiniDist = Infinity) {\n const bbox1 = getPolygonBBox(polygon1);\n const bbox2 = getPolygonBBox(polygon2);\n if (currentMiniDist !== Infinity &&\n bboxToBBoxDistance(bbox1, bbox2, ruler) >= currentMiniDist) {\n return currentMiniDist;\n }\n if (boxWithinBox(bbox1, bbox2)) {\n if (polygonIntersect(polygon1, polygon2)) {\n return 0.0;\n }\n }\n else if (polygonIntersect(polygon2, polygon1)) {\n return 0.0;\n }\n let dist = Infinity;\n for (const ring1 of polygon1) {\n for (let i = 0, len1 = ring1.length, l = len1 - 1; i < len1; l = i++) {\n const p1 = ring1[l];\n const p2 = ring1[i];\n for (const ring2 of polygon2) {\n for (let j = 0, len2 = ring2.length, k = len2 - 1; j < len2; k = j++) {\n const q1 = ring2[k];\n const q2 = ring2[j];\n if (segmentIntersectSegment(p1, p2, q1, q2)) {\n return 0.0;\n }\n dist = Math.min(dist, segmentToSegmentDistance(p1, p2, q1, q2, ruler));\n }\n }\n }\n }\n return dist;\n}\nfunction updateQueue(distQueue, miniDist, ruler, points, polyBBox, rangeA) {\n if (!rangeA) {\n return;\n }\n const tempDist = bboxToBBoxDistance(getBBox(points, rangeA), polyBBox, ruler);\n // Insert new pair to the queue if the bbox distance is less than\n // miniDist, The pair with biggest distance will be at the top\n if (tempDist < miniDist) {\n distQueue.push([tempDist, rangeA, [0, 0]]);\n }\n}\nfunction updateQueueTwoSets(distQueue, miniDist, ruler, pointSet1, pointSet2, range1, range2) {\n if (!range1 || !range2) {\n return;\n }\n const tempDist = bboxToBBoxDistance(getBBox(pointSet1, range1), getBBox(pointSet2, range2), ruler);\n // Insert new pair to the queue if the bbox distance is less than\n // miniDist, The pair with biggest distance will be at the top\n if (tempDist < miniDist) {\n distQueue.push([tempDist, range1, range2]);\n }\n}\n// Divide and conquer, the time complexity is O(n*lgn), faster than Brute force\n// O(n*n) Most of the time, use index for in-place processing.\nfunction pointsToPolygonDistance(points, isLine, polygon, ruler, currentMiniDist = Infinity) {\n let miniDist = Math.min(ruler.distance(points[0], polygon[0][0]), currentMiniDist);\n if (miniDist === 0.0) {\n return miniDist;\n }\n const distQueue = new TinyQueue([[0, [0, points.length - 1], [0, 0]]], compareDistPair);\n const polyBBox = getPolygonBBox(polygon);\n while (distQueue.length > 0) {\n const distPair = distQueue.pop();\n if (distPair[0] >= miniDist) {\n continue;\n }\n const range = distPair[1];\n // In case the set size are relatively small, we could use brute-force directly\n const threshold = isLine ? MinLinePointsSize : MinPointsSize;\n if (getRangeSize(range) <= threshold) {\n if (!isRangeSafe(range, points.length)) {\n return NaN;\n }\n if (isLine) {\n const tempDist = lineToPolygonDistance(points, range, polygon, ruler);\n if (isNaN(tempDist) || tempDist === 0.0) {\n return tempDist;\n }\n miniDist = Math.min(miniDist, tempDist);\n }\n else {\n for (let i = range[0]; i <= range[1]; ++i) {\n const tempDist = pointToPolygonDistance(points[i], polygon, ruler);\n miniDist = Math.min(miniDist, tempDist);\n if (miniDist === 0.0) {\n return 0.0;\n }\n }\n }\n }\n else {\n const newRangesA = splitRange(range, isLine);\n updateQueue(distQueue, miniDist, ruler, points, polyBBox, newRangesA[0]);\n updateQueue(distQueue, miniDist, ruler, points, polyBBox, newRangesA[1]);\n }\n }\n return miniDist;\n}\nfunction pointSetToPointSetDistance(pointSet1, isLine1, pointSet2, isLine2, ruler, currentMiniDist = Infinity) {\n let miniDist = Math.min(currentMiniDist, ruler.distance(pointSet1[0], pointSet2[0]));\n if (miniDist === 0.0) {\n return miniDist;\n }\n const distQueue = new TinyQueue([[0, [0, pointSet1.length - 1], [0, pointSet2.length - 1]]], compareDistPair);\n while (distQueue.length > 0) {\n const distPair = distQueue.pop();\n if (distPair[0] >= miniDist) {\n continue;\n }\n const rangeA = distPair[1];\n const rangeB = distPair[2];\n const threshold1 = isLine1 ? MinLinePointsSize : MinPointsSize;\n const threshold2 = isLine2 ? MinLinePointsSize : MinPointsSize;\n // In case the set size are relatively small, we could use brute-force directly\n if (getRangeSize(rangeA) <= threshold1 && getRangeSize(rangeB) <= threshold2) {\n if (!isRangeSafe(rangeA, pointSet1.length) && isRangeSafe(rangeB, pointSet2.length)) {\n return NaN;\n }\n let tempDist;\n if (isLine1 && isLine2) {\n tempDist = lineToLineDistance(pointSet1, rangeA, pointSet2, rangeB, ruler);\n miniDist = Math.min(miniDist, tempDist);\n }\n else if (isLine1 && !isLine2) {\n const sublibe = pointSet1.slice(rangeA[0], rangeA[1] + 1);\n for (let i = rangeB[0]; i <= rangeB[1]; ++i) {\n tempDist = pointToLineDistance(pointSet2[i], sublibe, ruler);\n miniDist = Math.min(miniDist, tempDist);\n if (miniDist === 0.0) {\n return miniDist;\n }\n }\n }\n else if (!isLine1 && isLine2) {\n const sublibe = pointSet2.slice(rangeB[0], rangeB[1] + 1);\n for (let i = rangeA[0]; i <= rangeA[1]; ++i) {\n tempDist = pointToLineDistance(pointSet1[i], sublibe, ruler);\n miniDist = Math.min(miniDist, tempDist);\n if (miniDist === 0.0) {\n return miniDist;\n }\n }\n }\n else {\n tempDist = pointsToPointsDistance(pointSet1, rangeA, pointSet2, rangeB, ruler);\n miniDist = Math.min(miniDist, tempDist);\n }\n }\n else {\n const newRangesA = splitRange(rangeA, isLine1);\n const newRangesB = splitRange(rangeB, isLine2);\n updateQueueTwoSets(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[0], newRangesB[0]);\n updateQueueTwoSets(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[0], newRangesB[1]);\n updateQueueTwoSets(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[1], newRangesB[0]);\n updateQueueTwoSets(distQueue, miniDist, ruler, pointSet1, pointSet2, newRangesA[1], newRangesB[1]);\n }\n }\n return miniDist;\n}\nfunction pointToGeometryDistance(ctx, geometries) {\n const tilePoints = ctx.geometry();\n const pointPosition = tilePoints\n .flat()\n .map((p) => getLngLatFromTileCoord([p.x, p.y], ctx.canonical));\n if (tilePoints.length === 0) {\n return NaN;\n }\n const ruler = new CheapRuler(pointPosition[0][1]);\n let dist = Infinity;\n for (const geometry of geometries) {\n switch (geometry.type) {\n case 'Point':\n dist = Math.min(dist, pointSetToPointSetDistance(pointPosition, false, [geometry.coordinates], false, ruler, dist));\n break;\n case 'LineString':\n dist = Math.min(dist, pointSetToPointSetDistance(pointPosition, false, geometry.coordinates, true, ruler, dist));\n break;\n case 'Polygon':\n dist = Math.min(dist, pointsToPolygonDistance(pointPosition, false, geometry.coordinates, ruler, dist));\n break;\n }\n if (dist === 0.0) {\n return dist;\n }\n }\n return dist;\n}\nfunction lineStringToGeometryDistance(ctx, geometries) {\n const tileLine = ctx.geometry();\n const linePositions = tileLine\n .flat()\n .map((p) => getLngLatFromTileCoord([p.x, p.y], ctx.canonical));\n if (tileLine.length === 0) {\n return NaN;\n }\n const ruler = new CheapRuler(linePositions[0][1]);\n let dist = Infinity;\n for (const geometry of geometries) {\n switch (geometry.type) {\n case 'Point':\n dist = Math.min(dist, pointSetToPointSetDistance(linePositions, true, [geometry.coordinates], false, ruler, dist));\n break;\n case 'LineString':\n dist = Math.min(dist, pointSetToPointSetDistance(linePositions, true, geometry.coordinates, true, ruler, dist));\n break;\n case 'Polygon':\n dist = Math.min(dist, pointsToPolygonDistance(linePositions, true, geometry.coordinates, ruler, dist));\n break;\n }\n if (dist === 0.0) {\n return dist;\n }\n }\n return dist;\n}\nfunction polygonToGeometryDistance(ctx, geometries) {\n const tilePolygon = ctx.geometry();\n if (tilePolygon.length === 0 || tilePolygon[0].length === 0) {\n return NaN;\n }\n const polygons = classifyRings(tilePolygon, 0).map((polygon) => {\n return polygon.map((ring) => {\n return ring.map((p) => getLngLatFromTileCoord([p.x, p.y], ctx.canonical));\n });\n });\n const ruler = new CheapRuler(polygons[0][0][0][1]);\n let dist = Infinity;\n for (const geometry of geometries) {\n for (const polygon of polygons) {\n switch (geometry.type) {\n case 'Point':\n dist = Math.min(dist, pointsToPolygonDistance([geometry.coordinates], false, polygon, ruler, dist));\n break;\n case 'LineString':\n dist = Math.min(dist, pointsToPolygonDistance(geometry.coordinates, true, polygon, ruler, dist));\n break;\n case 'Polygon':\n dist = Math.min(dist, polygonToPolygonDistance(polygon, geometry.coordinates, ruler, dist));\n break;\n }\n if (dist === 0.0) {\n return dist;\n }\n }\n }\n return dist;\n}\nfunction toSimpleGeometry(geometry) {\n if (geometry.type === 'MultiPolygon') {\n return geometry.coordinates.map((polygon) => {\n return {\n type: 'Polygon',\n coordinates: polygon\n };\n });\n }\n if (geometry.type === 'MultiLineString') {\n return geometry.coordinates.map((lineString) => {\n return {\n type: 'LineString',\n coordinates: lineString\n };\n });\n }\n if (geometry.type === 'MultiPoint') {\n return geometry.coordinates.map((point) => {\n return {\n type: 'Point',\n coordinates: point\n };\n });\n }\n return [geometry];\n}\nclass Distance {\n constructor(geojson, geometries) {\n this.type = NumberType;\n this.geojson = geojson;\n this.geometries = geometries;\n }\n static parse(args, context) {\n if (args.length !== 2)\n return context.error(`'distance' expression requires exactly one argument, but found ${args.length - 1} instead.`);\n if (isValue(args[1])) {\n const geojson = args[1];\n if (geojson.type === 'FeatureCollection') {\n return new Distance(geojson, geojson.features.map((feature) => toSimpleGeometry(feature.geometry)).flat());\n }\n else if (geojson.type === 'Feature') {\n return new Distance(geojson, toSimpleGeometry(geojson.geometry));\n }\n else if ('type' in geojson && 'coordinates' in geojson) {\n return new Distance(geojson, toSimpleGeometry(geojson));\n }\n }\n return context.error(\"'distance' expression requires valid geojson object that contains polygon geometry type.\");\n }\n evaluate(ctx) {\n if (ctx.geometry() != null && ctx.canonicalID() != null) {\n if (ctx.geometryType() === 'Point') {\n return pointToGeometryDistance(ctx, this.geometries);\n }\n else if (ctx.geometryType() === 'LineString') {\n return lineStringToGeometryDistance(ctx, this.geometries);\n }\n else if (ctx.geometryType() === 'Polygon') {\n return polygonToGeometryDistance(ctx, this.geometries);\n }\n }\n return NaN;\n }\n eachChild() { }\n outputDefined() {\n return true;\n }\n}\n\nclass GlobalState {\n constructor(key) {\n this.type = ValueType;\n this.key = key;\n }\n static parse(args, context) {\n if (args.length !== 2) {\n return context.error(`Expected 1 argument, but found ${args.length - 1} instead.`);\n }\n const key = args[1];\n if (key === undefined || key === null) {\n return context.error('Global state property must be defined.');\n }\n if (typeof key !== 'string') {\n return context.error(`Global state property must be string, but found ${typeof args[1]} instead.`);\n }\n return new GlobalState(key);\n }\n evaluate(ctx) {\n var _a;\n const globalState = (_a = ctx.globals) === null || _a === void 0 ? void 0 : _a.globalState;\n if (!globalState || Object.keys(globalState).length === 0)\n return null;\n return getOwn(globalState, this.key);\n }\n eachChild() { }\n outputDefined() {\n return false;\n }\n}\n\nconst expressions$1 = {\n // special forms\n '==': Equals,\n '!=': NotEquals,\n '>': GreaterThan,\n '<': LessThan,\n '>=': GreaterThanOrEqual,\n '<=': LessThanOrEqual,\n array: Assertion,\n at: At,\n boolean: Assertion,\n case: Case,\n coalesce: Coalesce,\n collator: CollatorExpression,\n format: FormatExpression,\n image: ImageExpression,\n in: In,\n 'index-of': IndexOf,\n interpolate: Interpolate,\n 'interpolate-hcl': Interpolate,\n 'interpolate-lab': Interpolate,\n length: Length,\n let: Let,\n literal: Literal,\n match: Match,\n number: Assertion,\n 'number-format': NumberFormat,\n object: Assertion,\n slice: Slice,\n step: Step,\n string: Assertion,\n 'to-boolean': Coercion,\n 'to-color': Coercion,\n 'to-number': Coercion,\n 'to-string': Coercion,\n var: Var,\n within: Within,\n distance: Distance,\n 'global-state': GlobalState\n};\n\nclass CompoundExpression {\n constructor(name, type, evaluate, args) {\n this.name = name;\n this.type = type;\n this._evaluate = evaluate;\n this.args = args;\n }\n evaluate(ctx) {\n return this._evaluate(ctx, this.args);\n }\n eachChild(fn) {\n this.args.forEach(fn);\n }\n outputDefined() {\n return false;\n }\n static parse(args, context) {\n const op = args[0];\n const definition = CompoundExpression.definitions[op];\n if (!definition) {\n return context.error(`Unknown expression \"${op}\". If you wanted a literal array, use [\"literal\", [...]].`, 0);\n }\n // Now check argument types against each signature\n const type = Array.isArray(definition) ? definition[0] : definition.type;\n const availableOverloads = Array.isArray(definition)\n ? [[definition[1], definition[2]]]\n : definition.overloads;\n const overloads = availableOverloads.filter(([signature]) => !Array.isArray(signature) || // varags\n signature.length === args.length - 1 // correct param count\n );\n let signatureContext = null;\n for (const [params, evaluate] of overloads) {\n // Use a fresh context for each attempted signature so that, if\n // we eventually succeed, we haven't polluted `context.errors`.\n signatureContext = new ParsingContext(context.registry, isExpressionConstant, context.path, null, context.scope);\n // First parse all the args, potentially coercing to the\n // types expected by this overload.\n const parsedArgs = [];\n let argParseFailed = false;\n for (let i = 1; i < args.length; i++) {\n const arg = args[i];\n const expectedType = Array.isArray(params)\n ? params[i - 1]\n : params.type;\n const parsed = signatureContext.parse(arg, 1 + parsedArgs.length, expectedType);\n if (!parsed) {\n argParseFailed = true;\n break;\n }\n parsedArgs.push(parsed);\n }\n if (argParseFailed) {\n // Couldn't coerce args of this overload to expected type, move\n // on to next one.\n continue;\n }\n if (Array.isArray(params)) {\n if (params.length !== parsedArgs.length) {\n signatureContext.error(`Expected ${params.length} arguments, but found ${parsedArgs.length} instead.`);\n continue;\n }\n }\n for (let i = 0; i < parsedArgs.length; i++) {\n const expected = Array.isArray(params) ? params[i] : params.type;\n const arg = parsedArgs[i];\n signatureContext.concat(i + 1).checkSubtype(expected, arg.type);\n }\n if (signatureContext.errors.length === 0) {\n return new CompoundExpression(op, type, evaluate, parsedArgs);\n }\n }\n if (overloads.length === 1) {\n context.errors.push(...signatureContext.errors);\n }\n else {\n const expected = overloads.length ? overloads : availableOverloads;\n const signatures = expected\n .map(([params]) => stringifySignature(params))\n .join(' | ');\n const actualTypes = [];\n // For error message, re-parse arguments without trying to\n // apply any coercions\n for (let i = 1; i < args.length; i++) {\n const parsed = context.parse(args[i], 1 + actualTypes.length);\n if (!parsed)\n return null;\n actualTypes.push(typeToString(parsed.type));\n }\n context.error(`Expected arguments of type ${signatures}, but found (${actualTypes.join(', ')}) instead.`);\n }\n return null;\n }\n static register(registry, definitions) {\n CompoundExpression.definitions = definitions;\n for (const name in definitions) {\n registry[name] = CompoundExpression;\n }\n }\n}\nfunction rgba(ctx, [r, g, b, a]) {\n r = r.evaluate(ctx);\n g = g.evaluate(ctx);\n b = b.evaluate(ctx);\n const alpha = a ? a.evaluate(ctx) : 1;\n const error = validateRGBA(r, g, b, alpha);\n if (error)\n throw new RuntimeError(error);\n return new Color(r / 255, g / 255, b / 255, alpha, false);\n}\nfunction has(key, obj) {\n return key in obj;\n}\nfunction get(key, obj) {\n const v = obj[key];\n return typeof v === 'undefined' ? null : v;\n}\nfunction binarySearch(v, a, i, j) {\n while (i <= j) {\n const m = (i + j) >> 1;\n if (a[m] === v)\n return true;\n if (a[m] > v)\n j = m - 1;\n else\n i = m + 1;\n }\n return false;\n}\nfunction varargs(type) {\n return { type };\n}\nCompoundExpression.register(expressions$1, {\n error: [\n ErrorType,\n [StringType],\n (ctx, [v]) => {\n throw new RuntimeError(v.evaluate(ctx));\n }\n ],\n typeof: [StringType, [ValueType], (ctx, [v]) => typeToString(typeOf(v.evaluate(ctx)))],\n 'to-rgba': [\n array(NumberType, 4),\n [ColorType],\n (ctx, [v]) => {\n const [r, g, b, a] = v.evaluate(ctx).rgb;\n return [r * 255, g * 255, b * 255, a];\n }\n ],\n rgb: [ColorType, [NumberType, NumberType, NumberType], rgba],\n rgba: [ColorType, [NumberType, NumberType, NumberType, NumberType], rgba],\n has: {\n type: BooleanType,\n overloads: [\n [[StringType], (ctx, [key]) => has(key.evaluate(ctx), ctx.properties())],\n [\n [StringType, ObjectType],\n (ctx, [key, obj]) => has(key.evaluate(ctx), obj.evaluate(ctx))\n ]\n ]\n },\n get: {\n type: ValueType,\n overloads: [\n [[StringType], (ctx, [key]) => get(key.evaluate(ctx), ctx.properties())],\n [\n [StringType, ObjectType],\n (ctx, [key, obj]) => get(key.evaluate(ctx), obj.evaluate(ctx))\n ]\n ]\n },\n 'feature-state': [\n ValueType,\n [StringType],\n (ctx, [key]) => get(key.evaluate(ctx), ctx.featureState || {})\n ],\n properties: [ObjectType, [], (ctx) => ctx.properties()],\n 'geometry-type': [StringType, [], (ctx) => ctx.geometryType()],\n id: [ValueType, [], (ctx) => ctx.id()],\n zoom: [NumberType, [], (ctx) => ctx.globals.zoom],\n 'heatmap-density': [NumberType, [], (ctx) => ctx.globals.heatmapDensity || 0],\n elevation: [NumberType, [], (ctx) => ctx.globals.elevation || 0],\n 'line-progress': [NumberType, [], (ctx) => ctx.globals.lineProgress || 0],\n accumulated: [\n ValueType,\n [],\n (ctx) => (ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated)\n ],\n '+': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => {\n let result = 0;\n for (const arg of args) {\n result += arg.evaluate(ctx);\n }\n return result;\n }\n ],\n '*': [\n NumberType,\n varargs(NumberType),\n (ctx, args) => {\n let result = 1;\n for (const arg of args) {\n result *= arg.evaluate(ctx);\n }\n return result;\n }\n ],\n '-': {\n type: NumberType,\n overloads: [\n [[NumberType, NumberType], (ctx, [a, b]) => a.evaluate(ctx) - b.evaluate(ctx)],\n [[NumberType], (ctx, [a]) => -a.evaluate(ctx)]\n ]\n },\n '/': [NumberType, [NumberType, NumberType], (ctx, [a, b]) => a.evaluate(ctx) / b.evaluate(ctx)],\n '%': [NumberType, [NumberType, NumberType], (ctx, [a, b]) => a.evaluate(ctx) % b.evaluate(ctx)],\n ln2: [NumberType, [], () => Math.LN2],\n pi: [NumberType, [], () => Math.PI],\n e: [NumberType, [], () => Math.E],\n '^': [\n NumberType,\n [NumberType, NumberType],\n (ctx, [b, e]) => Math.pow(b.evaluate(ctx), e.evaluate(ctx))\n ],\n sqrt: [NumberType, [NumberType], (ctx, [x]) => Math.sqrt(x.evaluate(ctx))],\n log10: [NumberType, [NumberType], (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN10],\n ln: [NumberType, [NumberType], (ctx, [n]) => Math.log(n.evaluate(ctx))],\n log2: [NumberType, [NumberType], (ctx, [n]) => Math.log(n.evaluate(ctx)) / Math.LN2],\n sin: [NumberType, [NumberType], (ctx, [n]) => Math.sin(n.evaluate(ctx))],\n cos: [NumberType, [NumberType], (ctx, [n]) => Math.cos(n.evaluate(ctx))],\n tan: [NumberType, [NumberType], (ctx, [n]) => Math.tan(n.evaluate(ctx))],\n asin: [NumberType, [NumberType], (ctx, [n]) => Math.asin(n.evaluate(ctx))],\n acos: [NumberType, [NumberType], (ctx, [n]) => Math.acos(n.evaluate(ctx))],\n atan: [NumberType, [NumberType], (ctx, [n]) => Math.atan(n.evaluate(ctx))],\n min: [\n NumberType,\n varargs(NumberType),\n (ctx, args) => Math.min(...args.map((arg) => arg.evaluate(ctx)))\n ],\n max: [\n NumberType,\n varargs(NumberType),\n (ctx, args) => Math.max(...args.map((arg) => arg.evaluate(ctx)))\n ],\n abs: [NumberType, [NumberType], (ctx, [n]) => Math.abs(n.evaluate(ctx))],\n round: [\n NumberType,\n [NumberType],\n (ctx, [n]) => {\n const v = n.evaluate(ctx);\n // Javascript's Math.round() rounds towards +Infinity for halfway\n // values, even when they're negative. It's more common to round\n // away from 0 (e.g., this is what python and C++ do)\n return v < 0 ? -Math.round(-v) : Math.round(v);\n }\n ],\n floor: [NumberType, [NumberType], (ctx, [n]) => Math.floor(n.evaluate(ctx))],\n ceil: [NumberType, [NumberType], (ctx, [n]) => Math.ceil(n.evaluate(ctx))],\n 'filter-==': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => ctx.properties()[k.value] === v.value\n ],\n 'filter-id-==': [BooleanType, [ValueType], (ctx, [v]) => ctx.id() === v.value],\n 'filter-type-==': [\n BooleanType,\n [StringType],\n (ctx, [v]) => ctx.geometryType() === v.value\n ],\n 'filter-<': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a < b;\n }\n ],\n 'filter-id-<': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a < b;\n }\n ],\n 'filter->': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a > b;\n }\n ],\n 'filter-id->': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a > b;\n }\n ],\n 'filter-<=': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a <= b;\n }\n ],\n 'filter-id-<=': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a <= b;\n }\n ],\n 'filter->=': [\n BooleanType,\n [StringType, ValueType],\n (ctx, [k, v]) => {\n const a = ctx.properties()[k.value];\n const b = v.value;\n return typeof a === typeof b && a >= b;\n }\n ],\n 'filter-id->=': [\n BooleanType,\n [ValueType],\n (ctx, [v]) => {\n const a = ctx.id();\n const b = v.value;\n return typeof a === typeof b && a >= b;\n }\n ],\n 'filter-has': [BooleanType, [ValueType], (ctx, [k]) => k.value in ctx.properties()],\n 'filter-has-id': [BooleanType, [], (ctx) => ctx.id() !== null && ctx.id() !== undefined],\n 'filter-type-in': [\n BooleanType,\n [array(StringType)],\n (ctx, [v]) => v.value.indexOf(ctx.geometryType()) >= 0\n ],\n 'filter-id-in': [\n BooleanType,\n [array(ValueType)],\n (ctx, [v]) => v.value.indexOf(ctx.id()) >= 0\n ],\n 'filter-in-small': [\n BooleanType,\n [StringType, array(ValueType)],\n // assumes v is an array literal\n (ctx, [k, v]) => v.value.indexOf(ctx.properties()[k.value]) >= 0\n ],\n 'filter-in-large': [\n BooleanType,\n [StringType, array(ValueType)],\n // assumes v is a array literal with values sorted in ascending order and of a single type\n (ctx, [k, v]) => binarySearch(ctx.properties()[k.value], v.value, 0, v.value.length - 1)\n ],\n all: {\n type: BooleanType,\n overloads: [\n [[BooleanType, BooleanType], (ctx, [a, b]) => a.evaluate(ctx) && b.evaluate(ctx)],\n [\n varargs(BooleanType),\n (ctx, args) => {\n for (const arg of args) {\n if (!arg.evaluate(ctx))\n return false;\n }\n return true;\n }\n ]\n ]\n },\n any: {\n type: BooleanType,\n overloads: [\n [[BooleanType, BooleanType], (ctx, [a, b]) => a.evaluate(ctx) || b.evaluate(ctx)],\n [\n varargs(BooleanType),\n (ctx, args) => {\n for (const arg of args) {\n if (arg.evaluate(ctx))\n return true;\n }\n return false;\n }\n ]\n ]\n },\n '!': [BooleanType, [BooleanType], (ctx, [b]) => !b.evaluate(ctx)],\n 'is-supported-script': [\n BooleanType,\n [StringType],\n // At parse time this will always return true, so we need to exclude this expression with isGlobalPropertyConstant\n (ctx, [s]) => {\n const isSupportedScript = ctx.globals && ctx.globals.isSupportedScript;\n if (isSupportedScript) {\n return isSupportedScript(s.evaluate(ctx));\n }\n return true;\n }\n ],\n upcase: [StringType, [StringType], (ctx, [s]) => s.evaluate(ctx).toUpperCase()],\n downcase: [StringType, [StringType], (ctx, [s]) => s.evaluate(ctx).toLowerCase()],\n concat: [\n StringType,\n varargs(ValueType),\n (ctx, args) => args.map((arg) => valueToString(arg.evaluate(ctx))).join('')\n ],\n 'resolved-locale': [\n StringType,\n [CollatorType],\n (ctx, [collator]) => collator.evaluate(ctx).resolvedLocale()\n ]\n});\nfunction stringifySignature(signature) {\n if (Array.isArray(signature)) {\n return `(${signature.map(typeToString).join(', ')})`;\n }\n else {\n return `(${typeToString(signature.type)}...)`;\n }\n}\nfunction isExpressionConstant(expression) {\n if (expression instanceof Var) {\n return isExpressionConstant(expression.boundExpression);\n }\n else if (expression instanceof CompoundExpression && expression.name === 'error') {\n return false;\n }\n else if (expression instanceof CollatorExpression) {\n // Although the results of a Collator expression with fixed arguments\n // generally shouldn't change between executions, we can't serialize them\n // as constant expressions because results change based on environment.\n return false;\n }\n else if (expression instanceof Within) {\n return false;\n }\n else if (expression instanceof Distance) {\n return false;\n }\n else if (expression instanceof GlobalState) {\n return false;\n }\n const isTypeAnnotation = expression instanceof Coercion || expression instanceof Assertion;\n let childrenConstant = true;\n expression.eachChild((child) => {\n // We can _almost_ assume that if `expressions` children are constant,\n // they would already have been evaluated to Literal values when they\n // were parsed. Type annotations are the exception, because they might\n // have been inferred and added after a child was parsed.\n // So we recurse into isConstant() for the children of type annotations,\n // but otherwise simply check whether they are Literals.\n if (isTypeAnnotation) {\n childrenConstant = childrenConstant && isExpressionConstant(child);\n }\n else {\n childrenConstant = childrenConstant && child instanceof Literal;\n }\n });\n if (!childrenConstant) {\n return false;\n }\n return (isFeatureConstant(expression) &&\n isGlobalPropertyConstant(expression, [\n 'zoom',\n 'heatmap-density',\n 'elevation',\n 'line-progress',\n 'accumulated',\n 'is-supported-script'\n ]));\n}\nfunction isFeatureConstant(e) {\n if (e instanceof CompoundExpression) {\n if (e.name === 'get' && e.args.length === 1) {\n return false;\n }\n else if (e.name === 'feature-state') {\n return false;\n }\n else if (e.name === 'has' && e.args.length === 1) {\n return false;\n }\n else if (e.name === 'properties' || e.name === 'geometry-type' || e.name === 'id') {\n return false;\n }\n else if (/^filter-/.test(e.name)) {\n return false;\n }\n }\n if (e instanceof Within) {\n return false;\n }\n if (e instanceof Distance) {\n return false;\n }\n let result = true;\n e.eachChild((arg) => {\n if (result && !isFeatureConstant(arg)) {\n result = false;\n }\n });\n return result;\n}\nfunction isStateConstant(e) {\n if (e instanceof CompoundExpression) {\n if (e.name === 'feature-state') {\n return false;\n }\n }\n let result = true;\n e.eachChild((arg) => {\n if (result && !isStateConstant(arg)) {\n result = false;\n }\n });\n return result;\n}\nfunction isGlobalPropertyConstant(e, properties) {\n if (e instanceof CompoundExpression && properties.indexOf(e.name) >= 0) {\n return false;\n }\n let result = true;\n e.eachChild((arg) => {\n if (result && !isGlobalPropertyConstant(arg, properties)) {\n result = false;\n }\n });\n return result;\n}\n\nfunction success(value) {\n return { result: 'success', value };\n}\nfunction error(value) {\n return { result: 'error', value };\n}\n\nfunction supportsPropertyExpression(spec) {\n return (spec['property-type'] === 'data-driven' ||\n spec['property-type'] === 'cross-faded-data-driven');\n}\nfunction supportsZoomExpression(spec) {\n return !!spec.expression && spec.expression.parameters.indexOf('zoom') > -1;\n}\nfunction supportsInterpolation(spec) {\n return !!spec.expression && spec.expression.interpolated;\n}\n\nfunction getType(val) {\n if (val instanceof Number) {\n return 'number';\n }\n else if (val instanceof String) {\n return 'string';\n }\n else if (val instanceof Boolean) {\n return 'boolean';\n }\n else if (Array.isArray(val)) {\n return 'array';\n }\n else if (val === null) {\n return 'null';\n }\n else {\n return typeof val;\n }\n}\n\nfunction isFunction$1(value) {\n return (typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value) &&\n typeOf(value) === ObjectType);\n}\nfunction identityFunction(x) {\n return x;\n}\nfunction getParseFunction(propertySpec) {\n switch (propertySpec.type) {\n case 'color':\n return Color.parse;\n case 'padding':\n return Padding.parse;\n case 'numberArray':\n return NumberArray.parse;\n case 'colorArray':\n return ColorArray.parse;\n default:\n return null;\n }\n}\nfunction getInnerFunction(type) {\n switch (type) {\n case 'exponential':\n return evaluateExponentialFunction;\n case 'interval':\n return evaluateIntervalFunction;\n case 'categorical':\n return evaluateCategoricalFunction;\n case 'identity':\n return evaluateIdentityFunction;\n default:\n throw new Error(`Unknown function type \"${type}\"`);\n }\n}\nfunction createFunction(parameters, propertySpec) {\n const zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === 'object';\n const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;\n const zoomDependent = zoomAndFeatureDependent || !featureDependent;\n const type = parameters.type || (supportsInterpolation(propertySpec) ? 'exponential' : 'interval');\n const parseFn = getParseFunction(propertySpec);\n if (parseFn) {\n parameters = extendBy({}, parameters);\n if (parameters.stops) {\n parameters.stops = parameters.stops.map((stop) => {\n return [stop[0], parseFn(stop[1])];\n });\n }\n if (parameters.default) {\n parameters.default = parseFn(parameters.default);\n }\n else {\n parameters.default = parseFn(propertySpec.default);\n }\n }\n if (parameters.colorSpace && !isSupportedInterpolationColorSpace(parameters.colorSpace)) {\n throw new Error(`Unknown color space: \"${parameters.colorSpace}\"`);\n }\n const innerFun = getInnerFunction(type);\n let hashedStops;\n let categoricalKeyType;\n if (type === 'categorical') {\n // For categorical functions, generate an Object as a hashmap of the stops for fast searching\n hashedStops = Object.create(null);\n for (const stop of parameters.stops) {\n hashedStops[stop[0]] = stop[1];\n }\n // Infer key type based on first stop key-- used to encforce strict type checking later\n categoricalKeyType = typeof parameters.stops[0][0];\n }\n if (zoomAndFeatureDependent) {\n const featureFunctions = {};\n const zoomStops = [];\n for (let s = 0; s < parameters.stops.length; s++) {\n const stop = parameters.stops[s];\n const zoom = stop[0].zoom;\n if (featureFunctions[zoom] === undefined) {\n featureFunctions[zoom] = {\n zoom,\n type: parameters.type,\n property: parameters.property,\n default: parameters.default,\n stops: []\n };\n zoomStops.push(zoom);\n }\n featureFunctions[zoom].stops.push([stop[0].value, stop[1]]);\n }\n const featureFunctionStops = [];\n for (const z of zoomStops) {\n featureFunctionStops.push([\n featureFunctions[z].zoom,\n createFunction(featureFunctions[z], propertySpec)\n ]);\n }\n const interpolationType = { name: 'linear' };\n return {\n kind: 'composite',\n interpolationType,\n interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),\n zoomStops: featureFunctionStops.map((s) => s[0]),\n evaluate({ zoom }, properties) {\n return evaluateExponentialFunction({\n stops: featureFunctionStops,\n base: parameters.base\n }, propertySpec, zoom).evaluate(zoom, properties);\n }\n };\n }\n else if (zoomDependent) {\n const interpolationType = type === 'exponential'\n ? { name: 'exponential', base: parameters.base !== undefined ? parameters.base : 1 }\n : null;\n return {\n kind: 'camera',\n interpolationType,\n interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),\n zoomStops: parameters.stops.map((s) => s[0]),\n evaluate: ({ zoom }) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)\n };\n }\n else {\n return {\n kind: 'source',\n evaluate(_, feature) {\n const value = feature && feature.properties\n ? feature.properties[parameters.property]\n : undefined;\n if (value === undefined) {\n return coalesce$1(parameters.default, propertySpec.default);\n }\n return innerFun(parameters, propertySpec, value, hashedStops, categoricalKeyType);\n }\n };\n }\n}\nfunction coalesce$1(a, b, c) {\n if (a !== undefined)\n return a;\n if (b !== undefined)\n return b;\n if (c !== undefined)\n return c;\n}\nfunction evaluateCategoricalFunction(parameters, propertySpec, input, hashedStops, keyType) {\n const evaluated = typeof input === keyType ? hashedStops[input] : undefined; // Enforce strict typing on input\n return coalesce$1(evaluated, parameters.default, propertySpec.default);\n}\nfunction evaluateIntervalFunction(parameters, propertySpec, input) {\n // Edge cases\n if (getType(input) !== 'number')\n return coalesce$1(parameters.default, propertySpec.default);\n const n = parameters.stops.length;\n if (n === 1)\n return parameters.stops[0][1];\n if (input <= parameters.stops[0][0])\n return parameters.stops[0][1];\n if (input >= parameters.stops[n - 1][0])\n return parameters.stops[n - 1][1];\n const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);\n return parameters.stops[index][1];\n}\nfunction evaluateExponentialFunction(parameters, propertySpec, input) {\n const base = parameters.base !== undefined ? parameters.base : 1;\n // Edge cases\n if (getType(input) !== 'number')\n return coalesce$1(parameters.default, propertySpec.default);\n const n = parameters.stops.length;\n if (n === 1)\n return parameters.stops[0][1];\n if (input <= parameters.stops[0][0])\n return parameters.stops[0][1];\n if (input >= parameters.stops[n - 1][0])\n return parameters.stops[n - 1][1];\n const index = findStopLessThanOrEqualTo(parameters.stops.map((stop) => stop[0]), input);\n const t = interpolationFactor(input, base, parameters.stops[index][0], parameters.stops[index + 1][0]);\n const outputLower = parameters.stops[index][1];\n const outputUpper = parameters.stops[index + 1][1];\n const interp = interpolateFactory[propertySpec.type] || identityFunction;\n if (typeof outputLower.evaluate === 'function') {\n return {\n evaluate(...args) {\n const evaluatedLower = outputLower.evaluate.apply(undefined, args);\n const evaluatedUpper = outputUpper.evaluate.apply(undefined, args);\n // Special case for fill-outline-color, which has no spec default.\n if (evaluatedLower === undefined || evaluatedUpper === undefined) {\n return undefined;\n }\n return interp(evaluatedLower, evaluatedUpper, t, parameters.colorSpace);\n }\n };\n }\n return interp(outputLower, outputUpper, t, parameters.colorSpace);\n}\nfunction evaluateIdentityFunction(parameters, propertySpec, input) {\n switch (propertySpec.type) {\n case 'color':\n input = Color.parse(input);\n break;\n case 'formatted':\n input = Formatted.fromString(input.toString());\n break;\n case 'resolvedImage':\n input = ResolvedImage.fromString(input.toString());\n break;\n case 'padding':\n input = Padding.parse(input);\n break;\n case 'colorArray':\n input = ColorArray.parse(input);\n break;\n case 'numberArray':\n input = NumberArray.parse(input);\n break;\n default:\n if (getType(input) !== propertySpec.type &&\n (propertySpec.type !== 'enum' || !propertySpec.values[input])) {\n input = undefined;\n }\n }\n return coalesce$1(input, parameters.default, propertySpec.default);\n}\n/**\n * Returns a ratio that can be used to interpolate between exponential function\n * stops.\n *\n * How it works:\n * Two consecutive stop values define a (scaled and shifted) exponential\n * function `f(x) = a * base^x + b`, where `base` is the user-specified base,\n * and `a` and `b` are constants affording sufficient degrees of freedom to fit\n * the function to the given stops.\n *\n * Here's a bit of algebra that lets us compute `f(x)` directly from the stop\n * values without explicitly solving for `a` and `b`:\n *\n * First stop value: `f(x0) = y0 = a * base^x0 + b`\n * Second stop value: `f(x1) = y1 = a * base^x1 + b`\n * => `y1 - y0 = a(base^x1 - base^x0)`\n * => `a = (y1 - y0)/(base^x1 - base^x0)`\n *\n * Desired value: `f(x) = y = a * base^x + b`\n * => `f(x) = y0 + a * (base^x - base^x0)`\n *\n * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a\n * little algebra:\n * ```\n * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)\n * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)\n * ```\n *\n * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have\n * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as\n * an interpolation factor between the two stops' output values.\n *\n * (Note: a slightly different form for `ratio`,\n * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer\n * expensive `Math.pow()` operations.)\n *\n * @private\n */\nfunction interpolationFactor(input, base, lowerValue, upperValue) {\n const difference = upperValue - lowerValue;\n const progress = input - lowerValue;\n if (difference === 0) {\n return 0;\n }\n else if (base === 1) {\n return progress / difference;\n }\n else {\n return (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);\n }\n}\n\nclass StyleExpression {\n constructor(expression, propertySpec, globalState) {\n this.expression = expression;\n this._warningHistory = {};\n this._evaluator = new EvaluationContext();\n this._defaultValue = propertySpec ? getDefaultValue(propertySpec) : null;\n this._enumValues =\n propertySpec && propertySpec.type === 'enum' ? propertySpec.values : null;\n this._globalState = globalState;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n if (this._globalState) {\n globals = addGlobalState(globals, this._globalState);\n }\n this._evaluator.globals = globals;\n this._evaluator.feature = feature;\n this._evaluator.featureState = featureState;\n this._evaluator.canonical = canonical;\n this._evaluator.availableImages = availableImages || null;\n this._evaluator.formattedSection = formattedSection;\n return this.expression.evaluate(this._evaluator);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n if (this._globalState) {\n globals = addGlobalState(globals, this._globalState);\n }\n this._evaluator.globals = globals;\n this._evaluator.feature = feature || null;\n this._evaluator.featureState = featureState || null;\n this._evaluator.canonical = canonical;\n this._evaluator.availableImages = availableImages || null;\n this._evaluator.formattedSection = formattedSection || null;\n try {\n const val = this.expression.evaluate(this._evaluator);\n if (val === null || val === undefined || (typeof val === 'number' && val !== val)) {\n return this._defaultValue;\n }\n if (this._enumValues && !(val in this._enumValues)) {\n throw new RuntimeError(`Expected value to be one of ${Object.keys(this._enumValues)\n .map((v) => JSON.stringify(v))\n .join(', ')}, but found ${JSON.stringify(val)} instead.`);\n }\n return val;\n }\n catch (e) {\n if (!this._warningHistory[e.message]) {\n this._warningHistory[e.message] = true;\n if (typeof console !== 'undefined') {\n console.warn(e.message);\n }\n }\n return this._defaultValue;\n }\n }\n}\nfunction isExpression(expression) {\n return (Array.isArray(expression) &&\n expression.length > 0 &&\n typeof expression[0] === 'string' &&\n expression[0] in expressions$1);\n}\n/**\n * Parse and typecheck the given style spec JSON expression. If\n * options.defaultValue is provided, then the resulting StyleExpression's\n * `evaluate()` method will handle errors by logging a warning (once per\n * message) and returning the default value. Otherwise, it will throw\n * evaluation errors.\n *\n * @private\n */\nfunction createExpression(expression, propertySpec, globalState) {\n const parser = new ParsingContext(expressions$1, isExpressionConstant, [], propertySpec ? getExpectedType(propertySpec) : undefined);\n // For string-valued properties, coerce to string at the top level rather than asserting.\n const parsed = parser.parse(expression, undefined, undefined, undefined, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : undefined);\n if (!parsed) {\n return error(parser.errors);\n }\n return success(new StyleExpression(parsed, propertySpec, globalState));\n}\nclass ZoomConstantExpression {\n constructor(kind, expression, globalState) {\n this.kind = kind;\n this._styleExpression = expression;\n this.isStateDependent =\n kind !== 'constant' && !isStateConstant(expression.expression);\n this.globalStateRefs = findGlobalStateRefs(expression.expression);\n this._globalState = globalState;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n if (this._globalState) {\n globals = addGlobalState(globals, this._globalState);\n }\n return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n if (this._globalState) {\n globals = addGlobalState(globals, this._globalState);\n }\n return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n}\nclass ZoomDependentExpression {\n constructor(kind, expression, zoomStops, interpolationType, globalState) {\n this.kind = kind;\n this.zoomStops = zoomStops;\n this._styleExpression = expression;\n this.isStateDependent =\n kind !== 'camera' && !isStateConstant(expression.expression);\n this.globalStateRefs = findGlobalStateRefs(expression.expression);\n this.interpolationType = interpolationType;\n this._globalState = globalState;\n }\n evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection) {\n if (this._globalState) {\n globals = addGlobalState(globals, this._globalState);\n }\n return this._styleExpression.evaluateWithoutErrorHandling(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n evaluate(globals, feature, featureState, canonical, availableImages, formattedSection) {\n if (this._globalState) {\n globals = addGlobalState(globals, this._globalState);\n }\n return this._styleExpression.evaluate(globals, feature, featureState, canonical, availableImages, formattedSection);\n }\n interpolationFactor(input, lower, upper) {\n if (this.interpolationType) {\n return Interpolate.interpolationFactor(this.interpolationType, input, lower, upper);\n }\n else {\n return 0;\n }\n }\n}\nfunction isZoomExpression(expression) {\n return expression._styleExpression !== undefined;\n}\nfunction createPropertyExpression(expressionInput, propertySpec, globalState) {\n const expression = createExpression(expressionInput, propertySpec, globalState);\n if (expression.result === 'error') {\n return expression;\n }\n const parsed = expression.value.expression;\n const isFeatureConstantResult = isFeatureConstant(parsed);\n if (!isFeatureConstantResult && !supportsPropertyExpression(propertySpec)) {\n return error([new ExpressionParsingError('', 'data expressions not supported')]);\n }\n const isZoomConstant = isGlobalPropertyConstant(parsed, ['zoom']);\n if (!isZoomConstant && !supportsZoomExpression(propertySpec)) {\n return error([new ExpressionParsingError('', 'zoom expressions not supported')]);\n }\n const zoomCurve = findZoomCurve(parsed);\n if (!zoomCurve && !isZoomConstant) {\n return error([\n new ExpressionParsingError('', '\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.')\n ]);\n }\n else if (zoomCurve instanceof ExpressionParsingError) {\n return error([zoomCurve]);\n }\n else if (zoomCurve instanceof Interpolate && !supportsInterpolation(propertySpec)) {\n return error([\n new ExpressionParsingError('', '\"interpolate\" expressions cannot be used with this property')\n ]);\n }\n if (!zoomCurve) {\n return success(isFeatureConstantResult\n ? new ZoomConstantExpression('constant', expression.value, globalState)\n : new ZoomConstantExpression('source', expression.value, globalState));\n }\n const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : undefined;\n return success(isFeatureConstantResult\n ? new ZoomDependentExpression('camera', expression.value, zoomCurve.labels, interpolationType, globalState)\n : new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType, globalState));\n}\n// serialization wrapper for old-style stop functions normalized to the\n// expression interface\nclass StylePropertyFunction {\n constructor(parameters, specification) {\n this._parameters = parameters;\n this._specification = specification;\n extendBy(this, createFunction(this._parameters, this._specification));\n }\n static deserialize(serialized) {\n return new StylePropertyFunction(serialized._parameters, serialized._specification);\n }\n static serialize(input) {\n return {\n _parameters: input._parameters,\n _specification: input._specification\n };\n }\n}\nfunction normalizePropertyExpression(value, specification, globalState) {\n if (isFunction$1(value)) {\n return new StylePropertyFunction(value, specification);\n }\n else if (isExpression(value)) {\n const expression = createPropertyExpression(value, specification, globalState);\n if (expression.result === 'error') {\n // this should have been caught in validation\n throw new Error(expression.value.map((err) => `${err.key}: ${err.message}`).join(', '));\n }\n return expression.value;\n }\n else {\n let constant = value;\n if (specification.type === 'color' && typeof value === 'string') {\n constant = Color.parse(value);\n }\n else if (specification.type === 'padding' &&\n (typeof value === 'number' || Array.isArray(value))) {\n constant = Padding.parse(value);\n }\n else if (specification.type === 'numberArray' &&\n (typeof value === 'number' || Array.isArray(value))) {\n constant = NumberArray.parse(value);\n }\n else if (specification.type === 'colorArray' &&\n (typeof value === 'string' || Array.isArray(value))) {\n constant = ColorArray.parse(value);\n }\n else if (specification.type === 'variableAnchorOffsetCollection' &&\n Array.isArray(value)) {\n constant = VariableAnchorOffsetCollection.parse(value);\n }\n else if (specification.type === 'projectionDefinition' && typeof value === 'string') {\n constant = ProjectionDefinition.parse(value);\n }\n return {\n globalStateRefs: new Set(),\n _globalState: null,\n kind: 'constant',\n evaluate: () => constant\n };\n }\n}\n// Zoom-dependent expressions may only use [\"zoom\"] as the input to a top-level \"step\" or \"interpolate\"\n// expression (collectively referred to as a \"curve\"). The curve may be wrapped in one or more \"let\" or\n// \"coalesce\" expressions.\nfunction findZoomCurve(expression) {\n let result = null;\n if (expression instanceof Let) {\n result = findZoomCurve(expression.result);\n }\n else if (expression instanceof Coalesce) {\n for (const arg of expression.args) {\n result = findZoomCurve(arg);\n if (result) {\n break;\n }\n }\n }\n else if ((expression instanceof Step || expression instanceof Interpolate) &&\n expression.input instanceof CompoundExpression &&\n expression.input.name === 'zoom') {\n result = expression;\n }\n if (result instanceof ExpressionParsingError) {\n return result;\n }\n expression.eachChild((child) => {\n const childResult = findZoomCurve(child);\n if (childResult instanceof ExpressionParsingError) {\n result = childResult;\n }\n else if (!result && childResult) {\n result = new ExpressionParsingError('', '\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression.');\n }\n else if (result && childResult && result !== childResult) {\n result = new ExpressionParsingError('', 'Only one zoom-based \"step\" or \"interpolate\" subexpression may be used in an expression.');\n }\n });\n return result;\n}\nfunction findGlobalStateRefs(expression, results = new Set()) {\n if (expression instanceof GlobalState) {\n results.add(expression.key);\n }\n expression.eachChild((childExpression) => {\n findGlobalStateRefs(childExpression, results);\n });\n return results;\n}\nfunction getExpectedType(spec) {\n const types = {\n color: ColorType,\n string: StringType,\n number: NumberType,\n enum: StringType,\n boolean: BooleanType,\n formatted: FormattedType,\n padding: PaddingType,\n numberArray: NumberArrayType,\n colorArray: ColorArrayType,\n projectionDefinition: ProjectionDefinitionType,\n resolvedImage: ResolvedImageType,\n variableAnchorOffsetCollection: VariableAnchorOffsetCollectionType\n };\n if (spec.type === 'array') {\n return array(types[spec.value] || ValueType, spec.length);\n }\n return types[spec.type];\n}\nfunction getDefaultValue(spec) {\n if (spec.type === 'color' && isFunction$1(spec.default)) {\n // Special case for heatmap-color: it uses the 'default:' to define a\n // default color ramp, but createExpression expects a simple value to fall\n // back to in case of runtime errors\n return new Color(0, 0, 0, 0);\n }\n switch (spec.type) {\n case 'color':\n return Color.parse(spec.default) || null;\n case 'padding':\n return Padding.parse(spec.default) || null;\n case 'numberArray':\n return NumberArray.parse(spec.default) || null;\n case 'colorArray':\n return ColorArray.parse(spec.default) || null;\n case 'variableAnchorOffsetCollection':\n return VariableAnchorOffsetCollection.parse(spec.default) || null;\n case 'projectionDefinition':\n return ProjectionDefinition.parse(spec.default) || null;\n default:\n return spec.default === undefined ? null : spec.default;\n }\n}\nfunction addGlobalState(globals, globalState) {\n const { zoom, heatmapDensity, elevation, lineProgress, isSupportedScript, accumulated } = globals !== null && globals !== void 0 ? globals : {};\n return {\n zoom,\n heatmapDensity,\n elevation,\n lineProgress,\n isSupportedScript,\n accumulated,\n globalState\n };\n}\n\nfunction isExpressionFilter(filter) {\n if (filter === true || filter === false) {\n return true;\n }\n if (!Array.isArray(filter) || filter.length === 0) {\n return false;\n }\n switch (filter[0]) {\n case 'has':\n return filter.length >= 2 && filter[1] !== '$id' && filter[1] !== '$type';\n case 'in':\n return (filter.length >= 3 && (typeof filter[1] !== 'string' || Array.isArray(filter[2])));\n case '!in':\n case '!has':\n case 'none':\n return false;\n case '==':\n case '!=':\n case '>':\n case '>=':\n case '<':\n case '<=':\n return filter.length !== 3 || Array.isArray(filter[1]) || Array.isArray(filter[2]);\n case 'any':\n case 'all':\n for (const f of filter.slice(1)) {\n if (!isExpressionFilter(f) && typeof f !== 'boolean') {\n return false;\n }\n }\n return true;\n default:\n return true;\n }\n}\nconst filterSpec = {\n type: 'boolean',\n default: false,\n transition: false,\n 'property-type': 'data-driven',\n expression: {\n interpolated: false,\n parameters: ['zoom', 'feature']\n }\n};\n/**\n * Given a filter expressed as nested arrays, return a new function\n * that evaluates whether a given feature (with a .properties or .tags property)\n * passes its test.\n *\n * @private\n * @param filter MapLibre filter\n * @param [globalState] Global state object to be used for evaluating 'global-state' expressions\n * @returns filter-evaluating function\n */\nfunction featureFilter(filter, globalState) {\n if (filter === null || filter === undefined) {\n return { filter: () => true, needGeometry: false, getGlobalStateRefs: () => new Set() };\n }\n if (!isExpressionFilter(filter)) {\n filter = convertFilter$1(filter);\n }\n const compiled = createExpression(filter, filterSpec, globalState);\n if (compiled.result === 'error') {\n throw new Error(compiled.value.map((err) => `${err.key}: ${err.message}`).join(', '));\n }\n else {\n const needGeometry = geometryNeeded(filter);\n return {\n filter: (globalProperties, feature, canonical) => compiled.value.evaluate(globalProperties, feature, {}, canonical),\n needGeometry,\n getGlobalStateRefs: () => findGlobalStateRefs(compiled.value.expression)\n };\n }\n}\n// Comparison function to sort numbers and strings\nfunction compare(a, b) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\nfunction geometryNeeded(filter) {\n if (!Array.isArray(filter))\n return false;\n if (filter[0] === 'within' || filter[0] === 'distance')\n return true;\n for (let index = 1; index < filter.length; index++) {\n if (geometryNeeded(filter[index]))\n return true;\n }\n return false;\n}\nfunction convertFilter$1(filter) {\n if (!filter)\n return true;\n const op = filter[0];\n if (filter.length <= 1)\n return op !== 'any';\n const converted = op === '=='\n ? convertComparisonOp$1(filter[1], filter[2], '==')\n : op === '!='\n ? convertNegation(convertComparisonOp$1(filter[1], filter[2], '=='))\n : op === '<' || op === '>' || op === '<=' || op === '>='\n ? convertComparisonOp$1(filter[1], filter[2], op)\n : op === 'any'\n ? convertDisjunctionOp(filter.slice(1))\n : op === 'all'\n ? ['all'].concat(filter.slice(1).map(convertFilter$1))\n : op === 'none'\n ? ['all'].concat(filter.slice(1).map(convertFilter$1).map(convertNegation))\n : op === 'in'\n ? convertInOp$1(filter[1], filter.slice(2))\n : op === '!in'\n ? convertNegation(convertInOp$1(filter[1], filter.slice(2)))\n : op === 'has'\n ? convertHasOp$1(filter[1])\n : op === '!has'\n ? convertNegation(convertHasOp$1(filter[1]))\n : true;\n return converted;\n}\nfunction convertComparisonOp$1(property, value, op) {\n switch (property) {\n case '$type':\n return [`filter-type-${op}`, value];\n case '$id':\n return [`filter-id-${op}`, value];\n default:\n return [`filter-${op}`, property, value];\n }\n}\nfunction convertDisjunctionOp(filters) {\n return ['any'].concat(filters.map(convertFilter$1));\n}\nfunction convertInOp$1(property, values) {\n if (values.length === 0) {\n return false;\n }\n switch (property) {\n case '$type':\n return ['filter-type-in', ['literal', values]];\n case '$id':\n return ['filter-id-in', ['literal', values]];\n default:\n if (values.length > 200 && !values.some((v) => typeof v !== typeof values[0])) {\n return ['filter-in-large', property, ['literal', values.sort(compare)]];\n }\n else {\n return ['filter-in-small', property, ['literal', values]];\n }\n }\n}\nfunction convertHasOp$1(property) {\n switch (property) {\n case '$type':\n return true;\n case '$id':\n return ['filter-has-id'];\n default:\n return ['filter-has', property];\n }\n}\nfunction convertNegation(filter) {\n return ['!', filter];\n}\n\n/*\n * Convert the given filter to an expression, storing the expected types for\n * any feature properties referenced in expectedTypes.\n *\n * These expected types are needed in order to construct preflight type checks\n * needed for handling 'any' filters. A preflight type check is necessary in\n * order to mimic legacy filters' semantics around expected type mismatches.\n * For example, consider the legacy filter:\n *\n * [\"any\", [\"all\", [\">\", \"y\", 0], [\">\", \"y\", 0]], [\">\", \"x\", 0]]\n *\n * Naively, we might convert this to the expression:\n *\n * [\"any\", [\"all\", [\">\", [\"get\", \"y\"], 0], [\">\", [\"get\", \"z\"], 0]], [\">\", [\"get\", \"x\"], 0]]\n *\n * But if we tried to evaluate this against, say `{x: 1, y: null, z: 0}`, the\n * [\">\", [\"get\", \"y\"], 0] would cause an evaluation error, leading to the\n * entire filter returning false. Legacy filter semantics, though, ask for\n * [\">\", \"y\", 0] to simply return `false` when `y` is of the wrong type,\n * allowing the subsequent terms of the outer \"any\" expression to be evaluated\n * (resulting, in this case, in a `true` value, because x > 0).\n *\n * We account for this by inserting a preflight type-checking expression before\n * each \"any\" term, allowing us to avoid evaluating the actual converted filter\n * if any type mismatches would cause it to produce an evaluation error:\n *\n * [\"any\",\n * [\"case\",\n * [\"all\", [\"==\", [\"typeof\", [\"get\", \"y\"]], \"number\"], [\"==\", [\"typeof\", [\"get\", \"z\"], \"number]],\n * [\"all\", [\">\", [\"get\", \"y\"], 0], [\">\", [\"get\", \"z\"], 0]],\n * false\n * ],\n * [\"case\",\n * [\"==\", [\"typeof\", [\"get\", \"x\"], \"number\"]],\n * [\">\", [\"get\", \"x\"], 0],\n * false\n * ]\n * ]\n *\n * An alternative, possibly more direct approach would be to use type checks\n * in the conversion of each comparison operator, so that the converted version\n * of each individual ==, >=, etc. would mimic the legacy filter semantics. The\n * downside of this approach is that it can lead to many more type checks than\n * would otherwise be necessary: outside the context of an \"any\" expression,\n * bailing out due to a runtime type error (expression semantics) and returning\n * false (legacy filter semantics) are equivalent: they cause the filter to\n * produce a `false` result.\n */\nfunction convertFilter(filter, expectedTypes = {}) {\n if (isExpressionFilter(filter))\n return filter;\n if (!filter)\n return true;\n const legacyFilter = filter;\n const legacyOp = legacyFilter[0];\n if (filter.length <= 1)\n return legacyOp !== 'any';\n switch (legacyOp) {\n case '==':\n case '!=':\n case '<':\n case '>':\n case '<=':\n case '>=': {\n const [, property, value] = filter;\n return convertComparisonOp(property, value, legacyOp, expectedTypes);\n }\n case 'any': {\n const [, ...conditions] = legacyFilter;\n const children = conditions.map((f) => {\n const types = {};\n const child = convertFilter(f, types);\n const typechecks = runtimeTypeChecks(types);\n return typechecks === true\n ? child\n : ['case', typechecks, child, false];\n });\n return ['any', ...children];\n }\n case 'all': {\n const [, ...conditions] = legacyFilter;\n const children = conditions.map((f) => convertFilter(f, expectedTypes));\n return children.length > 1 ? ['all', ...children] : children[0];\n }\n case 'none': {\n const [, ...conditions] = legacyFilter;\n return ['!', convertFilter(['any', ...conditions], {})];\n }\n case 'in': {\n const [, property, ...values] = legacyFilter;\n return convertInOp(property, values);\n }\n case '!in': {\n const [, property, ...values] = legacyFilter;\n return convertInOp(property, values, true);\n }\n case 'has':\n return convertHasOp(legacyFilter[1]);\n case '!has':\n return ['!', convertHasOp(legacyFilter[1])];\n default:\n return true;\n }\n}\n// Given a set of feature properties and an expected type for each one,\n// construct an boolean expression that tests whether each property has the\n// right type.\n// E.g.: for {name: 'string', population: 'number'}, return\n// [ 'all',\n// ['==', ['typeof', ['get', 'name'], 'string']],\n// ['==', ['typeof', ['get', 'population'], 'number]]\n// ]\nfunction runtimeTypeChecks(expectedTypes) {\n const conditions = [];\n for (const property in expectedTypes) {\n const get = property === '$id' ? ['id'] : ['get', property];\n conditions.push(['==', ['typeof', get], expectedTypes[property]]);\n }\n if (conditions.length === 0)\n return true;\n if (conditions.length === 1)\n return conditions[0];\n return ['all', ...conditions];\n}\nfunction convertComparisonOp(property, value, op, expectedTypes) {\n let get;\n if (property === '$type') {\n return [op, ['geometry-type'], value];\n }\n else if (property === '$id') {\n get = ['id'];\n }\n else {\n get = ['get', property];\n }\n if (expectedTypes && value !== null) {\n const type = typeof value;\n expectedTypes[property] = type;\n }\n if (op === '==' && property !== '$id' && value === null) {\n return [\n 'all',\n ['has', property], // missing property != null for legacy filters\n ['==', get, null]\n ];\n }\n else if (op === '!=' && property !== '$id' && value === null) {\n return [\n 'any',\n ['!', ['has', property]], // missing property != null for legacy filters\n ['!=', get, null]\n ];\n }\n return [op, get, value];\n}\nfunction convertInOp(property, values, negate = false) {\n if (values.length === 0)\n return negate;\n let get;\n if (property === '$type') {\n get = ['geometry-type'];\n }\n else if (property === '$id') {\n get = ['id'];\n }\n else {\n get = ['get', property];\n }\n // Determine if the list of values to be searched is homogenously typed.\n // If so (and if the type is string or number), then we can use a\n // [match, input, [...values], true, false] construction rather than a\n // bunch of `==` tests.\n let uniformTypes = true;\n const type = typeof values[0];\n for (const value of values) {\n if (typeof value !== type) {\n uniformTypes = false;\n break;\n }\n }\n if (uniformTypes && (type === 'string' || type === 'number')) {\n // Match expressions must have unique values.\n const uniqueValues = values.sort().filter((v, i) => i === 0 || values[i - 1] !== v);\n return ['match', get, uniqueValues, !negate, negate];\n }\n if (negate) {\n return ['all', ...values.map((v) => ['!=', get, v])];\n }\n else {\n return ['any', ...values.map((v) => ['==', get, v])];\n }\n}\nfunction convertHasOp(property) {\n if (property === '$type') {\n return true;\n }\n else if (property === '$id') {\n return ['!=', ['id'], null];\n }\n else {\n return ['has', property];\n }\n}\n\nfunction convertLiteral(value) {\n return typeof value === 'object' ? ['literal', value] : value;\n}\nfunction convertFunction(parameters, propertySpec) {\n let stops = parameters.stops;\n if (!stops) {\n // identity function\n return convertIdentityFunction(parameters, propertySpec);\n }\n const zoomAndFeatureDependent = stops && typeof stops[0][0] === 'object';\n const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;\n const zoomDependent = zoomAndFeatureDependent || !featureDependent;\n stops = stops.map((stop) => {\n if (!featureDependent && propertySpec.tokens && typeof stop[1] === 'string') {\n return [stop[0], convertTokenString(stop[1])];\n }\n return [stop[0], convertLiteral(stop[1])];\n });\n if (zoomAndFeatureDependent) {\n return convertZoomAndPropertyFunction(parameters, propertySpec, stops);\n }\n else if (zoomDependent) {\n return convertZoomFunction(parameters, propertySpec, stops);\n }\n else {\n return convertPropertyFunction(parameters, propertySpec, stops);\n }\n}\nfunction convertIdentityFunction(parameters, propertySpec) {\n const get = ['get', parameters.property];\n if (parameters.default === undefined) {\n // By default, expressions for string-valued properties get coerced. To preserve\n // legacy function semantics, insert an explicit assertion instead.\n return propertySpec.type === 'string' ? ['string', get] : get;\n }\n else if (propertySpec.type === 'enum') {\n return ['match', get, Object.keys(propertySpec.values), get, parameters.default];\n }\n else {\n const expression = [\n propertySpec.type === 'color' ? 'to-color' : propertySpec.type,\n get,\n convertLiteral(parameters.default)\n ];\n if (propertySpec.type === 'array') {\n expression.splice(1, 0, propertySpec.value, propertySpec.length || null);\n }\n return expression;\n }\n}\nfunction getInterpolateOperator(parameters) {\n switch (parameters.colorSpace) {\n case 'hcl':\n return 'interpolate-hcl';\n case 'lab':\n return 'interpolate-lab';\n default:\n return 'interpolate';\n }\n}\nfunction convertZoomAndPropertyFunction(parameters, propertySpec, stops) {\n const featureFunctionParameters = {};\n const featureFunctionStops = {};\n const zoomStops = [];\n for (let s = 0; s < stops.length; s++) {\n const stop = stops[s];\n const zoom = stop[0].zoom;\n if (featureFunctionParameters[zoom] === undefined) {\n featureFunctionParameters[zoom] = {\n zoom,\n type: parameters.type,\n property: parameters.property,\n default: parameters.default\n };\n featureFunctionStops[zoom] = [];\n zoomStops.push(zoom);\n }\n featureFunctionStops[zoom].push([stop[0].value, stop[1]]);\n }\n // the interpolation type for the zoom dimension of a zoom-and-property\n // function is determined directly from the style property specification\n // for which it's being used: linear for interpolatable properties, step\n // otherwise.\n const functionType = getFunctionType({}, propertySpec);\n if (functionType === 'exponential') {\n const expression = [getInterpolateOperator(parameters), ['linear'], ['zoom']];\n for (const z of zoomStops) {\n const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);\n appendStopPair(expression, z, output, false);\n }\n return expression;\n }\n else {\n const expression = ['step', ['zoom']];\n for (const z of zoomStops) {\n const output = convertPropertyFunction(featureFunctionParameters[z], propertySpec, featureFunctionStops[z]);\n appendStopPair(expression, z, output, true);\n }\n fixupDegenerateStepCurve(expression);\n return expression;\n }\n}\nfunction coalesce(a, b) {\n if (a !== undefined)\n return a;\n if (b !== undefined)\n return b;\n}\nfunction getFallback(parameters, propertySpec) {\n const defaultValue = convertLiteral(coalesce(parameters.default, propertySpec.default));\n /*\n * Some fields with type: resolvedImage have an undefined default.\n * Because undefined is an invalid value for resolvedImage, set fallback to\n * an empty string instead of undefined to ensure output\n * passes validation.\n */\n if (defaultValue === undefined && propertySpec.type === 'resolvedImage') {\n return '';\n }\n return defaultValue;\n}\nfunction convertPropertyFunction(parameters, propertySpec, stops) {\n const type = getFunctionType(parameters, propertySpec);\n const get = ['get', parameters.property];\n if (type === 'categorical' && typeof stops[0][0] === 'boolean') {\n const expression = ['case'];\n for (const stop of stops) {\n expression.push(['==', get, stop[0]], stop[1]);\n }\n expression.push(getFallback(parameters, propertySpec));\n return expression;\n }\n else if (type === 'categorical') {\n const expression = ['match', get];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], false);\n }\n expression.push(getFallback(parameters, propertySpec));\n return expression;\n }\n else if (type === 'interval') {\n const expression = ['step', ['number', get]];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], true);\n }\n fixupDegenerateStepCurve(expression);\n return parameters.default === undefined\n ? expression\n : [\n 'case',\n ['==', ['typeof', get], 'number'],\n expression,\n convertLiteral(parameters.default)\n ];\n }\n else if (type === 'exponential') {\n const base = parameters.base !== undefined ? parameters.base : 1;\n const expression = [\n getInterpolateOperator(parameters),\n base === 1 ? ['linear'] : ['exponential', base],\n ['number', get]\n ];\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], false);\n }\n return parameters.default === undefined\n ? expression\n : [\n 'case',\n ['==', ['typeof', get], 'number'],\n expression,\n convertLiteral(parameters.default)\n ];\n }\n else {\n throw new Error(`Unknown property function type ${type}`);\n }\n}\nfunction convertZoomFunction(parameters, propertySpec, stops, input = ['zoom']) {\n const type = getFunctionType(parameters, propertySpec);\n let expression;\n let isStep = false;\n if (type === 'interval') {\n expression = ['step', input];\n isStep = true;\n }\n else if (type === 'exponential') {\n const base = parameters.base !== undefined ? parameters.base : 1;\n expression = [\n getInterpolateOperator(parameters),\n base === 1 ? ['linear'] : ['exponential', base],\n input\n ];\n }\n else {\n throw new Error(`Unknown zoom function type \"${type}\"`);\n }\n for (const stop of stops) {\n appendStopPair(expression, stop[0], stop[1], isStep);\n }\n fixupDegenerateStepCurve(expression);\n return expression;\n}\nfunction fixupDegenerateStepCurve(expression) {\n // degenerate step curve (i.e. a constant function): add a noop stop\n if (expression[0] === 'step' && expression.length === 3) {\n expression.push(0);\n expression.push(expression[3]);\n }\n}\nfunction appendStopPair(curve, input, output, isStep) {\n // Skip duplicate stop values. They were not validated for functions, but they are for expressions.\n // https://github.com/mapbox/mapbox-gl-js/issues/4107\n if (curve.length > 3 && input === curve[curve.length - 2]) {\n return;\n }\n // step curves don't get the first input value, as it is redundant.\n if (!(isStep && curve.length === 2)) {\n curve.push(input);\n }\n curve.push(output);\n}\nfunction getFunctionType(parameters, propertySpec) {\n if (parameters.type) {\n return parameters.type;\n }\n else {\n return propertySpec.expression.interpolated ? 'exponential' : 'interval';\n }\n}\n// \"String with {name} token\" => [\"concat\", \"String with \", [\"get\", \"name\"], \" token\"]\nfunction convertTokenString(s) {\n const result = ['concat'];\n const re = /{([^{}]+)}/g;\n let pos = 0;\n for (let match = re.exec(s); match !== null; match = re.exec(s)) {\n const literal = s.slice(pos, re.lastIndex - match[0].length);\n pos = re.lastIndex;\n if (literal.length > 0)\n result.push(literal);\n result.push(['get', match[1]]);\n }\n if (result.length === 1) {\n return s;\n }\n if (pos < s.length) {\n result.push(s.slice(pos));\n }\n else if (result.length === 2) {\n return ['to-string', result[1]];\n }\n return result;\n}\n\nfunction getPropertyReference(propertyName) {\n for (let i = 0; i < v8Spec.layout.length; i++) {\n for (const key in v8Spec[v8Spec.layout[i]]) {\n if (key === propertyName)\n return v8Spec[v8Spec.layout[i]][key];\n }\n }\n for (let i = 0; i < v8Spec.paint.length; i++) {\n for (const key in v8Spec[v8Spec.paint[i]]) {\n if (key === propertyName)\n return v8Spec[v8Spec.paint[i]][key];\n }\n }\n return null;\n}\nfunction eachSource(style, callback) {\n for (const k in style.sources) {\n callback(style.sources[k]);\n }\n}\nfunction eachLayer(style, callback) {\n for (const layer of style.layers) {\n callback(layer);\n }\n}\nfunction eachProperty(style, options, callback) {\n function inner(layer, propertyType) {\n const properties = layer[propertyType];\n if (!properties)\n return;\n Object.keys(properties).forEach((key) => {\n callback({\n path: [layer.id, propertyType, key],\n key,\n value: properties[key],\n reference: getPropertyReference(key),\n set(x) {\n properties[key] = x;\n }\n });\n });\n }\n eachLayer(style, (layer) => {\n if (options.paint) {\n inner(layer, 'paint');\n }\n if (options.layout) {\n inner(layer, 'layout');\n }\n });\n}\n\nfunction stringify$1(obj) {\n const type = typeof obj;\n if (type === 'number' ||\n type === 'boolean' ||\n type === 'string' ||\n obj === undefined ||\n obj === null)\n return JSON.stringify(obj);\n if (Array.isArray(obj)) {\n let str = '[';\n for (const val of obj) {\n str += `${stringify$1(val)},`;\n }\n return `${str}]`;\n }\n const keys = Object.keys(obj).sort();\n let str = '{';\n for (let i = 0; i < keys.length; i++) {\n str += `${JSON.stringify(keys[i])}:${stringify$1(obj[keys[i]])},`;\n }\n return `${str}}`;\n}\nfunction getKey(layer) {\n let key = '';\n for (const k of refProperties) {\n key += `/${stringify$1(layer[k])}`;\n }\n return key;\n}\n/**\n * Groups layers by their layout-affecting properties.\n * These are the properties that were formerly used by explicit `ref` mechanism\n * for layers: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom',\n * 'filter', and 'layout'.\n *\n * The input is not modified. The output layers are references to the\n * input layers.\n *\n * @param layers - an array of {@link LayerSpecification}.\n * @param cachedKeys - an object to keep already calculated keys.\n * @returns an array of arrays of {@link LayerSpecification} objects, where each inner array\n * contains layers that share the same layout-affecting properties.\n */\nfunction groupByLayout(layers, cachedKeys) {\n const groups = {};\n for (let i = 0; i < layers.length; i++) {\n const k = (cachedKeys && cachedKeys[layers[i].id]) || getKey(layers[i]);\n // update the cache if there is one\n if (cachedKeys)\n cachedKeys[layers[i].id] = k;\n let group = groups[k];\n if (!group) {\n group = groups[k] = [];\n }\n group.push(layers[i]);\n }\n const result = [];\n for (const k in groups) {\n result.push(groups[k]);\n }\n return result;\n}\n\nfunction emptyStyle() {\n const style = {};\n const version = v8Spec['$version'];\n for (const styleKey in v8Spec['$root']) {\n const specification = v8Spec['$root'][styleKey];\n if (specification.required) {\n let value = null;\n if (styleKey === 'version') {\n value = version;\n }\n else {\n if (specification.type === 'array') {\n value = [];\n }\n else {\n value = {};\n }\n }\n if (value != null) {\n style[styleKey] = value;\n }\n }\n }\n return style;\n}\n\nfunction validateConstants(options) {\n const key = options.key;\n const constants = options.value;\n if (constants) {\n return [new ValidationError(key, constants, 'constants have been deprecated as of v8')];\n }\n else {\n return [];\n }\n}\n\n// Turn jsonlint-lines-primitives objects into primitive objects\nfunction unbundle(value) {\n if (value instanceof Number || value instanceof String || value instanceof Boolean) {\n return value.valueOf();\n }\n else {\n return value;\n }\n}\nfunction deepUnbundle(value) {\n if (Array.isArray(value)) {\n return value.map(deepUnbundle);\n }\n else if (value instanceof Object &&\n !(value instanceof Number || value instanceof String || value instanceof Boolean)) {\n const unbundledValue = {};\n for (const key in value) {\n unbundledValue[key] = deepUnbundle(value[key]);\n }\n return unbundledValue;\n }\n return unbundle(value);\n}\n\nfunction validateObject(options) {\n const key = options.key;\n const object = options.value;\n const elementSpecs = options.valueSpec || {};\n const elementValidators = options.objectElementValidators || {};\n const style = options.style;\n const styleSpec = options.styleSpec;\n const validateSpec = options.validateSpec;\n let errors = [];\n const type = getType(object);\n if (type !== 'object') {\n return [new ValidationError(key, object, `object expected, ${type} found`)];\n }\n for (const objectKey in object) {\n const elementSpecKey = objectKey.split('.')[0]; // treat 'paint.*' as 'paint'\n // objectKey comes from the user controlled style input, so elementSpecKey may be e.g. \"__proto__\"\n const elementSpec = getOwn(elementSpecs, elementSpecKey) || elementSpecs['*'];\n let validateElement;\n if (getOwn(elementValidators, elementSpecKey)) {\n validateElement = elementValidators[elementSpecKey];\n }\n else if (getOwn(elementSpecs, elementSpecKey)) {\n if (object[objectKey] === undefined) {\n // property is possible, set but set to undefined\n // we only check it if it is required and not defaulted in the next loop\n // without skipping here, we would alert to properties being set to undefined\n continue;\n }\n validateElement = validateSpec;\n }\n else if (elementValidators['*']) {\n validateElement = elementValidators['*'];\n }\n else if (elementSpecs['*']) {\n validateElement = validateSpec;\n }\n else {\n errors.push(new ValidationError(key, object[objectKey], `unknown property \"${objectKey}\"`));\n continue;\n }\n errors = errors.concat(validateElement({\n key: (key ? `${key}.` : key) + objectKey,\n value: object[objectKey],\n valueSpec: elementSpec,\n style,\n styleSpec,\n object,\n objectKey,\n validateSpec\n }, object));\n }\n for (const elementSpecKey in elementSpecs) {\n // Don't check `required` when there's a custom validator for that property.\n if (elementValidators[elementSpecKey]) {\n continue;\n }\n if (elementSpecs[elementSpecKey].required &&\n elementSpecs[elementSpecKey]['default'] === undefined &&\n object[elementSpecKey] === undefined) {\n errors.push(new ValidationError(key, object, `missing required property \"${elementSpecKey}\"`));\n }\n }\n return errors;\n}\n\nfunction validateArray(options) {\n const array = options.value;\n const arraySpec = options.valueSpec;\n const validateSpec = options.validateSpec;\n const style = options.style;\n const styleSpec = options.styleSpec;\n const key = options.key;\n const validateArrayElement = options.arrayElementValidator || validateSpec;\n if (getType(array) !== 'array') {\n return [new ValidationError(key, array, `array expected, ${getType(array)} found`)];\n }\n if (arraySpec.length && array.length !== arraySpec.length) {\n return [\n new ValidationError(key, array, `array length ${arraySpec.length} expected, length ${array.length} found`)\n ];\n }\n let arrayElementSpec = {\n type: arraySpec.value,\n values: arraySpec.values\n };\n if (styleSpec.$version < 7) {\n arrayElementSpec['function'] = arraySpec.function;\n }\n if (getType(arraySpec.value) === 'object') {\n arrayElementSpec = arraySpec.value;\n }\n let errors = [];\n for (let i = 0; i < array.length; i++) {\n errors = errors.concat(validateArrayElement({\n array,\n arrayIndex: i,\n value: array[i],\n valueSpec: arrayElementSpec,\n validateSpec: options.validateSpec,\n style,\n styleSpec,\n key: `${key}[${i}]`\n }));\n }\n return errors;\n}\n\nfunction validateNumber(options) {\n const key = options.key;\n const value = options.value;\n const valueSpec = options.valueSpec;\n let type = getType(value);\n if (type === 'number' && value !== value) {\n type = 'NaN';\n }\n if (type !== 'number') {\n return [new ValidationError(key, value, `number expected, ${type} found`)];\n }\n if ('minimum' in valueSpec && value < valueSpec.minimum) {\n return [\n new ValidationError(key, value, `${value} is less than the minimum value ${valueSpec.minimum}`)\n ];\n }\n if ('maximum' in valueSpec && value > valueSpec.maximum) {\n return [\n new ValidationError(key, value, `${value} is greater than the maximum value ${valueSpec.maximum}`)\n ];\n }\n return [];\n}\n\nfunction validateFunction(options) {\n const functionValueSpec = options.valueSpec;\n const functionType = unbundle(options.value.type);\n let stopKeyType;\n let stopDomainValues = {};\n let previousStopDomainValue;\n let previousStopDomainZoom;\n const isZoomFunction = functionType !== 'categorical' && options.value.property === undefined;\n const isPropertyFunction = !isZoomFunction;\n const isZoomAndPropertyFunction = getType(options.value.stops) === 'array' &&\n getType(options.value.stops[0]) === 'array' &&\n getType(options.value.stops[0][0]) === 'object';\n const errors = validateObject({\n key: options.key,\n value: options.value,\n valueSpec: options.styleSpec.function,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n objectElementValidators: {\n stops: validateFunctionStops,\n default: validateFunctionDefault\n }\n });\n if (functionType === 'identity' && isZoomFunction) {\n errors.push(new ValidationError(options.key, options.value, 'missing required property \"property\"'));\n }\n if (functionType !== 'identity' && !options.value.stops) {\n errors.push(new ValidationError(options.key, options.value, 'missing required property \"stops\"'));\n }\n if (functionType === 'exponential' &&\n options.valueSpec.expression &&\n !supportsInterpolation(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'exponential functions not supported'));\n }\n if (options.styleSpec.$version >= 8) {\n if (isPropertyFunction && !supportsPropertyExpression(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'property functions not supported'));\n }\n else if (isZoomFunction && !supportsZoomExpression(options.valueSpec)) {\n errors.push(new ValidationError(options.key, options.value, 'zoom functions not supported'));\n }\n }\n if ((functionType === 'categorical' || isZoomAndPropertyFunction) &&\n options.value.property === undefined) {\n errors.push(new ValidationError(options.key, options.value, '\"property\" property is required'));\n }\n return errors;\n function validateFunctionStops(options) {\n if (functionType === 'identity') {\n return [\n new ValidationError(options.key, options.value, 'identity function may not have a \"stops\" property')\n ];\n }\n let errors = [];\n const value = options.value;\n errors = errors.concat(validateArray({\n key: options.key,\n value,\n valueSpec: options.valueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n arrayElementValidator: validateFunctionStop\n }));\n if (getType(value) === 'array' && value.length === 0) {\n errors.push(new ValidationError(options.key, value, 'array must have at least one stop'));\n }\n return errors;\n }\n function validateFunctionStop(options) {\n let errors = [];\n const value = options.value;\n const key = options.key;\n if (getType(value) !== 'array') {\n return [new ValidationError(key, value, `array expected, ${getType(value)} found`)];\n }\n if (value.length !== 2) {\n return [\n new ValidationError(key, value, `array length 2 expected, length ${value.length} found`)\n ];\n }\n if (isZoomAndPropertyFunction) {\n if (getType(value[0]) !== 'object') {\n return [\n new ValidationError(key, value, `object expected, ${getType(value[0])} found`)\n ];\n }\n if (value[0].zoom === undefined) {\n return [new ValidationError(key, value, 'object stop key must have zoom')];\n }\n if (value[0].value === undefined) {\n return [new ValidationError(key, value, 'object stop key must have value')];\n }\n if (previousStopDomainZoom && previousStopDomainZoom > unbundle(value[0].zoom)) {\n return [\n new ValidationError(key, value[0].zoom, 'stop zoom values must appear in ascending order')\n ];\n }\n if (unbundle(value[0].zoom) !== previousStopDomainZoom) {\n previousStopDomainZoom = unbundle(value[0].zoom);\n previousStopDomainValue = undefined;\n stopDomainValues = {};\n }\n errors = errors.concat(validateObject({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: { zoom: {} },\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec,\n objectElementValidators: {\n zoom: validateNumber,\n value: validateStopDomainValue\n }\n }));\n }\n else {\n errors = errors.concat(validateStopDomainValue({\n key: `${key}[0]`,\n value: value[0],\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n }, value));\n }\n if (isExpression(deepUnbundle(value[1]))) {\n return errors.concat([\n new ValidationError(`${key}[1]`, value[1], 'expressions are not allowed in function stops.')\n ]);\n }\n return errors.concat(options.validateSpec({\n key: `${key}[1]`,\n value: value[1],\n valueSpec: functionValueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n function validateStopDomainValue(options, stop) {\n const type = getType(options.value);\n const value = unbundle(options.value);\n const reportValue = options.value !== null ? options.value : stop;\n if (!stopKeyType) {\n stopKeyType = type;\n }\n else if (type !== stopKeyType) {\n return [\n new ValidationError(options.key, reportValue, `${type} stop domain type must match previous stop domain type ${stopKeyType}`)\n ];\n }\n if (type !== 'number' && type !== 'string' && type !== 'boolean') {\n return [\n new ValidationError(options.key, reportValue, 'stop domain value must be a number, string, or boolean')\n ];\n }\n if (type !== 'number' && functionType !== 'categorical') {\n let message = `number expected, ${type} found`;\n if (supportsPropertyExpression(functionValueSpec) && functionType === undefined) {\n message +=\n '\\nIf you intended to use a categorical function, specify `\"type\": \"categorical\"`.';\n }\n return [new ValidationError(options.key, reportValue, message)];\n }\n if (functionType === 'categorical' &&\n type === 'number' &&\n (!isFinite(value) || Math.floor(value) !== value)) {\n return [\n new ValidationError(options.key, reportValue, `integer expected, found ${value}`)\n ];\n }\n if (functionType !== 'categorical' &&\n type === 'number' &&\n previousStopDomainValue !== undefined &&\n value < previousStopDomainValue) {\n return [\n new ValidationError(options.key, reportValue, 'stop domain values must appear in ascending order')\n ];\n }\n else {\n previousStopDomainValue = value;\n }\n if (functionType === 'categorical' && value in stopDomainValues) {\n return [\n new ValidationError(options.key, reportValue, 'stop domain values must be unique')\n ];\n }\n else {\n stopDomainValues[value] = true;\n }\n return [];\n }\n function validateFunctionDefault(options) {\n return options.validateSpec({\n key: options.key,\n value: options.value,\n valueSpec: functionValueSpec,\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec: options.styleSpec\n });\n }\n}\n\nfunction validateExpression(options) {\n const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec);\n if (expression.result === 'error') {\n return expression.value.map((error) => {\n return new ValidationError(`${options.key}${error.key}`, options.value, error.message);\n });\n }\n const expressionObj = expression.value.expression ||\n expression.value._styleExpression.expression;\n if (options.expressionContext === 'property' &&\n options.propertyKey === 'text-font' &&\n !expressionObj.outputDefined()) {\n return [\n new ValidationError(options.key, options.value, `Invalid data expression for \"${options.propertyKey}\". Output values must be contained as literals within the expression.`)\n ];\n }\n if (options.expressionContext === 'property' &&\n options.propertyType === 'layout' &&\n !isStateConstant(expressionObj)) {\n return [\n new ValidationError(options.key, options.value, '\"feature-state\" data expressions are not supported with layout properties.')\n ];\n }\n if (options.expressionContext === 'filter' && !isStateConstant(expressionObj)) {\n return [\n new ValidationError(options.key, options.value, '\"feature-state\" data expressions are not supported with filters.')\n ];\n }\n if (options.expressionContext && options.expressionContext.indexOf('cluster') === 0) {\n if (!isGlobalPropertyConstant(expressionObj, ['zoom', 'feature-state'])) {\n return [\n new ValidationError(options.key, options.value, '\"zoom\" and \"feature-state\" expressions are not supported with cluster properties.')\n ];\n }\n if (options.expressionContext === 'cluster-initial' && !isFeatureConstant(expressionObj)) {\n return [\n new ValidationError(options.key, options.value, 'Feature data expressions are not supported with initial expression part of cluster properties.')\n ];\n }\n }\n return [];\n}\n\nfunction validateBoolean(options) {\n const value = options.value;\n const key = options.key;\n const type = getType(value);\n if (type !== 'boolean') {\n return [new ValidationError(key, value, `boolean expected, ${type} found`)];\n }\n return [];\n}\n\nfunction validateColor(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type !== 'string') {\n return [new ValidationError(key, value, `color expected, ${type} found`)];\n }\n if (!Color.parse(String(value))) {\n // cast String object to string primitive\n return [new ValidationError(key, value, `color expected, \"${value}\" found`)];\n }\n return [];\n}\n\nfunction validateEnum(options) {\n const key = options.key;\n const value = options.value;\n const valueSpec = options.valueSpec;\n const errors = [];\n if (Array.isArray(valueSpec.values)) {\n // <=v7\n if (valueSpec.values.indexOf(unbundle(value)) === -1) {\n errors.push(new ValidationError(key, value, `expected one of [${valueSpec.values.join(', ')}], ${JSON.stringify(value)} found`));\n }\n }\n else {\n // >=v8\n if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) {\n errors.push(new ValidationError(key, value, `expected one of [${Object.keys(valueSpec.values).join(', ')}], ${JSON.stringify(value)} found`));\n }\n }\n return errors;\n}\n\nfunction validateFilter(options) {\n if (isExpressionFilter(deepUnbundle(options.value))) {\n return validateExpression(extendBy({}, options, {\n expressionContext: 'filter',\n valueSpec: { value: 'boolean' }\n }));\n }\n else {\n return validateNonExpressionFilter(options);\n }\n}\nfunction validateNonExpressionFilter(options) {\n const value = options.value;\n const key = options.key;\n if (getType(value) !== 'array') {\n return [new ValidationError(key, value, `array expected, ${getType(value)} found`)];\n }\n const styleSpec = options.styleSpec;\n let type;\n let errors = [];\n if (value.length < 1) {\n return [new ValidationError(key, value, 'filter array must have at least 1 element')];\n }\n errors = errors.concat(validateEnum({\n key: `${key}[0]`,\n value: value[0],\n valueSpec: styleSpec.filter_operator,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n switch (unbundle(value[0])) {\n case '<':\n case '<=':\n case '>':\n case '>=':\n if (value.length >= 2 && unbundle(value[1]) === '$type') {\n errors.push(new ValidationError(key, value, `\"$type\" cannot be use with operator \"${value[0]}\"`));\n }\n /* falls through */\n case '==':\n case '!=':\n if (value.length !== 3) {\n errors.push(new ValidationError(key, value, `filter array for operator \"${value[0]}\" must have 3 elements`));\n }\n /* falls through */\n case 'in':\n case '!in':\n if (value.length >= 2) {\n type = getType(value[1]);\n if (type !== 'string') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));\n }\n }\n for (let i = 2; i < value.length; i++) {\n type = getType(value[i]);\n if (unbundle(value[1]) === '$type') {\n errors = errors.concat(validateEnum({\n key: `${key}[${i}]`,\n value: value[i],\n valueSpec: styleSpec.geometry_type,\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n else if (type !== 'string' && type !== 'number' && type !== 'boolean') {\n errors.push(new ValidationError(`${key}[${i}]`, value[i], `string, number, or boolean expected, ${type} found`));\n }\n }\n break;\n case 'any':\n case 'all':\n case 'none':\n for (let i = 1; i < value.length; i++) {\n errors = errors.concat(validateNonExpressionFilter({\n key: `${key}[${i}]`,\n value: value[i],\n style: options.style,\n styleSpec: options.styleSpec\n }));\n }\n break;\n case 'has':\n case '!has':\n type = getType(value[1]);\n if (value.length !== 2) {\n errors.push(new ValidationError(key, value, `filter array for \"${value[0]}\" operator must have 2 elements`));\n }\n else if (type !== 'string') {\n errors.push(new ValidationError(`${key}[1]`, value[1], `string expected, ${type} found`));\n }\n break;\n }\n return errors;\n}\n\nfunction validateProperty(options, propertyType) {\n const key = options.key;\n const validateSpec = options.validateSpec;\n const style = options.style;\n const styleSpec = options.styleSpec;\n const value = options.value;\n const propertyKey = options.objectKey;\n const layerSpec = styleSpec[`${propertyType}_${options.layerType}`];\n if (!layerSpec)\n return [];\n const transitionMatch = propertyKey.match(/^(.*)-transition$/);\n if (propertyType === 'paint' &&\n transitionMatch &&\n layerSpec[transitionMatch[1]] &&\n layerSpec[transitionMatch[1]].transition) {\n return validateSpec({\n key,\n value,\n valueSpec: styleSpec.transition,\n style,\n styleSpec\n });\n }\n const valueSpec = options.valueSpec || layerSpec[propertyKey];\n if (!valueSpec) {\n return [new ValidationError(key, value, `unknown property \"${propertyKey}\"`)];\n }\n let tokenMatch;\n if (getType(value) === 'string' &&\n supportsPropertyExpression(valueSpec) &&\n !valueSpec.tokens &&\n (tokenMatch = /^{([^}]+)}$/.exec(value))) {\n return [\n new ValidationError(key, value, `\"${propertyKey}\" does not support interpolation syntax\\n` +\n `Use an identity property function instead: \\`{ \"type\": \"identity\", \"property\": ${JSON.stringify(tokenMatch[1])} }\\`.`)\n ];\n }\n const errors = [];\n if (options.layerType === 'symbol') {\n if (propertyKey === 'text-font' &&\n isFunction$1(deepUnbundle(value)) &&\n unbundle(value.type) === 'identity') {\n errors.push(new ValidationError(key, value, '\"text-font\" does not support identity functions'));\n }\n }\n return errors.concat(validateSpec({\n key: options.key,\n value,\n valueSpec,\n style,\n styleSpec,\n expressionContext: 'property',\n propertyType,\n propertyKey\n }));\n}\n\nfunction validatePaintProperty(options) {\n return validateProperty(options, 'paint');\n}\n\nfunction validateLayoutProperty(options) {\n return validateProperty(options, 'layout');\n}\n\nfunction validateLayer(options) {\n let errors = [];\n const layer = options.value;\n const key = options.key;\n const style = options.style;\n const styleSpec = options.styleSpec;\n if (getType(layer) !== 'object') {\n return [new ValidationError(key, layer, `object expected, ${getType(layer)} found`)];\n }\n if (!layer.type && !layer.ref) {\n errors.push(new ValidationError(key, layer, 'either \"type\" or \"ref\" is required'));\n }\n let type = unbundle(layer.type);\n const ref = unbundle(layer.ref);\n if (layer.id) {\n const layerId = unbundle(layer.id);\n for (let i = 0; i < options.arrayIndex; i++) {\n const otherLayer = style.layers[i];\n if (unbundle(otherLayer.id) === layerId) {\n errors.push(new ValidationError(key, layer.id, `duplicate layer id \"${layer.id}\", previously used at line ${otherLayer.id.__line__}`));\n }\n }\n }\n if ('ref' in layer) {\n ['type', 'source', 'source-layer', 'filter', 'layout'].forEach((p) => {\n if (p in layer) {\n errors.push(new ValidationError(key, layer[p], `\"${p}\" is prohibited for ref layers`));\n }\n });\n let parent;\n style.layers.forEach((layer) => {\n if (unbundle(layer.id) === ref)\n parent = layer;\n });\n if (!parent) {\n errors.push(new ValidationError(key, layer.ref, `ref layer \"${ref}\" not found`));\n }\n else if (parent.ref) {\n errors.push(new ValidationError(key, layer.ref, 'ref cannot reference another ref layer'));\n }\n else {\n type = unbundle(parent.type);\n }\n }\n else if (type !== 'background') {\n if (!layer.source) {\n errors.push(new ValidationError(key, layer, 'missing required property \"source\"'));\n }\n else {\n const source = style.sources && style.sources[layer.source];\n const sourceType = source && unbundle(source.type);\n if (!source) {\n errors.push(new ValidationError(key, layer.source, `source \"${layer.source}\" not found`));\n }\n else if (sourceType === 'vector' && type === 'raster') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster source`));\n }\n else if (sourceType !== 'raster-dem' && type === 'hillshade') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster-dem source`));\n }\n else if (sourceType !== 'raster-dem' && type === 'color-relief') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a raster-dem source`));\n }\n else if (sourceType === 'raster' && type !== 'raster') {\n errors.push(new ValidationError(key, layer.source, `layer \"${layer.id}\" requires a vector source`));\n }\n else if (sourceType === 'vector' && !layer['source-layer']) {\n errors.push(new ValidationError(key, layer, `layer \"${layer.id}\" must specify a \"source-layer\"`));\n }\n else if (sourceType === 'raster-dem' &&\n type !== 'hillshade' &&\n type !== 'color-relief') {\n errors.push(new ValidationError(key, layer.source, \"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.\"));\n }\n else if (type === 'line' &&\n layer.paint &&\n layer.paint['line-gradient'] &&\n (sourceType !== 'geojson' || !source.lineMetrics)) {\n errors.push(new ValidationError(key, layer, `layer \"${layer.id}\" specifies a line-gradient, which requires a GeoJSON source with \\`lineMetrics\\` enabled.`));\n }\n }\n }\n errors = errors.concat(validateObject({\n key,\n value: layer,\n valueSpec: styleSpec.layer,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'() {\n return [];\n },\n // We don't want to enforce the spec's `\"requires\": true` for backward compatibility with refs;\n // the actual requirement is validated above. See https://github.com/mapbox/mapbox-gl-js/issues/5772.\n type() {\n return options.validateSpec({\n key: `${key}.type`,\n value: layer.type,\n valueSpec: styleSpec.layer.type,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n object: layer,\n objectKey: 'type'\n });\n },\n filter: validateFilter,\n layout(options) {\n return validateObject({\n layer,\n key: options.key,\n value: options.value,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'(options) {\n return validateLayoutProperty(extendBy({ layerType: type }, options));\n }\n }\n });\n },\n paint(options) {\n return validateObject({\n layer,\n key: options.key,\n value: options.value,\n style: options.style,\n styleSpec: options.styleSpec,\n validateSpec: options.validateSpec,\n objectElementValidators: {\n '*'(options) {\n return validatePaintProperty(extendBy({ layerType: type }, options));\n }\n }\n });\n }\n }\n }));\n return errors;\n}\n\nfunction validateString(options) {\n const value = options.value;\n const key = options.key;\n const type = getType(value);\n if (type !== 'string') {\n return [new ValidationError(key, value, `string expected, ${type} found`)];\n }\n return [];\n}\n\nfunction validateRasterDEMSource(options) {\n var _a;\n const sourceName = (_a = options.sourceName) !== null && _a !== void 0 ? _a : '';\n const rasterDEM = options.value;\n const styleSpec = options.styleSpec;\n const rasterDEMSpec = styleSpec.source_raster_dem;\n const style = options.style;\n let errors = [];\n const rootType = getType(rasterDEM);\n if (rasterDEM === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors.push(new ValidationError('source_raster_dem', rasterDEM, `object expected, ${rootType} found`));\n return errors;\n }\n const encoding = unbundle(rasterDEM.encoding);\n const isCustomEncoding = encoding === 'custom';\n const customEncodingKeys = ['redFactor', 'greenFactor', 'blueFactor', 'baseShift'];\n const encodingName = options.value.encoding ? `\"${options.value.encoding}\"` : 'Default';\n for (const key in rasterDEM) {\n if (!isCustomEncoding && customEncodingKeys.includes(key)) {\n errors.push(new ValidationError(key, rasterDEM[key], `In \"${sourceName}\": \"${key}\" is only valid when \"encoding\" is set to \"custom\". ${encodingName} encoding found`));\n }\n else if (rasterDEMSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: rasterDEM[key],\n valueSpec: rasterDEMSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors.push(new ValidationError(key, rasterDEM[key], `unknown property \"${key}\"`));\n }\n }\n return errors;\n}\n\nconst objectElementValidators = {\n promoteId: validatePromoteId\n};\nfunction validateSource(options) {\n const value = options.value;\n const key = options.key;\n const styleSpec = options.styleSpec;\n const style = options.style;\n const validateSpec = options.validateSpec;\n if (!value.type) {\n return [new ValidationError(key, value, '\"type\" is required')];\n }\n const type = unbundle(value.type);\n let errors;\n switch (type) {\n case 'vector':\n case 'raster':\n errors = validateObject({\n key,\n value,\n valueSpec: styleSpec[`source_${type.replace('-', '_')}`],\n style: options.style,\n styleSpec,\n objectElementValidators,\n validateSpec\n });\n return errors;\n case 'raster-dem':\n errors = validateRasterDEMSource({\n sourceName: key,\n value,\n style: options.style,\n styleSpec,\n validateSpec\n });\n return errors;\n case 'geojson':\n errors = validateObject({\n key,\n value,\n valueSpec: styleSpec.source_geojson,\n style,\n styleSpec,\n validateSpec,\n objectElementValidators\n });\n if (value.cluster) {\n for (const prop in value.clusterProperties) {\n const [operator, mapExpr] = value.clusterProperties[prop];\n const reduceExpr = typeof operator === 'string'\n ? [operator, ['accumulated'], ['get', prop]]\n : operator;\n errors.push(...validateExpression({\n key: `${key}.${prop}.map`,\n value: mapExpr,\n expressionContext: 'cluster-map'\n }));\n errors.push(...validateExpression({\n key: `${key}.${prop}.reduce`,\n value: reduceExpr,\n expressionContext: 'cluster-reduce'\n }));\n }\n }\n return errors;\n case 'video':\n return validateObject({\n key,\n value,\n valueSpec: styleSpec.source_video,\n style,\n validateSpec,\n styleSpec\n });\n case 'image':\n return validateObject({\n key,\n value,\n valueSpec: styleSpec.source_image,\n style,\n validateSpec,\n styleSpec\n });\n case 'canvas':\n return [\n new ValidationError(key, null, 'Please use runtime APIs to add canvas sources, rather than including them in stylesheets.', 'source.canvas')\n ];\n default:\n return validateEnum({\n key: `${key}.type`,\n value: value.type,\n valueSpec: {\n values: ['vector', 'raster', 'raster-dem', 'geojson', 'video', 'image']\n }});\n }\n}\nfunction validatePromoteId({ key, value }) {\n if (getType(value) === 'string') {\n return validateString({ key, value });\n }\n else {\n const errors = [];\n for (const prop in value) {\n errors.push(...validateString({ key: `${key}.${prop}`, value: value[prop] }));\n }\n return errors;\n }\n}\n\nfunction validateLight(options) {\n const light = options.value;\n const styleSpec = options.styleSpec;\n const lightSpec = styleSpec.light;\n const style = options.style;\n let errors = [];\n const rootType = getType(light);\n if (light === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors = errors.concat([\n new ValidationError('light', light, `object expected, ${rootType} found`)\n ]);\n return errors;\n }\n for (const key in light) {\n const transitionMatch = key.match(/^(.*)-transition$/);\n if (transitionMatch &&\n lightSpec[transitionMatch[1]] &&\n lightSpec[transitionMatch[1]].transition) {\n errors = errors.concat(options.validateSpec({\n key,\n value: light[key],\n valueSpec: styleSpec.transition,\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else if (lightSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: light[key],\n valueSpec: lightSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([\n new ValidationError(key, light[key], `unknown property \"${key}\"`)\n ]);\n }\n }\n return errors;\n}\n\nfunction validateSky(options) {\n const sky = options.value;\n const styleSpec = options.styleSpec;\n const skySpec = styleSpec.sky;\n const style = options.style;\n const rootType = getType(sky);\n if (sky === undefined) {\n return [];\n }\n else if (rootType !== 'object') {\n return [new ValidationError('sky', sky, `object expected, ${rootType} found`)];\n }\n let errors = [];\n for (const key in sky) {\n if (skySpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: sky[key],\n valueSpec: skySpec[key],\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([\n new ValidationError(key, sky[key], `unknown property \"${key}\"`)\n ]);\n }\n }\n return errors;\n}\n\nfunction validateTerrain(options) {\n const terrain = options.value;\n const styleSpec = options.styleSpec;\n const terrainSpec = styleSpec.terrain;\n const style = options.style;\n let errors = [];\n const rootType = getType(terrain);\n if (terrain === undefined) {\n return errors;\n }\n else if (rootType !== 'object') {\n errors = errors.concat([\n new ValidationError('terrain', terrain, `object expected, ${rootType} found`)\n ]);\n return errors;\n }\n for (const key in terrain) {\n if (terrainSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: terrain[key],\n valueSpec: terrainSpec[key],\n validateSpec: options.validateSpec,\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([\n new ValidationError(key, terrain[key], `unknown property \"${key}\"`)\n ]);\n }\n }\n return errors;\n}\n\nfunction validateFormatted(options) {\n if (validateString(options).length === 0) {\n return [];\n }\n return validateExpression(options);\n}\n\nfunction validateImage(options) {\n if (validateString(options).length === 0) {\n return [];\n }\n return validateExpression(options);\n}\n\nfunction validatePadding(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type === 'array') {\n if (value.length < 1 || value.length > 4) {\n return [\n new ValidationError(key, value, `padding requires 1 to 4 values; ${value.length} values found`)\n ];\n }\n const arrayElementSpec = {\n type: 'number'\n };\n let errors = [];\n for (let i = 0; i < value.length; i++) {\n errors = errors.concat(options.validateSpec({\n key: `${key}[${i}]`,\n value: value[i],\n validateSpec: options.validateSpec,\n valueSpec: arrayElementSpec\n }));\n }\n return errors;\n }\n else {\n return validateNumber({\n key,\n value,\n valueSpec: {}\n });\n }\n}\n\nfunction validateNumberArray(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type === 'array') {\n const arrayElementSpec = {\n type: 'number'\n };\n if (value.length < 1) {\n return [\n new ValidationError(key, value, 'array length at least 1 expected, length 0 found')\n ];\n }\n let errors = [];\n for (let i = 0; i < value.length; i++) {\n errors = errors.concat(options.validateSpec({\n key: `${key}[${i}]`,\n value: value[i],\n validateSpec: options.validateSpec,\n valueSpec: arrayElementSpec\n }));\n }\n return errors;\n }\n else {\n return validateNumber({\n key,\n value,\n valueSpec: {}\n });\n }\n}\n\nfunction validateColorArray(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n if (type === 'array') {\n if (value.length < 1) {\n return [\n new ValidationError(key, value, 'array length at least 1 expected, length 0 found')\n ];\n }\n let errors = [];\n for (let i = 0; i < value.length; i++) {\n errors = errors.concat(validateColor({\n key: `${key}[${i}]`,\n value: value[i]}));\n }\n return errors;\n }\n else {\n return validateColor({\n key,\n value});\n }\n}\n\nfunction validateVariableAnchorOffsetCollection(options) {\n const key = options.key;\n const value = options.value;\n const type = getType(value);\n const styleSpec = options.styleSpec;\n if (type !== 'array' || value.length < 1 || value.length % 2 !== 0) {\n return [\n new ValidationError(key, value, 'variableAnchorOffsetCollection requires a non-empty array of even length')\n ];\n }\n let errors = [];\n for (let i = 0; i < value.length; i += 2) {\n // Elements in even positions should be values from text-anchor enum\n errors = errors.concat(validateEnum({\n key: `${key}[${i}]`,\n value: value[i],\n valueSpec: styleSpec['layout_symbol']['text-anchor']\n }));\n // Elements in odd positions should be points (2-element numeric arrays)\n errors = errors.concat(validateArray({\n key: `${key}[${i + 1}]`,\n value: value[i + 1],\n valueSpec: {\n length: 2,\n value: 'number'\n },\n validateSpec: options.validateSpec,\n style: options.style,\n styleSpec\n }));\n }\n return errors;\n}\n\nfunction validateSprite(options) {\n let errors = [];\n const sprite = options.value;\n const key = options.key;\n if (!Array.isArray(sprite)) {\n return validateString({\n key,\n value: sprite\n });\n }\n else {\n const allSpriteIds = [];\n const allSpriteURLs = [];\n for (const i in sprite) {\n if (sprite[i].id && allSpriteIds.includes(sprite[i].id))\n errors.push(new ValidationError(key, sprite, `all the sprites' ids must be unique, but ${sprite[i].id} is duplicated`));\n allSpriteIds.push(sprite[i].id);\n if (sprite[i].url && allSpriteURLs.includes(sprite[i].url))\n errors.push(new ValidationError(key, sprite, `all the sprites' URLs must be unique, but ${sprite[i].url} is duplicated`));\n allSpriteURLs.push(sprite[i].url);\n const pairSpec = {\n id: {\n type: 'string',\n required: true\n },\n url: {\n type: 'string',\n required: true\n }\n };\n errors = errors.concat(validateObject({\n key: `${key}[${i}]`,\n value: sprite[i],\n valueSpec: pairSpec,\n validateSpec: options.validateSpec\n }));\n }\n return errors;\n }\n}\n\nfunction validateProjection(options) {\n const projection = options.value;\n const styleSpec = options.styleSpec;\n const projectionSpec = styleSpec.projection;\n const style = options.style;\n const rootType = getType(projection);\n if (projection === undefined) {\n return [];\n }\n else if (rootType !== 'object') {\n return [\n new ValidationError('projection', projection, `object expected, ${rootType} found`)\n ];\n }\n let errors = [];\n for (const key in projection) {\n if (projectionSpec[key]) {\n errors = errors.concat(options.validateSpec({\n key,\n value: projection[key],\n valueSpec: projectionSpec[key],\n style,\n styleSpec\n }));\n }\n else {\n errors = errors.concat([\n new ValidationError(key, projection[key], `unknown property \"${key}\"`)\n ]);\n }\n }\n return errors;\n}\n\nfunction validateProjectionDefinition(options) {\n const key = options.key;\n let value = options.value;\n value = value instanceof String ? value.valueOf() : value;\n const type = getType(value);\n if (type === 'array' &&\n !isProjectionDefinitionValue(value) &&\n !isPropertyValueSpecification(value)) {\n return [\n new ValidationError(key, value, `projection expected, invalid array ${JSON.stringify(value)} found`)\n ];\n }\n else if (!['array', 'string'].includes(type)) {\n return [\n new ValidationError(key, value, `projection expected, invalid type \"${type}\" found`)\n ];\n }\n return [];\n}\nfunction isPropertyValueSpecification(value) {\n if (['interpolate', 'step', 'literal'].includes(value[0])) {\n return true;\n }\n return false;\n}\nfunction isProjectionDefinitionValue(value) {\n return (Array.isArray(value) &&\n value.length === 3 &&\n typeof value[0] === 'string' &&\n typeof value[1] === 'string' &&\n typeof value[2] === 'number');\n}\n\nfunction isObjectLiteral(anything) {\n return Boolean(anything) && anything.constructor === Object;\n}\n\nfunction validateState(options) {\n if (!isObjectLiteral(options.value)) {\n return [\n new ValidationError(options.key, options.value, `object expected, ${getType(options.value)} found`)\n ];\n }\n return [];\n}\n\nfunction validateFontFaces(options) {\n const key = options.key;\n const value = options.value;\n const validateSpec = options.validateSpec;\n const styleSpec = options.styleSpec;\n const style = options.style;\n if (!isObjectLiteral(value)) {\n return [new ValidationError(key, value, `object expected, ${getType(value)} found`)];\n }\n const errors = [];\n for (const fontName in value) {\n const fontValue = value[fontName];\n const fontValueType = getType(fontValue);\n if (fontValueType === 'string') {\n // Validate as a string URL\n errors.push(...validateString({\n key: `${key}.${fontName}`,\n value: fontValue\n }));\n }\n else if (fontValueType === 'array') {\n // Validate as an array of font face objects\n const fontFaceSpec = {\n url: {\n type: 'string',\n required: true\n },\n 'unicode-range': {\n type: 'array',\n value: 'string'\n }\n };\n for (const [i, fontFace] of fontValue.entries()) {\n errors.push(...validateObject({\n key: `${key}.${fontName}[${i}]`,\n value: fontFace,\n valueSpec: fontFaceSpec,\n styleSpec,\n style,\n validateSpec\n }));\n }\n }\n else {\n errors.push(new ValidationError(`${key}.${fontName}`, fontValue, `string or array expected, ${fontValueType} found`));\n }\n }\n return errors;\n}\n\nconst VALIDATORS = {\n '*'() {\n return [];\n },\n array: validateArray,\n boolean: validateBoolean,\n number: validateNumber,\n color: validateColor,\n constants: validateConstants,\n enum: validateEnum,\n filter: validateFilter,\n function: validateFunction,\n layer: validateLayer,\n object: validateObject,\n source: validateSource,\n light: validateLight,\n sky: validateSky,\n terrain: validateTerrain,\n projection: validateProjection,\n projectionDefinition: validateProjectionDefinition,\n string: validateString,\n formatted: validateFormatted,\n resolvedImage: validateImage,\n padding: validatePadding,\n numberArray: validateNumberArray,\n colorArray: validateColorArray,\n variableAnchorOffsetCollection: validateVariableAnchorOffsetCollection,\n sprite: validateSprite,\n state: validateState,\n fontFaces: validateFontFaces\n};\n/**\n * Main recursive validation function used internally.\n * You should use `validateStyleMin` in the browser or `validateStyle` in node env.\n * @param options - the options object\n * @param options.key - string representing location of validation in style tree. Used only\n * for more informative error reporting.\n * @param options.value - current value from style being evaluated. May be anything from a\n * high level object that needs to be descended into deeper or a simple\n * scalar value.\n * @param options.valueSpec - current spec being evaluated. Tracks value.\n * @param options.styleSpec - current full spec being evaluated.\n * @param options.validateSpec - the validate function itself\n * @param options.style - the style object\n * @param options.objectElementValidators - optional object of functions that will be called\n * @returns an array of errors, or an empty array if no errors are found.\n */\nfunction validate(options) {\n const value = options.value;\n const valueSpec = options.valueSpec;\n const styleSpec = options.styleSpec;\n options.validateSpec = validate;\n if (valueSpec.expression && isFunction$1(unbundle(value))) {\n return validateFunction(options);\n }\n else if (valueSpec.expression && isExpression(deepUnbundle(value))) {\n return validateExpression(options);\n }\n else if (valueSpec.type && VALIDATORS[valueSpec.type]) {\n return VALIDATORS[valueSpec.type](options);\n }\n else {\n const valid = validateObject(extendBy({}, options, {\n valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec\n }));\n return valid;\n }\n}\n\nfunction validateGlyphsUrl(options) {\n const value = options.value;\n const key = options.key;\n const errors = validateString(options);\n if (errors.length)\n return errors;\n if (value.indexOf('{fontstack}') === -1) {\n errors.push(new ValidationError(key, value, '\"glyphs\" url must include a \"{fontstack}\" token'));\n }\n if (value.indexOf('{range}') === -1) {\n errors.push(new ValidationError(key, value, '\"glyphs\" url must include a \"{range}\" token'));\n }\n return errors;\n}\n\n/**\n * Validate a MapLibre style against the style specification.\n * Use this when running in the browser.\n *\n * @param style - The style to be validated.\n * @param styleSpec - The style specification to validate against.\n * If omitted, the latest style spec is used.\n * @returns an array of errors, or an empty array if no errors are found.\n * @example\n * const validate = require('@maplibre/maplibre-gl-style-spec/').validateStyleMin;\n * const errors = validate(style);\n */\nfunction validateStyleMin(style, styleSpec = v8Spec) {\n let errors = [];\n errors = errors.concat(validate({\n key: '',\n value: style,\n valueSpec: styleSpec.$root,\n styleSpec,\n style,\n validateSpec: validate,\n objectElementValidators: {\n glyphs: validateGlyphsUrl,\n '*'() {\n return [];\n }\n }\n }));\n if (style['constants']) {\n errors = errors.concat(validateConstants({\n key: 'constants',\n value: style['constants']}));\n }\n return sortErrors(errors);\n}\nvalidateStyleMin.source = wrapCleanErrors(injectValidateSpec(validateSource));\nvalidateStyleMin.sprite = wrapCleanErrors(injectValidateSpec(validateSprite));\nvalidateStyleMin.glyphs = wrapCleanErrors(injectValidateSpec(validateGlyphsUrl));\nvalidateStyleMin.light = wrapCleanErrors(injectValidateSpec(validateLight));\nvalidateStyleMin.sky = wrapCleanErrors(injectValidateSpec(validateSky));\nvalidateStyleMin.terrain = wrapCleanErrors(injectValidateSpec(validateTerrain));\nvalidateStyleMin.state = wrapCleanErrors(injectValidateSpec(validateState));\nvalidateStyleMin.layer = wrapCleanErrors(injectValidateSpec(validateLayer));\nvalidateStyleMin.filter = wrapCleanErrors(injectValidateSpec(validateFilter));\nvalidateStyleMin.paintProperty = wrapCleanErrors(injectValidateSpec(validatePaintProperty));\nvalidateStyleMin.layoutProperty = wrapCleanErrors(injectValidateSpec(validateLayoutProperty));\nfunction injectValidateSpec(validator) {\n return function (options) {\n return validator(Object.assign({}, options, { validateSpec: validate }));\n };\n}\nfunction sortErrors(errors) {\n return [].concat(errors).sort((a, b) => {\n return a.line - b.line;\n });\n}\nfunction wrapCleanErrors(inner) {\n return function (...args) {\n return sortErrors(inner.apply(this, args));\n };\n}\n\n// Note: This regex matches even invalid JSON strings, but since we’re\n// working on the output of `JSON.stringify` we know that only valid strings\n// are present (unless the user supplied a weird `options.indent` but in\n// that case we don’t care since the output would be invalid anyway).\nconst stringOrChar = /(\"(?:[^\\\\\"]|\\\\.)*\")|[:,]/g;\n\nfunction stringify(passedObj, options = {}) {\n const indent = JSON.stringify(\n [1],\n undefined,\n options.indent === undefined ? 2 : options.indent\n ).slice(2, -3);\n\n const maxLength =\n indent === \"\"\n ? Infinity\n : options.maxLength === undefined\n ? 80\n : options.maxLength;\n\n let { replacer } = options;\n\n return (function _stringify(obj, currentIndent, reserved) {\n if (obj && typeof obj.toJSON === \"function\") {\n obj = obj.toJSON();\n }\n\n const string = JSON.stringify(obj, replacer);\n\n if (string === undefined) {\n return string;\n }\n\n const length = maxLength - currentIndent.length - reserved;\n\n if (string.length <= length) {\n const prettified = string.replace(\n stringOrChar,\n (match, stringLiteral) => {\n return stringLiteral || `${match} `;\n }\n );\n if (prettified.length <= length) {\n return prettified;\n }\n }\n\n if (replacer != null) {\n obj = JSON.parse(string);\n replacer = undefined;\n }\n\n if (typeof obj === \"object\" && obj !== null) {\n const nextIndent = currentIndent + indent;\n const items = [];\n let index = 0;\n let start;\n let end;\n\n if (Array.isArray(obj)) {\n start = \"[\";\n end = \"]\";\n const { length } = obj;\n for (; index < length; index++) {\n items.push(\n _stringify(obj[index], nextIndent, index === length - 1 ? 0 : 1) ||\n \"null\"\n );\n }\n } else {\n start = \"{\";\n end = \"}\";\n const keys = Object.keys(obj);\n const { length } = keys;\n for (; index < length; index++) {\n const key = keys[index];\n const keyPart = `${JSON.stringify(key)}: `;\n const value = _stringify(\n obj[key],\n nextIndent,\n keyPart.length + (index === length - 1 ? 0 : 1)\n );\n if (value !== undefined) {\n items.push(keyPart + value);\n }\n }\n }\n\n if (items.length > 0) {\n return [start, indent + items.join(`,\\n${nextIndent}`), end].join(\n `\\n${currentIndent}`\n );\n }\n }\n\n return string;\n })(passedObj, \"\", 0);\n}\n\nfunction sortKeysBy(obj, reference) {\n const result = {};\n for (const key in reference) {\n if (obj[key] !== undefined) {\n result[key] = obj[key];\n }\n }\n for (const key in obj) {\n if (result[key] === undefined) {\n result[key] = obj[key];\n }\n }\n return result;\n}\n/**\n * Format a MapLibre Style. Returns a stringified style with its keys\n * sorted in the same order as the reference style.\n *\n * The optional `space` argument is passed to\n * [`JSON.stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)\n * to generate formatted output.\n *\n * If `space` is unspecified, a default of `2` spaces will be used.\n *\n * @private\n * @param {Object} style a MapLibre Style\n * @param {number} [space] space argument to pass to `JSON.stringify`\n * @returns {string} stringified formatted JSON\n * @example\n * var fs = require('fs');\n * var format = require('maplibre-gl-style-spec').format;\n * var style = fs.readFileSync('./source.json', 'utf8');\n * fs.writeFileSync('./dest.json', format(style));\n * fs.writeFileSync('./dest.min.json', format(style, 0));\n */\nfunction format(style, space = 2) {\n style = sortKeysBy(style, v8Spec.$root);\n if (style.layers) {\n style.layers = style.layers.map((layer) => sortKeysBy(layer, v8Spec.layer));\n }\n return stringify(style, { indent: space });\n}\n\nfunction eachLayout(layer, callback) {\n for (const k in layer) {\n if (k.indexOf('layout') === 0) {\n callback(layer[k], k);\n }\n }\n}\nfunction eachPaint(layer, callback) {\n for (const k in layer) {\n if (k.indexOf('paint') === 0) {\n callback(layer[k], k);\n }\n }\n}\nfunction resolveConstant(style, value) {\n if (typeof value === 'string' && value[0] === '@') {\n return resolveConstant(style, style.constants[value]);\n }\n else {\n return value;\n }\n}\nfunction isFunction(value) {\n return Array.isArray(value.stops);\n}\nfunction renameProperty(obj, from, to) {\n obj[to] = obj[from];\n delete obj[from];\n}\nfunction migrateV8(style) {\n style.version = 8;\n // Rename properties, reverse coordinates in source and layers\n eachSource(style, (source) => {\n if (source.type === 'video' && source['url'] !== undefined) {\n renameProperty(source, 'url', 'urls');\n }\n if (source.type === 'video') {\n source.coordinates.forEach((coord) => {\n return coord.reverse();\n });\n }\n });\n eachLayer(style, (layer) => {\n eachLayout(layer, (layout) => {\n if (layout['symbol-min-distance'] !== undefined) {\n renameProperty(layout, 'symbol-min-distance', 'symbol-spacing');\n }\n });\n eachPaint(layer, (paint) => {\n if (paint['background-image'] !== undefined) {\n renameProperty(paint, 'background-image', 'background-pattern');\n }\n if (paint['line-image'] !== undefined) {\n renameProperty(paint, 'line-image', 'line-pattern');\n }\n if (paint['fill-image'] !== undefined) {\n renameProperty(paint, 'fill-image', 'fill-pattern');\n }\n });\n });\n // Inline Constants\n eachProperty(style, { paint: true, layout: true }, (property) => {\n const value = resolveConstant(style, property.value);\n if (isFunction(value)) {\n value.stops.forEach((stop) => {\n stop[1] = resolveConstant(style, stop[1]);\n });\n }\n property.set(value);\n });\n delete style['constants'];\n eachLayer(style, (layer) => {\n // get rid of text-max-size, icon-max-size\n // turn text-size, icon-size into layout properties\n // https://github.com/mapbox/mapbox-gl-style-spec/issues/255\n eachLayout(layer, (layout) => {\n delete layout['text-max-size'];\n delete layout['icon-max-size'];\n });\n eachPaint(layer, (paint) => {\n if (paint['text-size']) {\n if (!layer.layout)\n layer.layout = {};\n layer.layout['text-size'] = paint['text-size'];\n delete paint['text-size'];\n }\n if (paint['icon-size']) {\n if (!layer.layout)\n layer.layout = {};\n layer.layout['icon-size'] = paint['icon-size'];\n delete paint['icon-size'];\n }\n });\n });\n function migrateFontStack(font) {\n function splitAndTrim(string) {\n return string.split(',').map((s) => {\n return s.trim();\n });\n }\n if (Array.isArray(font)) {\n // Assume it's a previously migrated font-array.\n return font;\n }\n else if (typeof font === 'string') {\n return splitAndTrim(font);\n }\n else if (typeof font === 'object') {\n font.stops.forEach((stop) => {\n stop[1] = splitAndTrim(stop[1]);\n });\n return font;\n }\n else {\n throw new Error('unexpected font value');\n }\n }\n eachLayer(style, (layer) => {\n eachLayout(layer, (layout) => {\n if (layout['text-font']) {\n layout['text-font'] = migrateFontStack(layout['text-font']);\n }\n });\n });\n // Reverse order of symbol layers. This is an imperfect migration.\n //\n // The order of a symbol layer in the layers list affects two things:\n // - how it is drawn relative to other layers (like oneway arrows below bridges)\n // - the placement priority compared to other layers\n //\n // It's impossible to reverse the placement priority without breaking the draw order\n // in some cases. This migration only reverses the order of symbol layers that\n // are above all other types of layers.\n //\n // Symbol layers that are at the top of the map preserve their priority.\n // Symbol layers that are below another type (line, fill) of layer preserve their draw order.\n let firstSymbolLayer = 0;\n for (let i = style.layers.length - 1; i >= 0; i--) {\n const layer = style.layers[i];\n if (layer.type !== 'symbol') {\n firstSymbolLayer = i + 1;\n break;\n }\n }\n const symbolLayers = style.layers.splice(firstSymbolLayer);\n symbolLayers.reverse();\n style.layers = style.layers.concat(symbolLayers);\n return style;\n}\n\n/**\n * Migrate the given style object in place to use expressions. Specifically,\n * this will convert (a) \"stop\" functions, and (b) legacy filters to their\n * expression equivalents.\n * @param style The style object to migrate.\n * @returns The migrated style object.\n */\nfunction expressions(style) {\n const converted = [];\n eachLayer(style, (layer) => {\n if (layer.filter) {\n layer.filter = convertFilter(layer.filter);\n }\n });\n eachProperty(style, { paint: true, layout: true }, ({ path, key, value, reference, set }) => {\n if (isExpression(value) || key.endsWith('-transition') || reference === null)\n return;\n if (typeof value === 'object' && !Array.isArray(value)) {\n set(convertFunction(value, reference));\n converted.push(path.join('.'));\n }\n else if (reference.tokens && typeof value === 'string') {\n set(convertTokenString(value));\n }\n });\n return style;\n}\n\n/**\n * Migrate color style values to supported format.\n *\n * @param colorToMigrate Color value to migrate, could be a string or an expression.\n * @returns Color style value in supported format.\n */\nfunction migrateColors(colorToMigrate) {\n return JSON.parse(migrateHslColors(JSON.stringify(colorToMigrate)));\n}\n/**\n * Created to migrate from colors supported by the former CSS color parsing\n * library `csscolorparser` but not compliant with the CSS Color specification,\n * like `hsl(900, 0.15, 90%)`.\n *\n * @param colorToMigrate Serialized color style value.\n * @returns A serialized color style value in which all non-standard hsl color values\n * have been converted to a format that complies with the CSS Color specification.\n *\n * @example\n * migrateHslColors('\"hsl(900, 0.15, 90%)\"'); // returns '\"hsl(900, 15%, 90%)\"'\n * migrateHslColors('\"hsla(900, .15, .9)\"'); // returns '\"hsl(900, 15%, 90%)\"'\n * migrateHslColors('\"hsl(900, 15%, 90%)\"'); // returns '\"hsl(900, 15%, 90%)\"' - no changes\n */\nfunction migrateHslColors(colorToMigrate) {\n return colorToMigrate.replace(/\"hsla?\\((.+?)\\)\"/gi, (match, hslArgs) => {\n const argsMatch = hslArgs.match(/^(.+?)\\s*,\\s*(.+?)\\s*,\\s*(.+?)(?:\\s*,\\s*(.+))?$/i);\n if (argsMatch) {\n let [h, s, l, a] = argsMatch.slice(1);\n [s, l] = [s, l].map((v) => (v.endsWith('%') ? v : `${parseFloat(v) * 100}%`));\n return `\"hsl${typeof a === 'string' ? 'a' : ''}(${[h, s, l, a].filter(Boolean).join(',')})\"`;\n }\n return match;\n });\n}\n\n/**\n * Migrate a Mapbox/MapLibre GL Style to the latest version.\n *\n * @param style - a MapLibre Style\n * @returns a migrated style\n * @example\n * const fs = require('fs');\n * const migrate = require('@maplibre/maplibre-gl-style-spec').migrate;\n * const style = fs.readFileSync('./style.json', 'utf8');\n * fs.writeFileSync('./style.json', JSON.stringify(migrate(style)));\n */\nfunction migrate(style) {\n let migrated = false;\n if (style.version === 7) {\n style = migrateV8(style);\n migrated = true;\n }\n if (style.version === 8) {\n migrated = !!expressions(style);\n migrated = true;\n }\n eachProperty(style, { paint: true, layout: true }, ({ value, reference, set }) => {\n if ((reference === null || reference === void 0 ? void 0 : reference.type) === 'color') {\n set(migrateColors(value));\n }\n });\n if (!migrated) {\n throw new Error(`Cannot migrate from ${style.version}`);\n }\n return style;\n}\n\nconst visibilitySpec = {\n type: 'enum',\n 'property-type': 'data-constant',\n expression: {\n interpolated: false,\n parameters: ['global-state']\n },\n values: { visible: {}, none: {} },\n transition: false,\n default: 'visible'\n};\nclass VisibilityExpressionClass {\n constructor(visibility, globalState) {\n this._globalState = globalState;\n this.setValue(visibility);\n }\n evaluate() {\n var _a;\n return (_a = this._literalValue) !== null && _a !== void 0 ? _a : this._compiledValue.evaluate({});\n }\n setValue(visibility) {\n if (visibility === null ||\n visibility === undefined ||\n visibility === 'visible' ||\n visibility === 'none') {\n this._literalValue = visibility === 'none' ? 'none' : 'visible';\n this._compiledValue = undefined;\n this._globalStateRefs = new Set();\n return;\n }\n const compiled = createExpression(visibility, visibilitySpec, this._globalState);\n if (compiled.result === 'error') {\n this._literalValue = 'visible';\n this._compiledValue = undefined;\n throw new Error(compiled.value.map((err) => `${err.key}: ${err.message}`).join(', '));\n }\n this._literalValue = undefined;\n this._compiledValue = compiled.value;\n this._globalStateRefs = findGlobalStateRefs(compiled.value.expression);\n }\n getGlobalStateRefs() {\n return this._globalStateRefs;\n }\n}\n/**\n * Creates a visibility expression from a visibility specification.\n * @param visibility - the visibility specification, literal or expression\n * @param globalState - the global state object\n * @returns visibility expression object\n */\nfunction createVisibility(visibility, globalState) {\n return new VisibilityExpressionClass(visibility, globalState);\n}\n\nconst v8 = v8Spec;\nconst expression = {\n StyleExpression,\n StylePropertyFunction,\n ZoomConstantExpression,\n ZoomDependentExpression,\n createExpression,\n createPropertyExpression,\n isExpression,\n isExpressionFilter,\n isZoomExpression,\n normalizePropertyExpression\n};\nconst styleFunction = {\n convertFunction,\n createFunction,\n isFunction: isFunction$1\n};\nconst visit = { eachLayer, eachProperty, eachSource };\n\nexport { Color, ColorArray, ColorType, CompoundExpression, EvaluationContext, FormatExpression, Formatted, FormattedSection, FormattedType, Interpolate, Literal, NullType, NumberArray, Padding, ParsingError, ProjectionDefinition, ProjectionDefinitionType, ResolvedImage, Step, StyleExpression, StylePropertyFunction, ValidationError, VariableAnchorOffsetCollection, ZoomConstantExpression, ZoomDependentExpression, classifyRings, convertFilter, convertFunction, createExpression, createFunction, createPropertyExpression, createVisibility as createVisibilityExpression, derefLayers, diff, emptyStyle, expression, expressions$1 as expressions, featureFilter, format, styleFunction as function, groupByLayout, interpolateFactory as interpolates, isExpression, isFunction$1 as isFunction, isZoomExpression, v8Spec as latest, migrate, normalizePropertyExpression, supportsPropertyExpression, typeToString as toString, typeOf, v8, validate, validateStyleMin, visit };\n//# sourceMappingURL=index.mjs.map\n","import { expression, latest } from '@maplibre/maplibre-gl-style-spec'\r\n\r\nexport class StyleLayerProperties {\r\n constructor(groupName, styleProperties = {}) {\r\n this.data = styleProperties\r\n /**@type {Map<string,import('@maplibre/maplibre-gl-style-spec').StylePropertyExpression>} */\r\n this.props = new Map()\r\n\r\n const groupReference = latest[groupName]\r\n for (const key in groupReference) {\r\n if (Object.hasOwnProperty.call(groupReference, key)) {\r\n const reference = groupReference[key];\r\n const value = styleProperties[key];\r\n const property = expression.normalizePropertyExpression(\r\n value === undefined ? reference.default : value, reference,\r\n )\r\n this.props.set(key, property)\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Replace tokens in a string template with values in an object\r\n *\r\n * @param properties - a key/value relationship between tokens and replacements\r\n * @param text - the template string\r\n * @returns the template with tokens replaced\r\n */\r\n resolveTokens(properties, text) {\r\n return text.replace(/{([^{}]+)}/g, (match, key) => {\r\n return properties && key in properties ? String(properties[key]) : '';\r\n });\r\n }\r\n getDataConstValue(name, zoom) {\r\n const expr = this.props.get(name)\r\n return expr && expr.evaluate({ zoom })\r\n }\r\n\r\n getDataValue(name, zoom, feature) {\r\n const expr = this.props.get(name)\r\n return expr && expr.evaluate({ zoom }, feature)\r\n }\r\n}","import { featureFilter, Color } from \"@maplibre/maplibre-gl-style-spec\";\r\nimport { StyleLayerProperties } from \"./StyleLayerProperties\";\r\n\r\nexport class StyleLayer {\r\n /**\r\n * @param {import('@maplibre/maplibre-gl-style-spec').LayerSpecification} layer \r\n */\r\n constructor(layer) {\r\n this.data = layer\r\n this.type = layer.type\r\n this.id = layer.id\r\n this.minzoom = layer.minzoom || 0\r\n this.maxzoom = layer.maxzoom || 24\r\n this.source = layer.source\r\n /**@type {string} */\r\n this.sourceLayer = layer['source-layer']\r\n /**@type {import(\"@maplibre/maplibre-gl-style-spec\").FeatureFilter|null} */\r\n this.filter = null\r\n this.paint = new StyleLayerProperties('paint_' + layer.type, layer.paint)\r\n this.layout = new StyleLayerProperties('layout_' + layer.type, layer.layout)\r\n if (layer.filter) {\r\n this.filter = featureFilter(layer.filter)\r\n }\r\n }\r\n\r\n /**\r\n * 转换图层样式颜色,内部进行预乘Alpha的逆处理,@maplibre/maplibre-gl-style-spec内部会自动对颜色进行premultiplyAlpha操作,直接使用会出现明显的色差\r\n * @param {Color} styleColor \r\n * @param {Cesium.Color} [result] \r\n * @returns \r\n */\r\n convertColor(styleColor, result) {\r\n const alphaScalar = styleColor.a > 0 ? 1. / styleColor.a : 1\r\n if (!result) {\r\n result = new Cesium.Color()\r\n }\r\n result.red = styleColor.r * alphaScalar\r\n result.green = styleColor.g * alphaScalar\r\n result.blue = styleColor.b * alphaScalar\r\n result.alpha = styleColor.a\r\n return result\r\n }\r\n}","import { IRenderLayer } from \"./layers/IRenderLayer\"\r\n\r\nexport class VectorTileRenderList {\r\n constructor(styleLayers) {\r\n this.styleLayers = styleLayers\r\n this.renderLayers = []\r\n this.layerIndexMap = {}\r\n /**\r\n * @type {IRenderLayer[]}\r\n * @private\r\n */\r\n this.list = []\r\n /**@type {Cesium.DrawCommand[]} */\r\n this.tileIdCommands = []\r\n /**@type {Cesium.DrawCommand[]} */\r\n this.tileCommands = []\r\n }\r\n\r\n init() {\r\n const { styleLayers, renderLayers, layerIndexMap } = this\r\n for (let layerIndex = 0; layerIndex < styleLayers.length; layerIndex++) {\r\n const styleLayer = styleLayers[layerIndex]\r\n renderLayers[layerIndex] = []\r\n layerIndexMap[styleLayer.id] = layerIndex\r\n }\r\n this.tileIdCommands.length = 0\r\n this.tileCommands.length = 0\r\n }\r\n\r\n beginFrame() {\r\n const renderLayers = this.renderLayers\r\n for (const renderLayer of renderLayers) {\r\n renderLayer.length = 0\r\n }\r\n this.tileIdCommands.length = 0\r\n this.tileCommands.length = 0\r\n }\r\n\r\n push(renderLayer) {\r\n const layerIndex = this.layerIndexMap[renderLayer.id]\r\n this.renderLayers[layerIndex].push(renderLayer)\r\n }\r\n\r\n /**\r\n * @returns {IRenderLayer[]}\r\n */\r\n getList() {\r\n const list = this.list\r\n list.length = 0\r\n const renderLayers = this.renderLayers\r\n for (const renderLayer of renderLayers) {\r\n if (renderLayer) {\r\n list.push(...renderLayer)\r\n }\r\n }\r\n return list\r\n }\r\n\r\n destroy() {\r\n this.styleLayers.length = 0\r\n this.renderLayers.length = 0\r\n this.layerIndexMap = null\r\n this.init()\r\n }\r\n}","\nexport default function earcut(data, holeIndices, dim = 2) {\n\n const hasHoles = holeIndices && holeIndices.length;\n const outerLen = hasHoles ? holeIndices[0] * dim : data.length;\n let outerNode = linkedList(data, 0, outerLen, dim, true);\n const triangles = [];\n\n if (!outerNode || outerNode.next === outerNode.prev) return triangles;\n\n let minX, minY, invSize;\n\n if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);\n\n // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox\n if (data.length > 80 * dim) {\n minX = data[0];\n minY = data[1];\n let maxX = minX;\n let maxY = minY;\n\n for (let i = dim; i < outerLen; i += dim) {\n const x = data[i];\n const y = data[i + 1];\n if (x < minX) minX = x;\n if (y < minY) minY = y;\n if (x > maxX) maxX = x;\n if (y > maxY) maxY = y;\n }\n\n // minX, minY and invSize are later used to transform coords into integers for z-order calculation\n invSize = Math.max(maxX - minX, maxY - minY);\n invSize = invSize !== 0 ? 32767 / invSize : 0;\n }\n\n earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);\n\n return triangles;\n}\n\n// create a circular doubly linked list from polygon points in the specified winding order\nfunction linkedList(data, start, end, dim, clockwise) {\n let last;\n\n if (clockwise === (signedArea(data, start, end, dim) > 0)) {\n for (let i = start; i < end; i += dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);\n } else {\n for (let i = end - dim; i >= start; i -= dim) last = insertNode(i / dim | 0, data[i], data[i + 1], last);\n }\n\n if (last && equals(last, last.next)) {\n removeNode(last);\n last = last.next;\n }\n\n return last;\n}\n\n// eliminate colinear or duplicate points\nfunction filterPoints(start, end) {\n if (!start) return start;\n if (!end) end = start;\n\n let p = start,\n again;\n do {\n again = false;\n\n if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {\n removeNode(p);\n p = end = p.prev;\n if (p === p.next) break;\n again = true;\n\n } else {\n p = p.next;\n }\n } while (again || p !== end);\n\n return end;\n}\n\n// main ear slicing loop which triangulates a polygon (given as a linked list)\nfunction earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {\n if (!ear) return;\n\n // interlink polygon nodes in z-order\n if (!pass && invSize) indexCurve(ear, minX, minY, invSize);\n\n let stop = ear;\n\n // iterate through ears, slicing them one by one\n while (ear.prev !== ear.next) {\n const prev = ear.prev;\n const next = ear.next;\n\n if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {\n triangles.push(prev.i, ear.i, next.i); // cut off the triangle\n\n removeNode(ear);\n\n // skipping the next vertex leads to less sliver triangles\n ear = next.next;\n stop = next.next;\n\n continue;\n }\n\n ear = next;\n\n // if we looped through the whole remaining polygon and can't find any more ears\n if (ear === stop) {\n // try filtering points and slicing again\n if (!pass) {\n earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);\n\n // if this didn't work, try curing all small self-intersections locally\n } else if (pass === 1) {\n ear = cureLocalIntersections(filterPoints(ear), triangles);\n earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);\n\n // as a last resort, try splitting the remaining polygon into two\n } else if (pass === 2) {\n splitEarcut(ear, triangles, dim, minX, minY, invSize);\n }\n\n break;\n }\n }\n}\n\n// check whether a polygon node forms a valid ear with adjacent nodes\nfunction isEar(ear) {\n const a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n // now make sure we don't have other points inside the potential ear\n const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox\n const x0 = Math.min(ax, bx, cx),\n y0 = Math.min(ay, by, cy),\n x1 = Math.max(ax, bx, cx),\n y1 = Math.max(ay, by, cy);\n\n let p = c.next;\n while (p !== a) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&\n pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) &&\n area(p.prev, p, p.next) >= 0) return false;\n p = p.next;\n }\n\n return true;\n}\n\nfunction isEarHashed(ear, minX, minY, invSize) {\n const a = ear.prev,\n b = ear,\n c = ear.next;\n\n if (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\n const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;\n\n // triangle bbox\n const x0 = Math.min(ax, bx, cx),\n y0 = Math.min(ay, by, cy),\n x1 = Math.max(ax, bx, cx),\n y1 = Math.max(ay, by, cy);\n\n // z-order range for the current triangle bbox;\n const minZ = zOrder(x0, y0, minX, minY, invSize),\n maxZ = zOrder(x1, y1, minX, minY, invSize);\n\n let p = ear.prevZ,\n n = ear.nextZ;\n\n // look for points inside the triangle in both directions\n while (p && p.z >= minZ && n && n.z <= maxZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n // look for remaining points in decreasing z-order\n while (p && p.z >= minZ) {\n if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&\n pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n p = p.prevZ;\n }\n\n // look for remaining points in increasing z-order\n while (n && n.z <= maxZ) {\n if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&\n pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n n = n.nextZ;\n }\n\n return true;\n}\n\n// go through all polygon nodes and cure small local self-intersections\nfunction cureLocalIntersections(start, triangles) {\n let p = start;\n do {\n const a = p.prev,\n b = p.next.next;\n\n if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {\n\n triangles.push(a.i, p.i, b.i);\n\n // remove two nodes involved\n removeNode(p);\n removeNode(p.next);\n\n p = start = b;\n }\n p = p.next;\n } while (p !== start);\n\n return filterPoints(p);\n}\n\n// try splitting polygon into two and triangulate them independently\nfunction splitEarcut(start, triangles, dim, minX, minY, invSize) {\n // look for a valid diagonal that divides the polygon into two\n let a = start;\n do {\n let b = a.next.next;\n while (b !== a.prev) {\n if (a.i !== b.i && isValidDiagonal(a, b)) {\n // split the polygon in two by the diagonal\n let c = splitPolygon(a, b);\n\n // filter colinear points around the cuts\n a = filterPoints(a, a.next);\n c = filterPoints(c, c.next);\n\n // run earcut on each half\n earcutLinked(a, triangles, dim, minX, minY, invSize, 0);\n earcutLinked(c, triangles, dim, minX, minY, invSize, 0);\n return;\n }\n b = b.next;\n }\n a = a.next;\n } while (a !== start);\n}\n\n// link every hole into the outer loop, producing a single-ring polygon without holes\nfunction eliminateHoles(data, holeIndices, outerNode, dim) {\n const queue = [];\n\n for (let i = 0, len = holeIndices.length; i < len; i++) {\n const start = holeIndices[i] * dim;\n const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n const list = linkedList(data, start, end, dim, false);\n if (list === list.next) list.steiner = true;\n queue.push(getLeftmost(list));\n }\n\n queue.sort(compareXYSlope);\n\n // process holes from left to right\n for (let i = 0; i < queue.length; i++) {\n outerNode = eliminateHole(queue[i], outerNode);\n }\n\n return outerNode;\n}\n\nfunction compareXYSlope(a, b) {\n let result = a.x - b.x;\n // when the left-most point of 2 holes meet at a vertex, sort the holes counterclockwise so that when we find\n // the bridge to the outer shell is always the point that they meet at.\n if (result === 0) {\n result = a.y - b.y;\n if (result === 0) {\n const aSlope = (a.next.y - a.y) / (a.next.x - a.x);\n const bSlope = (b.next.y - b.y) / (b.next.x - b.x);\n result = aSlope - bSlope;\n }\n }\n return result;\n}\n\n// find a bridge between vertices that connects hole with an outer ring and link it\nfunction eliminateHole(hole, outerNode) {\n const bridge = findHoleBridge(hole, outerNode);\n if (!bridge) {\n return outerNode;\n }\n\n const bridgeReverse = splitPolygon(bridge, hole);\n\n // filter collinear points around the cuts\n filterPoints(bridgeReverse, bridgeReverse.next);\n return filterPoints(bridge, bridge.next);\n}\n\n// David Eberly's algorithm for finding a bridge between hole and outer polygon\nfunction findHoleBridge(hole, outerNode) {\n let p = outerNode;\n const hx = hole.x;\n const hy = hole.y;\n let qx = -Infinity;\n let m;\n\n // find a segment intersected by a ray from the hole's leftmost point to the left;\n // segment's endpoint with lesser x will be potential connection point\n // unless they intersect at a vertex, then choose the vertex\n if (equals(hole, p)) return p;\n do {\n if (equals(hole, p.next)) return p.next;\n else if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {\n const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);\n if (x <= hx && x > qx) {\n qx = x;\n m = p.x < p.next.x ? p : p.next;\n if (x === hx) return m; // hole touches outer segment; pick leftmost endpoint\n }\n }\n p = p.next;\n } while (p !== outerNode);\n\n if (!m) return null;\n\n // look for points inside the triangle of hole point, segment intersection and endpoint;\n // if there are no points found, we have a valid connection;\n // otherwise choose the point of the minimum angle with the ray as connection point\n\n const stop = m;\n const mx = m.x;\n const my = m.y;\n let tanMin = Infinity;\n\n p = m;\n\n do {\n if (hx >= p.x && p.x >= mx && hx !== p.x &&\n pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {\n\n const tan = Math.abs(hy - p.y) / (hx - p.x); // tangential\n\n if (locallyInside(p, hole) &&\n (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {\n m = p;\n tanMin = tan;\n }\n }\n\n p = p.next;\n } while (p !== stop);\n\n return m;\n}\n\n// whether sector in vertex m contains sector in vertex p in the same coordinates\nfunction sectorContainsSector(m, p) {\n return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;\n}\n\n// interlink polygon nodes in z-order\nfunction indexCurve(start, minX, minY, invSize) {\n let p = start;\n do {\n if (p.z === 0) p.z = zOrder(p.x, p.y, minX, minY, invSize);\n p.prevZ = p.prev;\n p.nextZ = p.next;\n p = p.next;\n } while (p !== start);\n\n p.prevZ.nextZ = null;\n p.prevZ = null;\n\n sortLinked(p);\n}\n\n// Simon Tatham's linked list merge sort algorithm\n// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html\nfunction sortLinked(list) {\n let numMerges;\n let inSize = 1;\n\n do {\n let p = list;\n let e;\n list = null;\n let tail = null;\n numMerges = 0;\n\n while (p) {\n numMerges++;\n let q = p;\n let pSize = 0;\n for (let i = 0; i < inSize; i++) {\n pSize++;\n q = q.nextZ;\n if (!q) break;\n }\n let qSize = inSize;\n\n while (pSize > 0 || (qSize > 0 && q)) {\n\n if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {\n e = p;\n p = p.nextZ;\n pSize--;\n } else {\n e = q;\n q = q.nextZ;\n qSize--;\n }\n\n if (tail) tail.nextZ = e;\n else list = e;\n\n e.prevZ = tail;\n tail = e;\n }\n\n p = q;\n }\n\n tail.nextZ = null;\n inSize *= 2;\n\n } while (numMerges > 1);\n\n return list;\n}\n\n// z-order of a point given coords and inverse of the longer side of data bbox\nfunction zOrder(x, y, minX, minY, invSize) {\n // coords are transformed into non-negative 15-bit integer range\n x = (x - minX) * invSize | 0;\n y = (y - minY) * invSize | 0;\n\n x = (x | (x << 8)) & 0x00FF00FF;\n x = (x | (x << 4)) & 0x0F0F0F0F;\n x = (x | (x << 2)) & 0x33333333;\n x = (x | (x << 1)) & 0x55555555;\n\n y = (y | (y << 8)) & 0x00FF00FF;\n y = (y | (y << 4)) & 0x0F0F0F0F;\n y = (y | (y << 2)) & 0x33333333;\n y = (y | (y << 1)) & 0x55555555;\n\n return x | (y << 1);\n}\n\n// find the leftmost node of a polygon ring\nfunction getLeftmost(start) {\n let p = start,\n leftmost = start;\n do {\n if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;\n p = p.next;\n } while (p !== start);\n\n return leftmost;\n}\n\n// check if a point lies within a convex triangle\nfunction pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {\n return (cx - px) * (ay - py) >= (ax - px) * (cy - py) &&\n (ax - px) * (by - py) >= (bx - px) * (ay - py) &&\n (bx - px) * (cy - py) >= (cx - px) * (by - py);\n}\n\n// check if a point lies within a convex triangle but false if its equal to the first point of the triangle\nfunction pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, px, py) {\n return !(ax === px && ay === py) && pointInTriangle(ax, ay, bx, by, cx, cy, px, py);\n}\n\n// check if a diagonal between two polygon nodes is valid (lies in polygon interior)\nfunction isValidDiagonal(a, b) {\n return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // doesn't intersect other edges\n (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible\n (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors\n equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case\n}\n\n// signed area of a triangle\nfunction area(p, q, r) {\n return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);\n}\n\n// check if two points are equal\nfunction equals(p1, p2) {\n return p1.x === p2.x && p1.y === p2.y;\n}\n\n// check if two segments intersect\nfunction intersects(p1, q1, p2, q2) {\n const o1 = sign(area(p1, q1, p2));\n const o2 = sign(area(p1, q1, q2));\n const o3 = sign(area(p2, q2, p1));\n const o4 = sign(area(p2, q2, q1));\n\n if (o1 !== o2 && o3 !== o4) return true; // general case\n\n if (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1\n if (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1\n if (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2\n if (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2\n\n return false;\n}\n\n// for collinear points p, q, r, check if point q lies on segment pr\nfunction onSegment(p, q, r) {\n return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);\n}\n\nfunction sign(num) {\n return num > 0 ? 1 : num < 0 ? -1 : 0;\n}\n\n// check if a polygon diagonal intersects any polygon segments\nfunction intersectsPolygon(a, b) {\n let p = a;\n do {\n if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&\n intersects(p, p.next, a, b)) return true;\n p = p.next;\n } while (p !== a);\n\n return false;\n}\n\n// check if a polygon diagonal is locally inside the polygon\nfunction locallyInside(a, b) {\n return area(a.prev, a, a.next) < 0 ?\n area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :\n area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;\n}\n\n// check if the middle point of a polygon diagonal is inside the polygon\nfunction middleInside(a, b) {\n let p = a;\n let inside = false;\n const px = (a.x + b.x) / 2;\n const py = (a.y + b.y) / 2;\n do {\n if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&\n (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))\n inside = !inside;\n p = p.next;\n } while (p !== a);\n\n return inside;\n}\n\n// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;\n// if one belongs to the outer ring and another to a hole, it merges it into a single ring\nfunction splitPolygon(a, b) {\n const a2 = createNode(a.i, a.x, a.y),\n b2 = createNode(b.i, b.x, b.y),\n an = a.next,\n bp = b.prev;\n\n a.next = b;\n b.prev = a;\n\n a2.next = an;\n an.prev = a2;\n\n b2.next = a2;\n a2.prev = b2;\n\n bp.next = b2;\n b2.prev = bp;\n\n return b2;\n}\n\n// create a node and optionally link it with previous one (in a circular doubly linked list)\nfunction insertNode(i, x, y, last) {\n const p = createNode(i, x, y);\n\n if (!last) {\n p.prev = p;\n p.next = p;\n\n } else {\n p.next = last.next;\n p.prev = last;\n last.next.prev = p;\n last.next = p;\n }\n return p;\n}\n\nfunction removeNode(p) {\n p.next.prev = p.prev;\n p.prev.next = p.next;\n\n if (p.prevZ) p.prevZ.nextZ = p.nextZ;\n if (p.nextZ) p.nextZ.prevZ = p.prevZ;\n}\n\nfunction createNode(i, x, y) {\n return {\n i, // vertex index in coordinates array\n x, y, // vertex coordinates\n prev: null, // previous and next vertex nodes in a polygon ring\n next: null,\n z: 0, // z-order curve value\n prevZ: null, // previous and next nodes in z-order\n nextZ: null,\n steiner: false // indicates whether this is a steiner point\n };\n}\n\n// return a percentage difference between the polygon area and its triangulation area;\n// used to verify correctness of triangulation\nexport function deviation(data, holeIndices, dim, triangles) {\n const hasHoles = holeIndices && holeIndices.length;\n const outerLen = hasHoles ? holeIndices[0] * dim : data.length;\n\n let polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));\n if (hasHoles) {\n for (let i = 0, len = holeIndices.length; i < len; i++) {\n const start = holeIndices[i] * dim;\n const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n polygonArea -= Math.abs(signedArea(data, start, end, dim));\n }\n }\n\n let trianglesArea = 0;\n for (let i = 0; i < triangles.length; i += 3) {\n const a = triangles[i] * dim;\n const b = triangles[i + 1] * dim;\n const c = triangles[i + 2] * dim;\n trianglesArea += Math.abs(\n (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -\n (data[a] - data[b]) * (data[c + 1] - data[a + 1]));\n }\n\n return polygonArea === 0 && trianglesArea === 0 ? 0 :\n Math.abs((trianglesArea - polygonArea) / polygonArea);\n}\n\nfunction signedArea(data, start, end, dim) {\n let sum = 0;\n for (let i = start, j = end - dim; i < end; i += dim) {\n sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);\n j = i;\n }\n return sum;\n}\n\n// turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts\nexport function flatten(data) {\n const vertices = [];\n const holes = [];\n const dimensions = data[0][0].length;\n let holeIndex = 0;\n let prevLen = 0;\n\n for (const ring of data) {\n for (const p of ring) {\n for (let d = 0; d < dimensions; d++) vertices.push(p[d]);\n }\n if (prevLen) {\n holeIndex += prevLen;\n holes.push(holeIndex);\n }\n prevLen = ring.length;\n }\n return {vertices, holes, dimensions};\n}\n","// Should match actual possible granularity settings from circle_bucket.ts\n\n/**\n * Defines the granularity of subdivision for circles with `circle-pitch-alignment: 'map'` and for heatmap kernels.\n * More subdivision will cause circles to more closely follow the planet's surface.\n *\n * Possible values: 1, 3, 5, 7.\n * Subdivision of 1 results in a simple quad.\n */\nexport type CircleGranularity = 1 | 3 | 5 | 7;\n\n/**\n * Controls how much subdivision happens for a given type of geometry at different zoom levels.\n */\nexport class SubdivisionGranularityExpression {\n /**\n * A tile of zoom level 0 will be subdivided to this granularity level.\n * Each subsequent zoom level will have its granularity halved.\n */\n private readonly _baseZoomGranularity: number;\n\n /**\n * No tile will have granularity level smaller than this.\n */\n private readonly _minGranularity: number;\n\n constructor(baseZoomGranularity: number, minGranularity: number) {\n if (minGranularity > baseZoomGranularity) {\n throw new Error('Min granularity must not be greater than base granularity.');\n }\n\n this._baseZoomGranularity = baseZoomGranularity;\n this._minGranularity = minGranularity;\n }\n\n public getGranularityForZoomLevel(zoomLevel: number): number {\n const divisor = 1 << zoomLevel;\n return Math.max(Math.floor(this._baseZoomGranularity / divisor), this._minGranularity, 1);\n }\n}\n\n/**\n * An object describing how much subdivision should be applied to different types of geometry at different zoom levels.\n */\nexport class SubdivisionGranularitySetting {\n /**\n * Granularity settings used for fill and fill-extrusion layers (for fill, both polygons and their anti-aliasing outlines).\n */\n public readonly fill: SubdivisionGranularityExpression;\n\n /**\n * Granularity used for the line layer.\n */\n public readonly line: SubdivisionGranularityExpression;\n\n /**\n * Granularity used for geometry covering the entire tile: raster tiles, etc.\n */\n public readonly tile: SubdivisionGranularityExpression;\n\n /**\n * Granularity used for stencil masks for tiles.\n */\n public readonly stencil: SubdivisionGranularityExpression;\n\n /**\n * Controls the granularity of `pitch-alignment: map` circles and heatmap kernels.\n * More granular circles will more closely follow the map's surface.\n */\n public readonly circle: CircleGranularity;\n\n constructor(options: {\n /**\n * Granularity settings used for fill and fill-extrusion layers (for fill, both polygons and their anti-aliasing outlines).\n */\n fill: SubdivisionGranularityExpression;\n /**\n * Granularity used for the line layer.\n */\n line: SubdivisionGranularityExpression;\n /**\n * Granularity used for geometry covering the entire tile: stencil masks, raster tiles, etc.\n */\n tile: SubdivisionGranularityExpression;\n /**\n * Granularity used for stencil masks for tiles.\n */\n stencil: SubdivisionGranularityExpression;\n /**\n * Controls the granularity of `pitch-alignment: map` circles and heatmap kernels.\n * More granular circles will more closely follow the map's surface.\n */\n circle: CircleGranularity;\n }) {\n this.fill = options.fill;\n this.line = options.line;\n this.tile = options.tile;\n this.stencil = options.stencil;\n this.circle = options.circle;\n }\n\n /**\n * Granularity settings that disable subdivision altogether.\n */\n public static readonly noSubdivision = new SubdivisionGranularitySetting({\n fill: new SubdivisionGranularityExpression(0, 0),\n line: new SubdivisionGranularityExpression(0, 0),\n tile: new SubdivisionGranularityExpression(0, 0),\n stencil: new SubdivisionGranularityExpression(0, 0),\n circle: 1\n });\n}\n","/*\nThis file was copied from https://github.com/mapbox/grid-index and was\nmigrated from JavaScript to TypeScript.\n\nCopyright (c) 2016, Mapbox\n\nPermission to use, copy, modify, and/or distribute this software for any purpose\nwith or without fee is hereby granted, provided that the above copyright notice\nand this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\nOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\nTORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF\nTHIS SOFTWARE.\n*/\n\nconst NUM_PARAMS = 3;\n\nexport type SerializedGrid = {\n buffer: ArrayBuffer;\n};\n\nexport class TransferableGridIndex {\n cells: number[][];\n arrayBuffer: ArrayBuffer;\n d: number;\n keys: number[];\n bboxes: number[];\n n: number;\n extent: number;\n padding: number;\n scale: any;\n uid: number;\n min: number;\n max: number;\n\n constructor(extent: number | ArrayBuffer, n?: number, padding?: number) {\n const cells = this.cells = [];\n\n if (extent instanceof ArrayBuffer) {\n this.arrayBuffer = extent;\n const array = new Int32Array(this.arrayBuffer);\n extent = array[0];\n n = array[1];\n padding = array[2];\n\n this.d = n + 2 * padding;\n for (let k = 0; k < this.d * this.d; k++) {\n const start = array[NUM_PARAMS + k];\n const end = array[NUM_PARAMS + k + 1];\n cells.push(start === end ? null : array.subarray(start, end));\n }\n const keysOffset = array[NUM_PARAMS + cells.length];\n const bboxesOffset = array[NUM_PARAMS + cells.length + 1];\n this.keys = array.subarray(keysOffset, bboxesOffset) as any as number[];\n this.bboxes = array.subarray(bboxesOffset) as any as number[];\n\n this.insert = this._insertReadonly;\n\n } else {\n this.d = n + 2 * padding;\n for (let i = 0; i < this.d * this.d; i++) {\n cells.push([]);\n }\n this.keys = [];\n this.bboxes = [];\n }\n\n this.n = n;\n this.extent = extent;\n this.padding = padding;\n this.scale = n / extent;\n this.uid = 0;\n\n const p = (padding / n) * extent;\n this.min = -p;\n this.max = extent + p;\n }\n\n insert(key: number, x1: number, y1: number, x2: number, y2: number) {\n this._forEachCell(x1, y1, x2, y2, this._insertCell, this.uid++, undefined, undefined);\n this.keys.push(key);\n this.bboxes.push(x1);\n this.bboxes.push(y1);\n this.bboxes.push(x2);\n this.bboxes.push(y2);\n }\n\n _insertReadonly() {\n throw new Error('Cannot insert into a GridIndex created from an ArrayBuffer.');\n }\n\n _insertCell(x1: number, y1: number, x2: number, y2: number, cellIndex: number, uid: number) {\n this.cells[cellIndex].push(uid);\n }\n\n query(x1: number, y1: number, x2: number, y2: number, intersectionTest?: Function): number[] {\n const min = this.min;\n const max = this.max;\n if (x1 <= min && y1 <= min && max <= x2 && max <= y2 && !intersectionTest) {\n // We use `Array.slice` because `this.keys` may be a `Int32Array` and\n // some browsers (Safari and IE) do not support `TypedArray.slice`\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/slice#Browser_compatibility\n return Array.prototype.slice.call(this.keys);\n\n } else {\n const result = [];\n const seenUids = {};\n this._forEachCell(x1, y1, x2, y2, this._queryCell, result, seenUids, intersectionTest);\n return result;\n }\n }\n\n _queryCell(x1: number, y1: number, x2: number, y2:number, cellIndex:number, result, seenUids, intersectionTest: Function) {\n const cell = this.cells[cellIndex];\n if (cell !== null) {\n const keys = this.keys;\n const bboxes = this.bboxes;\n for (let u = 0; u < cell.length; u++) {\n const uid = cell[u];\n if (seenUids[uid] === undefined) {\n const offset = uid * 4;\n if (intersectionTest ?\n intersectionTest(bboxes[offset + 0], bboxes[offset + 1], bboxes[offset + 2], bboxes[offset + 3]) :\n ((x1 <= bboxes[offset + 2]) &&\n (y1 <= bboxes[offset + 3]) &&\n (x2 >= bboxes[offset + 0]) &&\n (y2 >= bboxes[offset + 1]))) {\n seenUids[uid] = true;\n result.push(keys[uid]);\n } else {\n seenUids[uid] = false;\n }\n }\n }\n }\n }\n\n _forEachCell(x1: number, y1: number, x2:number, y2:number, fn: Function, arg1, arg2, intersectionTest) {\n const cx1 = this._convertToCellCoord(x1);\n const cy1 = this._convertToCellCoord(y1);\n const cx2 = this._convertToCellCoord(x2);\n const cy2 = this._convertToCellCoord(y2);\n for (let x = cx1; x <= cx2; x++) {\n for (let y = cy1; y <= cy2; y++) {\n const cellIndex = this.d * y + x;\n if (intersectionTest && !intersectionTest(\n this._convertFromCellCoord(x),\n this._convertFromCellCoord(y),\n this._convertFromCellCoord(x + 1),\n this._convertFromCellCoord(y + 1))) continue;\n if (fn.call(this, x1, y1, x2, y2, cellIndex, arg1, arg2, intersectionTest)) return;\n }\n }\n }\n\n _convertFromCellCoord (x) {\n return (x - this.padding) / this.scale;\n }\n\n _convertToCellCoord(x) {\n return Math.max(0, Math.min(this.d - 1, Math.floor(x * this.scale) + this.padding));\n }\n\n toArrayBuffer(): ArrayBuffer {\n if (this.arrayBuffer) return this.arrayBuffer;\n\n const cells = this.cells;\n\n const metadataLength = NUM_PARAMS + this.cells.length + 1 + 1;\n let totalCellLength = 0;\n for (let i = 0; i < this.cells.length; i++) {\n totalCellLength += this.cells[i].length;\n }\n\n const array = new Int32Array(metadataLength + totalCellLength + this.keys.length + this.bboxes.length);\n array[0] = this.extent;\n array[1] = this.n;\n array[2] = this.padding;\n\n let offset = metadataLength;\n for (let k = 0; k < cells.length; k++) {\n const cell = cells[k];\n array[NUM_PARAMS + k] = offset;\n array.set(cell, offset);\n offset += cell.length;\n }\n\n array[NUM_PARAMS + cells.length] = offset;\n array.set(this.keys, offset);\n offset += this.keys.length;\n\n array[NUM_PARAMS + cells.length + 1] = offset;\n array.set(this.bboxes, offset);\n offset += this.bboxes.length;\n\n return array.buffer;\n }\n\n public static serialize(grid: TransferableGridIndex, transferables?: Array<Transferable>): SerializedGrid {\n const buffer = grid.toArrayBuffer();\n if (transferables) {\n transferables.push(buffer);\n }\n return {buffer};\n }\n\n public static deserialize(serialized: SerializedGrid): TransferableGridIndex {\n return new TransferableGridIndex(serialized.buffer);\n }\n}\n","'use strict';\n\nmodule.exports = UnitBezier;\n\nfunction UnitBezier(p1x, p1y, p2x, p2y) {\n // Calculate the polynomial coefficients, implicit first and last control points are (0,0) and (1,1).\n this.cx = 3.0 * p1x;\n this.bx = 3.0 * (p2x - p1x) - this.cx;\n this.ax = 1.0 - this.cx - this.bx;\n\n this.cy = 3.0 * p1y;\n this.by = 3.0 * (p2y - p1y) - this.cy;\n this.ay = 1.0 - this.cy - this.by;\n\n this.p1x = p1x;\n this.p1y = p1y;\n this.p2x = p2x;\n this.p2y = p2y;\n}\n\nUnitBezier.prototype = {\n sampleCurveX: function (t) {\n // `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.\n return ((this.ax * t + this.bx) * t + this.cx) * t;\n },\n\n sampleCurveY: function (t) {\n return ((this.ay * t + this.by) * t + this.cy) * t;\n },\n\n sampleCurveDerivativeX: function (t) {\n return (3.0 * this.ax * t + 2.0 * this.bx) * t + this.cx;\n },\n\n solveCurveX: function (x, epsilon) {\n if (epsilon === undefined) epsilon = 1e-6;\n\n if (x < 0.0) return 0.0;\n if (x > 1.0) return 1.0;\n\n var t = x;\n\n // First try a few iterations of Newton's method - normally very fast.\n for (var i = 0; i < 8; i++) {\n var x2 = this.sampleCurveX(t) - x;\n if (Math.abs(x2) < epsilon) return t;\n\n var d2 = this.sampleCurveDerivativeX(t);\n if (Math.abs(d2) < 1e-6) break;\n\n t = t - x2 / d2;\n }\n\n // Fall back to the bisection method for reliability.\n var t0 = 0.0;\n var t1 = 1.0;\n t = x;\n\n for (i = 0; i < 20; i++) {\n x2 = this.sampleCurveX(t);\n if (Math.abs(x2 - x) < epsilon) break;\n\n if (x > x2) {\n t0 = t;\n } else {\n t1 = t;\n }\n\n t = (t1 - t0) * 0.5 + t0;\n }\n\n return t;\n },\n\n solve: function (x, epsilon) {\n return this.sampleCurveY(this.solveCurveX(x, epsilon));\n }\n};\n","import Point from '@mapbox/point-geometry';\nimport UnitBezier from '@mapbox/unitbezier';\nimport {isOffscreenCanvasDistorted} from './offscreen_canvas_distorted';\nimport type {Size} from './image';\nimport type {WorkerGlobalScopeInterface} from './web_worker';\nimport {mat3, mat4, quat, vec2, vec3, type vec4} from 'gl-matrix';\nimport {pixelsToTileUnits} from '../source/pixels_to_tile_units';\nimport {type OverscaledTileID} from '../tile/tile_id';\nimport type {Event} from './evented';\n\n/**\n * Returns a new 64 bit float vec4 of zeroes.\n */\nexport function createVec4f64(): vec4 { return new Float64Array(4) as any; }\n/**\n * Returns a new 64 bit float vec3 of zeroes.\n */\nexport function createVec3f64(): vec3 { return new Float64Array(3) as any; }\n/**\n * Returns a new 64 bit float mat4 of zeroes.\n */\nexport function createMat4f64(): mat4 { return new Float64Array(16) as any; }\n/**\n * Returns a new 32 bit float mat4 of zeroes.\n */\nexport function createMat4f32(): mat4 { return new Float32Array(16) as any; }\n/**\n * Returns a new 64 bit float mat4 set to identity.\n */\nexport function createIdentityMat4f64(): mat4 {\n const m = new Float64Array(16) as any;\n mat4.identity(m);\n return m;\n}\n/**\n * Returns a new 32 bit float mat4 set to identity.\n */\nexport function createIdentityMat4f32(): mat4 {\n const m = new Float32Array(16) as any;\n mat4.identity(m);\n return m;\n}\n\n/**\n * Returns a translation in tile units that correctly incorporates the view angle and the *-translate and *-translate-anchor properties.\n * @param inViewportPixelUnitsUnits - True when the units accepted by the matrix are in viewport pixels instead of tile units.\n */\nexport function translatePosition(\n transform: { bearingInRadians: number; zoom: number },\n tile: { tileID: OverscaledTileID; tileSize: number },\n translate: [number, number],\n translateAnchor: 'map' | 'viewport',\n inViewportPixelUnitsUnits: boolean = false\n): [number, number] {\n if (!translate[0] && !translate[1]) return [0, 0];\n\n const angle = inViewportPixelUnitsUnits ?\n (translateAnchor === 'map' ? -transform.bearingInRadians : 0) :\n (translateAnchor === 'viewport' ? transform.bearingInRadians : 0);\n\n if (angle) {\n const sinA = Math.sin(angle);\n const cosA = Math.cos(angle);\n translate = [\n translate[0] * cosA - translate[1] * sinA,\n translate[0] * sinA + translate[1] * cosA\n ];\n }\n\n return [\n inViewportPixelUnitsUnits ? translate[0] : pixelsToTileUnits(tile, translate[0], transform.zoom),\n inViewportPixelUnitsUnits ? translate[1] : pixelsToTileUnits(tile, translate[1], transform.zoom)];\n}\n\n/**\n * Returns the signed distance between a point and a plane.\n * @param plane - The plane equation, in the form where the first three components are the normal and the fourth component is the plane's distance from origin along normal.\n * @param point - The point whose distance from plane is returned.\n * @returns Signed distance of the point from the plane. Positive distances are in the half space where the plane normal points to, negative otherwise.\n */\nexport function pointPlaneSignedDistance(\n plane: vec4 | [number, number, number, number],\n point: vec3 | [number, number, number]\n): number {\n return plane[0] * point[0] + plane[1] * point[1] + plane[2] * point[2] + plane[3];\n}\n\n/**\n * Finds an intersection points of three planes. Returns `null` if no such (single) point exists.\n * The planes *must* be in Hessian normal form - their xyz components must form a unit vector.\n */\nexport function threePlaneIntersection(plane0: vec4, plane1: vec4, plane2: vec4): vec3 | null {\n // https://mathworld.wolfram.com/Plane-PlaneIntersection.html\n const det = mat3.determinant([\n plane0[0], plane0[1], plane0[2],\n plane1[0], plane1[1], plane1[2],\n plane2[0], plane2[1], plane2[2]\n ] as mat3);\n if (det === 0) {\n return null;\n }\n const cross12 = vec3.cross([] as any, [plane1[0], plane1[1], plane1[2]], [plane2[0], plane2[1], plane2[2]]);\n const cross20 = vec3.cross([] as any, [plane2[0], plane2[1], plane2[2]], [plane0[0], plane0[1], plane0[2]]);\n const cross01 = vec3.cross([] as any, [plane0[0], plane0[1], plane0[2]], [plane1[0], plane1[1], plane1[2]]);\n const sum = vec3.scale([] as any, cross12, -plane0[3]);\n vec3.add(sum, sum, vec3.scale([] as any, cross20, -plane1[3]));\n vec3.add(sum, sum, vec3.scale([] as any, cross01, -plane2[3]));\n vec3.scale(sum, sum, 1.0 / det);\n return sum;\n}\n\n/**\n * Returns a parameter `t` such that the point obtained by\n * `origin + direction * t` lies on the given plane.\n * If the ray is parallel to the plane, returns null.\n * Returns a negative value if the ray is pointing away from the plane.\n * Direction does not need to be normalized.\n */\nexport function rayPlaneIntersection(origin: vec3, direction: vec3, plane: vec4): number | null {\n const dotOriginPlane = origin[0] * plane[0] + origin[1] * plane[1] + origin[2] * plane[2];\n const dotDirectionPlane = direction[0] * plane[0] + direction[1] * plane[1] + direction[2] * plane[2];\n if (dotDirectionPlane === 0) {\n return null;\n }\n return (-dotOriginPlane -plane[3]) / dotDirectionPlane;\n}\n\n/**\n * Solves a quadratic equation in the form ax^2 + bx + c = 0 and returns its roots in no particular order.\n * Returns null if the equation has no roots or if it has infinitely many roots.\n */\nexport function solveQuadratic(a: number, b: number, c: number): {\n t0: number;\n t1: number;\n} {\n const d = b * b - 4 * a * c;\n if (d < 0 || (a === 0 && b === 0)) {\n return null;\n }\n\n // Uses a more precise solution from the book Ray Tracing Gems, chapter 7.\n // https://www.realtimerendering.com/raytracinggems/rtg/index.html\n const q = -0.5 * (b + Math.sign(b) * Math.sqrt(d));\n if (Math.abs(q) > 1e-12) {\n return {\n t0: c / q,\n t1: q / a\n };\n } else {\n // Use the schoolbook way if q is too small\n return {\n t0: (-b + Math.sqrt(d)) * 0.5 / a,\n t1: (-b + Math.sqrt(d)) * 0.5 / a\n };\n }\n}\n\n/**\n * Returns the angle in radians between two 2D vectors.\n * The angle is signed and describes how much the first vector would need to be be rotated clockwise\n * (assuming X is right and Y is down) so that it points in the same direction as the second vector.\n * @param vec1x - The X component of the first vector.\n * @param vec1y - The Y component of the first vector.\n * @param vec2x - The X component of the second vector.\n * @param vec2y - The Y component of the second vector.\n * @returns The signed angle between the two vectors, in range -PI..PI.\n */\nexport function angleToRotateBetweenVectors2D(vec1x: number, vec1y: number, vec2x: number, vec2y: number): number {\n // Normalize both vectors\n const length1 = Math.sqrt(vec1x * vec1x + vec1y * vec1y);\n const length2 = Math.sqrt(vec2x * vec2x + vec2y * vec2y);\n vec1x /= length1;\n vec1y /= length1;\n vec2x /= length2;\n vec2y /= length2;\n const dot = vec1x * vec2x + vec1y * vec2y;\n const angle = Math.acos(dot);\n // dot second vector with vector to the right of first (-vec1y, vec1x)\n const isVec2RightOfVec1 = (-vec1y * vec2x + vec1x * vec2y) > 0;\n if (isVec2RightOfVec1) {\n return angle;\n } else {\n return -angle;\n }\n}\n\n/**\n * For two angles in degrees, returns how many degrees to add to the first angle in order to obtain the second angle.\n * The returned difference value is always the shorted of the two - its absolute value is never greater than 180°.\n */\nexport function differenceOfAnglesDegrees(degreesA: number, degreesB: number): number {\n const a = mod(degreesA, 360);\n const b = mod(degreesB, 360);\n const diff1 = b - a;\n const diff2 = (b > a) ? (diff1 - 360) : (diff1 + 360);\n if (Math.abs(diff1) < Math.abs(diff2)) {\n return diff1;\n } else {\n return diff2;\n }\n}\n\n/**\n * For two angles in radians, returns how many radians to add to the first angle in order to obtain the second angle.\n * The returned difference value is always the shorted of the two - its absolute value is never greater than PI.\n */\nexport function differenceOfAnglesRadians(degreesA: number, degreesB: number): number {\n const a = mod(degreesA, Math.PI * 2);\n const b = mod(degreesB, Math.PI * 2);\n const diff1 = b - a;\n const diff2 = (b > a) ? (diff1 - Math.PI * 2) : (diff1 + Math.PI * 2);\n if (Math.abs(diff1) < Math.abs(diff2)) {\n return diff1;\n } else {\n return diff2;\n }\n}\n\n/**\n * When given two angles in degrees, returns the angular distance between them - the shorter one of the two possible arcs.\n */\nexport function distanceOfAnglesDegrees(degreesA: number, degreesB: number): number {\n const a = mod(degreesA, 360);\n const b = mod(degreesB, 360);\n return Math.min(\n Math.abs(a - b),\n Math.abs(a - b + 360),\n Math.abs(a - b - 360)\n );\n}\n\n/**\n * When given two angles in radians, returns the angular distance between them - the shorter one of the two possible arcs.\n */\nexport function distanceOfAnglesRadians(radiansA: number, radiansB: number): number {\n const a = mod(radiansA, Math.PI * 2);\n const b = mod(radiansB, Math.PI * 2);\n return Math.min(\n Math.abs(a - b),\n Math.abs(a - b + Math.PI * 2),\n Math.abs(a - b - Math.PI * 2)\n );\n}\n\n/**\n * Modulo function, as opposed to javascript's `%`, which is a remainder.\n * This functions will return positive values, even if the first operand is negative.\n */\nexport function mod(n, m) {\n return ((n % m) + m) % m;\n}\n\n/**\n * Takes a value in *old range*, linearly maps that range to *new range*, and returns the value in that new range.\n * Additionally, if the value is outside *old range*, it is clamped inside it.\n * Also works if one of the ranges is flipped (its `min` being larger than `max`).\n */\nexport function remapSaturate(value: number, oldRangeMin: number, oldRangeMax: number, newRangeMin: number, newRangeMax: number): number {\n const inOldRange = clamp((value - oldRangeMin) / (oldRangeMax - oldRangeMin), 0.0, 1.0);\n return lerp(newRangeMin, newRangeMax, inOldRange);\n}\n\n/**\n * Linearly interpolate between two values, similar to `mix` function from GLSL. No clamping is done.\n * @param a - The first value to interpolate. This value is returned when mix=0.\n * @param b - The second value to interpolate. This value is returned when mix=1.\n * @param mix - The interpolation factor. Range 0..1 interpolates between `a` and `b`, but values outside this range are also accepted.\n */\nexport function lerp(a: number, b: number, mix: number): number {\n return a * (1.0 - mix) + b * mix;\n}\n\n/**\n * For a given collection of 2D points, returns their axis-aligned bounding box,\n * in the format [minX, minY, maxX, maxY].\n */\nexport function getAABB(points: Array<Point>): [number, number, number, number] {\n let tlX = Infinity;\n let tlY = Infinity;\n let brX = -Infinity;\n let brY = -Infinity;\n\n for (const p of points) {\n tlX = Math.min(tlX, p.x);\n tlY = Math.min(tlY, p.y);\n brX = Math.max(brX, p.x);\n brY = Math.max(brY, p.y);\n }\n\n return [tlX, tlY, brX, brY];\n}\n\n/**\n * For a given set of tile ids, returns the edge tile ids for the bounding box.\n */\nexport function getEdgeTiles(tileIDs: OverscaledTileID[]): Set<OverscaledTileID> {\n if (!tileIDs.length) return new Set<OverscaledTileID>();\n\n // set a common zoom for calculation (highest zoom) to reproject all tiles to this same zoom\n const targetZ = Math.max(...tileIDs.map(id => id.canonical.z));\n\n // vars to store the min and max tile x/y coordinates for edge finding\n let minX = Infinity, maxX = -Infinity;\n let minY = Infinity, maxY = -Infinity;\n\n // project all tiles to targetZ while maintaining the reference to the original tile\n const projected: {id: OverscaledTileID; x: number; y: number}[] = [];\n for (const id of tileIDs) {\n const {x, y, z} = id.canonical;\n const scale = Math.pow(2, targetZ - z);\n const px = x * scale;\n const py = y * scale;\n\n projected.push({id, x: px, y: py});\n\n if (px < minX) minX = px;\n if (px > maxX) maxX = px;\n if (py < minY) minY = py;\n if (py > maxY) maxY = py;\n }\n\n // find edge tiles using the reprojected tile ids\n const edgeTiles: Set<OverscaledTileID> = new Set<OverscaledTileID>();\n for (const p of projected) {\n if (p.x === minX || p.x === maxX || p.y === minY || p.y === maxY) {\n edgeTiles.add(p.id);\n }\n }\n\n return edgeTiles;\n}\n\n/**\n * Given a value `t` that varies between 0 and 1, return\n * an interpolation function that eases between 0 and 1 in a pleasing\n * cubic in-out fashion.\n */\nexport function easeCubicInOut(t: number): number {\n if (t <= 0) return 0;\n if (t >= 1) return 1;\n const t2 = t * t,\n t3 = t2 * t;\n return 4 * (t < 0.5 ? t3 : 3 * (t - t2) + t3 - 0.75);\n}\n\n/**\n * Given given (x, y), (x1, y1) control points for a bezier curve,\n * return a function that interpolates along that curve.\n *\n * @param p1x - control point 1 x coordinate\n * @param p1y - control point 1 y coordinate\n * @param p2x - control point 2 x coordinate\n * @param p2y - control point 2 y coordinate\n */\nexport function bezier(p1x: number, p1y: number, p2x: number, p2y: number): (t: number) => number {\n const bezier = new UnitBezier(p1x, p1y, p2x, p2y);\n return (t: number) => {\n return bezier.solve(t);\n };\n}\n\n/**\n * A default bezier-curve powered easing function with\n * control points (0.25, 0.1) and (0.25, 1)\n */\nexport const defaultEasing = bezier(0.25, 0.1, 0.25, 1);\n\n/**\n * constrain n to the given range via min + max\n *\n * @param n - value\n * @param min - the minimum value to be returned\n * @param max - the maximum value to be returned\n * @returns the clamped value\n */\nexport function clamp(n: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, n));\n}\n\n/**\n * constrain n to the given range, excluding the minimum, via modular arithmetic\n *\n * @param n - value\n * @param min - the minimum value to be returned, exclusive\n * @param max - the maximum value to be returned, inclusive\n * @returns constrained number\n */\nexport function wrap(n: number, min: number, max: number): number {\n const d = max - min;\n const w = ((n - min) % d + d) % d + min;\n return (w === min) ? max : w;\n}\n\n/**\n * Compute the difference between the keys in one object and the keys\n * in another object.\n *\n * @returns keys difference\n */\nexport function keysDifference<S, T>(\n obj: {[key: string]: S},\n other: {[key: string]: T}\n): Array<string> {\n const difference = [];\n for (const i in obj) {\n if (!(i in other)) {\n difference.push(i);\n }\n }\n return difference;\n}\n\n/**\n * Given a destination object and optionally many source objects,\n * copy all properties from the source objects into the destination.\n * The last source object given overrides properties from previous\n * source objects.\n *\n * @param dest - destination object\n * @param sources - sources from which properties are pulled\n */\nexport function extend<T extends {}, U>(dest: T, source: U): T & U;\nexport function extend<T extends {}, U, V>(dest: T, source1: U, source2: V): T & U & V;\nexport function extend<T extends {}, U, V, W>(dest: T, source1: U, source2: V, source3: W): T & U & V & W;\nexport function extend(dest: object, ...sources: Array<any>): any;\nexport function extend(dest: object, ...sources: Array<any>): any {\n for (const src of sources) {\n for (const k in src) {\n dest[k] = src[k];\n }\n }\n return dest;\n}\n\n// See https://stackoverflow.com/questions/49401866/all-possible-keys-of-an-union-type\ntype KeysOfUnion<T> = T extends T ? keyof T: never;\n\n/**\n * Given an object and a number of properties as strings, return version\n * of that object with only those properties.\n *\n * @param src - the object\n * @param properties - an array of property names chosen\n * to appear on the resulting object.\n * @returns object with limited properties.\n * @example\n * ```ts\n * let foo = { name: 'Charlie', age: 10 };\n * let justName = pick(foo, ['name']); // justName = { name: 'Charlie' }\n * ```\n */\nexport function pick<T extends object>(src: T, properties: Array<KeysOfUnion<T>>): Partial<T> {\n const result: Partial<T> = {};\n for (let i = 0; i < properties.length; i++) {\n const k = properties[i];\n if (k in src) {\n result[k] = src[k];\n }\n }\n return result;\n}\n\nlet id = 1;\n\n/**\n * Return a unique numeric id, starting at 1 and incrementing with\n * each call.\n *\n * @returns unique numeric id.\n */\nexport function uniqueId(): number {\n return id++;\n}\n\n/**\n * Return whether a given value is a power of two\n */\nexport function isPowerOfTwo(value: number): boolean {\n return (Math.log(value) / Math.LN2) % 1 === 0;\n}\n\n/**\n * Return the next power of two, or the input value if already a power of two\n */\nexport function nextPowerOfTwo(value: number): number {\n if (value <= 1) return 1;\n return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));\n}\n\n/**\n * Computes scaling from zoom level.\n */\nexport function zoomScale(zoom: number) { return Math.pow(2, zoom); }\n\n/**\n * Computes zoom level from scaling.\n */\nexport function scaleZoom(scale: number) { return Math.log(scale) / Math.LN2; }\n\n/**\n * Create an object by mapping all the values of an existing object while\n * preserving their keys.\n */\nexport function mapObject(input: any, iterator: Function, context?: any): any {\n const output = {};\n for (const key in input) {\n output[key] = iterator.call(context || this, input[key], key, input);\n }\n return output;\n}\n\n/**\n * Create an object by filtering out values of an existing object.\n */\nexport function filterObject(input: any, iterator: Function, context?: any): any {\n const output = {};\n for (const key in input) {\n if (iterator.call(context || this, input[key], key, input)) {\n output[key] = input[key];\n }\n }\n return output;\n}\n\n/**\n * Deeply compares two object literals.\n * @param a - first object literal to be compared\n * @param b - second object literal to be compared\n * @returns true if the two object literals are deeply equal, false otherwise\n */\nexport function deepEqual(a?: unknown | null, b?: unknown | null): boolean {\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false;\n }\n return true;\n }\n if (typeof a === 'object' && a !== null && b !== null) {\n if (!(typeof b === 'object')) return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n for (const key in a) {\n if (!deepEqual(a[key], b[key])) return false;\n }\n return true;\n }\n return a === b;\n}\n\n/**\n * Deeply clones two objects.\n */\nexport function clone<T>(input: T): T {\n if (Array.isArray(input)) {\n return input.map(clone) as any as T;\n } else if (typeof input === 'object' && input) {\n return mapObject(input, clone) as any as T;\n } else {\n return input;\n }\n}\n\n/**\n * Check if two arrays have at least one common element.\n */\nexport function arraysIntersect<T>(a: Array<T>, b: Array<T>): boolean {\n for (let l = 0; l < a.length; l++) {\n if (b.indexOf(a[l]) >= 0) return true;\n }\n return false;\n}\n\n/**\n * Print a warning message to the console and ensure duplicate warning messages\n * are not printed.\n */\nconst warnOnceHistory: {[key: string]: boolean} = {};\n\nexport function warnOnce(message: string): void {\n if (!warnOnceHistory[message]) {\n // console isn't defined in some WebWorkers, see #2558\n if (typeof console !== 'undefined') console.warn(message);\n warnOnceHistory[message] = true;\n }\n}\n\n/**\n * Indicates if the provided Points are in a counter clockwise (true) or clockwise (false) order\n *\n * @returns true for a counter clockwise set of points\n */\n// https://bryceboe.com/2006/10/23/line-segment-intersection-algorithm/\nexport function isCounterClockwise(a: Point, b: Point, c: Point): boolean {\n return (c.y - a.y) * (b.x - a.x) > (b.y - a.y) * (c.x - a.x);\n}\n\n/**\n * For two lines a and b in 2d space, defined by any two points along the lines,\n * find the intersection point, or return null if the lines are parallel\n *\n * @param a1 - First point on line a\n * @param a2 - Second point on line a\n * @param b1 - First point on line b\n * @param b2 - Second point on line b\n *\n * @returns the intersection point of the two lines or null if they are parallel\n */\nexport function findLineIntersection(a1: Point, a2: Point, b1: Point, b2: Point): Point | null {\n const aDeltaY = a2.y - a1.y;\n const aDeltaX = a2.x - a1.x;\n const bDeltaY = b2.y - b1.y;\n const bDeltaX = b2.x - b1.x;\n\n const denominator = (bDeltaY * aDeltaX) - (bDeltaX * aDeltaY);\n\n if (denominator === 0) {\n // Lines are parallel\n return null;\n }\n\n const originDeltaY = a1.y - b1.y;\n const originDeltaX = a1.x - b1.x;\n const aInterpolation = (bDeltaX * originDeltaY - bDeltaY * originDeltaX) / denominator;\n\n // Find intersection by projecting out from origin of first segment\n return new Point(a1.x + (aInterpolation * aDeltaX), a1.y + (aInterpolation * aDeltaY));\n}\n\n/**\n * Converts spherical coordinates to cartesian coordinates.\n *\n * @param spherical - Spherical coordinates, in [radial, azimuthal, polar]\n * @returns cartesian coordinates in [x, y, z]\n */\n\nexport function sphericalToCartesian([r, azimuthal, polar]: [number, number, number]): {\n x: number;\n y: number;\n z: number;\n} {\n // We abstract \"north\"/\"up\" (compass-wise) to be 0° when really this is 90° (π/2):\n // correct for that here\n azimuthal += 90;\n\n // Convert azimuthal and polar angles to radians\n azimuthal *= Math.PI / 180;\n polar *= Math.PI / 180;\n\n return {\n x: r * Math.cos(azimuthal) * Math.sin(polar),\n y: r * Math.sin(azimuthal) * Math.sin(polar),\n z: r * Math.cos(polar)\n };\n}\n\n/**\n * Returns true if the when run in the web-worker context.\n *\n * @returns `true` if the when run in the web-worker context.\n */\nexport function isWorker(self: any): self is WorkerGlobalScopeInterface {\n // @ts-ignore\n return typeof WorkerGlobalScope !== 'undefined' && typeof self !== 'undefined' && self instanceof WorkerGlobalScope;\n}\n\n/**\n * Parses data from 'Cache-Control' headers.\n *\n * @param cacheControl - Value of 'Cache-Control' header\n * @returns object containing parsed header info.\n */\n\nexport function parseCacheControl(cacheControl: string): any {\n // Taken from [Wreck](https://github.com/hapijs/wreck)\n const re = /(?:^|(?:\\s*\\,\\s*))([^\\x00-\\x20\\(\\)<>@\\,;\\:\\\\\"\\/\\[\\]\\?\\=\\{\\}\\x7F]+)(?:\\=(?:([^\\x00-\\x20\\(\\)<>@\\,;\\:\\\\\"\\/\\[\\]\\?\\=\\{\\}\\x7F]+)|(?:\\\"((?:[^\"\\\\]|\\\\.)*)\\\")))?/g;\n\n const header = {};\n cacheControl.replace(re, ($0, $1, $2, $3) => {\n const value = $2 || $3;\n header[$1] = value ? value.toLowerCase() : true;\n return '';\n });\n\n if (header['max-age']) {\n const maxAge = parseInt(header['max-age'], 10);\n if (isNaN(maxAge)) delete header['max-age'];\n else header['max-age'] = maxAge;\n }\n\n return header;\n}\n\nlet _isSafari = null;\n\n/**\n * Returns true when run in WebKit derived browsers.\n * This is used as a workaround for a memory leak in Safari caused by using Transferable objects to\n * transfer data between WebWorkers and the main thread.\n * https://github.com/mapbox/mapbox-gl-js/issues/8771\n *\n * This should be removed once the underlying Safari issue is fixed.\n *\n * @param scope - Since this function is used both on the main thread and WebWorker context,\n * let the calling scope pass in the global scope object.\n * @returns `true` when run in WebKit derived browsers.\n */\nexport function isSafari(scope: any): boolean {\n if (_isSafari == null) {\n const userAgent = scope.navigator ? scope.navigator.userAgent : null;\n _isSafari = !!scope.safari ||\n !!(userAgent && (/\\b(iPad|iPhone|iPod)\\b/.test(userAgent) || (!!userAgent.match('Safari') && !userAgent.match('Chrome'))));\n }\n return _isSafari;\n}\n\nexport function storageAvailable(type: string): boolean {\n try {\n const storage = window[type];\n storage.setItem('_mapbox_test_', 1);\n storage.removeItem('_mapbox_test_');\n return true;\n } catch {\n return false;\n }\n}\n\n// The following methods are from https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding#The_Unicode_Problem\n//Unicode compliant base64 encoder for strings\nexport function b64EncodeUnicode(str: string) {\n return btoa(\n encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,\n (match, p1) => {\n return String.fromCharCode(Number('0x' + p1)); //eslint-disable-line\n }\n )\n );\n}\n\n// Unicode compliant decoder for base64-encoded strings\nexport function b64DecodeUnicode(str: string) {\n return decodeURIComponent(atob(str).split('').map((c) => {\n return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); //eslint-disable-line\n }).join(''));\n}\n\nexport function isImageBitmap(image: any): image is ImageBitmap {\n return typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap;\n}\n\n/**\n * Converts an ArrayBuffer to an ImageBitmap.\n *\n * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work\n * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting\n * ArrayBuffers.\n *\n * @param data - Data to convert\n * @returns - A promise resolved when the conversion is finished\n */\nexport const arrayBufferToImageBitmap = async (data: ArrayBuffer): Promise<ImageBitmap> => {\n if (data.byteLength === 0) {\n return createImageBitmap(new ImageData(1, 1));\n }\n const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'});\n try {\n return createImageBitmap(blob);\n } catch (e) {\n throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`);\n }\n};\n\nconst transparentPngUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=';\n\n/**\n * Converts an ArrayBuffer to an HTMLImageElement.\n *\n * Used mostly for testing purposes only, because mocking libs don't know how to work with ArrayBuffers, but work\n * perfectly fine with ImageBitmaps. Might also be used for environments (other than testing) not supporting\n * ArrayBuffers.\n *\n * @param data - Data to convert\n * @returns - A promise resolved when the conversion is finished\n */\nexport const arrayBufferToImage = (data: ArrayBuffer): Promise<HTMLImageElement> => {\n return new Promise((resolve, reject) => {\n const img: HTMLImageElement = new Image();\n img.onload = () => {\n resolve(img);\n URL.revokeObjectURL(img.src);\n // prevent image dataURI memory leak in Safari;\n // but don't free the image immediately because it might be uploaded in the next frame\n // https://github.com/mapbox/mapbox-gl-js/issues/10226\n img.onload = null;\n window.requestAnimationFrame(() => { img.src = transparentPngUrl; });\n };\n img.onerror = () => reject(new Error('Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.'));\n const blob: Blob = new Blob([new Uint8Array(data)], {type: 'image/png'});\n img.src = data.byteLength ? URL.createObjectURL(blob) : transparentPngUrl;\n });\n};\n\n/**\n * Computes the webcodecs VideoFrame API options to select a rectangle out of\n * an image and write it into the destination rectangle.\n *\n * Rect (x/y/width/height) select the overlapping rectangle from the source image\n * and layout (offset/stride) write that overlapping rectangle to the correct place\n * in the destination image.\n *\n * Offset is the byte offset in the dest image that the first pixel appears at\n * and stride is the number of bytes to the start of the next row:\n * ┌───────────┐\n * │ dest │\n * │ ┌───┼───────┐\n * │offset→│▓▓▓│ source│\n * │ │▓▓▓│ │\n * │ └───┼───────┘\n * │stride ⇠╌╌╌│\n * │╌╌╌╌╌╌→ │\n * └───────────┘\n *\n * @param image - source image containing a width and height attribute\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns the layout and rect options to pass into VideoFrame API\n */\nfunction computeVideoFrameParameters(image: Size, x: number, y: number, width: number, height: number): VideoFrameCopyToOptions {\n const destRowOffset = Math.max(-x, 0) * 4;\n const firstSourceRow = Math.max(0, y);\n const firstDestRow = firstSourceRow - y;\n const offset = firstDestRow * width * 4 + destRowOffset;\n const stride = width * 4;\n\n const sourceLeft = Math.max(0, x);\n const sourceTop = Math.max(0, y);\n const sourceRight = Math.min(image.width, x + width);\n const sourceBottom = Math.min(image.height, y + height);\n return {\n rect: {\n x: sourceLeft,\n y: sourceTop,\n width: sourceRight - sourceLeft,\n height: sourceBottom - sourceTop\n },\n layout: [{offset, stride}]\n };\n}\n\n/**\n * Reads pixels from an ImageBitmap/Image/canvas using webcodec VideoFrame API.\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred\n */\nexport async function readImageUsingVideoFrame(\n image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Promise<Uint8ClampedArray> {\n if (typeof VideoFrame === 'undefined') {\n throw new Error('VideoFrame not supported');\n }\n const frame = new VideoFrame(image, {timestamp: 0});\n try {\n const format = frame?.format;\n if (!format || !(format.startsWith('BGR') || format.startsWith('RGB'))) {\n throw new Error(`Unrecognized format ${format}`);\n }\n const swapBR = format.startsWith('BGR');\n const result = new Uint8ClampedArray(width * height * 4);\n await frame.copyTo(result, computeVideoFrameParameters(image, x, y, width, height));\n if (swapBR) {\n for (let i = 0; i < result.length; i += 4) {\n const tmp = result[i];\n result[i] = result[i + 2];\n result[i + 2] = tmp;\n }\n }\n return result;\n } finally {\n frame.close();\n }\n}\n\nlet offscreenCanvas: OffscreenCanvas;\nlet offscreenCanvasContext: OffscreenCanvasRenderingContext2D;\n\n/**\n * Reads pixels from an ImageBitmap/Image/canvas using OffscreenCanvas\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image, or the error if an error occurred\n */\nexport function readImageDataUsingOffscreenCanvas(\n imgBitmap: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Uint8ClampedArray {\n const origWidth = imgBitmap.width;\n const origHeight = imgBitmap.height;\n // Lazily initialize OffscreenCanvas\n if (!offscreenCanvas || !offscreenCanvasContext) {\n // Dem tiles are typically 256x256\n offscreenCanvas = new OffscreenCanvas(origWidth, origHeight);\n offscreenCanvasContext = offscreenCanvas.getContext('2d', {willReadFrequently: true});\n }\n\n offscreenCanvas.width = origWidth;\n offscreenCanvas.height = origHeight;\n\n offscreenCanvasContext.drawImage(imgBitmap, 0, 0, origWidth, origHeight);\n const imgData = offscreenCanvasContext.getImageData(x, y, width, height);\n offscreenCanvasContext.clearRect(0, 0, origWidth, origHeight);\n return imgData.data;\n}\n\n/**\n * Reads RGBA pixels from an preferring OffscreenCanvas, but falling back to VideoFrame if supported and\n * the browser is mangling OffscreenCanvas getImageData results.\n *\n * @param data - image, imagebitmap, or canvas to parse\n * @param x - top-left x coordinate to read from the image\n * @param y - top-left y coordinate to read from the image\n * @param width - width of the rectangle to read from the image\n * @param height - height of the rectangle to read from the image\n * @returns a promise containing the parsed RGBA pixel values of the image\n */\nexport async function getImageData(\n image: HTMLImageElement | HTMLCanvasElement | ImageBitmap | OffscreenCanvas,\n x: number, y: number, width: number, height: number\n): Promise<Uint8ClampedArray> {\n if (isOffscreenCanvasDistorted()) {\n try {\n return await readImageUsingVideoFrame(image, x, y, width, height);\n } catch {\n // fall back to OffscreenCanvas\n }\n }\n return readImageDataUsingOffscreenCanvas(image, x, y, width, height);\n}\n\n/**\n * Allows to unsubscribe from events without the need to store the method reference.\n */\nexport interface Subscription {\n /**\n * Unsubscribes from the event.\n */\n unsubscribe(): void;\n}\n\nexport interface Subscriber {\n addEventListener: typeof window.addEventListener;\n removeEventListener: typeof window.removeEventListener;\n}\n\n/**\n * This method is used in order to register an event listener using a lambda function.\n * The return value will allow unsubscribing from the event, without the need to store the method reference.\n * @param target - The target\n * @param message - The message\n * @param listener - The listener\n * @param options - The options\n * @returns a subscription object that can be used to unsubscribe from the event\n */\nexport function subscribe(target: Subscriber, message: keyof WindowEventMap, listener: (...args: any) => void, options: boolean | AddEventListenerOptions): Subscription {\n target.addEventListener(message, listener, options);\n return {\n unsubscribe: () => {\n target.removeEventListener(message, listener, options);\n }\n };\n}\n\n/**\n * This method converts degrees to radians.\n * The return value is the radian value.\n * @param degrees - The number of degrees\n * @returns radians\n */\nexport function degreesToRadians(degrees: number): number {\n return degrees * Math.PI / 180;\n}\n\n/**\n * This method converts radians to degrees.\n * The return value is the degrees value.\n * @param degrees - The number of radians\n * @returns degrees\n */\nexport function radiansToDegrees(degrees: number): number {\n return degrees / Math.PI * 180;\n}\n\nexport type RollPitchBearing = {\n roll: number;\n pitch: number;\n bearing: number;\n};\n\nexport function rollPitchBearingEqual(a: RollPitchBearing, b: RollPitchBearing): boolean {\n return a.roll == b.roll && a.pitch == b.pitch && a.bearing == b.bearing;\n}\n\n/**\n * This method converts a rotation quaternion to roll, pitch, and bearing angles in degrees.\n * @param rotation - The rotation quaternion\n * @returns roll, pitch, and bearing angles in degrees\n */\nexport function getRollPitchBearing(rotation: quat): RollPitchBearing {\n const m: mat3 = new Float64Array(9) as any;\n mat3.fromQuat(m, rotation);\n\n const xAngle = radiansToDegrees(-Math.asin(clamp(m[2], -1, 1)));\n let roll: number;\n let bearing: number;\n if (Math.hypot(m[5], m[8]) < 1.0e-3) {\n roll = 0.0;\n bearing = -radiansToDegrees(Math.atan2(m[3], m[4]));\n } else {\n roll = radiansToDegrees((m[5] === 0.0 && m[8] === 0.0) ? 0.0 : Math.atan2(m[5], m[8]));\n bearing = radiansToDegrees((m[1] === 0.0 && m[0] === 0.0) ? 0.0 : Math.atan2(m[1], m[0]));\n }\n\n return {roll, pitch: xAngle + 90.0, bearing};\n}\n\nexport function getAngleDelta(lastPoint: Point, currentPoint: Point, center: Point): number {\n const pointVect = vec2.fromValues(currentPoint.x - center.x, currentPoint.y - center.y);\n const lastPointVec = vec2.fromValues(lastPoint.x - center.x, lastPoint.y - center.y);\n\n const crossProduct = pointVect[0] * lastPointVec[1] - pointVect[1] * lastPointVec[0];\n const angleRadians = Math.atan2(crossProduct, vec2.dot(pointVect, lastPointVec));\n return radiansToDegrees(angleRadians);\n}\n\n/**\n * This method converts roll, pitch, and bearing angles in degrees to a rotation quaternion.\n * @param roll - Roll angle in degrees\n * @param pitch - Pitch angle in degrees\n * @param bearing - Bearing angle in degrees\n * @returns The rotation quaternion\n */\nexport function rollPitchBearingToQuat(roll: number, pitch: number, bearing: number): quat {\n const rotation: quat = new Float64Array(4) as any;\n quat.fromEuler(rotation, roll, pitch - 90.0, bearing);\n return rotation;\n}\n\n/**\n * Makes optional keys required and add the the undefined type.\n *\n * ```\n * interface Test {\n * foo: number;\n * bar?: number;\n * baz: number | undefined;\n * }\n *\n * Complete<Test> {\n * foo: number;\n * bar: number | undefined;\n * baz: number | undefined;\n * }\n *\n * ```\n *\n * See https://medium.com/terria/typescript-transforming-optional-properties-to-required-properties-that-may-be-undefined-7482cb4e1585\n */\n\nexport type Complete<T> = {\n [P in keyof Required<T>]: Pick<T, P> extends Required<Pick<T, P>> ? T[P] : (T[P] | undefined);\n};\n\n/**\n * A helper to allow require of at least one property\n */\nexport type RequireAtLeastOne<T> = { [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>; }[keyof T];\n\n/**\n* A helper to allow require exactly one one property\n */\nexport type ExactlyOne<T, Keys extends keyof T = keyof T> = {\n [K in Keys]: Required<Pick<T, K>> & { [P in Exclude<Keys, K>]?: never }\n}[Keys];\n\nexport type TileJSON = {\n tilejson: '2.2.0' | '2.1.0' | '2.0.1' | '2.0.0' | '1.0.0';\n name?: string;\n description?: string;\n version?: string;\n attribution?: string;\n template?: string;\n tiles: Array<string>;\n grids?: Array<string>;\n data?: Array<string>;\n minzoom?: number;\n maxzoom?: number;\n bounds?: [number, number, number, number];\n center?: [number, number, number];\n vector_layers: [{id: string}]; // this is partial but enough for what we need\n};\n\n/**\n * The maximum world tile zoom (Z).\n * In other words, the upper bound supported for tile zoom.\n */\nexport const MAX_TILE_ZOOM = 25;\n\n/**\n * The minimum world tile zoom (Z).\n * In other words, the lower bound supported for tile zoom.\n */\nexport const MIN_TILE_ZOOM = 0;\n\nexport const MAX_VALID_LATITUDE = 85.051129;\n\nconst touchableEvents = {\n touchstart: true,\n touchmove: true,\n touchmoveWindow: true,\n touchend: true,\n touchcancel: true\n};\n\nconst pointableEvents = {\n dblclick: true,\n click: true,\n mouseover: true,\n mouseout: true,\n mousedown: true,\n mousemove: true,\n mousemoveWindow: true,\n mouseup: true,\n mouseupWindow: true,\n contextmenu: true,\n wheel: true\n};\n\nexport function isTouchableEvent(event: Event, eventType: string): event is TouchEvent {\n return touchableEvents[eventType] && 'touches' in event;\n}\n\nexport function isPointableEvent(event: Event, eventType: string): event is MouseEvent {\n return pointableEvents[eventType] && (event instanceof MouseEvent || event instanceof WheelEvent);\n}\n\nexport function isTouchableOrPointableType(eventType: string): boolean {\n return touchableEvents[eventType] || pointableEvents[eventType];\n}\n","import {extend, isWorker} from './util';\nimport {AbortError, isAbortError} from './abort_error';\nimport {getProtocol} from '../source/protocol_crud';\nimport {MessageType} from './actor_messages';\n\n/**\n * This is used to identify the global dispatcher id when sending a message from the worker without a target map id.\n */\nexport const GLOBAL_DISPATCHER_ID = 'global-dispatcher';\n\n/**\n * A type used to store the tile's expiration date and cache control definition\n */\nexport type ExpiryData = {cacheControl?: string | null; expires?: Date | string | null};\n\n/**\n * A `RequestParameters` object to be returned from Map.options.transformRequest callbacks.\n * @example\n * ```ts\n * // use transformRequest to modify requests that begin with `http://myHost`\n * transformRequest: function(url, resourceType) {\n * if (resourceType === 'Source' && url.indexOf('http://myHost') > -1) {\n * return {\n * url: url.replace('http', 'https'),\n * headers: { 'my-custom-header': true },\n * credentials: 'include' // Include cookies for cross-origin requests\n * }\n * }\n * }\n * ```\n */\nexport type RequestParameters = {\n /**\n * The URL to be requested.\n */\n url: string;\n /**\n * The headers to be sent with the request.\n */\n headers?: any;\n /**\n * Request method `'GET' | 'POST' | 'PUT'`.\n */\n method?: 'GET' | 'POST' | 'PUT';\n /**\n * Request body.\n */\n body?: string;\n /**\n * Response body type to be returned.\n */\n type?: 'string' | 'json' | 'arrayBuffer' | 'image';\n /**\n * `'same-origin'|'include'` Use 'include' to send cookies with cross-origin requests.\n */\n credentials?: 'same-origin' | 'include';\n /**\n * If `true`, Resource Timing API information will be collected for these transformed requests and returned in a resourceTiming property of relevant data events.\n */\n collectResourceTiming?: boolean;\n /**\n * Parameters supported only by browser fetch API. Property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache. (https://developer.mozilla.org/en-US/docs/Web/API/Request/cache)\n */\n cache?: RequestCache;\n};\n\n/**\n * The response object returned from a successful AJAx request\n */\nexport type GetResourceResponse<T> = ExpiryData & {\n data: T;\n};\n\n/**\n * The response callback used in various places\n */\nexport type ResponseCallback<T> = (\n error?: Error | null,\n data?: T | null,\n cacheControl?: string | null,\n expires?: string | Date | null\n) => void;\n\n/**\n * An error thrown when a HTTP request results in an error response.\n */\nexport class AJAXError extends Error {\n /**\n * The response's HTTP status code.\n */\n status: number;\n\n /**\n * The response's HTTP status text.\n */\n statusText: string;\n\n /**\n * The request's URL.\n */\n url: string;\n\n /**\n * The response's body.\n */\n body: Blob;\n\n /**\n * @param status - The response's HTTP status code.\n * @param statusText - The response's HTTP status text.\n * @param url - The request's URL.\n * @param body - The response's body.\n */\n constructor(status: number, statusText: string, url: string, body: Blob) {\n super(`AJAXError: ${statusText} (${status}): ${url}`);\n this.status = status;\n this.statusText = statusText;\n this.url = url;\n this.body = body;\n }\n}\n\n/**\n * Ensure that we're sending the correct referrer from blob URL worker bundles.\n * For files loaded from the local file system, `location.origin` will be set\n * to the string(!) \"null\" (Firefox), or \"file://\" (Chrome, Safari, Edge),\n * and we will set an empty referrer. Otherwise, we're using the document's URL.\n */\nexport const getReferrer = () => isWorker(self) ?\n self.worker && self.worker.referrer :\n (window.location.protocol === 'blob:' ? window.parent : window).location.href;\n\n/**\n * Determines whether a URL is a file:// URL. This is obviously the case if it begins\n * with file://. Relative URLs are also file:// URLs iff the original document was loaded\n * via a file:// URL.\n * @param url - The URL to check\n * @returns `true` if the URL is a file:// URL, `false` otherwise\n */\nconst isFileURL = url => /^file:/.test(url) || (/^file:/.test(getReferrer()) && !/^\\w+:/.test(url));\n\nasync function makeFetchRequest(requestParameters: RequestParameters, abortController: AbortController): Promise<GetResourceResponse<any>> {\n const request = new Request(requestParameters.url, {\n method: requestParameters.method || 'GET',\n body: requestParameters.body,\n credentials: requestParameters.credentials,\n headers: requestParameters.headers,\n cache: requestParameters.cache,\n referrer: getReferrer(),\n signal: abortController.signal\n });\n\n // If the user has already set an Accept header, do not overwrite it here\n if (requestParameters.type === 'json' && !request.headers.has('Accept')) {\n request.headers.set('Accept', 'application/json');\n }\n\n let response: Response;\n try {\n response = await fetch(request);\n } catch (e) {\n // Pass through AbortErrors for upstream handling\n if (isAbortError(e)) {\n throw e;\n }\n\n // When the error is due to CORS policy, DNS issue or malformed URL, the fetch call does not resolve but throws a generic TypeError instead.\n // It is preferable to throw an AJAXError so that the Map event \"error\" can catch it and still have\n // access to the faulty url. In such case, we provide the arbitrary HTTP error code of `0`.\n throw new AJAXError(0, e.message, requestParameters.url, new Blob());\n }\n\n if (!response.ok) {\n const body = await response.blob();\n throw new AJAXError(response.status, response.statusText, requestParameters.url, body);\n }\n let parsePromise: Promise<any>;\n if ((requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image')) {\n parsePromise = response.arrayBuffer();\n } else if (requestParameters.type === 'json') {\n parsePromise = response.json();\n } else {\n parsePromise = response.text();\n }\n const result = await parsePromise;\n abortController.signal.throwIfAborted();\n return {data: result, cacheControl: response.headers.get('Cache-Control'), expires: response.headers.get('Expires')};\n}\n\nfunction makeXMLHttpRequest(requestParameters: RequestParameters, abortController: AbortController): Promise<GetResourceResponse<any>> {\n return new Promise((resolve, reject) => {\n const xhr: XMLHttpRequest = new XMLHttpRequest();\n\n xhr.open(requestParameters.method || 'GET', requestParameters.url, true);\n if (requestParameters.type === 'arrayBuffer' || requestParameters.type === 'image') {\n xhr.responseType = 'arraybuffer';\n }\n for (const k in requestParameters.headers) {\n xhr.setRequestHeader(k, requestParameters.headers[k]);\n }\n if (requestParameters.type === 'json') {\n xhr.responseType = 'text';\n // Do not overwrite the user-provided Accept header\n if (!requestParameters.headers?.Accept) {\n xhr.setRequestHeader('Accept', 'application/json');\n }\n }\n xhr.withCredentials = requestParameters.credentials === 'include';\n xhr.onerror = () => {\n reject(new Error(xhr.statusText));\n };\n xhr.onload = () => {\n if (abortController.signal.aborted) {\n return;\n }\n if (((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) && xhr.response !== null) {\n let data: unknown = xhr.response;\n if (requestParameters.type === 'json') {\n // We're manually parsing JSON here to get better error messages.\n try {\n data = JSON.parse(xhr.response);\n } catch (err) {\n reject(err);\n return;\n }\n }\n resolve({data, cacheControl: xhr.getResponseHeader('Cache-Control'), expires: xhr.getResponseHeader('Expires')});\n } else {\n const body = new Blob([xhr.response], {type: xhr.getResponseHeader('Content-Type')});\n reject(new AJAXError(xhr.status, xhr.statusText, requestParameters.url, body));\n }\n };\n abortController.signal.addEventListener('abort', () => {\n xhr.abort();\n reject(new AbortError(abortController.signal.reason));\n });\n xhr.send(requestParameters.body);\n });\n}\n\n/**\n * We're trying to use the Fetch API if possible. However, requests for resources with the file:// URI scheme don't work with the Fetch API.\n * In this case we unconditionally use XHR on the current thread since referrers don't matter.\n * This method can also use the registered method if `addProtocol` was called.\n * @param requestParameters - The request parameters\n * @param abortController - The abort controller allowing to cancel the request\n * @returns a promise resolving to the response, including cache control and expiry data\n */\nexport const makeRequest = function(requestParameters: RequestParameters, abortController: AbortController): Promise<GetResourceResponse<any>> {\n if (/:\\/\\//.test(requestParameters.url) && !(/^https?:|^file:/.test(requestParameters.url))) {\n const protocolLoadFn = getProtocol(requestParameters.url);\n if (protocolLoadFn) {\n return protocolLoadFn(requestParameters, abortController);\n }\n if (isWorker(self) && self.worker && self.worker.actor) {\n return self.worker.actor.sendAsync({type: MessageType.getResource, data: requestParameters, targetMapId: GLOBAL_DISPATCHER_ID}, abortController);\n }\n }\n if (!isFileURL(requestParameters.url)) {\n if (fetch && Request && AbortController && Object.prototype.hasOwnProperty.call(Request.prototype, 'signal')) {\n return makeFetchRequest(requestParameters, abortController);\n }\n if (isWorker(self) && self.worker && self.worker.actor) {\n return self.worker.actor.sendAsync({type: MessageType.getResource, data: requestParameters, mustQueue: true, targetMapId: GLOBAL_DISPATCHER_ID}, abortController);\n }\n }\n return makeXMLHttpRequest(requestParameters, abortController);\n};\n\nexport const getJSON = <T>(requestParameters: RequestParameters, abortController: AbortController): Promise<{data: T} & ExpiryData> => {\n return makeRequest(extend(requestParameters, {type: 'json'}), abortController);\n};\n\nexport const getArrayBuffer = (requestParameters: RequestParameters, abortController: AbortController): Promise<{data: ArrayBuffer} & ExpiryData> => {\n return makeRequest(extend(requestParameters, {type: 'arrayBuffer'}), abortController);\n};\n\nexport function sameOrigin(inComingUrl: string) {\n // A relative URL \"/foo\" or \"./foo\" will throw exception in URL's ctor,\n // try-catch is expansive so just use a heuristic check to avoid it\n // also check data URL\n if (!inComingUrl ||\n inComingUrl.indexOf('://') <= 0 || // relative URL\n inComingUrl.indexOf('data:image/') === 0 || // data image URL\n inComingUrl.indexOf('blob:') === 0) { // blob\n return true;\n }\n const urlObj = new URL(inComingUrl);\n const locationObj = window.location;\n return urlObj.protocol === locationObj.protocol && urlObj.host === locationObj.host;\n}\n\nexport const getVideo = (urls: Array<string>): Promise<HTMLVideoElement> => {\n const video: HTMLVideoElement = window.document.createElement('video');\n video.muted = true;\n return new Promise((resolve) => {\n video.onloadstart = () => {\n resolve(video);\n };\n for (const url of urls) {\n const s: HTMLSourceElement = window.document.createElement('source');\n if (!sameOrigin(url)) {\n video.crossOrigin = 'Anonymous';\n }\n s.src = url;\n video.appendChild(s);\n }\n });\n};\n","import {TransferableGridIndex} from './transferable_grid_index';\nimport {Color, CompoundExpression, expressions, ResolvedImage, StylePropertyFunction,\n StyleExpression, ZoomDependentExpression, ZoomConstantExpression} from '@maplibre/maplibre-gl-style-spec';\nimport {AJAXError} from './ajax';\nimport {isImageBitmap} from './util';\n\n/**\n * A class that is serialized to and json, that can be constructed back to the original class in the worker or in the main thread\n */\ntype SerializedObject<S extends Serialized = any> = {\n [_: string]: S;\n};\n\n/**\n * All the possible values that can be serialized and sent to and from the worker\n */\nexport type Serialized = null | void | boolean | number | string | Boolean | Number | String | Date | RegExp | ArrayBuffer | ArrayBufferView | ImageData | ImageBitmap | Blob | Array<Serialized> | SerializedObject;\n\ntype Registry = {\n [_: string]: {\n klass: {\n new (...args: any): any;\n deserialize?: (input: Serialized) => unknown;\n serialize?: (input: any, transferables: Transferable[]) => SerializedObject;\n };\n omit: ReadonlyArray<string>;\n shallow: ReadonlyArray<string>;\n };\n};\n\n/**\n * Register options\n */\ntype RegisterOptions<T> = {\n /**\n * List of properties to omit from serialization (e.g., cached/computed properties)\n */\n omit?: ReadonlyArray<keyof T>;\n /**\n * List of properties that should be serialized by a simple shallow copy, rather than by a recursive call to serialize().\n */\n shallow?: ReadonlyArray<keyof T>;\n};\n\nconst registry: Registry = {};\n\n/**\n * Register the given class as serializable.\n *\n * @param options - the registration options\n */\nexport function register<T extends any>(\n name: string,\n klass: {\n new (...args: any): T;\n },\n options: RegisterOptions<T> = {}\n) {\n if (registry[name]) throw new Error(`${name} is already registered.`);\n ((Object.defineProperty as any))(klass, '_classRegistryKey', {\n value: name,\n writeable: false\n });\n registry[name] = {\n klass,\n omit: options.omit as ReadonlyArray<string> || [],\n shallow: options.shallow as ReadonlyArray<string> || []\n };\n}\n\nregister('Object', Object);\nregister('Set', Set);\nregister('TransferableGridIndex', TransferableGridIndex);\n\nregister('Color', Color);\nregister('Error', Error);\nregister('AJAXError', AJAXError);\nregister('ResolvedImage', ResolvedImage);\n\nregister('StylePropertyFunction', StylePropertyFunction);\nregister('StyleExpression', StyleExpression, {omit: ['_evaluator']});\n\nregister('ZoomDependentExpression', ZoomDependentExpression);\nregister('ZoomConstantExpression', ZoomConstantExpression);\nregister('CompoundExpression', CompoundExpression, {omit: ['_evaluate']});\nfor (const name in expressions) {\n if ((expressions[name] as any)._classRegistryKey) continue;\n register(`Expression_${name}`, expressions[name]);\n}\n\nfunction isArrayBuffer(value: any): value is ArrayBuffer {\n return value && typeof ArrayBuffer !== 'undefined' &&\n (value instanceof ArrayBuffer || (value.constructor && value.constructor.name === 'ArrayBuffer'));\n}\n\nfunction getClassRegistryKey(input: Object|SerializedObject): string {\n const klass = (input.constructor as any);\n return (input as SerializedObject).$name || klass._classRegistryKey;\n}\n\nfunction isRegistered(input: unknown): boolean {\n if (input === null || typeof input !== 'object') {\n return false;\n }\n const classRegistryKey = getClassRegistryKey(input);\n if (classRegistryKey && classRegistryKey !== 'Object') {\n return true;\n }\n return false;\n}\n\nfunction isSerializeHandledByBuiltin(input: unknown) {\n return (!isRegistered(input) && (\n input === null ||\n input === undefined ||\n typeof input === 'boolean' ||\n typeof input === 'number' ||\n typeof input === 'string' ||\n input instanceof Boolean ||\n input instanceof Number ||\n input instanceof String ||\n input instanceof Date ||\n input instanceof RegExp ||\n input instanceof Blob ||\n input instanceof Error ||\n isArrayBuffer(input) ||\n isImageBitmap(input) ||\n ArrayBuffer.isView(input) ||\n input instanceof ImageData)\n );\n}\n\n/**\n * Serialize the given object for transfer to or from a web worker.\n *\n * For non-builtin types, recursively serialize each property (possibly\n * omitting certain properties - see register()), and package the result along\n * with the constructor's `name` so that the appropriate constructor can be\n * looked up in `deserialize()`.\n *\n * If a `transferables` array is provided, add any transferable objects (i.e.,\n * any ArrayBuffers or ArrayBuffer views) to the list. (If a copy is needed,\n * this should happen in the client code, before using serialize().)\n */\nexport function serialize(input: unknown, transferables?: Array<Transferable> | null): Serialized {\n if (isSerializeHandledByBuiltin(input)) {\n if (isArrayBuffer(input) || isImageBitmap(input)) {\n if (transferables) {\n transferables.push(input);\n }\n }\n if (ArrayBuffer.isView(input)) {\n const view = input;\n if (transferables) {\n transferables.push(view.buffer);\n }\n }\n if (input instanceof ImageData) {\n if (transferables) {\n transferables.push(input.data.buffer);\n }\n }\n return input;\n }\n\n if (Array.isArray(input)) {\n const serialized: Array<Serialized> = [];\n for (const item of input) {\n serialized.push(serialize(item, transferables));\n }\n return serialized;\n }\n\n if (typeof input !== 'object') {\n throw new Error(`can't serialize object of type ${typeof input}`);\n }\n const classRegistryKey = getClassRegistryKey(input);\n if (!classRegistryKey) {\n throw new Error(`can't serialize object of unregistered class ${input.constructor.name}`);\n }\n if (!registry[classRegistryKey]) throw new Error(`${classRegistryKey} is not registered.`);\n const {klass} = registry[classRegistryKey];\n const properties: SerializedObject = klass.serialize ?\n // (Temporary workaround) allow a class to provide static\n // `serialize()` and `deserialize()` methods to bypass the generic\n // approach.\n // This temporary workaround lets us use the generic serialization\n // approach for objects whose members include instances of dynamic\n // StructArray types. Once we refactor StructArray to be static,\n // we can remove this complexity.\n (klass.serialize(input, transferables) as SerializedObject) : {};\n\n if (!klass.serialize) {\n for (const key in input) {\n if (!input.hasOwnProperty(key)) continue;\n if (registry[classRegistryKey].omit.indexOf(key) >= 0) continue;\n const property = input[key];\n properties[key] = registry[classRegistryKey].shallow.indexOf(key) >= 0 ?\n property :\n serialize(property, transferables);\n }\n if (input instanceof Error) {\n properties.message = input.message;\n }\n } else {\n if (transferables && properties === transferables[transferables.length - 1]) {\n throw new Error('statically serialized object won\\'t survive transfer of $name property');\n }\n }\n\n if (properties.$name) {\n throw new Error('$name property is reserved for worker serialization logic.');\n }\n if (classRegistryKey !== 'Object') {\n properties.$name = classRegistryKey;\n }\n\n return properties;\n}\n\nexport function deserialize(input: Serialized): unknown {\n if (isSerializeHandledByBuiltin(input)) {\n return input;\n }\n\n if (Array.isArray(input)) {\n return input.map(deserialize);\n }\n\n if (typeof input !== 'object') {\n throw new Error(`can't deserialize object of type ${typeof input}`);\n }\n const classRegistryKey = getClassRegistryKey(input) || 'Object';\n if (!registry[classRegistryKey]) {\n throw new Error(`can't deserialize unregistered class ${classRegistryKey}`);\n }\n const {klass} = registry[classRegistryKey];\n if (!klass) {\n throw new Error(`can't deserialize unregistered class ${classRegistryKey}`);\n }\n\n if (klass.deserialize) {\n return klass.deserialize(input);\n }\n\n const result = Object.create(klass.prototype);\n\n for (const key of Object.keys(input)) {\n if (key === '$name') continue;\n const value = (input as SerializedObject)[key];\n result[key] = registry[classRegistryKey].shallow.indexOf(key) >= 0 ? value : deserialize(value);\n }\n\n return result;\n}\n","import Point from '@mapbox/point-geometry';\nimport {EXTENT} from '../data/extent';\nimport {type CanonicalTileID} from '../tile/tile_id';\nimport earcut from 'earcut';\nimport {SubdivisionGranularityExpression, SubdivisionGranularitySetting} from './subdivision_granularity_settings';\nimport {register} from '../util/web_worker_transfer';\n\nregister('SubdivisionGranularityExpression', SubdivisionGranularityExpression);\nregister('SubdivisionGranularitySetting', SubdivisionGranularitySetting);\n\ntype SubdivisionResult = {\n verticesFlattened: Array<number>;\n indicesTriangles: Array<number>;\n\n /**\n * An array of arrays of indices of subdivided lines for polygon outlines.\n * Each array of lines corresponds to one ring of the original polygon.\n */\n indicesLineList: Array<Array<number>>;\n};\n\n// Special pole vertices have coordinates -32768,-32768 for the north pole and 32767,32767 for the south pole.\n// First, find any *non-pole* vertices at those coordinates and move them slightly elsewhere.\nexport const NORTH_POLE_Y = -32768;\nexport const SOUTH_POLE_Y = 32767;\n\nclass Subdivider {\n /**\n * Flattened vertex positions (xyxyxy).\n */\n private _vertexBuffer: Array<number> = [];\n\n /**\n * Map of \"vertex x and y coordinate\" to \"index of such vertex\".\n */\n private _vertexDictionary: Map<number, number> = new Map<number, number>();\n private _used: boolean = false;\n\n private readonly _canonical: CanonicalTileID;\n\n private readonly _granularity;\n private readonly _granularityCellSize;\n\n constructor(granularity: number, canonical: CanonicalTileID) {\n this._granularity = granularity;\n this._granularityCellSize = EXTENT / granularity;\n this._canonical = canonical;\n }\n\n private _getKey(x: number, y: number) {\n // Assumes signed 16 bit positions.\n x = x + 32768;\n y = y + 32768;\n return (x << 16) | (y << 0);\n }\n\n /**\n * Returns an index into the internal vertex buffer for a vertex at the given coordinates.\n * If the internal vertex buffer contains no such vertex, then it is added.\n */\n private _vertexToIndex(x: number, y: number): number {\n if (x < -32768 || y < -32768 || x > 32767 || y > 32767) {\n throw new Error('Vertex coordinates are out of signed 16 bit integer range.');\n }\n const xInt = Math.round(x) | 0;\n const yInt = Math.round(y) | 0;\n const key = this._getKey(xInt, yInt);\n if (this._vertexDictionary.has(key)) {\n return this._vertexDictionary.get(key);\n }\n const index = this._vertexBuffer.length / 2;\n this._vertexDictionary.set(key, index);\n this._vertexBuffer.push(xInt, yInt);\n return index;\n }\n\n /**\n * Subdivides a polygon by iterating over rows of granularity subdivision cells and splitting each row along vertical subdivision axes.\n * @param inputIndices - Indices into the internal vertex buffer of the triangulated polygon (after running `earcut`).\n * @returns Indices into the internal vertex buffer for triangles that are a subdivision of the input geometry.\n */\n private _subdivideTrianglesScanline(inputIndices: Array<number>): Array<number> {\n // A granularity cell is the square space between axes that subdivide geometry.\n // For granularity 8, cells would be 1024 by 1024 units.\n // For each triangle, we iterate over all cell rows it intersects, and generate subdivided geometry\n // only within one cell row at a time. This way, we implicitly subdivide along the X-parallel axes (cell row boundaries).\n // For each cell row, we generate an ordered point ring that describes the subdivided geometry inside this row (an intersection of the triangle and a given cell row).\n // Such ordered ring can be trivially triangulated.\n // Each ring may consist of sections of triangle edges that lie inside the cell row, and cell boundaries that lie inside the triangle. Both must be further subdivided along Y-parallel axes.\n // Most complexity of this function comes from generating correct vertex rings, and from placing the vertices into the ring in the correct order.\n\n if (this._granularity < 2) {\n // The actual subdivision code always produces triangles with the correct winding order.\n // Also apply winding order correction when skipping subdivision altogether to maintain consistency.\n return fixWindingOrder(this._vertexBuffer, inputIndices);\n }\n\n const finalIndices = [];\n\n // Iterate over all input triangles\n const numIndices = inputIndices.length;\n for (let primitiveIndex = 0; primitiveIndex < numIndices; primitiveIndex += 3) {\n const triangleIndices: [number, number, number] = [\n inputIndices[primitiveIndex + 0], // v0\n inputIndices[primitiveIndex + 1], // v1\n inputIndices[primitiveIndex + 2], // v2\n ];\n\n const triangleVertices: [number, number, number, number, number, number] = [\n this._vertexBuffer[inputIndices[primitiveIndex + 0] * 2 + 0], // v0.x\n this._vertexBuffer[inputIndices[primitiveIndex + 0] * 2 + 1], // v0.y\n this._vertexBuffer[inputIndices[primitiveIndex + 1] * 2 + 0], // v1.x\n this._vertexBuffer[inputIndices[primitiveIndex + 1] * 2 + 1], // v1.y\n this._vertexBuffer[inputIndices[primitiveIndex + 2] * 2 + 0], // v2.x\n this._vertexBuffer[inputIndices[primitiveIndex + 2] * 2 + 1], // v2.y\n ];\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n // Compute AABB\n for (let i = 0; i < 3; i++) {\n const vx = triangleVertices[i * 2];\n const vy = triangleVertices[i * 2 + 1];\n minX = Math.min(minX, vx);\n maxX = Math.max(maxX, vx);\n minY = Math.min(minY, vy);\n maxY = Math.max(maxY, vy);\n }\n\n if (minX === maxX || minY === maxY) {\n continue; // Skip degenerate linear axis-aligned triangles\n }\n\n const cellXmin = Math.floor(minX / this._granularityCellSize);\n const cellXmax = Math.ceil(maxX / this._granularityCellSize);\n const cellYmin = Math.floor(minY / this._granularityCellSize);\n const cellYmax = Math.ceil(maxY / this._granularityCellSize);\n\n // Skip subdividing triangles that do not span multiple cells - just add them \"as is\".\n if (cellXmin === cellXmax && cellYmin === cellYmax) {\n finalIndices.push(...triangleIndices);\n continue;\n }\n\n // Iterate over cell rows that intersect this triangle\n for (let cellRow = cellYmin; cellRow < cellYmax; cellRow++) {\n const ring = this._scanlineGenerateVertexRingForCellRow(cellRow, triangleVertices, triangleIndices);\n scanlineTriangulateVertexRing(this._vertexBuffer, ring, finalIndices);\n }\n }\n\n return finalIndices;\n }\n\n /**\n * Takes a triangle and a cell row index, returns a subdivided vertex ring of the intersection of the triangle and the cell row.\n * @param cellRow - Index of the cell row. A cell row of index `i` covert range from `i * granularityCellSize` to `(i + 1) * granularityCellSize`.\n * @param triangleVertices - An array of 6 elements, contains flattened positions of the triangle's vertices: `[v0x, v0y, v1x, v1y, v2x, v2y]`.\n * @param triangleIndices - An array of 3 elements, contains the original indices of the triangle's vertices: `[index0, index1, index2]`.\n * @returns The resulting ring of vertex indices and the index (to the returned ring array) of the leftmost vertex in the ring.\n */\n private _scanlineGenerateVertexRingForCellRow(\n cellRow: number,\n triangleVertices: [number, number, number, number, number, number],\n triangleIndices: [number, number, number]\n ) {\n const cellRowYTop = cellRow * this._granularityCellSize;\n const cellRowYBottom = cellRowYTop + this._granularityCellSize;\n const ring = [];\n\n // Generate the vertex ring\n for (let edgeIndex = 0; edgeIndex < 3; edgeIndex++) {\n // Current edge that will be subdivided: a --> b\n // The remaining vertex of the triangle: c\n const aX = triangleVertices[edgeIndex * 2];\n const aY = triangleVertices[edgeIndex * 2 + 1];\n const bX = triangleVertices[((edgeIndex + 1) * 2) % 6];\n const bY = triangleVertices[((edgeIndex + 1) * 2 + 1) % 6];\n const cX = triangleVertices[((edgeIndex + 2) * 2) % 6];\n const cY = triangleVertices[((edgeIndex + 2) * 2 + 1) % 6];\n // Edge direction\n const dirX = bX - aX;\n const dirY = bY - aY;\n\n // Edges parallel with either axis will need special handling later.\n const isParallelY = dirX === 0;\n const isParallelX = dirY === 0;\n\n // Distance along edge where it enters/exits current cell row,\n // where distance 0 is the edge start point, 1 the endpoint, 0.5 the mid point, etc.\n const tTop = (cellRowYTop - aY) / dirY;\n const tBottom = (cellRowYBottom - aY) / dirY;\n const tEnter = Math.min(tTop, tBottom);\n const tExit = Math.max(tTop, tBottom);\n\n // Determine if edge lies entirely outside this cell row.\n // Check entry and exit points, or if edge is parallel with X, check its Y coordinate.\n if ((!isParallelX && (tEnter >= 1 || tExit <= 0)) ||\n (isParallelX && (aY < cellRowYTop || aY > cellRowYBottom))) {\n // Skip this edge\n // But make sure to add its endpoint vertex if needed.\n if (bY >= cellRowYTop && bY <= cellRowYBottom) {\n // The edge endpoint is withing this row, add it to the ring\n ring.push(triangleIndices[(edgeIndex + 1) % 3]);\n }\n continue;\n }\n\n // Do not add original triangle vertices now, those are handled separately later\n\n // Special case: edge vertex for entry into cell row\n // If edge is parallel with X axis, there is no entry vertex\n if (!isParallelX && tEnter > 0) {\n const x = aX + dirX * tEnter;\n const y = aY + dirY * tEnter;\n ring.push(this._vertexToIndex(x, y));\n }\n\n // The X coordinates of the points where the edge enters/exits the current cell row,\n // or the edge start/endpoint, if the entry/exit happens beyond the edge bounds.\n const enterX = aX + dirX * Math.max(tEnter, 0);\n const exitX = aX + dirX * Math.min(tExit, 1);\n\n // Generate edge interior vertices\n // No need to subdivide (along X) edges that are parallel with Y\n if (!isParallelY) {\n this._generateIntraEdgeVertices(ring, aX, aY, bX, bY, enterX, exitX);\n }\n\n // Special case: edge vertex for exit from cell row\n if (!isParallelX && tExit < 1) {\n const x = aX + dirX * tExit;\n const y = aY + dirY * tExit;\n ring.push(this._vertexToIndex(x, y));\n }\n\n // When to split inter-edge boundary segments?\n // When the boundary doesn't intersect a vertex, its easy. But what if it does?\n\n // a\n // /|\n // / |\n // --c--|--boundary\n // \\ |\n // \\|\n // b\n //\n // Inter-edge region should be generated when processing the a-b edge.\n // This happens fine for the top row, for the bottom row,\n //\n\n // x\n // /|\n // / |\n // --x--x--boundary\n //\n // Edge that lies on boundary should be subdivided in its edge phase.\n // The inter-edge phase will correctly skip it.\n\n // Add endpoint vertex\n if (isParallelX || (bY >= cellRowYTop && bY <= cellRowYBottom)) {\n ring.push(triangleIndices[(edgeIndex + 1) % 3]);\n }\n // Any edge that has endpoint outside this row or on its boundary gets\n // inter-edge vertices.\n // No row boundary to split for edges parallel with X\n if (!isParallelX && (bY <= cellRowYTop || bY >= cellRowYBottom)) {\n this._generateInterEdgeVertices(ring, aX, aY, bX, bY, cX, cY,\n exitX, cellRowYTop, cellRowYBottom);\n }\n }\n\n return ring;\n }\n\n /**\n * Generates ring vertices along an edge A-\\>B, but only in the part that intersects a given cell row.\n * Does not handle adding edge endpoint vertices or edge cell row enter/exit vertices.\n * @param ring - Ordered array of vertex indices for the constructed ring. New indices are placed here.\n * @param enterX - The X coordinate of the point where edge A-\\>B enters the current cell row.\n * @param exitX - The X coordinate of the point where edge A-\\>B exits the current cell row.\n */\n private _generateIntraEdgeVertices(\n ring: Array<number>,\n aX: number,\n aY: number,\n bX: number,\n bY: number,\n enterX: number,\n exitX: number\n ): void {\n const dirX = bX - aX;\n const dirY = bY - aY;\n const isParallelX = dirY === 0;\n\n const leftX = isParallelX ? Math.min(aX, bX) : Math.min(enterX, exitX);\n const rightX = isParallelX ? Math.max(aX, bX) : Math.max(enterX, exitX);\n\n const edgeSubdivisionLeftCellX = Math.floor(leftX / this._granularityCellSize) + 1;\n const edgeSubdivisionRightCellX = Math.ceil(rightX / this._granularityCellSize) - 1;\n\n const isEdgeLeftToRight = isParallelX ? (aX < bX) : (enterX < exitX);\n if (isEdgeLeftToRight) {\n // Left to right\n for (let cellX = edgeSubdivisionLeftCellX; cellX <= edgeSubdivisionRightCellX; cellX++) {\n const x = cellX * this._granularityCellSize;\n const y = aY + dirY * (x - aX) / dirX;\n ring.push(this._vertexToIndex(x, y));\n }\n } else {\n // Right to left\n for (let cellX = edgeSubdivisionRightCellX; cellX >= edgeSubdivisionLeftCellX; cellX--) {\n const x = cellX * this._granularityCellSize;\n const y = aY + dirY * (x - aX) / dirX;\n ring.push(this._vertexToIndex(x, y));\n }\n }\n }\n\n /**\n * Generates ring vertices along cell border.\n * Call when processing an edge A-\\>B that exits the current row (B lies outside the current row).\n * Generates vertices along the cell edge between the exit point from cell row\n * of edge A-\\>B and entry of edge B-\\>C, or entry of C-\\>A if both A and C lie outside the cell row.\n * Does not handle adding edge endpoint vertices or edge cell row enter/exit vertices.\n * @param ring - Ordered array of vertex indices for the constructed ring. New indices are placed here.\n * @param exitX - The X coordinate of the point where edge A-\\>B exits the current cell row.\n * @param cellRowYTop - The current cell row top Y coordinate.\n * @param cellRowYBottom - The current cell row bottom Y coordinate.\n */\n private _generateInterEdgeVertices(\n ring: Array<number>,\n aX: number,\n aY: number,\n bX: number,\n bY: number,\n cX: number,\n cY: number,\n exitX: number,\n cellRowYTop: number,\n cellRowYBottom: number\n ): void {\n const dirY = bY - aY;\n\n const dir2X = cX - bX;\n const dir2Y = cY - bY;\n const t2Top = (cellRowYTop - bY) / dir2Y;\n const t2Bottom = (cellRowYBottom - bY) / dir2Y;\n // The distance along edge B->C where it enters/exits the current cell row,\n // where distance 0 is B, 1 is C, 0.5 is the edge midpoint, etc.\n const t2Enter = Math.min(t2Top, t2Bottom);\n const t2Exit = Math.max(t2Top, t2Bottom);\n const enter2X = bX + dir2X * t2Enter;\n let boundarySubdivisionLeftCellX = Math.floor(Math.min(enter2X, exitX) / this._granularityCellSize) + 1;\n let boundarySubdivisionRightCellX = Math.ceil(Math.max(enter2X, exitX) / this._granularityCellSize) - 1;\n let isBoundaryLeftToRight = exitX < enter2X;\n\n const isParallelX2 = dir2Y === 0;\n\n if (isParallelX2 && (cY === cellRowYTop || cY === cellRowYBottom)) {\n // Special case when edge b->c that lies on the cell boundary.\n // Do not generate any inter-edge vertices in this case,\n // this b->c edge gets subdivided when it is itself processed.\n return;\n }\n\n if (isParallelX2 || t2Enter >= 1 || t2Exit <= 0) {\n // The next edge (b->c) lies entirely outside this cell row\n // Find entry point for the edge after that instead (c->a)\n\n // There may be at most 1 edge that is parallel to X in a triangle.\n // The main \"a->b\" edge must not be parallel at this point in the code.\n // We know that \"a->b\" crosses the current cell row boundary, such that point \"b\" is beyond the boundary.\n // If \"b->c\" is parallel to X, then \"c->a\" must not be parallel and must cross the cell row boundary back:\n // a\n // |\\\n // -----|-\\--cell row boundary----\n // | \\\n // c---b\n // If \"b->c\" is not parallel to X and doesn't cross the cell row boundary,\n // then c->a must also not be parallel to X and must cross the cell boundary back,\n // since points \"a\" and \"c\" lie on different sides of the boundary and on different Y coordinates.\n //\n // Thus there is no need for \"parallel with X\" checks inside this condition branch.\n\n // Compute the X coordinate where edge C->A enters the current cell row\n const dir3X = aX - cX;\n const dir3Y = aY - cY;\n const t3Top = (cellRowYTop - cY) / dir3Y;\n const t3Bottom = (cellRowYBottom - cY) / dir3Y;\n const t3Enter = Math.min(t3Top, t3Bottom);\n const enter3X = cX + dir3X * t3Enter;\n\n boundarySubdivisionLeftCellX = Math.floor(Math.min(enter3X, exitX) / this._granularityCellSize) + 1;\n boundarySubdivisionRightCellX = Math.ceil(Math.max(enter3X, exitX) / this._granularityCellSize) - 1;\n isBoundaryLeftToRight = exitX < enter3X;\n }\n\n const boundaryY = dirY > 0 ? cellRowYBottom : cellRowYTop;\n if (isBoundaryLeftToRight) {\n // Left to right\n for (let cellX = boundarySubdivisionLeftCellX; cellX <= boundarySubdivisionRightCellX; cellX++) {\n const x = cellX * this._granularityCellSize;\n ring.push(this._vertexToIndex(x, boundaryY));\n }\n } else {\n // Right to left\n for (let cellX = boundarySubdivisionRightCellX; cellX >= boundarySubdivisionLeftCellX; cellX--) {\n const x = cellX * this._granularityCellSize;\n ring.push(this._vertexToIndex(x, boundaryY));\n }\n }\n }\n\n /**\n * Generates an outline for a given polygon, returns a list of arrays of line indices.\n */\n private _generateOutline(polygon: Array<Array<Point>>): Array<Array<number>> {\n const subdividedLines: Array<Array<number>> = [];\n for (const ring of polygon) {\n const line = subdivideVertexLine(ring, this._granularity, true);\n const pathIndices = this._pointArrayToIndices(line);\n // Points returned by subdivideVertexLine are \"path\" waypoints,\n // for example with indices 0 1 2 3 0.\n // We need list of individual line segments for rendering,\n // for example 0, 1, 1, 2, 2, 3, 3, 0.\n const lineIndices: Array<number> = [];\n for (let i = 1; i < pathIndices.length; i++) {\n lineIndices.push(pathIndices[i - 1]);\n lineIndices.push(pathIndices[i]);\n }\n subdividedLines.push(lineIndices);\n }\n return subdividedLines;\n }\n\n /**\n * Adds pole geometry if needed.\n * @param subdividedTriangles - Array of generated triangle indices, new pole geometry is appended here.\n */\n private _handlePoles(subdividedTriangles: Array<number>) {\n // Add pole vertices if the tile is at north/south mercator edge\n let north = false;\n let south = false;\n if (this._canonical) {\n if (this._canonical.y === 0) {\n north = true;\n }\n if (this._canonical.y === (1 << this._canonical.z) - 1) {\n south = true;\n }\n }\n if (north || south) {\n this._fillPoles(subdividedTriangles, north, south);\n }\n }\n\n /**\n * Checks the internal vertex buffer for all vertices that might lie on the special pole coordinates and shifts them by one unit.\n * Use for removing unintended pole vertices that might have been created during subdivision. After calling this function, actual pole vertices can be safely generated.\n */\n private _ensureNoPoleVertices() {\n const flattened = this._vertexBuffer;\n\n for (let i = 0; i < flattened.length; i += 2) {\n const vy = flattened[i + 1];\n if (vy === NORTH_POLE_Y) {\n // Move slightly down\n flattened[i + 1] = NORTH_POLE_Y + 1;\n }\n if (vy === SOUTH_POLE_Y) {\n // Move slightly down\n flattened[i + 1] = SOUTH_POLE_Y - 1;\n }\n }\n }\n\n /**\n * Generates a quad from an edge to a pole with the correct winding order.\n * Helper function used inside {@link _fillPoles}.\n * @param indices - Index array into which the geometry is generated.\n * @param i0 - Index of the first edge vertex.\n * @param i1 - Index of the second edge vertex.\n * @param v0x - X coordinate of the first edge vertex.\n * @param v1x - X coordinate of the second edge vertex.\n * @param poleY - The Y coordinate of the desired pole (NORTH_POLE_Y or SOUTH_POLE_Y).\n */\n private _generatePoleQuad(indices, i0, i1, v0x, v1x, poleY): void {\n const flip = (v0x > v1x) !== (poleY === NORTH_POLE_Y);\n\n if (flip) {\n indices.push(i0);\n indices.push(i1);\n indices.push(this._vertexToIndex(v0x, poleY));\n\n indices.push(i1);\n indices.push(this._vertexToIndex(v1x, poleY));\n indices.push(this._vertexToIndex(v0x, poleY));\n } else {\n indices.push(i1);\n indices.push(i0);\n indices.push(this._vertexToIndex(v0x, poleY));\n\n indices.push(this._vertexToIndex(v1x, poleY));\n indices.push(i1);\n indices.push(this._vertexToIndex(v0x, poleY));\n }\n }\n\n /**\n * Detects edges that border the north or south tile edge\n * and adds triangles that extend those edges to the poles.\n * Only run this function on tiles that border the poles.\n * Assumes that supplied geometry is clipped to the inclusive range of 0..EXTENT.\n * Mutates the supplies vertex and index arrays.\n * @param indices - Triangle indices. This array is appended with new primitives.\n * @param north - Whether to generate geometry for the north pole.\n * @param south - Whether to generate geometry for the south pole.\n */\n private _fillPoles(indices: Array<number>, north: boolean, south: boolean): void {\n const flattened = this._vertexBuffer;\n\n const northEdge = 0;\n const southEdge = EXTENT;\n\n const numIndices = indices.length;\n for (let primitiveIndex = 2; primitiveIndex < numIndices; primitiveIndex += 3) {\n const i0 = indices[primitiveIndex - 2];\n const i1 = indices[primitiveIndex - 1];\n const i2 = indices[primitiveIndex];\n const v0x = flattened[i0 * 2];\n const v0y = flattened[i0 * 2 + 1];\n const v1x = flattened[i1 * 2];\n const v1y = flattened[i1 * 2 + 1];\n const v2x = flattened[i2 * 2];\n const v2y = flattened[i2 * 2 + 1];\n\n if (north) {\n if (v0y === northEdge && v1y === northEdge) {\n this._generatePoleQuad(indices, i0, i1, v0x, v1x, NORTH_POLE_Y);\n }\n if (v1y === northEdge && v2y === northEdge) {\n this._generatePoleQuad(indices, i1, i2, v1x, v2x, NORTH_POLE_Y);\n }\n if (v2y === northEdge && v0y === northEdge) {\n this._generatePoleQuad(indices, i2, i0, v2x, v0x, NORTH_POLE_Y);\n }\n }\n if (south) {\n if (v0y === southEdge && v1y === southEdge) {\n this._generatePoleQuad(indices, i0, i1, v0x, v1x, SOUTH_POLE_Y);\n }\n if (v1y === southEdge && v2y === southEdge) {\n this._generatePoleQuad(indices, i1, i2, v1x, v2x, SOUTH_POLE_Y);\n }\n if (v2y === southEdge && v0y === southEdge) {\n this._generatePoleQuad(indices, i2, i0, v2x, v0x, SOUTH_POLE_Y);\n }\n }\n }\n }\n\n /**\n * Adds all vertices in the supplied flattened vertex buffer into the internal vertex buffer.\n */\n private _initializeVertices(flattened: Array<number>) {\n for (let i = 0; i < flattened.length; i += 2) {\n this._vertexToIndex(flattened[i], flattened[i + 1]);\n }\n }\n\n /**\n * Subdivides an input mesh. Imagine a regular square grid with the target granularity overlaid over the mesh - this is the subdivision's result.\n * Assumes a mesh of tile features - vertex coordinates are integers, visible range where subdivision happens is 0..8192.\n * @param polygon - The input polygon, specified as a list of vertex rings.\n * @param generateOutlineLines - When true, also generates line indices for outline of the supplied polygon.\n * @returns Vertex and index buffers with subdivision applied.\n */\n public subdividePolygonInternal(polygon: Array<Array<Point>>, generateOutlineLines: boolean): SubdivisionResult {\n if (this._used) {\n throw new Error('Subdivision: multiple use not allowed.');\n }\n this._used = true;\n\n // Initialize the vertex dictionary with input vertices since we will use all of them anyway\n const {flattened, holeIndices} = flatten(polygon);\n this._initializeVertices(flattened);\n\n // Subdivide triangles\n let subdividedTriangles: Array<number>;\n try {\n // At this point this._finalVertices is just flattened polygon points\n const earcutResult = earcut(flattened, holeIndices);\n const cut = this._convertIndices(flattened, earcutResult);\n subdividedTriangles = this._subdivideTrianglesScanline(cut);\n } catch (e) {\n console.error(e);\n }\n\n // Subdivide lines\n let subdividedLines: Array<Array<number>> = [];\n if (generateOutlineLines) {\n subdividedLines = this._generateOutline(polygon);\n }\n\n // Ensure no vertex has the special value used for pole vertices\n this._ensureNoPoleVertices();\n\n // Add pole geometry if needed\n this._handlePoles(subdividedTriangles);\n\n return {\n verticesFlattened: this._vertexBuffer,\n indicesTriangles: subdividedTriangles,\n indicesLineList: subdividedLines,\n };\n }\n\n /**\n * Sometimes the supplies vertex and index array has duplicate vertices - same coordinates that are referenced by multiple different indices.\n * That is not allowed for purposes of subdivision, duplicates are removed in `this.initializeVertices`.\n * This function converts the original index array that indexes into the original vertex array with duplicates\n * into an index array that indexes into `this._finalVertices`.\n * @param vertices - Flattened vertex array used by the old indices. This may contain duplicate vertices.\n * @param oldIndices - Indices into the old vertex array.\n * @returns Indices transformed so that they are valid indices into `this._finalVertices` (with duplicates removed).\n */\n private _convertIndices(vertices: Array<number>, oldIndices: Array<number>): Array<number> {\n const newIndices = [];\n for (let i = 0; i < oldIndices.length; i++) {\n const x = vertices[oldIndices[i] * 2];\n const y = vertices[oldIndices[i] * 2 + 1];\n newIndices.push(this._vertexToIndex(x, y));\n }\n return newIndices;\n }\n\n /**\n * Converts an array of points into an array of indices into the internal vertex buffer (`_finalVertices`).\n */\n private _pointArrayToIndices(array: Array<Point>): Array<number> {\n const indices = [];\n for (let i = 0; i < array.length; i++) {\n const p = array[i];\n indices.push(this._vertexToIndex(p.x, p.y));\n }\n return indices;\n }\n}\n\n/**\n * Subdivides a polygon to a given granularity. Intended for preprocessing geometry for the 'fill' and 'fill-extrusion' layer types.\n * All returned triangles have the counter-clockwise winding order.\n * @param polygon - An array of point rings that specify the polygon. The first ring is the polygon exterior, all subsequent rings form holes inside the first ring.\n * @param canonical - The canonical tile ID of the tile this polygon belongs to. Needed for generating special geometry for tiles that border the poles.\n * @param granularity - The subdivision granularity. If we assume tile EXTENT=8192, then a granularity of 2 will result in geometry being \"cut\" on each axis\n * divisible by 4096 (including outside the tile range, so -8192, -4096, or 12288...), granularity of 8 on axes divisible by 1024 and so on.\n * Granularity of 1 or lower results in *no* subdivision.\n * @param generateOutlineLines - When true, also generates index arrays for subdivided lines that form the outline of the supplied polygon. True by default.\n * @returns An object that contains the generated vertex array, triangle index array and, if specified, line index arrays.\n */\nexport function subdividePolygon(polygon: Array<Array<Point>>, canonical: CanonicalTileID, granularity: number, generateOutlineLines: boolean = true): SubdivisionResult {\n const subdivider = new Subdivider(granularity, canonical);\n return subdivider.subdividePolygonInternal(polygon, generateOutlineLines);\n}\n\n/**\n * Subdivides a line represented by an array of points. Mainly intended for preprocessing geometry for the 'line' layer type.\n * Assumes a line segment between each two consecutive points in the array.\n * Does not assume a line segment from last point to first point, unless `isRing` is set to `true`.\n * For example, an array of 4 points describes exactly 3 line segments.\n * @param linePoints - An array of points describing the line segments.\n * @param granularity - Subdivision granularity.\n * @param isRing - When true, an additional line segment is assumed to exist between the input array's last and first point.\n * @returns A new array of points of the subdivided line segments. The array may contain some of the original Point objects. If `isRing` is set to `true`, then this also includes the (subdivided) segment from the last point of the input array to the first point.\n *\n * @example\n * ```ts\n * const result = subdivideVertexLine([\n * new Point(0, 0),\n * new Point(8, 0),\n * new Point(0, 8),\n * ], EXTENT / 4, false);\n * // Results in an array of points with these (x, y) coordinates:\n * // 0, 0\n * // 4, 0\n * // 8, 0\n * // 4, 4\n * // 0, 8\n * ```\n *\n * @example\n * ```ts\n * const result = subdivideVertexLine([\n * new Point(0, 0),\n * new Point(8, 0),\n * new Point(0, 8),\n * ], EXTENT / 4, true);\n * // Results in an array of points with these (x, y) coordinates:\n * // 0, 0\n * // 4, 0\n * // 8, 0\n * // 4, 4\n * // 0, 8\n * // 0, 4\n * // 0, 0\n * ```\n */\nexport function subdivideVertexLine(linePoints: Array<Point>, granularity: number, isRing: boolean = false): Array<Point> {\n if (!linePoints || linePoints.length < 1) {\n return [];\n }\n\n if (linePoints.length < 2) {\n return [];\n }\n\n // Generate an extra line segment between the input array's first and last points,\n // but only if isRing=true AND the first and last points actually differ.\n const first = linePoints[0];\n const last = linePoints[linePoints.length - 1];\n const addLastToFirstSegment = isRing && (first.x !== last.x || first.y !== last.y);\n\n if (granularity < 2) {\n if (addLastToFirstSegment) {\n return [...linePoints, linePoints[0]];\n } else {\n return [...linePoints];\n }\n }\n\n const cellSize = Math.floor(EXTENT / granularity);\n const finalLineVertices: Array<Point> = [];\n\n finalLineVertices.push(new Point(linePoints[0].x, linePoints[0].y));\n\n // Iterate over all input lines\n const totalPoints = linePoints.length;\n const lastIndex = addLastToFirstSegment ? totalPoints : (totalPoints - 1);\n for (let pointIndex = 0; pointIndex < lastIndex; pointIndex++) {\n const linePoint0 = linePoints[pointIndex];\n const linePoint1 = pointIndex < (totalPoints - 1) ? linePoints[pointIndex + 1] : linePoints[0];\n const lineVertex0x = linePoint0.x;\n const lineVertex0y = linePoint0.y;\n const lineVertex1x = linePoint1.x;\n const lineVertex1y = linePoint1.y;\n\n const dirXnonZero = lineVertex0x !== lineVertex1x;\n const dirYnonZero = lineVertex0y !== lineVertex1y;\n\n if (!dirXnonZero && !dirYnonZero) {\n continue;\n }\n\n const dirX = lineVertex1x - lineVertex0x;\n const dirY = lineVertex1y - lineVertex0y;\n const absDirX = Math.abs(dirX);\n const absDirY = Math.abs(dirY);\n\n let lastPointX = lineVertex0x;\n let lastPointY = lineVertex0y;\n\n // Walk along the line segment from start to end. In every step,\n // find out the distance from start until the line intersects either the X-parallel or Y-parallel subdivision axis.\n // Pick the closer intersection, add it to the final line points and consider that point the new start of the line.\n // But also make sure the intersection point does not lie beyond the end of the line.\n // If none of the intersection points is closer than line end, add the endpoint to the final line and break the loop.\n\n while (true) {\n const nextBoundaryX = dirX > 0 ?\n ((Math.floor(lastPointX / cellSize) + 1) * cellSize) :\n ((Math.ceil(lastPointX / cellSize) - 1) * cellSize);\n const nextBoundaryY = dirY > 0 ?\n ((Math.floor(lastPointY / cellSize) + 1) * cellSize) :\n ((Math.ceil(lastPointY / cellSize) - 1) * cellSize);\n const axisDistanceToBoundaryX = Math.abs(lastPointX - nextBoundaryX);\n const axisDistanceToBoundaryY = Math.abs(lastPointY - nextBoundaryY);\n\n const axisDistanceToEndX = Math.abs(lastPointX - lineVertex1x);\n const axisDistanceToEndY = Math.abs(lastPointY - lineVertex1y);\n\n const realDistanceToBoundaryX = dirXnonZero ? axisDistanceToBoundaryX / absDirX : Number.POSITIVE_INFINITY;\n const realDistanceToBoundaryY = dirYnonZero ? axisDistanceToBoundaryY / absDirY : Number.POSITIVE_INFINITY;\n\n if ((axisDistanceToEndX <= axisDistanceToBoundaryX || !dirXnonZero) &&\n (axisDistanceToEndY <= axisDistanceToBoundaryY || !dirYnonZero)) {\n break;\n }\n\n if ((realDistanceToBoundaryX < realDistanceToBoundaryY && dirXnonZero) || !dirYnonZero) {\n // We hit the X cell boundary first\n // Always consider the X cell hit if Y dir is zero\n lastPointX = nextBoundaryX;\n lastPointY = lastPointY + dirY * realDistanceToBoundaryX;\n const next = new Point(lastPointX, Math.round(lastPointY));\n\n // Do not add the next vertex if it is equal to the last added vertex\n if (finalLineVertices[finalLineVertices.length - 1].x !== next.x ||\n finalLineVertices[finalLineVertices.length - 1].y !== next.y) {\n finalLineVertices.push(next);\n }\n } else {\n lastPointX = lastPointX + dirX * realDistanceToBoundaryY;\n lastPointY = nextBoundaryY;\n const next = new Point(Math.round(lastPointX), lastPointY);\n\n if (finalLineVertices[finalLineVertices.length - 1].x !== next.x ||\n finalLineVertices[finalLineVertices.length - 1].y !== next.y) {\n finalLineVertices.push(next);\n }\n }\n }\n\n const last = new Point(lineVertex1x, lineVertex1y);\n if (finalLineVertices[finalLineVertices.length - 1].x !== last.x ||\n finalLineVertices[finalLineVertices.length - 1].y !== last.y) {\n finalLineVertices.push(last);\n }\n }\n\n return finalLineVertices;\n}\n\n/**\n * Takes a polygon as an array of point rings, returns a flattened array of the X,Y coordinates of these points.\n * Also creates an array of hole indices. Both returned arrays are required for `earcut`.\n */\nfunction flatten(polygon: Array<Array<Point>>): {\n flattened: Array<number>;\n holeIndices: Array<number>;\n} {\n const holeIndices = [];\n const flattened = [];\n\n for (const ring of polygon) {\n if (ring.length === 0) {\n continue;\n }\n\n if (ring !== polygon[0]) {\n holeIndices.push(flattened.length / 2);\n }\n\n for (let i = 0; i < ring.length; i++) {\n flattened.push(ring[i].x);\n flattened.push(ring[i].y);\n }\n }\n\n return {\n flattened,\n holeIndices\n };\n}\n\n/**\n * Returns a new array of indices where all triangles have the counter-clockwise winding order.\n * @param flattened - Flattened vertex buffer.\n * @param indices - Triangle indices.\n */\nexport function fixWindingOrder(flattened: Array<number>, indices: Array<number>): Array<number> {\n const corrected = [];\n\n for (let i = 0; i < indices.length; i += 3) {\n const i0 = indices[i];\n const i1 = indices[i + 1];\n const i2 = indices[i + 2];\n\n const v0x = flattened[i0 * 2];\n const v0y = flattened[i0 * 2 + 1];\n const v1x = flattened[i1 * 2];\n const v1y = flattened[i1 * 2 + 1];\n const v2x = flattened[i2 * 2];\n const v2y = flattened[i2 * 2 + 1];\n\n const e0x = v1x - v0x;\n const e0y = v1y - v0y;\n const e1x = v2x - v0x;\n const e1y = v2y - v0y;\n\n const crossProduct = e0x * e1y - e0y * e1x;\n\n if (crossProduct > 0) {\n // Flip\n corrected.push(i0);\n corrected.push(i2);\n corrected.push(i1);\n } else {\n // Don't flip\n corrected.push(i0);\n corrected.push(i1);\n corrected.push(i2);\n }\n }\n\n return corrected;\n}\n\n/**\n * Triangulates a ring of vertex indices. Appends to the supplied array of final triangle indices.\n * @param vertexBuffer - Flattened vertex coordinate array.\n * @param ring - Ordered ring of vertex indices to triangulate.\n * @param leftmostIndex - The index of the leftmost vertex in the supplied ring.\n * @param finalIndices - Array of final triangle indices, into where the resulting triangles are appended.\n */\nexport function scanlineTriangulateVertexRing(vertexBuffer: Array<number>, ring: Array<number>, finalIndices: Array<number>): void {\n // Triangulate the ring\n // It is guaranteed to be convex and ordered\n if (ring.length === 0) {\n throw new Error('Subdivision vertex ring is empty.');\n }\n\n // Find the leftmost vertex in the ring\n let leftmostIndex = 0;\n let leftmostX = vertexBuffer[ring[0] * 2];\n for (let i = 1; i < ring.length; i++) {\n const x = vertexBuffer[ring[i] * 2];\n if (x < leftmostX) {\n leftmostX = x;\n leftmostIndex = i;\n }\n }\n\n // Traverse the ring in both directions from the leftmost vertex\n // Assume ring is in CCW order (to produce CCW triangles)\n const ringVertexLength = ring.length;\n let lastEdgeA = leftmostIndex;\n let lastEdgeB = (lastEdgeA + 1) % ringVertexLength;\n\n while (true) {\n const candidateIndexA = (lastEdgeA - 1) >= 0 ? (lastEdgeA - 1) : (ringVertexLength - 1);\n const candidateIndexB = (lastEdgeB + 1) % ringVertexLength;\n\n // Pick candidate, move edge\n const candidateAx = vertexBuffer[ring[candidateIndexA] * 2];\n const candidateAy = vertexBuffer[ring[candidateIndexA] * 2 + 1];\n const candidateBx = vertexBuffer[ring[candidateIndexB] * 2];\n const candidateBy = vertexBuffer[ring[candidateIndexB] * 2 + 1];\n const lastEdgeAx = vertexBuffer[ring[lastEdgeA] * 2];\n const lastEdgeAy = vertexBuffer[ring[lastEdgeA] * 2 + 1];\n const lastEdgeBx = vertexBuffer[ring[lastEdgeB] * 2];\n const lastEdgeBy = vertexBuffer[ring[lastEdgeB] * 2 + 1];\n\n let pickA = false;\n\n if (candidateAx < candidateBx) {\n pickA = true;\n } else if (candidateAx > candidateBx) {\n pickA = false;\n } else {\n // Pick the candidate that is more \"right\" of the last edge's line\n const ex = lastEdgeBx - lastEdgeAx;\n const ey = lastEdgeBy - lastEdgeAy;\n const nx = ey;\n const ny = -ex;\n const sign = (lastEdgeAy < lastEdgeBy) ? 1 : -1;\n // dot( (candidateA <-- lastEdgeA), normal )\n const aRight = ((candidateAx - lastEdgeAx) * nx + (candidateAy - lastEdgeAy) * ny) * sign;\n // dot( (candidateB <-- lastEdgeA), normal )\n const bRight = ((candidateBx - lastEdgeAx) * nx + (candidateBy - lastEdgeAy) * ny) * sign;\n if (aRight > bRight) {\n pickA = true;\n }\n }\n\n if (pickA) {\n // Pick candidate A\n const c = ring[candidateIndexA];\n const a = ring[lastEdgeA];\n const b = ring[lastEdgeB];\n if (c !== a && c !== b && a !== b) {\n finalIndices.push(b, a, c);\n }\n lastEdgeA--;\n if (lastEdgeA < 0) {\n lastEdgeA = ringVertexLength - 1;\n }\n } else {\n // Pick candidate B\n const c = ring[candidateIndexB];\n const a = ring[lastEdgeA];\n const b = ring[lastEdgeB];\n if (c !== a && c !== b && a !== b) {\n finalIndices.push(b, a, c);\n }\n lastEdgeB++;\n if (lastEdgeB >= ringVertexLength) {\n lastEdgeB = 0;\n }\n }\n\n if (candidateIndexA === candidateIndexB) {\n break; // We ran out of ring vertices\n }\n }\n}\n","import { SubdivisionGranularitySetting, SubdivisionGranularityExpression } from \"maplibre-gl/src/render/subdivision_granularity_settings\"\r\n\r\nconst granularitySettings = {\r\n globe: new SubdivisionGranularitySetting({\r\n fill: new SubdivisionGranularityExpression(128, 2),\r\n line: new SubdivisionGranularityExpression(512, 0),\r\n // Always keep at least some subdivision on raster tiles, etc,\r\n // otherwise they will be visibly warped at high zooms (before mercator transition).\r\n // This si not needed on fill, because fill geometry tends to already be\r\n // highly tessellated and granular at high zooms.\r\n tile: new SubdivisionGranularityExpression(128, 32),\r\n // Stencil granularity must never be higher than fill granularity,\r\n // otherwise we would get seams in the oceans at zoom levels where\r\n // stencil has higher granularity than fill.\r\n stencil: new SubdivisionGranularityExpression(128, 1),\r\n circle: 3\r\n })\r\n}\r\n\r\nexport { granularitySettings }","import { VectorTileset } from \"./VectorTileset\";\r\nimport * as MVT from '@mapbox/vector-tile'\r\nimport { IRenderLayer, ILayerVisualizer, RenderLayers, LayerVisualizers } from \"./layers\";\r\nimport { VectorTileRenderList } from \"./VectorTileRenderList\";\r\nimport { ISource } from \"./sources/ISource\";\r\nimport { EXTENT } from \"maplibre-gl/src/data/extent\";\r\nimport Point from \"@mapbox/point-geometry\";\r\nimport { subdivideVertexLine } from \"maplibre-gl/src/render/subdivision\";\r\nimport { granularitySettings } from \"./sources/granularitySettings\";\r\n\r\nlet tileDepthRenderSate = null\r\nlet nextTileKey = 0\r\nlet levelZeroMaximumGeometricError = null\r\n/**\r\n * 计算指定LOD层级的最大几何误差,相当于动态计算3DTiles中geometricError,只是形瓦片的几何误差是一个层级的所有瓦片都相同(rectangle大小都一样)\r\n * @param {number} z 瓦片层级(整数,不是地图的缩放级别)\r\n * @param {Cesium.TilingScheme} tilingScheme \r\n * @returns \r\n */\r\nfunction getLevelMaximumGeometricError(z, tilingScheme) {\r\n if (levelZeroMaximumGeometricError === null) {\r\n levelZeroMaximumGeometricError = Cesium.TerrainProvider.getEstimatedLevelZeroGeometricErrorForAHeightmap(\r\n tilingScheme.ellipsoid,\r\n 128,\r\n tilingScheme.getNumberOfXTilesAtLevel(0)\r\n );\r\n }\r\n return levelZeroMaximumGeometricError / (1 << z);\r\n}\r\n\r\n/**\r\n * LOD调度重要参数SSE的计算函数,从Cesium地形调度模块中提取出来的代码,调度逻辑和地形瓦片的一致\r\n * @param {Cesium.FrameState} frameState \r\n * @param {VectorTileLOD} tile \r\n * @returns \r\n */\r\nfunction screenSpaceError(frameState, tile) {\r\n const maxGeometricError = getLevelMaximumGeometricError(\r\n tile.z, tile.tilingScheme\r\n );\r\n\r\n const distance2 = tile.distanceToCamera;\r\n const height = frameState.context.drawingBufferHeight;\r\n const sseDenominator = frameState.camera.frustum.sseDenominator;\r\n let error = maxGeometricError * height / (distance2 * sseDenominator);\r\n if (frameState.fog.enabled) {\r\n error -= Cesium.Math.fog(distance2, frameState.fog.density) * frameState.fog.sse;\r\n }\r\n error /= frameState.pixelRatio;\r\n return error;\r\n}\r\n\r\nfunction initConstants() {\r\n if (tileDepthRenderSate !== null) return\r\n\r\n tileDepthRenderSate = Cesium.RenderState.fromCache({\r\n id: 'vt_tile-depth',\r\n blending: Cesium.BlendingState.DISABLED,\r\n depthTest: {\r\n enabled: true\r\n },\r\n depthMask: true,\r\n cull: {\r\n enabled: true\r\n },\r\n stencilMask: Cesium.StencilConstants.CESIUM_3D_TILE_MASK,\r\n stencilTest: {\r\n backFunction: 519,\r\n backOperation: { fail: 7680, zFail: 7680, zPass: 7681 },\r\n enabled: true,\r\n frontFunction: 519,\r\n frontOperation: { fail: 7680, zFail: 7680, zPass: 7681 },\r\n mask: 128,\r\n reference: 128\r\n },\r\n colorMask: {\r\n red: false,\r\n green: false,\r\n blue: false,\r\n alpha: false\r\n }\r\n })\r\n}\r\n\r\nexport class VectorTileLOD {\r\n constructor(options) {\r\n initConstants()\r\n\r\n this.x = options.x\r\n this.y = options.y\r\n this.z = options.z\r\n /**暂时用不到,但是还是记录父级瓦片 */\r\n this.parent = options.parent\r\n this.children = []\r\n\r\n /**@type {Cesium.TilingScheme} */\r\n this.tilingScheme = options.tilingScheme\r\n this.rectangle = this.tilingScheme.tileXYToRectangle(this.x, this.y, this.z)\r\n /**\r\n * Cesium.TileBoundingRegion 不是公开的API,但是可以从Cesium地形调度相关模块源码学习,\r\n */\r\n this.tileBoundingRegion = new Cesium.TileBoundingRegion({\r\n rectangle: this.rectangle,\r\n minimumHeight: 0,\r\n maximumHeight: 0,\r\n ellipsoid: this.tilingScheme.ellipsoid,\r\n computeBoundingVolumes: true\r\n })\r\n\r\n /**@type {IRenderLayer[]} */\r\n this.layers = []\r\n /**@type {ILayerVisualizer[]} */\r\n this.visualizers = []\r\n /**\r\n * 保存pbf/mvt文件解析结果,准备创建图层(要素过滤)时候进一步读取要素,创建图层渲染对象时读取要素几何数据\r\n * @type {Record<string,MVT.VectorTile>}\r\n */\r\n this.sources = {}\r\n\r\n this.tileId = null\r\n /**\r\n * 记录最近一次访问时间(用渲染帧数表示),用于筛选过期瓦片\r\n */\r\n this.lastVisitTime = 0\r\n /**\r\n * 瓦片调度状态\r\n * @type {'none'|'done'|'error'}\r\n */\r\n this.state = 'none'\r\n\r\n this.tileId = {\r\n x: this.x, y: this.y, z: this.z,\r\n key: nextTileKey++,\r\n color: Cesium.Color.fromRgba(nextTileKey - 1),\r\n tileColor: Cesium.Color.fromRandom({\r\n alpha: 1\r\n })\r\n }\r\n\r\n const size = EXTENT * Math.pow(2, this.z),\r\n x0 = EXTENT * this.x,\r\n y0 = EXTENT * this.y;\r\n this.transformPoint = function (x, y, lonlat) {\r\n lonlat[0] = (x + x0) * 360 / size - 180\r\n lonlat[1] = 360 / Math.PI * Math.atan(Math.exp((1 - (y + y0) * 2 / size) * Math.PI)) - 90\r\n return lonlat //[x, y]\r\n }\r\n }\r\n\r\n createChildren() {\r\n var tiles = [{\r\n x: this.x * 2,\r\n y: this.y * 2 + 1,\r\n z: this.z + 1\r\n }, {\r\n x: this.x * 2 + 1,\r\n y: this.y * 2 + 1,\r\n z: this.z + 1,\r\n }, {\r\n x: this.x * 2,\r\n y: this.y * 2,\r\n z: this.z + 1,\r\n }, {\r\n x: this.x * 2 + 1,\r\n y: this.y * 2,\r\n z: this.z + 1,\r\n }]\r\n\r\n for (const { x, y, z } of tiles) {\r\n var child = new VectorTileLOD({\r\n x, y, z,\r\n tilingScheme: this.tilingScheme,\r\n parent: this\r\n })\r\n this.children.push(child)\r\n }\r\n }\r\n\r\n /**\r\n * @param {Cesium.FrameState} frameState \r\n * @param {{visitChildren(child:VectorTileLOD):void;accept(tile:VectorTileLOD):void}} visitor \r\n * @returns \r\n */\r\n visit(frameState, visitor) {\r\n const tileBoundingRegion = this.tileBoundingRegion\r\n\r\n //相机视锥剔除\r\n this.distanceToCamera = tileBoundingRegion.distanceToCamera(frameState)\r\n this.visibility = frameState.cullingVolume.computeVisibility(tileBoundingRegion)\r\n if (this.visibility == Cesium.Intersect.OUTSIDE) {\r\n return\r\n }\r\n\r\n //性能优化:还可以进行地平线剔除更多被地球完全遮挡的瓦片\r\n\r\n const maxSSE = frameState.maximumScreenSpaceError\r\n const sse = screenSpaceError(frameState, this)\r\n if (sse >= maxSSE) {//继续遍历子级瓦片\r\n visitor.visitChildren(this)\r\n }\r\n else {//使用当前瓦片渲染\r\n visitor.accept(this)\r\n }\r\n }\r\n\r\n /**\r\n * @param {VectorTileset} tileset \r\n */\r\n async getSources(tileset) {\r\n /**@type {Record<string,ISource>} */\r\n const sourcesToLoad = {}\r\n const style = tileset._styleJson\r\n\r\n for (const styleLayer of style.layers) {\r\n const sourceId = styleLayer.source\r\n const source = tileset.sources[sourceId]\r\n if (source && !sourcesToLoad[sourceId]) {\r\n sourcesToLoad[sourceId] = source\r\n }\r\n }\r\n\r\n for (const sourceId in sourcesToLoad) {\r\n const source = sourcesToLoad[sourceId]\r\n try {\r\n const tileData = await source.requestTile(this.x, this.y, this.z, tileset)\r\n if (tileData) {\r\n this.sources[sourceId] = tileData\r\n }\r\n } catch (err) { }\r\n }\r\n\r\n tileset.numLoading--\r\n this.state = 'loaded'\r\n }\r\n\r\n /**\r\n * @param {Cesium.FrameRateMonitor} frameState \r\n * @param {VectorTileset} tileset \r\n */\r\n async createRenderLayers(frameState, tileset) {\r\n const sources = this.sources\r\n const styleLayers = tileset._styleLayers\r\n const renderLayers = this.layers\r\n const visualizers = this.visualizers\r\n /**@type {Record<string,ILayerVisualizer>} */\r\n const visualizerMap = {}\r\n\r\n for (const styleLayer of styleLayers) {\r\n const sourceVectorTile = sources[styleLayer.source]\r\n /**\r\n * 按图层类型获取对应的渲染图层类\r\n * @type {typeof IRenderLayer} \r\n */\r\n const RenderLayer = RenderLayers[styleLayer.type]\r\n const LayerVisualizer = LayerVisualizers[styleLayer.type]\r\n const isBackgroundLayer = styleLayer.type === 'background'\r\n if ((!isBackgroundLayer && !sourceVectorTile) || !RenderLayer) continue\r\n\r\n const features = []\r\n if (!isBackgroundLayer) {\r\n const sourceType = styleLayer.source && tileset.sources[styleLayer.source].type\r\n const sourceLayer = sourceType == 'geojson' ? '_geojsonTileLayer' : styleLayer.sourceLayer\r\n const vectorTileLayer = sourceVectorTile.layers[sourceLayer]\r\n if (!vectorTileLayer) continue\r\n\r\n //读取要素,并根据图层样式filter表达式进行过滤\r\n //性能优化:同一帧读取和过滤大量要素,耗时较长,应该将其移到Web Worker\r\n const featureCount = vectorTileLayer.length\r\n for (let i = 0; i < featureCount; i++) {\r\n //读取要素\r\n const feature = vectorTileLayer.feature(i)\r\n //过滤要素\r\n if (styleLayer.filter && !styleLayer.filter.filter({ zoom: this.z }, feature)) {\r\n continue\r\n }\r\n features.push(feature)\r\n }\r\n if (!features.length) continue\r\n }\r\n\r\n //创建渲染图层\r\n const renderLayer = new RenderLayer(features, styleLayer, this)\r\n renderLayers.push(renderLayer)\r\n\r\n //将渲染图层分配到对应类型的图层渲染器,图层渲染器应实现如下功能,以提升渲染性能:\r\n //1、合批创建几何体、批次表和 DrawCommand;\r\n //2、克隆合批DrwaCommand,创建副本,通过offset和count指定图层的绘制范围。\r\n if (LayerVisualizer) {\r\n let visualizer = visualizerMap[styleLayer.type]\r\n if (!visualizer) {\r\n visualizer = new LayerVisualizer(this)\r\n visualizerMap[styleLayer.type] = visualizer\r\n visualizers.push(visualizer)\r\n }\r\n visualizer.addLayer(features, renderLayer, frameState, tileset)\r\n }\r\n }\r\n\r\n this.state = 'ready'\r\n }\r\n\r\n /**\r\n * @param {Cesium.FrameState} frameState \r\n * @param {VectorTileRenderList} renderList \r\n * @param {VectorTileset} tileset \r\n */\r\n update(frameState, renderList, tileset) {\r\n // 这里构建的 primitive 有如下用途:\r\n // 1. showTileColor 设置为 true 时,展示瓦片范围,验证LOD调度效果 \r\n // 2. 生成绘制瓦片 id 的 DrawCommand,在 VectorTileset 中实时更新瓦片id纹理,实现瓦片边界精准裁剪\r\n\r\n if (!this.primitive) {\r\n\r\n this.primitive = new Cesium.Primitive({\r\n geometryInstances: new Cesium.GeometryInstance({\r\n geometry: new Cesium.RectangleGeometry({\r\n rectangle: this.rectangle\r\n })\r\n }),\r\n compressVertices: false,\r\n asynchronous: false,\r\n appearance: new Cesium.MaterialAppearance({\r\n flat: true,\r\n translucent: false,\r\n material: Cesium.Material.fromType('Color', {\r\n color: Cesium.Color.fromAlpha(this.tileId.tileColor, 0.25)\r\n }),\r\n renderState: {\r\n blending: Cesium.BlendingState.ALPHA_BLEND,\r\n depthMask: false,\r\n depthTest: {\r\n enabled: true\r\n },\r\n cull: {\r\n enabled: false\r\n }\r\n }\r\n })\r\n })\r\n this.primitive.name = '_tile-color_'\r\n }\r\n\r\n const tileComandList = this.commandList || []\r\n const tileIdCommands = this.tileIdCommands || []\r\n const tileDepthCommands = this.tileDepthCommands || []\r\n\r\n if (!tileComandList.length) {\r\n const preCommandList = frameState.commandList\r\n frameState.commandList = tileComandList\r\n\r\n this.primitive.update(frameState)\r\n\r\n if (tileComandList.length) {\r\n\r\n const tileIdColor = this.tileId.color\r\n for (const tileComand of tileComandList) {\r\n tileComand.pass = Cesium.Pass.CESIUM_3D_TILE\r\n\r\n const tileIdCommand = Cesium.DrawCommand.shallowClone(tileComand)\r\n tileIdCommand.renderState = Cesium.RenderState.fromCache({\r\n id: 'tileId',\r\n blending: {\r\n enabled: false\r\n },\r\n depthTest: {\r\n enabled: false\r\n },\r\n depthMask: true,\r\n cull: {\r\n enabled: true\r\n }\r\n })\r\n tileIdCommand.layerType = 'tile-id'\r\n tileIdCommand.uniformMap = {\r\n ...tileComand.uniformMap\r\n }\r\n tileIdCommand.uniformMap.color_0 = function () {\r\n return tileIdColor\r\n }\r\n tileIdCommands.push(tileIdCommand)\r\n // 浅克隆一个副本,renderState替换成只写入深度和开启模板测试的版本,以支持Entity和GroundPrimitive等贴地对象\r\n const tileDepthCommand = Cesium.DrawCommand.shallowClone(tileComand)\r\n tileDepthCommand.pass = Cesium.Pass.CESIUM_3D_TILE\r\n tileDepthCommand.renderState = tileDepthRenderSate\r\n tileDepthCommands.layerType = 'tile-depth'\r\n tileDepthCommands.push(tileDepthCommand)\r\n }\r\n this.tileIdCommands = tileIdCommands\r\n this.tileDepthCommands = tileDepthCommands\r\n }\r\n\r\n this.commandList = tileComandList\r\n frameState.commandList = preCommandList\r\n }\r\n\r\n //瓦片id纹理\r\n for (const tileIdCommand of tileIdCommands) {\r\n renderList.tileIdCommands.push(tileIdCommand)\r\n }\r\n //瓦片范围\r\n if (tileset.showTileColor && tileComandList.length) {\r\n renderList.tileCommands.push(...tileComandList)\r\n }\r\n //最后将瓦片深度写入主深度缓冲区,这样才能使Entity和GroundPrimitive等贴地对象能贴合瓦片内的矢量要素\r\n if (tileDepthCommands.length) {\r\n renderList.tileCommands.push(...tileDepthCommands)\r\n }\r\n\r\n //更新瓦片状态,根据状态执行不同的处理过程\r\n\r\n //请求瓦片数据,解析pbf/mvt文件\r\n if (this.state == 'none' && tileset.numLoading < 1) {\r\n tileset.numLoading++\r\n this.state = 'loading'\r\n this.getSources(tileset)\r\n }\r\n\r\n //创建渲染图层实例\r\n if (this.state === 'loaded' && tileset.numInitializing < 1) {\r\n this.state = 'initializing'\r\n tileset.numInitializing++\r\n this.createRenderLayers(frameState, tileset)\r\n }\r\n\r\n if (this.state === 'ready') {\r\n //更新图层渲染器\r\n for (const visualizer of this.visualizers) {\r\n visualizer.update(frameState, tileset)\r\n }\r\n //将渲染图层追加到相应的渲染队列(渲染队列内部按图层id分组,确保不同瓦片的同一个id图层都在一组内,然后按图层顺序逐组渲染)\r\n for (const layer of this.layers) {\r\n renderList.push(layer)\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * 卸载瓦片,当瓦片过期(不可见,且符合其他过期规则)时,释放pbf/mvt解析数据、图层渲染对象等资源,重置瓦片状态\r\n */\r\n unload() {\r\n //释放用于展示瓦片范围的primitive\r\n if (this.primitive) {\r\n this.primitive.destroy()\r\n this.primitive = null\r\n }\r\n this.tileGeometry = null\r\n\r\n //清空瓦片克隆的 DrawCommand,不需要手动释放,相关资源在 primitive.destroy 执行时已经释放\r\n if (this.commandList) {\r\n this.commandList.length = 0\r\n }\r\n if (this.tileIdCommands) {\r\n this.tileIdCommands.length = 0\r\n }\r\n if (this.tileDepthCommands) {\r\n this.tileDepthCommands.length = 0\r\n }\r\n\r\n //销毁渲染图层,释放图层渲染资源\r\n for (const visualizer of this.visualizers) {\r\n visualizer.destroy()\r\n }\r\n this.visualizers.length = 0\r\n\r\n for (const layer of this.layers) {\r\n layer.destroy()\r\n }\r\n this.layers.length = 0\r\n\r\n //释放pbf/mvt解析数据\r\n this.sources = {}\r\n\r\n //重置瓦片状态\r\n this.state = 'none'\r\n }\r\n\r\n /**\r\n * 销毁瓦片,释放所有资源\r\n */\r\n destroy() {\r\n this.unload()\r\n\r\n this.tileId = null\r\n this.tilingScheme = null\r\n this.parent = null\r\n if (this.children) {\r\n for (const child of this.children) {\r\n child.destroy()\r\n }\r\n this.children.length = 0\r\n this.children = null\r\n }\r\n }\r\n}","import { VectorTileLOD } from \"./VectorTileLOD\"\r\nimport { StyleLayer } from \"./style/StyleLayer\"\r\nimport './layers/index'\r\nimport { VectorTileRenderList } from \"./VectorTileRenderList\"\r\nimport { Sources } from \"./sources\"\r\nimport { ISource } from \"./sources/ISource\"\r\nimport { warnOnce } from \"maplibre-gl/src/util/util\"\r\n\r\nexport class VectorTileset {\r\n /**\r\n * @param {object} options \r\n * @param {string|import('@maplibre/maplibre-gl-style-spec').StyleSpecification} options.style\r\n * @param {boolean} [options.showTileColor=false]\r\n */\r\n constructor(options) {\r\n this.maximumLevel = 24\r\n this.show = true\r\n this.showTileColor = !!options.showTileColor\r\n this.ready = false\r\n this.tilingScheme = new Cesium.WebMercatorTilingScheme()\r\n\r\n this.readyEvent = new Cesium.Event()\r\n this.errorEvent = new Cesium.Event()\r\n\r\n this._styleJson = null\r\n this._style = options.style\r\n this._rootTiles = []\r\n this._cacheTiles = []\r\n this._tilesToRender = []\r\n /**@type {StyleLayer[]} */\r\n this._styleLayers = []\r\n /**@type {VectorTileRenderList} */\r\n this._renderList = new VectorTileRenderList(this._styleLayers)\r\n this.numLoading = 0\r\n this.numInitializing = 0\r\n /**@type {Cesium.Texture} */\r\n this.tileIdTexture = null\r\n\r\n requestAnimationFrame(() => {\r\n this.init()\r\n })\r\n }\r\n\r\n async init() {\r\n let style = this._style\r\n if (!style) {\r\n this.errorEvent.raiseEvent(new Error('请传入 style 参数'))\r\n return\r\n }\r\n\r\n this.path = ''\r\n if (typeof style == 'string') {\r\n this.path = style.split('/').slice(0, -1).join('/')\r\n if (this.path) this.path += '/'\r\n style = await Cesium.Resource.fetchJson(style)\r\n }\r\n\r\n //初始化数据源\r\n\r\n /** @type {{[sourceId:string]:ISource}}*/\r\n this.sources = {}\r\n for (const sourceId in style.sources) {\r\n /**@type {import('@maplibre/maplibre-gl-style-spec').SourceSpecification} */\r\n const sourceParams = style.sources[sourceId]\r\n const SourceCls = Sources[sourceParams.type]\r\n if (SourceCls) {\r\n this.sources[sourceId] = new SourceCls(sourceParams, this.path)\r\n try {\r\n await this.sources[sourceId].init()\r\n this.maximumLevel = Math.min(sourceParams.maxzoom || 24, this.maximumLevel)\r\n } catch (err) {\r\n this.errorEvent.raiseEvent(err)\r\n }\r\n }\r\n }\r\n\r\n //初始化样式图层\r\n for (let i = 0; i < style.layers.length; i++) {\r\n this._styleLayers[i] = new StyleLayer(style.layers[i])\r\n }\r\n\r\n //创建顶级瓦片LOD\r\n const numX = this.tilingScheme.getNumberOfXTilesAtLevel(0)\r\n const numY = this.tilingScheme.getNumberOfYTilesAtLevel(0)\r\n let i = 0\r\n for (let y = 0; y < numY; y++) {\r\n for (let x = 0; x < numX; x++) {\r\n var tile = new VectorTileLOD({\r\n parent: this, x, y, z: 0,\r\n tilingScheme: this.tilingScheme\r\n })\r\n tile.createChildren()\r\n this._rootTiles[i++] = tile\r\n }\r\n }\r\n\r\n //初始化渲染队列\r\n this._renderList.init()\r\n\r\n this._styleJson = style\r\n this.ready = true\r\n this.readyEvent.raiseEvent(this)\r\n }\r\n\r\n //更新瓦片id纹理,用于裁剪超出瓦片边界的像素\r\n executeTileIdCommands(frameState) {\r\n const tileIdCommands = this._renderList.tileIdCommands\r\n\r\n if (tileIdCommands.length > 0) {\r\n const context = frameState.context\r\n /**@type {Cesium.FrameBuffer} */\r\n let tileIdFbo = this._tileIdFbo\r\n if (!tileIdFbo) {\r\n tileIdFbo = new Cesium.FramebufferManager({\r\n depthStencil: true,\r\n supportsDepthTexture: true,\r\n })\r\n this._tileIdFbo = tileIdFbo\r\n this._idClearCommand = new Cesium.ClearCommand({\r\n color: new Cesium.Color(0.0, 0.0, 0.0, 0.0),\r\n depth: 1.0,\r\n stencil: 0.0,\r\n })\r\n }\r\n const pixelDatatype = context.floatingPointTexture\r\n ? Cesium.PixelDatatype.FLOAT\r\n : Cesium.PixelDatatype.UNSIGNED_BYTE;\r\n const width = context.drawingBufferWidth\r\n const height = context.drawingBufferHeight\r\n tileIdFbo.update(context, width, height, 1, pixelDatatype)\r\n tileIdFbo.clear(context, this._idClearCommand)\r\n\r\n const framebuffer = tileIdFbo.framebuffer\r\n for (const tileIdCommand of tileIdCommands) {\r\n tileIdCommand.framebuffer = framebuffer\r\n tileIdCommand.execute(context)\r\n }\r\n\r\n this.tileIdTexture = tileIdFbo.getColorTexture(0)\r\n }\r\n }\r\n\r\n update(frameState) {\r\n if (!this.ready || !this.show) return\r\n\r\n if (frameState.context.webgl2) {\r\n warnOnce('webgl2模式下贴地线面的支持将导致性能下降')\r\n }\r\n\r\n const renderList = this._renderList\r\n //清空渲染队列\r\n renderList.beginFrame()\r\n\r\n this.numInitializing = 0\r\n\r\n /**@type {Cesium.Globe} */\r\n const scene = frameState.camera._scene\r\n const globe = scene.globe\r\n const globeSuspendLodUpdate = globe._surface._debug.suspendLodUpdate\r\n this.scene = scene\r\n\r\n // 获取可见瓦片\r\n // 优化:采用更高效的LOD调度算法,获取当前帧实际可渲染到屏幕的瓦片,避免出现瓦片层级切换时候出现闪烁\r\n\r\n /**@type {VectorTileLOD[]} */\r\n const tilesToRender = globeSuspendLodUpdate ? this._tilesToRender : getTilesToRender(frameState, this)\r\n\r\n //瓦片排序,决定瓦片加载瓦片数据、初始化的优先级\r\n //优化:采用更精细、高效的优先级策略\r\n if (!globeSuspendLodUpdate) {\r\n tilesToRender.sort((a, b) => a.distanceToCamera - b.distanceToCamera)\r\n }\r\n\r\n //更新瓦片状态:请求瓦片数据,创建渲染图层,初始化等\r\n for (const tile of tilesToRender) {\r\n tile.lastVisitTime = frameState.frameNumber\r\n tile.expired = false\r\n tile.update(frameState, renderList, this)\r\n }\r\n\r\n //渲染图层分组、排序\r\n const orderedRenderLayers = renderList.getList()\r\n //获取渲染命令(DrawCommand),渲染图层内部可以使用Primitive、PolylineCollection、LabelCollection、BillboardCollection等API,\r\n //也可以自定义DrawCommand\r\n for (const renderLayer of orderedRenderLayers) {\r\n renderLayer.update(frameState, this)\r\n }\r\n //瓦片颜色、深度\r\n frameState.commandList.push(...renderList.tileCommands)\r\n\r\n this.executeTileIdCommands(frameState)\r\n\r\n //释放过期瓦片\r\n //优化:使用更高效的内存缓存管理策略\r\n const expiredTiles = []\r\n for (const cacheTile of this._cacheTiles) {\r\n if (cacheTile.lastVisitTime < frameState.frameNumber) {\r\n if (!cacheTile.expired) expiredTiles.push(cacheTile)\r\n }\r\n }\r\n expiredTiles.sort((a, b) => a.lastVisitTime - b.lastVisitTime)\r\n if (expiredTiles.length > 100) {\r\n for (const expiredTile of expiredTiles) {\r\n expiredTile.unload()\r\n expiredTile.expired = true\r\n if (expiredTiles.length <= 50) break\r\n }\r\n }\r\n }\r\n\r\n destroy() {\r\n const scene = this.scene\r\n const rootTiles = this._rootTiles\r\n this.scene = null\r\n if (scene && scene.primitives.contains(this)) {\r\n scene.primitives.remove(this)\r\n }\r\n\r\n if (rootTiles) {\r\n for (const tile of rootTiles) {\r\n tile.destroy()\r\n }\r\n rootTiles.length = 0\r\n this._rootTiles = null\r\n }\r\n if (this._cacheTiles) {\r\n this._cacheTiles.length = 0\r\n this._cacheTiles = null\r\n }\r\n\r\n if (this.sources) {\r\n for (const key in this.sources) {\r\n if (Object.hasOwnProperty.call(this.sources, key)) {\r\n const source = this.sources[key];\r\n source.destroy()\r\n }\r\n }\r\n this.sources = null\r\n }\r\n this._styleLayers = null\r\n\r\n if (this._renderList) {\r\n this._renderList.destroy()\r\n this._renderList = null\r\n }\r\n\r\n if (this._tilesToRender) {\r\n this._tilesToRender.length = 0\r\n this._tilesToRender = null\r\n }\r\n\r\n if (this._tileIdFbo) {\r\n this._tileIdFbo.destroy()\r\n this.tileIdTexture = null\r\n this._tileIdFbo = null\r\n this._idClearCommand = null\r\n }\r\n\r\n this._styleJson = null\r\n }\r\n\r\n isDestroyed() {\r\n return false\r\n }\r\n}\r\n\r\n/**\r\n * 遍历LOD四叉树,获取所有可见瓦片\r\n * @param {Cesium.FrameState} frameState \r\n * @param {VectorTileset} tileset \r\n * @returns \r\n */\r\nfunction getTilesToRender(frameState, tileset) {\r\n const queue = [\r\n ...tileset._rootTiles\r\n ]\r\n const tilesToRender = tileset._tilesToRender\r\n const visitor = {\r\n //当see大于阈值,继续查找子级瓦片\r\n visitChildren(tile) {\r\n if (tile.z >= tileset.maximumLevel) {\r\n return tilesToRender.push(tile)\r\n }\r\n\r\n if (tile.children.length == 0) {\r\n tile.createChildren()\r\n for (const child of tile.children) {\r\n tileset._cacheTiles.push(child)\r\n }\r\n }\r\n for (const child of tile.children) {\r\n queue.push(child)\r\n }\r\n },\r\n //否则使用当前瓦片填充视口\r\n accept(tile) {\r\n tilesToRender.push(tile)\r\n }\r\n }\r\n\r\n tilesToRender.length = 0\r\n\r\n do {\r\n const tile = queue.shift()\r\n tile.visit(frameState, visitor)\r\n } while (queue.length > 0);\r\n\r\n return tilesToRender\r\n}","import * as MVT from '@mapbox/vector-tile'\r\nimport { StyleLayer } from '../style/StyleLayer'\r\nimport { VectorTileset } from '../VectorTileset'\r\nimport { VectorTileLOD } from '../VectorTileLOD'\r\n\r\n/**\r\n * 渲染要素接口,对应数据要素中的一个图形(例如 MultiLineString 中的1个多段线)\r\n */\r\nexport class IRenderFeature {\r\n constructor() {\r\n //如下2个属性用于表达式取值\r\n this.id = null\r\n this.properties = {}\r\n\r\n //如下2个属性用于同步图层样式\r\n this.batchId = 0\r\n this.featureId = 0\r\n\r\n //可选,批量构建几何体可能需要临时存储,创建结束后应及时释放\r\n this.coordinates = []\r\n }\r\n}\r\n\r\n/**\r\n * 渲染图层基类,定义渲染图层的通用属性和方法(更新、销毁)\r\n */\r\nexport class IRenderLayer {\r\n /**\r\n * 构造渲染图层实例。注意:该构造函数由VectorTileset调用,请勿在其他模块直接调用\r\n * @param {MVT.VectorTileFeature[]} sourceFeatures \r\n * @param {StyleLayer} styleLayer \r\n * @param {VectorTileLOD} tile \r\n */\r\n constructor(sourceFeatures, styleLayer, tile) {\r\n /**@type {MVT.VectorTileFeature[]} */\r\n this.sourceFeatures = sourceFeatures\r\n /**@type {StyleLayer} */\r\n this.style = styleLayer\r\n /**@type {VectorTileLOD} */\r\n this.tile = tile\r\n /**\r\n * @type {IRenderFeature[]}\r\n */\r\n this.features = []\r\n\r\n //如下5个属性是图层渲染器专用,未定义相应类型图层渲染器的可以忽略\r\n /**\r\n * 图层渲染器构造几何体实例过程中,记录当前图层第一个实例的索引,这个索引与批次表及几何体顶点数组中的的batchId一致。\r\n * 注意:该属性是针对图层渲染器设计,未定义相应类型图层渲染器的可以忽略\r\n * @type {number}\r\n */\r\n this.firstBatchId = -1\r\n /**\r\n * 图层渲染器构造几何体实例过程中,记录当前图层最后一个实例的索引,这个索引与批次表及几何体顶点数组中的的batchId一致\r\n * 注意:该属性是针对图层渲染器设计,未定义相应类型图层渲染器的可以忽略\r\n * @type {number}\r\n */\r\n this.lastBatchId = -1\r\n /**\r\n * 图层渲染器构造绘图命令后,根据 firstBatchId 、 lastBatchId 、几何体顶点数组中的 batchId 计算当前图层的绘制范围,\r\n * 绘制范围用几何体的起始索引和索引数量表示,对应绘图命令中的offset和count,由于 Cesium 合批构造几何体的结果仍然可能是多个几何体,\r\n * 所以这里用数组存储起始索引(offset)部分,与合批构造结果一一对应。\r\n * 注意:该属性是针对图层渲染器设计,未定义相应类型图层渲染器的可以忽略\r\n */\r\n this.offsets = []\r\n /**\r\n * 这里用数组存储索引数量(count)部分,与合批构造结果一一对应。详细说明同 offsets 注释\r\n * 注意:该属性是针对图层渲染器设计,未定义相应类型图层渲染器的可以忽略\r\n */\r\n this.counts = []\r\n /**\r\n * 这里用数组存储渲染器分配到图层的绘图命令(DrawCommand)副本,与合批构造结果一一对应。详细说明同 offsets 注释。\r\n */\r\n this.commandList = []\r\n }\r\n\r\n get id() {\r\n return this.style.id\r\n }\r\n\r\n get type() {\r\n return this.style.type\r\n }\r\n\r\n /**\r\n * 更渲染图层,可在该方法内实现绘图命令构建、动态样式更新等图层渲染相关功能。该方法可以被子类重写或复用,内部从 commandList 属性获取绘图命令(DrawCommand)并加入 frameState.commandList,完成图层渲染对象到Cesium渲染管线的连接 \r\n * @param {Cesium.FrameState} frameState \r\n * @param {VectorTileset} tileset \r\n */\r\n update(frameState, tileset) {\r\n const visibility = this.style.layout.getDataConstValue('visibility', this.tile.z)\r\n if (visibility === 'none') return\r\n\r\n const commandList = this.commandList\r\n if (commandList && commandList.length) {\r\n for (const command of commandList) {\r\n frameState.commandList.push(command)\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * 判断对象是否已销毁。基类的 destroy 会自动将该方法改写成返回值为true的版本,子类的 destroy 应通过 super.destory 调用基类的 destroy\r\n * @returns \r\n */\r\n isDestroyed() {\r\n return false\r\n }\r\n\r\n /**\r\n * 销毁渲染图层,释放资源。基类负责释放通用属性存储的数据,子类的 destroy 应通过 super.destory 调用基类的 destroy\r\n */\r\n destroy() {\r\n if (this.commandList) {\r\n this.commandList.length = 0\r\n }\r\n if (this.sourceFeatures) {\r\n this.sourceFeatures.length = 0\r\n }\r\n this.style = null\r\n this.offsets = null\r\n this.counts = null\r\n this.tile = null\r\n this.isDestroyed = function returnTrue() {\r\n return true\r\n }\r\n }\r\n}","import { VectorTileFeature } from \"@mapbox/vector-tile\";\r\nimport { IRenderLayer } from \"../IRenderLayer\";\r\nimport { VectorTileset } from \"../../VectorTileset\";\r\nimport { VectorTileLOD } from \"../../VectorTileLOD\";\r\n\r\n/**\r\n * 图层渲染器基类,负责瓦片内指定类型图层的合批几何体、批次表、绘图命令(DrawCommand)的构建,以及图层DrawCommand浅拷贝副本(shallow clone)的分配\r\n * @see FillLayerVisualizer\r\n * @see LineLayerVisualizer\r\n * @see SymbolLayerVisualizer\r\n */\r\nexport class ILayerVisualizer {\r\n /**\r\n * 构造图层渲染器实例。图层渲染器负责瓦片内指定类型图层的合批几何体、批次表、绘图命令(DrawCommand)的构建,以及图层DrawCommand浅拷贝副本(shallow clone)的分配。\r\n * 注意:构造函数仅供VectorTileLOD调用,请勿在其他模块直接调用\r\n * @param {VectorTileLOD} tile \r\n * @param {IRenderLayer[]} [layers] \r\n * @inner\r\n * @see FillLayerVisualizer\r\n * @see LineLayerVisualizer\r\n * @see SymbolLayerVisualizer\r\n */\r\n constructor(tile, layers = []) {\r\n /**\r\n * @type {VectorTileLOD}\r\n */\r\n this.tile = tile\r\n /**\r\n * @type {IRenderLayer[]}\r\n */\r\n this.layers = layers\r\n /**\r\n * 图层渲染器状态\r\n * @type {'none'|'done'|'error'}\r\n */\r\n this.state = 'none'\r\n }\r\n\r\n /**\r\n * 添加图层:将图层及其过滤后的要素添加到图层渲染器,子类实现该方法,完成图层存储、要素转换等合批构建需要的准备工作\r\n * @param {VectorTileFeature[]} features \r\n * @param {IRenderLayer} renderLayer \r\n * @param {Cesium.frameState} frameState \r\n * @param {VectorTileset} tileset \r\n */\r\n addLayer(features, renderLayer, frameState, tileset) {\r\n\r\n }\r\n\r\n /**\r\n * 更新渲染器:子类实现该方法,完成合批几何体、批次表、绘图命令(DrawCommand)的构建,以及图层DrawCommand浅拷贝副本(shallow clone)的分配等工作\r\n * @param {*} frameState \r\n * @param {*} tileset \r\n */\r\n update(frameState, tileset) {\r\n\r\n }\r\n\r\n /**\r\n * 销毁图层渲染器对象,释放资源\r\n */\r\n destroy() {\r\n this.tile = null\r\n this.layers.length = 0\r\n this.isDestroyed = function returnTrue() {\r\n return true\r\n }\r\n }\r\n\r\n isDestroyed() {\r\n return false\r\n }\r\n}","import { ILayerVisualizer } from \"./visualizers/ILayerVisualizer\"\r\nimport { IRenderLayer } from \"./IRenderLayer\"\r\n\r\n/**\r\n * @type {Record<string,typeof IRenderLayer>}\r\n */\r\nconst RenderLayers = {}\r\n/**\r\n * @type {Record<string,typeof ILayerVisualizer>}\r\n */\r\nconst LayerVisualizers = {}\r\n\r\n/**\r\n * 注册图层类型,设置渲染图层类和图层渲染器类(非必须)\r\n * @param {\"symbol\" | \"fill\" | \"line\" | \"circle\" | \"heatmap\" | \"fill-extrusion\" | \"raster\" | \"hillshade\" | \"color-relief\" | \"background\"} type 图层类型\r\n * @param {typeof IRenderLayer} renderLayerCls 渲染图层类,必须继承 IRenderLayer\r\n * @param {typeof ILayerVisualizer} [layerVisualizerCls] 图层渲染器类,必须继承 ILayerVisualizer\r\n */\r\nfunction registerRenderLayer(type, renderLayerCls, layerVisualizerCls) {\r\n RenderLayers[type] = renderLayerCls\r\n LayerVisualizers[type] = layerVisualizerCls\r\n}\r\n\r\nexport { RenderLayers, LayerVisualizers, registerRenderLayer }","import { VectorTileset } from '../VectorTileset'\r\nimport { IRenderLayer } from './IRenderLayer'\r\nimport { registerRenderLayer } from './registerRenderLayer'\r\nimport { warnOnce } from 'maplibre-gl/src/util/util'\r\n\r\nexport class BackgroundRenderLayer extends IRenderLayer {\r\n createPrimitve(frameState, tileset) {\r\n const style = this.style\r\n const tile = this.tile\r\n const color = style.convertColor(style.paint.getDataConstValue('background-color', tile.z))\r\n const opacity = style.paint.getDataConstValue('background-opacity', tile.z)\r\n const pattern = style.paint.getDataConstValue('background-pattern', tile.z)\r\n if (pattern) {\r\n return warnOnce('background图层:不支持纹理填充')\r\n }\r\n color.alpha *= opacity\r\n\r\n const primitive = new Cesium.Primitive({\r\n geometryInstances: new Cesium.GeometryInstance({\r\n geometry: new Cesium.RectangleGeometry({\r\n rectangle: this.tile.rectangle\r\n }),\r\n }),\r\n compressVertices: false,\r\n asynchronous: false,\r\n appearance: new Cesium.MaterialAppearance({\r\n translucent: false,\r\n material: Cesium.Material.fromType('Color', {\r\n color: color\r\n }),\r\n flat: true\r\n })\r\n })\r\n\r\n this.primitive = primitive\r\n }\r\n\r\n /**\r\n * @param {Cesium.FrameState} frameState \r\n * @param {VectorTileset} tileset \r\n */\r\n update(frameState, tileset) {\r\n if (!this.primitive) {\r\n this.createPrimitve(frameState, tileset)\r\n }\r\n if (this.primitive && !this.commandList.length) {\r\n const preCommandList = frameState.commandList\r\n const layerCommandList = frameState.commandList = this.commandList\r\n\r\n this.primitive.update(frameState)\r\n\r\n //DrawCommand创建完成后,关闭深度写入,开启深度测试\r\n if (layerCommandList.length > 0) {\r\n const renderState = Cesium.RenderState.fromCache({\r\n blending: Cesium.BlendingState.ALPHA_BLEND,\r\n depthMask: false,\r\n depthTest: {\r\n enabled: true\r\n },\r\n cull: {\r\n enabled: true\r\n }\r\n })\r\n for (const layerCommand of layerCommandList) {\r\n layerCommand.renderState = renderState\r\n layerCommand.pass = Cesium.Pass.CESIUM_3D_TILE\r\n }\r\n }\r\n\r\n frameState.commandList = preCommandList\r\n }\r\n\r\n super.update(frameState, tileset)\r\n }\r\n\r\n destroy() {\r\n this.primitive = this.primitive && this.primitive.destroy()\r\n super.destroy()\r\n }\r\n}\r\n\r\nregisterRenderLayer('background', BackgroundRenderLayer)","import {warnOnce, clamp} from '../util/util';\n\nimport {EXTENT} from './extent';\n\nimport type Point from '@mapbox/point-geometry';\nimport type {VectorTileFeatureLike} from '@maplibre/vt-pbf';\n\n// These bounds define the minimum and maximum supported coordinate values.\n// While visible coordinates are within [0, EXTENT], tiles may theoretically\n// contain coordinates within [-Infinity, Infinity]. Our range is limited by the\n// number of bits used to represent the coordinate.\nconst BITS = 15;\nconst MAX = Math.pow(2, BITS - 1) - 1;\nconst MIN = -MAX - 1;\n\n/**\n * Loads a geometry from a VectorTileFeatureLike and scales it to the common extent\n * used internally.\n * @param feature - the vector tile feature to load\n */\nexport function loadGeometry(feature: VectorTileFeatureLike): Array<Array<Point>> {\n const scale = EXTENT / feature.extent;\n const geometry = feature.loadGeometry();\n for (let r = 0; r < geometry.length; r++) {\n const ring = geometry[r];\n for (let p = 0; p < ring.length; p++) {\n const point = ring[p];\n // round here because mapbox-gl-native uses integers to represent\n // points and we need to do the same to avoid rendering differences.\n const x = Math.round(point.x * scale);\n const y = Math.round(point.y * scale);\n\n point.x = clamp(x, MIN, MAX);\n point.y = clamp(y, MIN, MAX);\n\n if (x < point.x || x > point.x + 1 || y < point.y || y > point.y + 1) {\n // warn when exceeding allowed extent except for the 1-px-off case\n // https://github.com/mapbox/mapbox-gl-js/issues/8992\n warnOnce('Geometry exceeds allowed extent, reduce your vector tile buffer size');\n }\n }\n }\n return geometry;\n}\n","import { VectorTileFeature, classifyRings } from \"@mapbox/vector-tile\"\r\nimport { IRenderLayer } from \"../IRenderLayer\"\r\nimport { ILayerVisualizer } from \"./ILayerVisualizer\"\r\nimport { loadGeometry } from \"maplibre-gl/src/data/load_geometry\"\r\nimport { EXTENT } from 'maplibre-gl/src/data/extent';\r\nimport { subdividePolygon } from \"maplibre-gl/src/render/subdivision\"\r\nimport { granularitySettings } from \"../../sources/granularitySettings\";\r\nimport { warnOnce } from \"maplibre-gl/src/util/util\";\r\nimport { VectorTileset } from \"../../VectorTileset\";\r\n\r\nexport class FillFeature {\r\n constructor() {\r\n this.featureId = 0\r\n this.fillColor = Cesium.Color.BLACK.clone()\r\n this.fillOpacity = 1\r\n this.coordinates = []\r\n }\r\n}\r\n\r\nexport class FillLayerVisualizer extends ILayerVisualizer {\r\n constructor(layers, tile) {\r\n super(layers, tile)\r\n\r\n this.geometryInstances = []\r\n this.primitive = null\r\n this.commandsReady = false\r\n }\r\n\r\n /**\r\n * @param {VectorTileFeature[]} features \r\n * @param {IRenderLayer} layer \r\n * @param {Cesium.frameState} frameState \r\n * @param {VectorTileset} tileset \r\n */\r\n addLayer(features, layer, frameState, tileset) {\r\n const style = layer.style\r\n const { tile, geometryInstances } = this\r\n const granularity = granularitySettings.globe.line.getGranularityForZoomLevel(tile.z) / 2\r\n const scope = this\r\n let featureId = 0\r\n const promoteId = tileset.sources[layer.style.source].styleSource.promoteId\r\n\r\n for (const sourceFeature of features) {\r\n const featureType = VectorTileFeature.types[sourceFeature.type]\r\n const properties = sourceFeature.properties\r\n if (featureType !== 'Polygon') continue\r\n\r\n const fillPattern = style.paint.getDataValue('fill-pattern', tile.z, sourceFeature)\r\n if (fillPattern) {\r\n warnOnce('fill图层:不支持纹理填充(fill-pattern)')\r\n continue\r\n }\r\n\r\n const sourceFeatureId = sourceFeature.id || properties[promoteId]\r\n //读取图层样式属性\r\n const fillColor = style.convertColor(style.paint.getDataValue('fill-color', tile.z, sourceFeature))\r\n const fillOpacity = style.paint.getDataValue('fill-opacity', tile.z, sourceFeature)\r\n\r\n //关键:对投影坐标细分,而不是使用cesium内置的细分\r\n const vtCoords = loadGeometry(sourceFeature)\r\n const polygons = classifyRings(vtCoords)\r\n for (const coordinates of polygons) {\r\n if (coordinates.some(ring => ring.length < 3)) continue\r\n\r\n const batchId = geometryInstances.length\r\n if (featureId == 0) {\r\n layer.firstBatchId = batchId\r\n }\r\n layer.lastBatchId = batchId\r\n\r\n const fillFeature = {\r\n coordinates,\r\n featureId,\r\n fillColor,\r\n fillOpacity,\r\n properties,\r\n //保存原始数据的要素id,后续可以用来支持 featureState 表达式,这个表达式可以实现选定要素高亮显示\r\n id: sourceFeatureId,\r\n //保存batchId,将矢量要素与几何顶点关联,后续可以实时更新图层样式\r\n batchId\r\n }\r\n\r\n scope.addFeature(fillFeature, granularity)\r\n\r\n featureId++\r\n }\r\n }\r\n\r\n layer.offsets = []\r\n layer.counts = []\r\n\r\n this.layers.push(layer)\r\n }\r\n\r\n /**\r\n * 创建一个多边形的几何体实例\r\n * @param {FillFeature} feature\r\n * @param {number} granularity\r\n */\r\n addFeature(feature, granularity) {\r\n const geometryInstances = this.geometryInstances\r\n const { coordinates, fillColor, fillOpacity } = feature\r\n const colorBytes = fillColor.toBytes()\r\n colorBytes[3] = Math.floor(colorBytes[3] * fillOpacity)\r\n\r\n // 使用 maplibre-gl 的 subdividePolygon 基于投影坐标进行细分,\r\n // 而不是在转成世界坐标后再使用 Cesium.PolygonGeometry 构建,这样才能避免出现自相交、破面等现象。\r\n // 商业版性能优化:将此过程移到 Web Worker ,多线程加速,同时避免主线程阻塞\r\n\r\n const subdivisionRes = subdividePolygon(coordinates, this.tile, granularity, false)\r\n const verticesFlattened = subdivisionRes.verticesFlattened\r\n const coordDeg = [0, 0], cartesian = new Cesium.Cartesian3()\r\n const vertCount = verticesFlattened.length / 2\r\n const positions = new Float64Array(vertCount * 3)\r\n const normals = new Float32Array(vertCount * 3)\r\n const sts = new Float32Array(vertCount * 2)\r\n\r\n for (let i = 0, j = 0; i < verticesFlattened.length; i += 2, j++) {\r\n const x = verticesFlattened[i], y = verticesFlattened[i + 1]\r\n const coord = this.tile.transformPoint(x, y, coordDeg)\r\n const position = Cesium.Cartesian3.fromDegrees(coord[0], coord[1], 0, null, cartesian)\r\n positions[j * 3] = position.x\r\n positions[j * 3 + 1] = position.y\r\n positions[j * 3 + 2] = position.z\r\n\r\n const normal = Cesium.Cartesian3.normalize(position, position)\r\n normals[j * 3] = normal.x\r\n normals[j * 3 + 1] = normal.y\r\n normals[j * 3 + 2] = normal.z\r\n\r\n sts[j * 2] = x / EXTENT\r\n sts[j * 2 + 1] = y / EXTENT\r\n }\r\n\r\n const indices = new (vertCount > 65535 ? Uint32Array : vertCount > 255 ? Uint16Array : Uint8Array)(subdivisionRes.indicesTriangles)\r\n\r\n const geometry = new Cesium.Geometry({\r\n attributes: {\r\n position: {\r\n componentDatatype: Cesium.ComponentDatatype.DOUBLE,\r\n componentsPerAttribute: 3,\r\n normalize: false,\r\n values: positions\r\n },\r\n normal: {\r\n componentDatatype: Cesium.ComponentDatatype.FLOAT,\r\n componentsPerAttribute: 3,\r\n normalize: false,\r\n values: normals\r\n },\r\n st: {\r\n componentDatatype: Cesium.ComponentDatatype.FLOAT,\r\n componentsPerAttribute: 2,\r\n normalize: false,\r\n values: sts\r\n }\r\n },\r\n primitiveType: Cesium.PrimitiveType.TRIANGLES,\r\n indices: indices,\r\n boundingSphere: Cesium.BoundingSphere.fromVertices(positions)\r\n })\r\n\r\n const cartographic = Cesium.Cartographic.fromCartesian(geometry.boundingSphere.center)\r\n cartographic.height = 0//包围盒中心可能高于或者低于地面,需要避免双击锁定视角时进入地下\r\n const center = Cesium.Cartographic.toCartesian(cartographic, null, cartesian)\r\n\r\n const instance = new Cesium.GeometryInstance({\r\n geometry,\r\n attributes: {\r\n color: new Cesium.GeometryInstanceAttribute({\r\n componentDatatype: Cesium.ComponentDatatype.UNSIGNED_BYTE,\r\n componentsPerAttribute: 4,\r\n normalize: true,\r\n value: colorBytes\r\n }),\r\n },\r\n //通过entity的形式暴露给Cesium pickEntity,这样点击时系统自带的inforbox可以弹出\r\n id: new Cesium.Entity({\r\n position: center,\r\n id: feature.id,\r\n properties: feature.properties\r\n })\r\n })\r\n geometryInstances.push(instance)\r\n }\r\n\r\n createPrimitive() {\r\n const primitive = new Cesium.Primitive({\r\n geometryInstances: this.geometryInstances,\r\n asynchronous: !(this.geometryInstances[0].geometry instanceof Cesium.Geometry),\r\n appearance: new Cesium.PerInstanceColorAppearance({\r\n flat: true,\r\n translucent: false,\r\n renderState: {\r\n //这里设置是没有用的,只要 translucent 为 false,\r\n //Cesium 内部都会覆盖成 true,所以我们需要在 DrawCommand 创建完成后再设置\r\n depthMask: false,\r\n },\r\n fragmentShaderSource:/*glsl*/` \r\nin vec4 v_color;\r\n\r\nuniform vec4 tileId;\r\nuniform sampler2D tileIdTexture;\r\n\r\nvoid main()\r\n{\r\n vec2 id_st = gl_FragCoord.xy / czm_viewport.zw; \r\n vec4 bgId = texture(tileIdTexture, id_st);\r\n if (!all(equal(bgId, tileId)))\r\n {\r\n discard;\r\n }\r\n out_FragColor = v_color;\r\n}\r\n `\r\n }),\r\n })\r\n\r\n //通过定义 Primitive 私有变量 _geometries、_batchTable 的 setter 和 getter,\r\n //监听合批几何体和批次表的创建:\r\n //1、几何体创建完成后,根据 batchId 和 featureId,计算每个图层几何体的起始索引(offset)和索引数量(count)\r\n //2、批次表创建完成后,保存备用\r\n let scope = this\r\n Object.defineProperties(primitive, {\r\n _geometries: {\r\n get() {\r\n return this._geometries_\r\n },\r\n set(geometries) {\r\n this._geometries_ = geometries\r\n if (geometries) {\r\n scope.onGeometriesLoaded(geometries)\r\n }\r\n else {\r\n scope = null\r\n }\r\n }\r\n },\r\n _batchTable: {\r\n get() {\r\n return this._batchTable_\r\n },\r\n set(batchTable) {\r\n this._batchTable_ = batchTable\r\n if (batchTable) {\r\n scope.onBatchTableCreated(batchTable)\r\n }\r\n }\r\n }\r\n })\r\n\r\n this.primitive = primitive\r\n }\r\n\r\n /**\r\n * 根据 batchId 和 featureId,计算每个图层几何体的起始索引(offset)和索引数量(count)\r\n * @param {Cesium.Geometry[]} geometries \r\n */\r\n onGeometriesLoaded(geometries) {\r\n //Cesium 几何体合批结果可能是多个几何体,对应多个 DrawCommand\r\n for (let pass = 0; pass < geometries.length; pass++) {\r\n const batches = {}\r\n const geometry = geometries[pass];\r\n const batchIds = geometry.attributes.batchId.values\r\n const indices = geometry.indices\r\n\r\n //提取每个批次的起始和结束索引\r\n let currBatchId = -1\r\n let currBatch = null\r\n for (let i = 0; i < indices.length; i++) {\r\n const vertIndex = indices[i]\r\n const batchId = batchIds[vertIndex]\r\n if (currBatchId !== batchId) {\r\n currBatchId = batchId\r\n currBatch = batches[currBatchId] = {\r\n begin: i,\r\n end: i\r\n }\r\n }\r\n currBatch.end = i\r\n }\r\n\r\n //根据图层批次范围,提取图层几何体索引范围,即起始索引(offset)和索引数量(count)\r\n for (const layer of this.layers) {\r\n const { firstBatchId, lastBatchId } = layer\r\n if (firstBatchId === -1 || lastBatchId === -1) {\r\n continue\r\n }\r\n\r\n let begin = -1, end = -1\r\n for (let batchId = firstBatchId; batchId <= lastBatchId; batchId++) {\r\n const batch = batches[batchId]\r\n if (batch) {\r\n if (begin === -1) begin = batch.begin\r\n end = batch.end\r\n }\r\n }\r\n\r\n if (begin === -1 || end === -1) {\r\n continue\r\n }\r\n\r\n //起始和结束索引,索引数量需要加1\r\n layer.offsets[pass] = begin\r\n layer.counts[pass] = end - begin + 1\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * 保存 Cesium Primitive 创建的批次表。图层样式变化时,通过更新批次表传递到GPU,同步更新渲染效果\r\n * @param {Cesium.BatchTable} batchTable \r\n */\r\n onBatchTableCreated(batchTable) {\r\n this._batchTable = batchTable\r\n }\r\n\r\n /**\r\n * 使用合批后的 drawCommand 创建副本,为渲染图层分配 drawCommand \r\n * @param {Cesium.DrawCommand[]} batchedCommandList \r\n * @param {VectorTileset} tileset\r\n */\r\n createLayerCommands(batchedCommandList, tileset) {\r\n const renderState = Cesium.RenderState.fromCache({\r\n id: 'fill',\r\n blending: Cesium.BlendingState.ALPHA_BLEND,\r\n depthMask: false,\r\n depthTest: {\r\n enabled: true\r\n },\r\n cull: {\r\n enabled: true\r\n }\r\n })\r\n const tileId = this.tile.tileId\r\n this.renderState = renderState\r\n\r\n for (let i = 0; i < this.layers.length; i++) {\r\n const layer = this.layers[i]\r\n const layerCommandList = layer.commandList = []\r\n\r\n for (let pass = 0; pass < batchedCommandList.length; pass++) {\r\n const offset = layer.offsets[pass], count = layer.counts[pass]\r\n if (typeof offset !== 'number' || typeof count !== 'number') {\r\n continue\r\n }\r\n const command = batchedCommandList[pass]\r\n command.uniformMap.tileIdTexture = function () {\r\n return tileset.tileIdTexture\r\n }\r\n command.uniformMap.tileId = function () {\r\n return tileId.color\r\n }\r\n command.pass = Cesium.Pass.CESIUM_3D_TILE\r\n //通过副本的 offset 和 count 指定图层的绘制范围\r\n const layerCommand = Cesium.DrawCommand.shallowClone(command)\r\n layerCommand.pass = Cesium.Pass.CESIUM_3D_TILE\r\n layerCommand.renderState = renderState\r\n layerCommand.layerType = 'fill'\r\n layerCommand.offset = offset\r\n layerCommand.count = count\r\n layerCommandList.push(layerCommand)\r\n }\r\n }\r\n\r\n //标记 drawCommand 创建完成\r\n this.state = 'done'\r\n }\r\n\r\n update(frameState, tileset) {\r\n if (!this.geometryInstances) {\r\n return\r\n }\r\n\r\n super.update(frameState, tileset)\r\n\r\n if (!this.primitive && this.geometryInstances.length) {\r\n this.createPrimitive()\r\n }\r\n\r\n if (this.primitive && this.state !== 'done' && this.state !== 'error') {\r\n //先保存系统的 commandList\r\n const preCommandList = frameState.commandList\r\n //临时覆盖 frameState.commandList,用于获取合批之后的drawCommand\r\n const batchedCommandList = frameState.commandList = []\r\n\r\n //执行 primitive 的 update ,直到生成了合批后的drawCommand\r\n try {\r\n this.primitive.update(frameState)\r\n } catch (err) {//如果报错,下一帧就不要再执行 update 了,以免重复打印错误信息\r\n this.geometryInstances = []\r\n this.state = 'error'\r\n if (err.stack) console.trace(err.stack)\r\n else console.error(err);\r\n return\r\n }\r\n\r\n //使用合批后的 drawCommand 创建副本,为渲染图层分配 drawCommand \r\n if (batchedCommandList.length > 0) {\r\n this.createLayerCommands(batchedCommandList, tileset)\r\n }\r\n\r\n //恢复系统的 commandList\r\n frameState.commandList = preCommandList\r\n this.geometryInstances = []\r\n }\r\n }\r\n\r\n destroy() {\r\n this.primitive = this.primitive && this.primitive.destroy()\r\n this._batchTable = null\r\n this.geometryInstances = null\r\n\r\n super.destroy()\r\n }\r\n\r\n isDestroyed() {\r\n return false\r\n }\r\n}","import { VectorTileset } from '../VectorTileset'\r\nimport { IRenderLayer } from './IRenderLayer'\r\nimport { registerRenderLayer } from './registerRenderLayer'\r\nimport { FillLayerVisualizer } from './visualizers/FillLayerVisualizer'\r\n\r\nexport class FillRenderLayer extends IRenderLayer {\r\n /**\r\n * @param {Cesium.FrameState} frameState \r\n * @param {VectorTileset} tileset \r\n */\r\n update(frameState, tileset) {\r\n //可以在这里实现同步样式,动态更新图层颜色等样式\r\n\r\n super.update(frameState, tileset)\r\n }\r\n}\r\n\r\nregisterRenderLayer('fill', FillRenderLayer, FillLayerVisualizer)","import { VectorTileFeature } from \"@mapbox/vector-tile\"\r\nimport { IRenderLayer } from \"../IRenderLayer\"\r\nimport { ILayerVisualizer } from \"./ILayerVisualizer\"\r\nimport { VectorTileset } from \"../../VectorTileset\"\r\nimport { subdivideVertexLine } from \"maplibre-gl/src/render/subdivision\"\r\nimport { loadGeometry } from \"maplibre-gl/src/data/load_geometry\"\r\nimport * as mvt from '@mapbox/vector-tile';\r\nimport { EXTENT } from 'maplibre-gl/src/data/extent';\r\nimport { granularitySettings } from \"../../sources/granularitySettings\"\r\nimport { warnOnce } from \"maplibre-gl/src/util/util\"\r\nimport { LineRenderLayer } from \"../LineRenderLayer\"\r\nconst toGeoJSON = mvt.VectorTileFeature.prototype.toGeoJSON;\r\n\r\nexport class LineFeature {\r\n constructor() {\r\n this.featureId = 0\r\n this.lineColor = Cesium.Color.BLACK.clone()\r\n this.lineWidth = 1\r\n this.lineOpacity = 1\r\n this.coordinates = []\r\n }\r\n}\r\n\r\nexport class LineLayerVisualizer extends ILayerVisualizer {\r\n constructor(layers, tile) {\r\n super(layers, tile)\r\n\r\n this.geometryInstances = []\r\n this.primitive = null\r\n this.commandsReady = false\r\n }\r\n\r\n /**\r\n * @param {VectorTileFeature[]} features \r\n * @param {LineRenderLayer} layer \r\n * @param {Cesium.frameState} frameState \r\n * @param {VectorTileset} tileset \r\n */\r\n addLayer(features, layer, frameState, tileset) {\r\n const style = layer.style\r\n const { tile, geometryInstances } = this\r\n const granularity = granularitySettings.globe.line.getGranularityForZoomLevel(tile.z)\r\n const scope = this\r\n const promoteId = tileset.sources[layer.style.source].styleSource.promoteId\r\n let featureId = 0\r\n\r\n //支持虚线\r\n const dasharray = style.paint.getDataConstValue('line-dasharray', tile.z)\r\n if (dasharray && dasharray.length) {\r\n if (dasharray.length % 2 > 0) {\r\n dasharray.push(0)\r\n }\r\n layer.dashLength = 0\r\n for (let i = 0; i < dasharray.length; i++) {\r\n layer.dashLength += dasharray[i]\r\n }\r\n layer.dasharray = dasharray\r\n\r\n if (dasharray.length > 8) {\r\n warnOnce('line图层:line-dasharray 超过最大长度(8)')\r\n }\r\n }\r\n\r\n function addPolyline(coordinates, lineWidth, lineColor, lineOpacity, id, properties) {\r\n if (coordinates.length < 2) return\r\n\r\n const batchId = geometryInstances.length\r\n if (featureId == 0) {\r\n layer.firstBatchId = batchId\r\n }\r\n layer.lastBatchId = batchId\r\n\r\n const lineFeature = {\r\n coordinates,\r\n featureId,\r\n lineColor,\r\n lineOpacity,\r\n lineWidth,\r\n properties,\r\n //保存原始数据的要素id,后续可以用来支持 featureState 表达式,这个表达式可以实现选定要素高亮显示\r\n id,\r\n //保存batchId,将矢量要素与几何顶点关联,后续可以实时更新图层样式\r\n batchId\r\n }\r\n\r\n scope.addFeature(lineFeature)\r\n\r\n featureId++\r\n }\r\n\r\n for (const sourceFeature of features) {\r\n const featureType = VectorTileFeature.types[sourceFeature.type]\r\n if (featureType === 'Point' || featureType === 'Unknown') continue\r\n\r\n const properties = sourceFeature.properties\r\n\r\n //关键:使用 maplibre-gl 的 subdivideVertexLine 对投影坐标细分,\r\n // 如果转成经纬度之后使用cesium内置的细分,高纬度的线很难拟合地球椭球面\r\n const vtCoords = loadGeometry(sourceFeature)\r\n for (let i = 0; i < vtCoords.length; i++) {\r\n vtCoords[i] = subdivideVertexLine(vtCoords[i], granularity)\r\n }\r\n const feature = toGeoJSON.call({\r\n extent: EXTENT,\r\n type: sourceFeature.type,\r\n properties,\r\n loadGeometry() {\r\n return vtCoords\r\n }\r\n }, tile.x, tile.y, tile.z);\r\n if (!feature.geometry) continue\r\n\r\n const sourceFeatureId = sourceFeature.id || properties[promoteId]\r\n //读取图层样式属性\r\n const lineWidth = style.paint.getDataValue('line-width', tile.z, sourceFeature)\r\n const lineColor = style.convertColor(style.paint.getDataValue('line-color', tile.z, sourceFeature))\r\n const lineOpacity = style.paint.getDataValue('line-opacity', tile.z, sourceFeature)\r\n const linePattern = style.paint.getDataValue('line-pattern', tile.z, sourceFeature)\r\n if (linePattern) {\r\n warnOnce('line图层:不支持纹理填充(line-pattern)')\r\n continue\r\n }\r\n\r\n const lineJoin = style.paint.getDataValue('line-join', tile.z, sourceFeature)\r\n const lineCap = style.paint.getDataValue('line-cap', tile.z, sourceFeature)\r\n if (lineJoin !== 'miter') {\r\n warnOnce('line图层:line-join 仅支持 miter 模式')\r\n }\r\n if (lineCap !== 'butt') {\r\n warnOnce('line图层:line-cap 仅支持 butt 模式')\r\n }\r\n\r\n const geometryType = feature.geometry.type\r\n const coordinates = feature.geometry.coordinates\r\n if (geometryType == 'LineString') {\r\n addPolyline(coordinates, lineWidth, lineColor, lineOpacity, sourceFeatureId, properties)\r\n }\r\n else if (geometryType == 'MultiLineString' || geometryType == 'Polygon') {\r\n for (const ring of coordinates) {\r\n addPolyline(ring, lineWidth, lineColor, lineOpacity, sourceFeatureId, properties)\r\n }\r\n }\r\n else if (geometryType == 'MultiPolygon') {\r\n for (const polygon of coordinates) {\r\n for (const ring of polygon) {\r\n addPolyline(ring, lineWidth, lineColor, lineOpacity, sourceFeatureId, properties)\r\n }\r\n }\r\n }\r\n else {\r\n warnOnce('line图层:不支持几何类型:' + geometryType);\r\n }\r\n }\r\n\r\n layer.offsets = []\r\n layer.counts = []\r\n\r\n this.layers.push(layer)\r\n }\r\n\r\n /**\r\n * @param {LineFeature} feature \r\n */\r\n addFeature(feature) {\r\n const geometryInstances = this.geometryInstances\r\n const { coordinates, lineColor, lineWidth, lineOpacity } = feature\r\n const colorBytes = lineColor.toBytes()\r\n colorBytes[3] = Math.floor(colorBytes[3] * lineOpacity)\r\n\r\n const positions = coordinates.map(coord => Cesium.Cartesian3.fromDegrees(coord[0], coord[1]))\r\n\r\n const boundingSphere = Cesium.BoundingSphere.fromPoints(positions)\r\n const cartographic = Cesium.Cartographic.fromCartesian(boundingSphere.center)\r\n cartographic.height = 0//包围盒中心可能高于或者低于地面,需要避免双击锁定视角时进入地下\r\n const center = Cesium.Cartographic.toCartesian(cartographic, null, cartesian)\r\n\r\n const instance = new Cesium.GeometryInstance({\r\n geometry: new Cesium.PolylineGeometry({\r\n positions,\r\n width: lineWidth,\r\n }),\r\n attributes: {\r\n color: new Cesium.GeometryInstanceAttribute({\r\n componentDatatype: Cesium.ComponentDatatype.UNSIGNED_BYTE,\r\n componentsPerAttribute: 4,\r\n normalize: true,\r\n value: colorBytes\r\n }),\r\n },\r\n //通过entity的形式暴露给Cesium pickEntity,这样点击时系统自带的inforbox可以弹出\r\n id: new Cesium.Entity({\r\n position: center,\r\n id: feature.id,\r\n properties: feature.properties\r\n })\r\n })\r\n geometryInstances.push(instance)\r\n }\r\n\r\n createPrimitive() {\r\n const primitive = new Cesium.Primitive({\r\n geometryInstances: this.geometryInstances,\r\n asynchronous: true,\r\n appearance: new Cesium.PolylineMaterialAppearance({\r\n flat: true,\r\n translucent: false,\r\n vertexShaderSource:/*glsl*/`\r\n${Cesium._shadersPolylineCommon}\r\n \r\nin vec4 color;\r\nout vec4 v_color;\r\nin vec3 position3DHigh;\r\nin vec3 position3DLow;\r\nin vec3 prevPosition3DHigh;\r\nin vec3 prevPosition3DLow;\r\nin vec3 nextPosition3DHigh;\r\nin vec3 nextPosition3DLow;\r\nin vec2 expandAndWidth;\r\nin vec2 st;\r\nin float batchId;\r\n\r\nout float v_width;\r\nout vec2 v_st;\r\nout float v_polylineAngle;\r\n\r\nvoid main()\r\n{\r\n float expandDir = expandAndWidth.x;\r\n float width = abs(expandAndWidth.y) + 0.5;\r\n bool usePrev = expandAndWidth.y < 0.0;\r\n\r\n vec4 p = czm_computePosition();\r\n vec4 prev = czm_computePrevPosition();\r\n vec4 next = czm_computeNextPosition();\r\n\r\n float angle;\r\n vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, angle);\r\n gl_Position = czm_viewportOrthographic * positionWC;\r\n\r\n v_width = width;\r\n v_st.s = st.s;\r\n v_st.t = czm_writeNonPerspective(st.t, gl_Position.w);\r\n v_polylineAngle = angle;\r\n v_color = color;\r\n}\r\n `,\r\n fragmentShaderSource:/*glsl*/` \r\nin vec2 v_st;\r\n\r\nuniform vec4 tileId;\r\nuniform sampler2D tileIdTexture;\r\n\r\nvoid main()\r\n{\r\n vec2 id_st = gl_FragCoord.xy / czm_viewport.zw; \r\n vec4 bgId = texture(tileIdTexture, id_st);\r\n if (all(equal(bgId, tileId)) == false)\r\n {\r\n discard;\r\n }\r\n\r\n czm_materialInput materialInput;\r\n\r\n vec2 st = v_st;\r\n st.t = czm_readNonPerspective(st.t, gl_FragCoord.w);\r\n\r\n materialInput.s = st.s;\r\n materialInput.st = st;\r\n materialInput.str = vec3(st, 0.0);\r\n\r\n czm_material material = czm_getMaterial(materialInput);\r\n out_FragColor = vec4(material.diffuse + material.emission, material.alpha);\r\n\r\n czm_writeLogDepth();\r\n}\r\n `,\r\n material: new Cesium.Material({\r\n fabric: {\r\n //cesium不支持数组类型的uniform,我们在分配图层绘图命令的时候修改uniformMap\r\n // uniforms: {\r\n // dashLength: 16,\r\n // arrayLength: 0,\r\n // dasharray: []\r\n // },\r\n source:/*glsl*/`\r\nconst int maxArrayLength = 8;\r\n\r\nin float v_width;\r\nin vec4 v_color;\r\nuniform float dashLength;\r\nuniform float arrayLength;\r\nuniform float dasharray[maxArrayLength];\r\nin float v_polylineAngle;\r\n\r\nmat2 rotate(float rad) {\r\n float c = cos(rad);\r\n float s = sin(rad);\r\n return mat2(\r\n c, s,\r\n -s, c\r\n );\r\n}\r\n\r\nczm_material czm_getMaterial(czm_materialInput materialInput)\r\n{\r\n czm_material material = czm_getDefaultMaterial(materialInput);\r\n\r\n vec2 pos = rotate(v_polylineAngle) * gl_FragCoord.xy;\r\n\r\n // Get the relative position within the dash from 0 to 1\r\n float dashPosition = fract(pos.x / (v_width * dashLength * czm_pixelRatio));\r\n\r\n float currDashPos = 0.;\r\n for (int i = 0; i < maxArrayLength; i += 2) {\r\n if(float(i) >= arrayLength) break;\r\n\r\n float gapStart = currDashPos + dasharray[i] / dashLength;\r\n float gapEnd = gapStart + dasharray[i + 1] / dashLength;\r\n\r\n if(dashPosition > gapStart && dashPosition < gapEnd) {\r\n discard;\r\n break;\r\n }\r\n\r\n currDashPos = gapEnd;\r\n }\r\n \r\n vec4 fragColor = v_color;\r\n fragColor = czm_gammaCorrect(fragColor);\r\n material.emission = fragColor.rgb;\r\n material.alpha = fragColor.a;\r\n return material;\r\n} \r\n `\r\n }\r\n })\r\n }),\r\n })\r\n\r\n //通过定义 Primitive 私有变量 _geometries、_batchTable 的 setter 和 getter,\r\n //监听合批几何体和批次表的创建:\r\n //1、几何体创建完成后,根据 batchId 和 featureId,计算每个图层几何体的起始索引(offset)和索引数量(count)\r\n //2、批次表创建完成后,保存备用\r\n let scope = this\r\n Object.defineProperties(primitive, {\r\n _geometries: {\r\n get() {\r\n return this._geometries_\r\n },\r\n set(geometries) {\r\n this._geometries_ = geometries\r\n if (geometries) {\r\n scope.onGeometriesLoaded(geometries)\r\n }\r\n else {\r\n scope = null\r\n }\r\n }\r\n },\r\n _batchTable: {\r\n get() {\r\n return this._batchTable_\r\n },\r\n set(batchTable) {\r\n this._batchTable_ = batchTable\r\n if (batchTable) {\r\n scope.onBatchTableCreated(batchTable)\r\n }\r\n }\r\n }\r\n })\r\n\r\n this.primitive = primitive\r\n }\r\n\r\n /**\r\n * 根据 batchId 和 featureId,计算每个图层几何体的起始索引(offset)和索引数量(count)\r\n * @param {Cesium.Geometry[]} geometries \r\n */\r\n onGeometriesLoaded(geometries) {\r\n //Cesium 几何体合批结果可能是多个几何体,对应多个 DrawCommand\r\n for (let pass = 0; pass < geometries.length; pass++) {\r\n const batches = {}\r\n const geometry = geometries[pass];\r\n const batchIds = geometry.attributes.batchId.values\r\n const indices = geometry.indices\r\n\r\n //提取每个批次的起始和结束索引\r\n let currBatchId = -1\r\n let currBatch = null\r\n for (let i = 0; i < indices.length; i++) {\r\n const vertIndex = indices[i]\r\n const batchId = batchIds[vertIndex]\r\n if (currBatchId !== batchId) {\r\n currBatchId = batchId\r\n currBatch = batches[currBatchId] = {\r\n begin: i,\r\n end: i\r\n }\r\n }\r\n currBatch.end = i\r\n }\r\n\r\n //根据图层批次范围,提取图层几何体索引范围,即起始索引(offset)和索引数量(count)\r\n for (const layer of this.layers) {\r\n const { firstBatchId, lastBatchId } = layer\r\n if (firstBatchId === -1 || lastBatchId === -1) {\r\n continue\r\n }\r\n\r\n let begin = -1, end = -1\r\n for (let batchId = firstBatchId; batchId <= lastBatchId; batchId++) {\r\n const batch = batches[batchId]\r\n if (batch) {\r\n if (begin === -1) begin = batch.begin\r\n end = batch.end\r\n }\r\n }\r\n\r\n if (begin === -1 || end === -1) {\r\n continue\r\n }\r\n\r\n //起始和结束索引,索引数量需要加1\r\n layer.offsets[pass] = begin\r\n layer.counts[pass] = end - begin + 1\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * 保存 Cesium Primitive 创建的批次表。图层样式变化时,通过更新批次表传递到GPU,同步更新渲染效果\r\n * @param {Cesium.BatchTable} batchTable \r\n */\r\n onBatchTableCreated(batchTable) {\r\n this._batchTable = batchTable\r\n }\r\n\r\n /**\r\n * 使用合批后的 drawCommand 创建副本,为渲染图层分配 drawCommand \r\n * @param {Cesium.DrawCommand[]} batchedCommandList \r\n * @param {VectorTileset} tileset\r\n */\r\n createLayerCommands(batchedCommandList, tileset) {\r\n const renderState = Cesium.RenderState.fromCache({\r\n id: 'line',\r\n blending: Cesium.BlendingState.ALPHA_BLEND,\r\n depthMask: false,\r\n depthTest: {\r\n enabled: true\r\n },\r\n cull: {\r\n enabled: true\r\n },\r\n colorMask: {\r\n red: true,\r\n green: true,\r\n blue: true,\r\n alpha: true\r\n }\r\n })\r\n const tileId = this.tile.tileId\r\n\r\n function modifyUniformMap(uniformMap, layer) {\r\n uniformMap = {\r\n ...uniformMap\r\n }\r\n uniformMap.tileIdTexture = function () {\r\n return tileset.tileIdTexture\r\n }\r\n uniformMap.tileId = function () {\r\n return tileId.color\r\n }\r\n uniformMap.dasharray = function () {\r\n return layer.dasharray\r\n }\r\n uniformMap.dashLength = function () {\r\n return layer.dashLength\r\n }\r\n uniformMap.arrayLength = function () {\r\n return layer.dasharray.length\r\n }\r\n return uniformMap\r\n }\r\n\r\n for (let i = 0; i < this.layers.length; i++) {\r\n const layer = this.layers[i]\r\n const layerCommandList = layer.commandList = []\r\n\r\n for (let pass = 0; pass < batchedCommandList.length; pass++) {\r\n const offset = layer.offsets[pass], count = layer.counts[pass]\r\n if (typeof offset !== 'number' || typeof count !== 'number') {\r\n continue\r\n }\r\n const command = batchedCommandList[pass]\r\n //通过副本的 offset 和 count 指定图层的绘制范围\r\n const layerCommand = Cesium.DrawCommand.shallowClone(command)\r\n layerCommand.pass = Cesium.Pass.CESIUM_3D_TILE\r\n layerCommand.uniformMap = modifyUniformMap(layerCommand.uniformMap, layer)\r\n layerCommand.renderState = renderState\r\n layerCommand.offset = offset\r\n layerCommand.count = count\r\n layerCommandList.push(layerCommand)\r\n }\r\n }\r\n\r\n //标记 drawCommand 创建完成\r\n this.state = 'done'\r\n }\r\n\r\n update(frameState, tileset) {\r\n if (!this.geometryInstances) {\r\n return\r\n }\r\n\r\n super.update(frameState, tileset)\r\n\r\n if (!this.primitive && this.geometryInstances.length) {\r\n this.createPrimitive()\r\n }\r\n\r\n if (this.primitive && this.state !== 'done' && this.state !== 'error') {\r\n //先保存系统的 commandList\r\n const preCommandList = frameState.commandList\r\n //临时覆盖 frameState.commandList,用于获取合批之后的drawCommand\r\n const batchedCommandList = frameState.commandList = []\r\n\r\n //执行 primitive 的 update ,直到生成了合批后的drawCommand\r\n try {\r\n this.primitive.update(frameState)\r\n } catch (err) {//如果报错,下一帧就不要再执行 update 了,以免重复打印错误信息\r\n this.geometryInstances = []\r\n this.state = 'error'\r\n if (err.stack) console.trace(err.stack)\r\n else console.error(err);\r\n return\r\n }\r\n\r\n //使用合批后的 drawCommand 创建副本,为渲染图层分配 drawCommand \r\n if (batchedCommandList.length > 0) {\r\n this.createLayerCommands(batchedCommandList, tileset)\r\n }\r\n\r\n //恢复系统的 commandList\r\n frameState.commandList = preCommandList\r\n this.geometryInstances = []\r\n }\r\n\r\n if (this.primitive && frameState.camera.pitch > -1.309) {\r\n warnOnce('line图层:不支持透视,建议保持相机俯仰角(pitch)小于 -75 度')\r\n }\r\n }\r\n\r\n destroy() {\r\n this.primitive = this.primitive && this.primitive.destroy()\r\n this._batchTable = null\r\n this.geometryInstances = null\r\n\r\n super.destroy()\r\n }\r\n\r\n isDestroyed() {\r\n return false\r\n }\r\n}","import * as MVT from '@mapbox/vector-tile'\r\nimport { StyleLayer } from '../style/StyleLayer'\r\nimport { VectorTileset } from '../VectorTileset'\r\nimport { IRenderLayer } from './IRenderLayer'\r\nimport { registerRenderLayer } from './registerRenderLayer'\r\nimport { VectorTileLOD } from '../VectorTileLOD'\r\nimport { LineLayerVisualizer } from './visualizers/LineLayerVisualizer'\r\n\r\nexport class LineRenderLayer extends IRenderLayer {\r\n /**\r\n * @param {MVT.VectorTileFeature[]} sourceFeatures \r\n * @param {StyleLayer} styleLayer \r\n * @param {VectorTileLOD} tile \r\n */\r\n constructor(sourceFeatures, styleLayer, tile) {\r\n super(sourceFeatures, styleLayer, tile)\r\n this.primitive = null\r\n this.dasharray = []\r\n this.dashLength = 0\r\n }\r\n\r\n createPrimitve(frameState, tileset) {\r\n const primitive = new Cesium.PolylineCollection()\r\n const sourceFeatures = this.sourceFeatures\r\n const style = this.style\r\n const tile = this.tile\r\n\r\n function addPolyline(coordinates, lineWidth, lineColor) {\r\n if (coordinates.length < 2) return\r\n\r\n const positions = coordinates.map(coord => Cesium.Cartesian3.fromDegrees(coord[0], coord[1]))\r\n primitive.add({\r\n positions,\r\n width: lineWidth,\r\n material: Cesium.Material.fromType('Color', {\r\n color: style.convertColor(lineColor)\r\n })\r\n })\r\n }\r\n\r\n for (const sourceFeature of sourceFeatures) {\r\n const feature = sourceFeature.toGeoJSON(tile.x, tile.y, tile.z)\r\n if (!feature.geometry) continue\r\n\r\n //读取图层样式属性\r\n const lineWidth = style.paint.getDataValue('line-width', tile.z, sourceFeature)\r\n const lineColor = style.paint.getDataValue('line-color', tile.z, sourceFeature)\r\n\r\n const geometryType = feature.geometry.type\r\n const coordinates = feature.geometry.coordinates\r\n if (geometryType == 'LineString') {\r\n addPolyline(coordinates, lineWidth, lineColor)\r\n }\r\n else if (geometryType == 'MultiLineString' || geometryType == 'Polygon') {\r\n for (const ring of coordinates) {\r\n addPolyline(ring, lineWidth, lineColor)\r\n }\r\n }\r\n else if (geometryType == 'MultiPolygon') {\r\n for (const polygon of coordinates) {\r\n for (const ring of polygon) {\r\n addPolyline(ring, lineWidth, lineColor)\r\n }\r\n }\r\n }\r\n else {\r\n console.log('暂不支持几何类型:' + geometryType);\r\n }\r\n }\r\n\r\n this.primitive = primitive\r\n }\r\n\r\n /**\r\n * @param {Cesium.FrameState} frameState \r\n * @param {VectorTileset} tileset \r\n */\r\n update(frameState, tileset) {\r\n // if (!this.primitive) {\r\n // this.createPrimitve(frameState, tileset)\r\n // }\r\n // if (this.primitive && this.primitive.length) {\r\n // this.primitive.update(frameState)\r\n // }\r\n super.update(frameState, tileset)\r\n }\r\n\r\n destroy() {\r\n this.primitive = this.primitive && this.primitive.destroy()\r\n super.destroy()\r\n }\r\n}\r\n\r\nregisterRenderLayer('line', LineRenderLayer, LineLayerVisualizer)","import { VectorTileFeature } from \"@mapbox/vector-tile\"\r\nimport { ILayerVisualizer } from \"./ILayerVisualizer\"\r\nimport { SymbolRenderLayer } from \"../SymbolRenderLayer\"\r\nimport { warnOnce } from \"maplibre-gl/src/util/util\"\r\n\r\nexport class SymbolFeature {\r\n constructor() {\r\n this.featureId = 0\r\n this.textColor = Cesium.Color.BLACK.clone()\r\n this.textSize = 12\r\n this.coordinates = []\r\n }\r\n}\r\n\r\n/**@type {Cesium.Cartesian3} */\r\nlet scratchDirectionToEye = null\r\n/**@type {Cesium.Cartesian3} */\r\nlet scratchSurfaceNormal = null\r\n\r\nexport class SymbolLayerVisualizer extends ILayerVisualizer {\r\n constructor(layers, tile) {\r\n if (scratchDirectionToEye === null) {\r\n scratchDirectionToEye = new Cesium.Cartesian3()\r\n scratchSurfaceNormal = new Cesium.Cartesian3()\r\n }\r\n\r\n super(layers, tile)\r\n\r\n /**@type {Cesium.Label[]} */\r\n this.labels = []\r\n this.primitive = null\r\n this.dotCutOff = 0.0035\r\n }\r\n\r\n /**\r\n * 对符号进行地平线剔除\r\n * @param {Cesium.Cartesian3} positionWC \r\n * @param {Cesium.Cartesian3} cameraPositionWC \r\n */\r\n isOccluded(cameraPositionWC, positionWC) {\r\n /*\r\n 如下图,o为符号锚点,up为椭球面过锚点o的法线,tangent为过锚点o的切线,eye为相机位置。\r\n 可见,当锚点在地平线以下时,eye方向与up方向夹角小于90°。\r\n up\r\n ^\r\n |\r\n o —— —— > tangent\r\n \\\r\n \\\r\n eye\r\n */\r\n const eyeDir = Cesium.Cartesian3.subtract(cameraPositionWC, positionWC, scratchDirectionToEye)\r\n Cesium.Cartesian3.normalize(eyeDir, eyeDir)\r\n const up = Cesium.Cartesian3.normalize(positionWC, scratchSurfaceNormal)\r\n return Cesium.Cartesian3.dot(eyeDir, up) < this.dotCutOff\r\n }\r\n\r\n /**\r\n * @param {VectorTileFeature[]} features \r\n * @param {SymbolRenderLayer} layer \r\n * @param {Cesium.frameState} frameState \r\n * @param {VectorTileset} tileset \r\n */\r\n addLayer(features, layer, frameState, tileset) {\r\n const style = layer.style\r\n const { tile, labels } = this\r\n const rectangle = tile.rectangle\r\n\r\n function addText(coord, text, font, textSize, textColor, outlineWidth, outlineColor) {\r\n if (!Cesium.Rectangle.contains(rectangle, Cesium.Cartographic.fromDegrees(coord[0], coord[1]))) {\r\n return\r\n }\r\n const label = new Cesium.Label({\r\n position: Cesium.Cartesian3.fromDegrees(coord[0], coord[1]),\r\n text,\r\n font: textSize + 'px ' + font,\r\n fillColor: textColor,\r\n style: outlineWidth && Cesium.LabelStyle.FILL_AND_OUTLINE,\r\n outlineWidth: outlineWidth * textSize,\r\n outlineColor,\r\n //禁用深度测试\r\n disableDepthTestDistance: Infinity\r\n })\r\n labels.push(label)\r\n layer.labels.push(label)\r\n }\r\n\r\n for (const sourceFeature of features) {\r\n const feature = sourceFeature.toGeoJSON(tile.x, tile.y, tile.z)\r\n if (!feature.geometry) continue\r\n const properties = sourceFeature.properties\r\n\r\n //读取图层样式属性\r\n const iconImage = style.layout.getDataValue('icon-image', tile.z, sourceFeature)\r\n const textField = style.layout.getDataValue('text-field', tile.z, sourceFeature)\r\n let text = textField && style.layout.resolveTokens(properties, textField)\r\n if (iconImage) {\r\n warnOnce('symbol图层:不支持图标')\r\n continue\r\n }\r\n if (!text) {\r\n continue\r\n }\r\n const maxWidth = style.layout.getDataValue('text-max-width', tile.z, sourceFeature) * 3\r\n const textRotationAlignment = style.layout.getDataValue('text-rotation-alignment', tile.z, sourceFeature)\r\n const textPitchAlignment = style.layout.getDataValue('text-pitch-alignment', tile.z, sourceFeature)\r\n if (text.length > maxWidth) {\r\n warnOnce('symbol图层: 不支持 text-max-width,无自动换行效果')\r\n }\r\n if (textRotationAlignment === 'map') {\r\n warnOnce('symbol图层:text-rotation-alignment 仅支持 viewport')\r\n }\r\n if (textPitchAlignment === 'map') {\r\n warnOnce('symbol图层:text-pitch-alignment 仅支持 viewport')\r\n }\r\n\r\n const font = style.layout.getDataValue('text-font', tile.z, sourceFeature)\r\n const textSize = style.layout.getDataValue('text-size', tile.z, sourceFeature)\r\n const textColor = style.convertColor(style.paint.getDataValue('text-color', tile.z, sourceFeature))\r\n const outlineColor = style.convertColor(style.paint.getDataValue('text-halo-color', tile.z, sourceFeature))\r\n const outlineWidth = style.paint.getDataValue('text-halo-width', tile.z, sourceFeature)\r\n\r\n const geometryType = feature.geometry.type\r\n const coordinates = feature.geometry.coordinates\r\n if (geometryType == 'Point') {\r\n addText(coordinates, text, font, textSize, textColor, outlineWidth, outlineColor)\r\n }\r\n else if (geometryType == 'MultiPoint') {\r\n coordinates.forEach(coord => {\r\n addText(coord, text, font, textSize, textColor, outlineWidth, outlineColor)\r\n })\r\n }\r\n else {\r\n warnOnce('symbol图层:不支持符号沿线布局');\r\n }\r\n }\r\n\r\n this.layers.push(layer)\r\n }\r\n\r\n createPrimitive() {\r\n //所有图层的文字共用一个LabelCollection\r\n //注意:这样文字就没有了“图层”的特征了,渲染顺序可能和样式配置的不一致\r\n //优化:参考 maplibre-gl 的符号系统实现,但工作量巨大,如有需求建议使用商业版(Mesh-3D矢量地图引擎)\r\n\r\n const primitive = new Cesium.LabelCollection()\r\n for (let i = 0; i < this.labels.length; i++) {\r\n this.labels[i] = primitive.add(this.labels[i])\r\n }\r\n this.primitive = primitive\r\n }\r\n\r\n update(frameState, tileset) {\r\n if (!this.primitive && this.labels?.length) {\r\n this.createPrimitive()\r\n }\r\n\r\n //我们禁用了 label 的深度测试,这里剔除中心位置在地球背面的符号\r\n const cameraPositionWC = frameState.camera.positionWC\r\n for (const label of this.labels) {\r\n label.show = !this.isOccluded(cameraPositionWC, label.position)\r\n }\r\n\r\n //性能优化:这里应该进行自动避让处理\r\n\r\n if (this.primitive) {\r\n this.primitive.update(frameState)\r\n }\r\n }\r\n\r\n destroy() {\r\n this.primitive = this.primitive && this.primitive.destroy()\r\n super.destroy()\r\n }\r\n\r\n isDestroyed() {\r\n return false\r\n }\r\n}","import * as MVT from '@mapbox/vector-tile'\r\nimport { StyleLayer } from '../style/StyleLayer'\r\nimport { VectorTileLOD } from '../VectorTileLOD'\r\nimport { IRenderLayer } from './IRenderLayer'\r\nimport { SymbolLayerVisualizer } from './visualizers/SymbolLayerVisualizer'\r\nimport { registerRenderLayer } from './registerRenderLayer'\r\n\r\nexport class SymbolRenderLayer extends IRenderLayer {\r\n /**\r\n * @param {MVT.VectorTileFeature[]} sourceFeatures \r\n * @param {StyleLayer} style \r\n * @param {VectorTileLOD} tile \r\n */\r\n constructor(sourceFeatures, styleLayer, tile) {\r\n super(sourceFeatures, styleLayer, tile)\r\n this.labels = []\r\n }\r\n\r\n /**\r\n * @param {Cesium.FrameState} frameState \r\n * @param {VectorTileset} tileset \r\n */\r\n update(frameState, tileset) {\r\n //TODO:动态更新符号样式\r\n\r\n super.update(frameState, tileset)\r\n }\r\n\r\n}\r\n\r\nregisterRenderLayer('symbol', SymbolRenderLayer, SymbolLayerVisualizer)"],"names":["Point","x","y","p","k","a","m","other","dx","dy","b","angle","cos","sin","VectorTileFeature","pbf","end","extent","keys","values","readFeature","lines","line","cmd","length","cmdLen","x1","x2","y1","y2","z","size","x0","y0","vtCoords","projectPoint","projectLine","geometry","points","coordinates","polygons","classifyRings","polygon","result","tag","feature","readTag","key","value","rings","len","ccw","i","area","signedArea","ring","sum","j","p1","p2","VectorTileLayer","readLayer","layer","readValueMessage","VectorTile","readTile","layers","ISource","styleSource","path","Sources","registerSource","type","sourceCls","SHIFT_LEFT_32","SHIFT_RIGHT_32","TEXT_DECODER_MIN_LENGTH","utf8TextDecoder","PBF_VARINT","PBF_FIXED64","PBF_BYTES","PBF_FIXED32","Pbf","buf","readField","val","startPos","isSigned","readVarintRemainder","num","pos","readUtf8","buffer","arr","min","writeBigVarint","str","writeUtf8","makeRoomForExtraLength","fn","obj","writePackedVarint","writePackedSVarint","writePackedBoolean","writePackedFloat","writePackedDouble","writePackedFixed32","writePackedSFixed32","writePackedFixed64","writePackedSFixed64","l","s","h","toNum","low","high","writeBigVarintLow","writeBigVarintHigh","lsb","extraLen","b0","c","bytesPerSequence","b1","b2","b3","lead","VectorSource","sourceParams","url","metadata","err","tileUrl","tileBuf","res","simplify","coords","first","last","sqTolerance","maxSqDist","mid","minPosToMid","index","ax","ay","bx","by","getSqSegDist","posToMid","px","py","t","createFeature","id","geom","tags","calcLineBBox","convert","data","options","features","convertFeature","geojson","tolerance","convertPoint","convertLine","convertLines","newPolygon","singleGeometry","out","projectX","projectY","isPolygon","clip","scale","k1","k2","axis","minAll","maxAll","clipped","max","newGeometry","clipPoints","clipLine","clipLines","newGeom","addPoint","trackMetrics","slice","newSlice","intersect","intersectX","intersectY","segLen","az","exited","wrap","merged","left","right","shiftFeatureCoords","offset","newFeatures","shiftCoords","newPoints","transformTile","tile","z2","tx","ty","transformPoint","createTile","addFeature","simplified","addLine","tileFeature","isOuter","rewind","clockwise","defaultOptions","GeoJSONVT","extend","debug","cz","cx","cy","stack","toID","zoomSteps","k3","k4","tl","bl","tr","br","transform","z0","parent","dest","src","geojsonvt","n","e","r","EXTENT","GeoJSONSource","geoJSONTile","GeoJSONWrapper","$version","$root","sources","source","source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image","layout","layout_background","layout_fill","layout_circle","layout_heatmap","layout_line","layout_symbol","layout_raster","layout_hillshade","filter","filter_operator","geometry_type","function_stop","expression$1","light","sky","terrain","projection","paint","paint_fill","paint_line","paint_circle","paint_heatmap","paint_symbol","paint_raster","paint_hillshade","paint_background","transition","promoteId","interpolation","interpolation_name","v8Spec","extendBy","output","inputs","input","ExpressionParsingError","message","Scope","bindings","name","expression","NullType","NumberType","StringType","BooleanType","ColorType","ProjectionDefinitionType","ObjectType","ValueType","ErrorType","CollatorType","FormattedType","PaddingType","ColorArrayType","NumberArrayType","ResolvedImageType","VariableAnchorOffsetCollectionType","array","itemType","N","typeToString","valueMemberTypes","checkSubtype","expected","memberType","isValidType","provided","allowedTypes","isValidNativeType","verifyType","sample","Xn","Yn","Zn","t0","t1","t2","t3","deg2rad","rad2deg","constrainAngle","rgbToLab","g","alpha","rgb2xyz","xyz2lab","labToRgb","lab2xyz","xyz2rgb","rgbToHcl","rgbColor","hclToRgb","hslToRgb","f","hasOwnProperty","object","getOwn","parseCssColor","namedColorsMatch","namedColors","step","parseHex","rgbRegExp","rgbMatch","_","rp","f1","gp","f2","bp","f3","ap","argFormat","valFormat","maxValue","rgba","clamp","parseAlpha","validateNumbers","hslRegExp","hslMatch","hsla","hex","asPercentage","interpolateNumber","from","to","interpolateArray","d","isSupportedInterpolationColorSpace","colorSpace","Color","premultiplied","getterKey","lazyValue","spaceKey","hue0","chroma0","light0","alphaF","hue1","chroma1","light1","alphaT","hue","chroma","dh","Collator","caseSensitive","diacriticSensitive","locale","lhs","rhs","VERTICAL_ALIGN_OPTIONS","FormattedSection","text","image","fontStack","textColor","verticalAlign","Formatted","sections","unformatted","section","Padding","NumberArray","ColorArray","parsed_val","colors","RuntimeError","anchors","VariableAnchorOffsetCollection","anchorValue","offsetValue","fromValues","toValues","fx","fy","ResolvedImage","ProjectionDefinition","validateRGBA","isValue","mixed","item","typeOf","valueToString","Literal","args","context","types$1","Assertion","parsed","ctx","arg","types","Coercion","error","pad","coll","geometryTypes","EvaluationContext","cached","ParsingContext","registry","isConstantFunc","expectedType","scope","errors","part","expr","annotate","typeAnnotation","op","Expr","actual","ec","Let","binding","Var","boundExpression","At","In","needle","haystack","IndexOf","fromIndex","rawIndex","Match","inputType","outputType","cases","outputs","otherwise","labels","labelContext","label","Case","branches","test","Slice","beginIndex","endIndex","findStopLessThanOrEqualTo","stops","lastIndex","lowerIndex","upperIndex","currentIndex","currentValue","nextValue","Step","labelKey","valueKey","stopCount","getDefaultExportFromCjs","unitbezier","hasRequiredUnitbezier","requireUnitbezier","UnitBezier","p1x","p1y","p2x","p2y","epsilon","d2","unitbezierExports","Interpolate","operator","lower","upper","exponentialInterpolation","rest","base","controlPoints","outputLower","outputUpper","lowerValue","upperValue","difference","progress","interpolateFactory","Coalesce","parsedArgs","argCount","requestedImageName","isComparableType","eq","neq","lt","gt","lteq","gteq","eqCollate","neqCollate","ltCollate","gtCollate","lteqCollate","gteqCollate","makeComparison","compareBasic","compareWithCollator","isOrderComparison","Comparison","collator","rt","Equals","NotEquals","LessThan","GreaterThan","LessThanOrEqual","GreaterThanOrEqual","CollatorExpression","NumberFormat","number","currency","minFractionDigits","maxFractionDigits","FormatExpression","firstArg","nextTokenMayBeObject","font","lastExpression","content","kind","evaluateSection","evaluatedContent","ImageExpression","evaluatedImageName","Length","getTileCoordinates","canonical","mercatorXfromLng","mercatorYfromLat","tilesAtZoom","getLngLatFromTileCoord","coord","lngFromMercatorXfromLng","latFromMercatorY","lng","mercatorX","lat","mercatorY","updateBBox","bbox","boxWithinBox","bbox1","bbox2","rayIntersect","pointOnBoundary","segmentIntersectSegment","vectorP","vectorQ","perp","twoSided","lineIntersectPolygon","pointWithinPolygon","point","trueIfOnBoundary","inside","pointWithinPolygons","lineStringWithinPolygon","lineStringWithinPolygons","v1","v2","q1","q2","x3","y3","det1","det2","getTilePolygon","getTilePolygons","updatePoint","polyBBox","worldSize","halfWorldSize","shift","resetBBox","getTilePoints","pointBBox","shifts","tilePoints","getTileLines","lineBBox","tileLines","tileLine","pointsWithinPolygons","polygonGeometry","tilePolygon","tilePolygons","linesWithinPolygons","Within","geometries","polygonsCoords","multipolygonWrapper","TinyQueue","compare","top","bottom","current","halfLength","bestChild","maxRings","calculateSignedArea","RE","FE","E2","RAD","CheapRuler","coslat","w2","w","minDist","minX","minY","minI","minT","sqDist","deg","MinPointsSize","MinLinePointsSize","compareDistPair","getRangeSize","range","isRangeSafe","threshold","splitRange","isLine","size1","getBBox","getPolygonBBox","isValidBBox","bboxToBBoxDistance","ruler","pointToLineDistance","nearestPoint","segmentToSegmentDistance","dist1","dist2","lineToLineDistance","line1","range1","line2","range2","dist","pointsToPointsDistance","points1","points2","pointToPolygonDistance","front","back","lineToPolygonDistance","polygonIntersect","poly1","poly2","polygonToPolygonDistance","polygon1","polygon2","currentMiniDist","ring1","len1","ring2","len2","updateQueue","distQueue","miniDist","rangeA","tempDist","updateQueueTwoSets","pointSet1","pointSet2","pointsToPolygonDistance","distPair","newRangesA","pointSetToPointSetDistance","isLine1","isLine2","rangeB","threshold1","threshold2","sublibe","newRangesB","pointToGeometryDistance","pointPosition","lineStringToGeometryDistance","linePositions","polygonToGeometryDistance","toSimpleGeometry","lineString","Distance","GlobalState","_a","globalState","expressions$1","CompoundExpression","evaluate","definition","availableOverloads","overloads","signature","signatureContext","params","isExpressionConstant","argParseFailed","signatures","stringifySignature","actualTypes","definitions","has","get","v","binarySearch","varargs","isSupportedScript","isTypeAnnotation","childrenConstant","child","isFeatureConstant","isGlobalPropertyConstant","isStateConstant","properties","success","supportsPropertyExpression","spec","supportsZoomExpression","supportsInterpolation","getType","isFunction$1","identityFunction","getParseFunction","propertySpec","getInnerFunction","evaluateExponentialFunction","evaluateIntervalFunction","evaluateCategoricalFunction","evaluateIdentityFunction","createFunction","parameters","zoomAndFeatureDependent","featureDependent","zoomDependent","parseFn","stop","innerFun","hashedStops","categoricalKeyType","featureFunctions","zoomStops","zoom","featureFunctionStops","interpolationType","coalesce$1","keyType","evaluated","interpolationFactor","interp","evaluatedLower","evaluatedUpper","StyleExpression","getDefaultValue","globals","featureState","availableImages","formattedSection","addGlobalState","isExpression","createExpression","parser","getExpectedType","ZoomConstantExpression","findGlobalStateRefs","ZoomDependentExpression","isZoomExpression","createPropertyExpression","expressionInput","isFeatureConstantResult","isZoomConstant","zoomCurve","findZoomCurve","StylePropertyFunction","specification","serialized","normalizePropertyExpression","constant","childResult","results","childExpression","heatmapDensity","elevation","lineProgress","accumulated","isExpressionFilter","filterSpec","featureFilter","convertFilter$1","compiled","needGeometry","geometryNeeded","globalProperties","convertComparisonOp$1","convertNegation","convertDisjunctionOp","convertInOp$1","convertHasOp$1","property","filters","StyleLayerProperties","groupName","styleProperties","groupReference","latest","reference","match","StyleLayer","styleColor","alphaScalar","VectorTileRenderList","styleLayers","renderLayers","layerIndexMap","layerIndex","styleLayer","renderLayer","list","earcut","holeIndices","dim","hasHoles","outerLen","outerNode","linkedList","triangles","invSize","eliminateHoles","maxX","maxY","earcutLinked","start","insertNode","equals","removeNode","filterPoints","again","ear","pass","indexCurve","prev","next","isEarHashed","isEar","cureLocalIntersections","splitEarcut","pointInTriangleExceptFirst","minZ","zOrder","maxZ","intersects","locallyInside","isValidDiagonal","splitPolygon","queue","getLeftmost","compareXYSlope","eliminateHole","aSlope","bSlope","hole","bridge","findHoleBridge","bridgeReverse","hx","hy","qx","mx","my","tanMin","pointInTriangle","tan","sectorContainsSector","sortLinked","numMerges","inSize","tail","q","pSize","qSize","leftmost","intersectsPolygon","middleInside","o1","sign","o2","o3","o4","onSegment","a2","createNode","an","SubdivisionGranularityExpression","baseZoomGranularity","minGranularity","zoomLevel","divisor","_SubdivisionGranularitySetting","SubdivisionGranularitySetting","NUM_PARAMS","TransferableGridIndex","padding","cells","keysOffset","bboxesOffset","cellIndex","uid","intersectionTest","seenUids","cell","bboxes","u","arg1","arg2","cx1","cy1","cx2","cy2","metadataLength","totalCellLength","grid","transferables","bezier","warnOnceHistory","warnOnce","AJAXError","status","statusText","body","register","klass","expressions","NORTH_POLE_Y","SOUTH_POLE_Y","Subdivider","granularity","xInt","yInt","inputIndices","fixWindingOrder","finalIndices","numIndices","primitiveIndex","triangleIndices","triangleVertices","vx","vy","cellXmin","cellXmax","cellYmin","cellYmax","cellRow","scanlineTriangulateVertexRing","cellRowYTop","cellRowYBottom","edgeIndex","aX","aY","bX","bY","cX","cY","dirX","dirY","isParallelY","isParallelX","tTop","tBottom","tEnter","tExit","enterX","exitX","leftX","rightX","edgeSubdivisionLeftCellX","edgeSubdivisionRightCellX","cellX","dir2X","dir2Y","t2Top","t2Bottom","t2Enter","t2Exit","enter2X","boundarySubdivisionLeftCellX","boundarySubdivisionRightCellX","isBoundaryLeftToRight","isParallelX2","dir3X","dir3Y","t3Top","t3Bottom","t3Enter","enter3X","boundaryY","subdividedLines","subdivideVertexLine","pathIndices","lineIndices","subdividedTriangles","north","south","flattened","indices","i0","i1","v0x","v1x","poleY","northEdge","southEdge","i2","v0y","v1y","v2x","v2y","generateOutlineLines","flatten","earcutResult","cut","vertices","oldIndices","newIndices","subdividePolygon","linePoints","isRing","addLastToFirstSegment","cellSize","finalLineVertices","totalPoints","pointIndex","linePoint0","linePoint1","lineVertex0x","lineVertex0y","lineVertex1x","lineVertex1y","dirXnonZero","dirYnonZero","absDirX","absDirY","lastPointX","lastPointY","nextBoundaryX","nextBoundaryY","axisDistanceToBoundaryX","axisDistanceToBoundaryY","axisDistanceToEndX","axisDistanceToEndY","realDistanceToBoundaryX","realDistanceToBoundaryY","corrected","e0x","e0y","e1x","e1y","vertexBuffer","leftmostIndex","leftmostX","ringVertexLength","lastEdgeA","lastEdgeB","candidateIndexA","candidateIndexB","candidateAx","candidateAy","candidateBx","candidateBy","lastEdgeAx","lastEdgeAy","lastEdgeBx","lastEdgeBy","pickA","ex","nx","ny","aRight","bRight","granularitySettings","tileDepthRenderSate","nextTileKey","levelZeroMaximumGeometricError","getLevelMaximumGeometricError","tilingScheme","screenSpaceError","frameState","maxGeometricError","distance2","height","sseDenominator","initConstants","VectorTileLOD","lonlat","tiles","visitor","tileBoundingRegion","maxSSE","tileset","sourcesToLoad","style","sourceId","tileData","visualizers","visualizerMap","sourceVectorTile","RenderLayer","RenderLayers","LayerVisualizer","LayerVisualizers","isBackgroundLayer","sourceLayer","vectorTileLayer","featureCount","visualizer","renderList","tileComandList","tileIdCommands","tileDepthCommands","preCommandList","tileIdColor","tileComand","tileIdCommand","tileDepthCommand","VectorTileset","SourceCls","numX","numY","tileIdFbo","pixelDatatype","width","framebuffer","scene","globeSuspendLodUpdate","tilesToRender","getTilesToRender","orderedRenderLayers","expiredTiles","cacheTile","expiredTile","rootTiles","IRenderLayer","sourceFeatures","commandList","command","ILayerVisualizer","registerRenderLayer","renderLayerCls","layerVisualizerCls","BackgroundRenderLayer","color","opacity","primitive","layerCommandList","renderState","layerCommand","BITS","MAX","MIN","loadGeometry","FillLayerVisualizer","geometryInstances","featureId","sourceFeature","featureType","sourceFeatureId","fillColor","fillOpacity","batchId","fillFeature","colorBytes","subdivisionRes","verticesFlattened","coordDeg","cartesian","vertCount","positions","normals","sts","position","normal","cartographic","center","instance","batchTable","batches","batchIds","currBatchId","currBatch","vertIndex","firstBatchId","lastBatchId","begin","batch","batchedCommandList","tileId","count","FillRenderLayer","toGeoJSON","mvt.VectorTileFeature","LineLayerVisualizer","dasharray","addPolyline","lineWidth","lineColor","lineOpacity","lineFeature","lineJoin","lineCap","geometryType","boundingSphere","modifyUniformMap","uniformMap","LineRenderLayer","scratchDirectionToEye","scratchSurfaceNormal","SymbolLayerVisualizer","cameraPositionWC","positionWC","eyeDir","up","rectangle","addText","textSize","outlineWidth","outlineColor","iconImage","textField","maxWidth","textRotationAlignment","textPitchAlignment","SymbolRenderLayer"],"mappings":"AAWe,SAASA,EAAMC,GAAGC,GAAG;AAChC,OAAK,IAAID,GACT,KAAK,IAAIC;AACb;AAEAF,EAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMd,QAAQ;AAAE,WAAO,IAAIA,EAAM,KAAK,GAAG,KAAK,CAAC;AAAA,EAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,IAAIG,GAAG;AAAE,WAAO,K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