@mapbox/mapbox-gl-style-spec 14.4.0 → 14.5.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.
Files changed (142) hide show
  1. package/bin/gl-style-composite.js +0 -5
  2. package/bin/gl-style-format.js +0 -5
  3. package/bin/gl-style-migrate.js +0 -5
  4. package/bin/gl-style-validate.js +0 -5
  5. package/{composite.js → composite.ts} +1 -1
  6. package/data/{extent.js → extent.ts} +0 -2
  7. package/{deref.js → deref.ts} +7 -9
  8. package/{diff.js → diff.ts} +44 -21
  9. package/dist/index.cjs +794 -1226
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.ts +1746 -0
  12. package/dist/index.es.js +794 -1226
  13. package/dist/index.es.js.map +1 -1
  14. package/{empty.js → empty.ts} +1 -2
  15. package/error/{parsing_error.js → parsing_error.ts} +0 -2
  16. package/error/{validation_error.js → validation_error.ts} +5 -5
  17. package/expression/{compound_expression.js → compound_expression.ts} +29 -19
  18. package/expression/definitions/{assertion.js → assertion.ts} +16 -13
  19. package/expression/definitions/{at.js → at.ts} +12 -13
  20. package/expression/definitions/{case.js → case.ts} +12 -11
  21. package/expression/definitions/{coalesce.js → coalesce.ts} +11 -11
  22. package/expression/definitions/{coercion.js → coercion.ts} +21 -20
  23. package/expression/definitions/{collator.js → collator.ts} +11 -11
  24. package/expression/definitions/{comparison.js → comparison.ts} +30 -24
  25. package/expression/definitions/{config.js → config.ts} +16 -16
  26. package/expression/definitions/{distance.js → distance.ts} +60 -52
  27. package/expression/definitions/{format.js → format.ts} +26 -15
  28. package/expression/definitions/{image.js → image.ts} +12 -12
  29. package/expression/definitions/{in.js → in.ts} +22 -13
  30. package/expression/definitions/{index.js → index.ts} +70 -83
  31. package/expression/definitions/{index_of.js → index_of.ts} +24 -15
  32. package/expression/definitions/{interpolate.js → interpolate.ts} +44 -25
  33. package/expression/definitions/{length.js → length.ts} +11 -10
  34. package/expression/definitions/{let.js → let.ts} +10 -7
  35. package/expression/definitions/{literal.js → literal.ts} +11 -12
  36. package/expression/definitions/{match.js → match.ts} +25 -15
  37. package/expression/definitions/{number_format.js → number_format.ts} +10 -10
  38. package/expression/definitions/{slice.js → slice.ts} +23 -15
  39. package/expression/definitions/{step.js → step.ts} +14 -12
  40. package/expression/definitions/{var.js → var.ts} +5 -7
  41. package/expression/definitions/{within.js → within.ts} +41 -29
  42. package/expression/{evaluation_context.js → evaluation_context.ts} +26 -23
  43. package/expression/expression.ts +29 -0
  44. package/expression/{index.js → index.ts} +208 -110
  45. package/expression/{is_constant.js → is_constant.ts} +5 -7
  46. package/expression/{parsing_context.js → parsing_context.ts} +47 -34
  47. package/expression/{parsing_error.js → parsing_error.ts} +0 -2
  48. package/expression/{runtime_error.js → runtime_error.ts} +0 -2
  49. package/expression/{scope.js → scope.ts} +5 -5
  50. package/expression/{stops.js → stops.ts} +2 -4
  51. package/expression/types/{collator.js → collator.ts} +1 -3
  52. package/expression/types/{formatted.js → formatted.ts} +8 -7
  53. package/expression/types/{resolved_image.js → resolved_image.ts} +5 -7
  54. package/expression/{types.js → types.ts} +53 -45
  55. package/expression/{values.js → values.ts} +12 -12
  56. package/feature_filter/{convert.js → convert.ts} +19 -18
  57. package/feature_filter/{index.js → index.ts} +39 -21
  58. package/{format.js → format.ts} +3 -3
  59. package/function/{convert.js → convert.ts} +44 -44
  60. package/function/{index.js → index.ts} +12 -12
  61. package/{group_by_layout.js → group_by_layout.ts} +11 -8
  62. package/migrate/{expressions.js → expressions.ts} +7 -16
  63. package/migrate/{v8.js → v8.ts} +2 -2
  64. package/migrate/{v9.js → v9.ts} +2 -2
  65. package/{migrate.js → migrate.ts} +3 -3
  66. package/package.json +19 -18
  67. package/{read_style.js → read_style.ts} +5 -4
  68. package/reference/latest.ts +5 -0
  69. package/reference/v8.json +264 -7
  70. package/rollup.config.js +6 -24
  71. package/{style-spec.js → style-spec.ts} +41 -36
  72. package/test.js +3 -2
  73. package/types/config_options.ts +13 -0
  74. package/types/lut.ts +7 -0
  75. package/types/tile_id.ts +5 -0
  76. package/{types.js → types.ts} +527 -165
  77. package/util/{color.js → color.ts} +89 -3
  78. package/util/{color_spaces.js → color_spaces.ts} +12 -14
  79. package/util/{deep_equal.js → deep_equal.ts} +1 -3
  80. package/util/{extend.js → extend.ts} +1 -3
  81. package/util/{geometry_util.js → geometry_util.ts} +23 -11
  82. package/util/{get_type.js → get_type.ts} +1 -3
  83. package/util/{interpolate.js → interpolate.ts} +1 -3
  84. package/util/{properties.js → properties.ts} +5 -4
  85. package/util/{random.js → random.ts} +0 -2
  86. package/util/{ref_properties.js → ref_properties.ts} +0 -1
  87. package/util/{result.js → result.ts} +7 -5
  88. package/util/{unbundle_jsonlint.js → unbundle_jsonlint.ts} +5 -5
  89. package/validate/{validate.js → validate.ts} +33 -35
  90. package/validate/{validate_array.js → validate_array.ts} +5 -7
  91. package/validate/{validate_boolean.js → validate_boolean.ts} +3 -5
  92. package/validate/{validate_color.js → validate_color.ts} +3 -5
  93. package/validate/{validate_enum.js → validate_enum.ts} +4 -5
  94. package/validate/{validate_expression.js → validate_expression.ts} +7 -9
  95. package/validate/{validate_filter.js → validate_filter.ts} +16 -12
  96. package/validate/{validate_fog.js → validate_fog.ts} +4 -6
  97. package/validate/validate_formatted.ts +13 -0
  98. package/validate/{validate_function.js → validate_function.ts} +14 -16
  99. package/validate/{validate_glyphs_url.js → validate_glyphs_url.ts} +3 -5
  100. package/validate/validate_image.ts +13 -0
  101. package/validate/{validate_import.js → validate_import.ts} +6 -8
  102. package/validate/{validate_layer.js → validate_layer.ts} +17 -15
  103. package/validate/{validate_layout_property.js → validate_layout_property.ts} +3 -5
  104. package/validate/{validate_light.js → validate_light.ts} +4 -6
  105. package/validate/{validate_lights.js → validate_lights.ts} +7 -9
  106. package/validate/{validate_model.js → validate_model.ts} +4 -6
  107. package/validate/{validate_number.js → validate_number.ts} +4 -6
  108. package/validate/{validate_object.js → validate_object.ts} +5 -8
  109. package/validate/{validate_paint_property.js → validate_paint_property.ts} +3 -5
  110. package/validate/{validate_projection.js → validate_projection.ts} +4 -6
  111. package/validate/{validate_property.js → validate_property.ts} +15 -15
  112. package/validate/{validate_source.js → validate_source.ts} +16 -13
  113. package/validate/validate_string.ts +16 -0
  114. package/validate/validate_style.ts +33 -0
  115. package/validate/{validate_terrain.js → validate_terrain.ts} +5 -7
  116. package/{validate_mapbox_api_supported.js → validate_mapbox_api_supported.ts} +22 -18
  117. package/{validate_style.min.js → validate_style.min.ts} +20 -21
  118. package/{validate_style.js → validate_style.ts} +9 -9
  119. package/{visit.js → visit.ts} +22 -17
  120. package/.eslintrc +0 -10
  121. package/expression/expression.js +0 -28
  122. package/flow-typed/cheap-ruler.js +0 -25
  123. package/flow-typed/geojson.js +0 -44
  124. package/flow-typed/gl-matrix.js +0 -119
  125. package/flow-typed/gl.js +0 -5
  126. package/flow-typed/intl.js +0 -58
  127. package/flow-typed/kdbush.js +0 -9
  128. package/flow-typed/mapbox-gl-supported.js +0 -16
  129. package/flow-typed/mapbox-unitbezier.js +0 -14
  130. package/flow-typed/offscreen-canvas.js +0 -9
  131. package/flow-typed/pbf.js +0 -26
  132. package/flow-typed/point-geometry.js +0 -46
  133. package/flow-typed/potpack.js +0 -13
  134. package/flow-typed/tiny-sdf.js +0 -31
  135. package/flow-typed/tracked_parameters_proxy.js +0 -82
  136. package/flow-typed/vector-tile.js +0 -49
  137. package/flow-typed/webgl2.js +0 -41
  138. package/reference/latest.js +0 -7
  139. package/validate/validate_formatted.js +0 -15
  140. package/validate/validate_image.js +0 -15
  141. package/validate/validate_string.js +0 -18
  142. package/validate/validate_style.js +0 -29
package/dist/index.es.js CHANGED
@@ -111,6 +111,10 @@ var $root = {
111
111
  type: "camera",
112
112
  doc: "Global setting to control additional camera intrinsics parameters, e.g. projection type (perspective / orthographic)."
113
113
  },
114
+ "color-theme": {
115
+ type: "colorTheme",
116
+ doc: "A global modifier for the colors of the style."
117
+ },
114
118
  imports: {
115
119
  type: "array",
116
120
  value: "import",
@@ -227,6 +231,10 @@ var option = {
227
231
  "default": {
228
232
  type: "*",
229
233
  doc: "Default configuration value for this option.",
234
+ "property-type": "data-constant",
235
+ expression: {
236
+ interpolated: false
237
+ },
230
238
  required: true
231
239
  },
232
240
  type: {
@@ -810,6 +818,7 @@ var source_raster_dem = {
810
818
  }
811
819
  };
812
820
  var source_raster_array = {
821
+ experimental: true,
813
822
  type: {
814
823
  required: true,
815
824
  type: "enum",
@@ -1143,6 +1152,7 @@ var layer = {
1143
1152
  }
1144
1153
  },
1145
1154
  "raster-particle": {
1155
+ experimental: true,
1146
1156
  doc: "Particle animation driven by textures such as wind maps.",
1147
1157
  "sdk-support": {
1148
1158
  "basic functionality": {
@@ -1164,6 +1174,7 @@ var layer = {
1164
1174
  },
1165
1175
  model: {
1166
1176
  doc: "A 3D model",
1177
+ experimental: true,
1167
1178
  "sdk-support": {
1168
1179
  "basic functionality": {
1169
1180
  js: "3.0.0",
@@ -1201,6 +1212,17 @@ var layer = {
1201
1212
  ios: "11.0.0"
1202
1213
  }
1203
1214
  }
1215
+ },
1216
+ clip: {
1217
+ doc: "Layer that removes 3D content from map.",
1218
+ "sdk-support": {
1219
+ "basic functionality": {
1220
+ js: "3.5.0",
1221
+ android: "11.5.0",
1222
+ ios: "11.5.0"
1223
+ },
1224
+ experimental: true
1225
+ }
1204
1226
  }
1205
1227
  },
1206
1228
  doc: "Rendering type of this layer.",
@@ -1255,6 +1277,7 @@ var layer = {
1255
1277
  }
1256
1278
  };
1257
1279
  var layout = [
1280
+ "layout_clip",
1258
1281
  "layout_fill",
1259
1282
  "layout_line",
1260
1283
  "layout_circle",
@@ -1390,6 +1413,35 @@ var layout_model = {
1390
1413
  ]
1391
1414
  }
1392
1415
  };
1416
+ var layout_clip = {
1417
+ "clip-layer-types": {
1418
+ type: "array",
1419
+ value: "enum",
1420
+ values: {
1421
+ model: {
1422
+ doc: "If present the clip layer would remove all 3d model layers below it. Currently only instanced models (e.g. trees) are removed."
1423
+ },
1424
+ symbol: {
1425
+ doc: "If present the clip layer would remove all symbol layers below it."
1426
+ }
1427
+ },
1428
+ "default": [
1429
+ ],
1430
+ doc: "Layer types that will also be removed if fallen below this clip layer.",
1431
+ "sdk-support": {
1432
+ "basic functionality": {
1433
+ js: "3.5.0",
1434
+ android: "11.5.0",
1435
+ ios: "11.5.0"
1436
+ }
1437
+ },
1438
+ expression: {
1439
+ interpolated: false
1440
+ },
1441
+ "property-type": "data-constant",
1442
+ experimental: true
1443
+ }
1444
+ };
1393
1445
  var layout_fill = {
1394
1446
  "fill-sort-key": {
1395
1447
  type: "number",
@@ -1682,6 +1734,32 @@ var layout_line = {
1682
1734
  },
1683
1735
  "property-type": "data-driven"
1684
1736
  },
1737
+ "line-z-offset": {
1738
+ type: "number",
1739
+ experimental: true,
1740
+ doc: "Vertical offset from ground, in meters. Defaults to 0. Not supported for globe projection at the moment.",
1741
+ "sdk-support": {
1742
+ "basic functionality": {
1743
+ js: "3.5.0",
1744
+ android: "11.5.0",
1745
+ ios: "11.5.0"
1746
+ },
1747
+ "data-driven styling": {
1748
+ js: "3.5.0",
1749
+ android: "11.5.0",
1750
+ ios: "11.5.0"
1751
+ }
1752
+ },
1753
+ expression: {
1754
+ interpolated: false,
1755
+ parameters: [
1756
+ "zoom",
1757
+ "feature",
1758
+ "line-progress"
1759
+ ]
1760
+ },
1761
+ "property-type": "data-driven"
1762
+ },
1685
1763
  visibility: {
1686
1764
  type: "enum",
1687
1765
  values: {
@@ -4638,6 +4716,17 @@ var camera = {
4638
4716
  "property-type": "data-constant"
4639
4717
  }
4640
4718
  };
4719
+ var colorTheme = {
4720
+ data: {
4721
+ type: "string",
4722
+ doc: "Expects a base64 encoded PNG image which represents a cube strip LUT. The height of the image cannot exceed 32 pixels and the width must be equal to the height squared.",
4723
+ transition: false,
4724
+ "property-type": "data-constant",
4725
+ expression: {
4726
+ interpolated: false
4727
+ }
4728
+ }
4729
+ };
4641
4730
  var light = {
4642
4731
  anchor: {
4643
4732
  type: "enum",
@@ -4896,6 +4985,7 @@ var paint = [
4896
4985
  "paint_fill-extrusion",
4897
4986
  "paint_symbol",
4898
4987
  "paint_raster",
4988
+ "paint_raster-particle",
4899
4989
  "paint_hillshade",
4900
4990
  "paint_background",
4901
4991
  "paint_sky",
@@ -5478,7 +5568,7 @@ var paint_line = {
5478
5568
  "line-trim-offset": {
5479
5569
  type: "array",
5480
5570
  value: "number",
5481
- doc: "The line part between [trim-start, trim-end] will be marked as transparent to make a route vanishing effect. The line trim-off offset is based on the whole line range [0.0, 1.0].",
5571
+ doc: "The line part between [trim-start, trim-end] will be painted using `line-trim-color,` which is transparent by default to produce a route vanishing effect. The line trim-off offset is based on the whole line range [0.0, 1.0].",
5482
5572
  length: 2,
5483
5573
  "default": [
5484
5574
  0,
@@ -5510,6 +5600,81 @@ var paint_line = {
5510
5600
  },
5511
5601
  "property-type": "constant"
5512
5602
  },
5603
+ "line-trim-fade-range": {
5604
+ type: "array",
5605
+ value: "number",
5606
+ doc: "The fade range for the trim-start and trim-end points is defined by the `line-trim-offset` property. The first element of the array represents the fade range from the trim-start point toward the end of the line, while the second element defines the fade range from the trim-end point toward the beginning of the line. The fade result is achieved by interpolating between `line-trim-color` and the color specified by the `line-color` or the `line-gradient` property.",
5607
+ experimental: true,
5608
+ length: 2,
5609
+ "default": [
5610
+ 0,
5611
+ 0
5612
+ ],
5613
+ minimum: [
5614
+ 0,
5615
+ 0
5616
+ ],
5617
+ maximum: [
5618
+ 1,
5619
+ 1
5620
+ ],
5621
+ transition: false,
5622
+ requires: [
5623
+ "line-trim-offset",
5624
+ {
5625
+ source: "geojson",
5626
+ has: {
5627
+ lineMetrics: true
5628
+ }
5629
+ }
5630
+ ],
5631
+ expression: {
5632
+ interpolated: true,
5633
+ parameters: [
5634
+ "zoom",
5635
+ "measure-light"
5636
+ ]
5637
+ },
5638
+ "sdk-support": {
5639
+ "basic functionality": {
5640
+ js: "3.6.0",
5641
+ android: "11.6.0",
5642
+ ios: "11.6.0"
5643
+ }
5644
+ },
5645
+ "property-type": "data-constant"
5646
+ },
5647
+ "line-trim-color": {
5648
+ type: "color",
5649
+ doc: "The color to be used for rendering the trimmed line section that is defined by the `line-trim-offset` property.",
5650
+ experimental: true,
5651
+ "default": "transparent",
5652
+ transition: true,
5653
+ requires: [
5654
+ "line-trim-offset",
5655
+ {
5656
+ source: "geojson",
5657
+ has: {
5658
+ lineMetrics: true
5659
+ }
5660
+ }
5661
+ ],
5662
+ "sdk-support": {
5663
+ "basic functionality": {
5664
+ js: "3.6.0",
5665
+ android: "11.6.0",
5666
+ ios: "11.6.0"
5667
+ }
5668
+ },
5669
+ expression: {
5670
+ interpolated: true,
5671
+ parameters: [
5672
+ "zoom",
5673
+ "measure-light"
5674
+ ]
5675
+ },
5676
+ "property-type": "data-constant"
5677
+ },
5513
5678
  "line-emissive-strength": {
5514
5679
  type: "number",
5515
5680
  "default": 0,
@@ -5592,6 +5757,29 @@ var paint_line = {
5592
5757
  ]
5593
5758
  },
5594
5759
  "property-type": "data-driven"
5760
+ },
5761
+ "line-occlusion-opacity": {
5762
+ type: "number",
5763
+ "default": 0,
5764
+ minimum: 0,
5765
+ maximum: 1,
5766
+ experimental: true,
5767
+ doc: "Opacity multiplier (multiplies line-opacity value) of the line part that is occluded by 3D objects. Value 0 hides occluded part, value 1 means the same opacity as non-occluded part. The property is not supported when `line-opacity` has data-driven styling.",
5768
+ "sdk-support": {
5769
+ "basic functionality": {
5770
+ js: "3.5.0",
5771
+ android: "11.5.0",
5772
+ ios: "11.5.0"
5773
+ }
5774
+ },
5775
+ expression: {
5776
+ interpolated: true,
5777
+ parameters: [
5778
+ "zoom"
5779
+ ]
5780
+ },
5781
+ transition: true,
5782
+ "property-type": "data-constant"
5595
5783
  }
5596
5784
  };
5597
5785
  var paint_circle = {
@@ -6116,6 +6304,39 @@ var paint_symbol = {
6116
6304
  },
6117
6305
  "property-type": "data-driven"
6118
6306
  },
6307
+ "icon-occlusion-opacity": {
6308
+ doc: "The opacity at which the icon will be drawn in case of being depth occluded. Not supported on globe zoom levels.",
6309
+ type: "number",
6310
+ "default": 1,
6311
+ minimum: 0,
6312
+ maximum: 1,
6313
+ transition: true,
6314
+ requires: [
6315
+ "icon-image"
6316
+ ],
6317
+ "sdk-support": {
6318
+ "basic functionality": {
6319
+ js: "3.5.0",
6320
+ android: "11.5.0",
6321
+ ios: "11.6.0"
6322
+ },
6323
+ "data-driven styling": {
6324
+ js: "3.5.0",
6325
+ android: "11.5.0",
6326
+ ios: "11.6.0"
6327
+ }
6328
+ },
6329
+ expression: {
6330
+ interpolated: true,
6331
+ parameters: [
6332
+ "zoom",
6333
+ "feature",
6334
+ "feature-state",
6335
+ "measure-light"
6336
+ ]
6337
+ },
6338
+ "property-type": "data-driven"
6339
+ },
6119
6340
  "icon-emissive-strength": {
6120
6341
  type: "number",
6121
6342
  "default": 1,
@@ -6432,6 +6653,39 @@ var paint_symbol = {
6432
6653
  },
6433
6654
  "property-type": "data-driven"
6434
6655
  },
6656
+ "text-occlusion-opacity": {
6657
+ type: "number",
6658
+ doc: "The opacity at which the text will be drawn in case of being depth occluded. Not supported on globe zoom levels.",
6659
+ "default": 1,
6660
+ minimum: 0,
6661
+ maximum: 1,
6662
+ transition: true,
6663
+ requires: [
6664
+ "text-field"
6665
+ ],
6666
+ "sdk-support": {
6667
+ "basic functionality": {
6668
+ js: "3.5.0",
6669
+ android: "11.5.0",
6670
+ ios: "11.6.0"
6671
+ },
6672
+ "data-driven styling": {
6673
+ js: "3.5.0",
6674
+ android: "11.5.0",
6675
+ ios: "11.6.0"
6676
+ }
6677
+ },
6678
+ expression: {
6679
+ interpolated: true,
6680
+ parameters: [
6681
+ "zoom",
6682
+ "feature",
6683
+ "feature-state",
6684
+ "measure-light"
6685
+ ]
6686
+ },
6687
+ "property-type": "data-driven"
6688
+ },
6435
6689
  "text-color": {
6436
6690
  type: "color",
6437
6691
  doc: "The color with which the text will be drawn.",
@@ -6994,6 +7248,7 @@ var paint_raster = {
6994
7248
  "raster-array-band": {
6995
7249
  type: "string",
6996
7250
  required: false,
7251
+ experimental: true,
6997
7252
  "property-type": "data-constant",
6998
7253
  transition: false,
6999
7254
  requires: [
@@ -7017,6 +7272,7 @@ var paint_raster = {
7017
7272
  "default": 0,
7018
7273
  minimum: 0,
7019
7274
  transition: true,
7275
+ experimental: true,
7020
7276
  "sdk-support": {
7021
7277
  "basic functionality": {
7022
7278
  js: "3.1.0",
@@ -8063,6 +8319,7 @@ var v8 = {
8063
8319
  layout_background: layout_background,
8064
8320
  layout_sky: layout_sky,
8065
8321
  layout_model: layout_model,
8322
+ layout_clip: layout_clip,
8066
8323
  layout_fill: layout_fill,
8067
8324
  layout_circle: layout_circle,
8068
8325
  layout_heatmap: layout_heatmap,
@@ -8098,6 +8355,7 @@ var v8 = {
8098
8355
  },
8099
8356
  "fill-extrusion-edge-radius": {
8100
8357
  type: "number",
8358
+ experimental: true,
8101
8359
  "private": true,
8102
8360
  "default": 0,
8103
8361
  minimum: 0,
@@ -8245,6 +8503,7 @@ var v8 = {
8245
8503
  expression_name: expression_name,
8246
8504
  fog: fog,
8247
8505
  camera: camera,
8506
+ colorTheme: colorTheme,
8248
8507
  light: light,
8249
8508
  projection: projection,
8250
8509
  terrain: terrain,
@@ -8519,6 +8778,7 @@ var v8 = {
8519
8778
  "fill-extrusion-ambient-occlusion-wall-radius": {
8520
8779
  "property-type": "data-constant",
8521
8780
  type: "number",
8781
+ experimental: true,
8522
8782
  "default": 3,
8523
8783
  minimum: 0,
8524
8784
  expression: {
@@ -8544,6 +8804,7 @@ var v8 = {
8544
8804
  "fill-extrusion-ambient-occlusion-ground-radius": {
8545
8805
  "property-type": "data-constant",
8546
8806
  type: "number",
8807
+ experimental: true,
8547
8808
  "default": 3,
8548
8809
  minimum: 0,
8549
8810
  expression: {
@@ -8568,6 +8829,7 @@ var v8 = {
8568
8829
  "fill-extrusion-ambient-occlusion-ground-attenuation": {
8569
8830
  "property-type": "data-constant",
8570
8831
  type: "number",
8832
+ experimental: true,
8571
8833
  "default": 0.69,
8572
8834
  minimum: 0,
8573
8835
  maximum: 1,
@@ -8593,6 +8855,7 @@ var v8 = {
8593
8855
  "fill-extrusion-flood-light-color": {
8594
8856
  "property-type": "data-constant",
8595
8857
  type: "color",
8858
+ experimental: true,
8596
8859
  "default": "#ffffff",
8597
8860
  doc: "The color of the flood light effect on the walls of the extruded buildings.",
8598
8861
  requires: [
@@ -8617,6 +8880,7 @@ var v8 = {
8617
8880
  "fill-extrusion-flood-light-intensity": {
8618
8881
  "property-type": "data-constant",
8619
8882
  type: "number",
8883
+ experimental: true,
8620
8884
  "default": 0,
8621
8885
  minimum: 0,
8622
8886
  maximum: 1,
@@ -8643,6 +8907,7 @@ var v8 = {
8643
8907
  "fill-extrusion-flood-light-wall-radius": {
8644
8908
  "property-type": "data-driven",
8645
8909
  type: "number",
8910
+ experimental: true,
8646
8911
  units: "meters",
8647
8912
  "default": 0,
8648
8913
  minimum: 0,
@@ -8674,6 +8939,7 @@ var v8 = {
8674
8939
  "fill-extrusion-flood-light-ground-radius": {
8675
8940
  "property-type": "data-driven",
8676
8941
  type: "number",
8942
+ experimental: true,
8677
8943
  units: "meters",
8678
8944
  "default": 0,
8679
8945
  doc: "The extent of the flood light effect on the ground beneath the extruded buildings in meters.",
@@ -8704,6 +8970,7 @@ var v8 = {
8704
8970
  "fill-extrusion-flood-light-ground-attenuation": {
8705
8971
  "property-type": "data-constant",
8706
8972
  type: "number",
8973
+ experimental: true,
8707
8974
  "default": 0.69,
8708
8975
  minimum: 0,
8709
8976
  maximum: 1,
@@ -8729,6 +8996,7 @@ var v8 = {
8729
8996
  "fill-extrusion-vertical-scale": {
8730
8997
  "property-type": "data-constant",
8731
8998
  type: "number",
8999
+ experimental: true,
8732
9000
  "default": 1,
8733
9001
  minimum: 0,
8734
9002
  doc: "A global multiplier that can be used to scale base, height, AO, and flood light of the fill extrusions.",
@@ -8751,6 +9019,7 @@ var v8 = {
8751
9019
  "property-type": "data-constant",
8752
9020
  type: "boolean",
8753
9021
  "default": true,
9022
+ experimental: true,
8754
9023
  doc: "Indicates whether top edges should be rounded when fill-extrusion-edge-radius has a value greater than 0. If false, rounded edges are only applied to the sides. Default is true.",
8755
9024
  requires: [
8756
9025
  "fill-extrusion-edge-radius"
@@ -9044,42 +9313,20 @@ function stringify(passedObj, options = {}) {
9044
9313
  }(passedObj, '', 0);
9045
9314
  }
9046
9315
 
9047
- //
9048
- function sortKeysBy(obj, reference) {
9316
+ function sortKeysBy(obj, reference2) {
9049
9317
  const result = {};
9050
- for (const key in reference) {
9051
- if (obj[key] !== undefined) {
9318
+ for (const key in reference2) {
9319
+ if (obj[key] !== void 0) {
9052
9320
  result[key] = obj[key];
9053
9321
  }
9054
9322
  }
9055
9323
  for (const key in obj) {
9056
- if (result[key] === undefined) {
9324
+ if (result[key] === void 0) {
9057
9325
  result[key] = obj[key];
9058
9326
  }
9059
9327
  }
9060
9328
  return result;
9061
9329
  }
9062
- /**
9063
- * Format a Mapbox GL Style. Returns a stringified style with its keys
9064
- * sorted in the same order as the reference style.
9065
- *
9066
- * The optional `space` argument is passed to
9067
- * [`JSON.stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
9068
- * to generate formatted output.
9069
- *
9070
- * If `space` is unspecified, a default of `2` spaces will be used.
9071
- *
9072
- * @private
9073
- * @param {Object} style a Mapbox GL Style
9074
- * @param {number} [space] space argument to pass to `JSON.stringify`
9075
- * @returns {string} stringified formatted JSON
9076
- * @example
9077
- * var fs = require('fs');
9078
- * var format = require('mapbox-gl-style-spec').format;
9079
- * var style = fs.readFileSync('./source.json', 'utf8');
9080
- * fs.writeFileSync('./dest.json', format(style));
9081
- * fs.writeFileSync('./dest.min.json', format(style, 0));
9082
- */
9083
9330
  function format(style, space = 2) {
9084
9331
  style = sortKeysBy(style, v8.$root);
9085
9332
  if (style.layers) {
@@ -9088,7 +9335,6 @@ function format(style, space = 2) {
9088
9335
  return stringify(style, { indent: space });
9089
9336
  }
9090
9337
 
9091
- //
9092
9338
  function getPropertyReference(propertyName) {
9093
9339
  for (let i = 0; i < v8.layout.length; i++) {
9094
9340
  for (const key in v8[v8.layout[i]]) {
@@ -9116,7 +9362,7 @@ function eachLayer(style, callback) {
9116
9362
  }
9117
9363
  function eachProperty(style, options, callback) {
9118
9364
  function inner(layer, propertyType) {
9119
- if (layer.type === 'slot')
9365
+ if (layer.type === 'slot' || layer.type === 'clip')
9120
9366
  return;
9121
9367
  const properties = layer[propertyType];
9122
9368
  if (!properties)
@@ -9147,7 +9393,6 @@ function eachProperty(style, options, callback) {
9147
9393
  });
9148
9394
  }
9149
9395
 
9150
- //
9151
9396
  function eachLayout(layer, callback) {
9152
9397
  for (const k in layer) {
9153
9398
  if (k.indexOf('layout') === 0) {
@@ -9178,9 +9423,8 @@ function renameProperty(obj, from, to) {
9178
9423
  }
9179
9424
  function migrateToV8 (style) {
9180
9425
  style.version = 8;
9181
- // Rename properties, reverse coordinates in source and layers
9182
9426
  eachSource(style, source => {
9183
- if (source.type === 'video' && source.url !== undefined) {
9427
+ if (source.type === 'video' && source.url !== void 0) {
9184
9428
  renameProperty(source, 'url', 'urls');
9185
9429
  }
9186
9430
  if (source.type === 'video') {
@@ -9191,23 +9435,22 @@ function migrateToV8 (style) {
9191
9435
  });
9192
9436
  eachLayer(style, layer => {
9193
9437
  eachLayout(layer, layout => {
9194
- if (layout['symbol-min-distance'] !== undefined) {
9438
+ if (layout['symbol-min-distance'] !== void 0) {
9195
9439
  renameProperty(layout, 'symbol-min-distance', 'symbol-spacing');
9196
9440
  }
9197
9441
  });
9198
9442
  eachPaint(layer, paint => {
9199
- if (paint['background-image'] !== undefined) {
9443
+ if (paint['background-image'] !== void 0) {
9200
9444
  renameProperty(paint, 'background-image', 'background-pattern');
9201
9445
  }
9202
- if (paint['line-image'] !== undefined) {
9446
+ if (paint['line-image'] !== void 0) {
9203
9447
  renameProperty(paint, 'line-image', 'line-pattern');
9204
9448
  }
9205
- if (paint['fill-image'] !== undefined) {
9449
+ if (paint['fill-image'] !== void 0) {
9206
9450
  renameProperty(paint, 'fill-image', 'fill-pattern');
9207
9451
  }
9208
9452
  });
9209
9453
  });
9210
- // Inline Constants
9211
9454
  eachProperty(style, {
9212
9455
  paint: true,
9213
9456
  layout: true
@@ -9222,9 +9465,6 @@ function migrateToV8 (style) {
9222
9465
  });
9223
9466
  delete style.constants;
9224
9467
  eachLayer(style, layer => {
9225
- // get rid of text-max-size, icon-max-size
9226
- // turn text-size, icon-size into layout properties
9227
- // https://github.com/mapbox/mapbox-gl-style-spec/issues/255
9228
9468
  eachLayout(layer, layout => {
9229
9469
  delete layout['text-max-size'];
9230
9470
  delete layout['icon-max-size'];
@@ -9276,7 +9516,6 @@ function migrateToV8 (style) {
9276
9516
  });
9277
9517
  }
9278
9518
  if (Array.isArray(font)) {
9279
- // Assume it's a previously migrated font-array.
9280
9519
  return font;
9281
9520
  } else if (typeof font === 'string') {
9282
9521
  return splitAndTrim(font);
@@ -9296,18 +9535,6 @@ function migrateToV8 (style) {
9296
9535
  }
9297
9536
  });
9298
9537
  });
9299
- // Reverse order of symbol layers. This is an imperfect migration.
9300
- //
9301
- // The order of a symbol layer in the layers list affects two things:
9302
- // - how it is drawn relative to other layers (like oneway arrows below bridges)
9303
- // - the placement priority compared to other layers
9304
- //
9305
- // It's impossible to reverse the placement priority without breaking the draw order
9306
- // in some cases. This migration only reverses the order of symbol layers that
9307
- // are above all other types of layers.
9308
- //
9309
- // Symbol layers that are at the top of the map preserve their priority.
9310
- // Symbol layers that are below another type (line, fill) of layer preserve their draw order.
9311
9538
  let firstSymbolLayer = 0;
9312
9539
  for (let i = style.layers.length - 1; i >= 0; i--) {
9313
9540
  const layer = style.layers[i];
@@ -9322,7 +9549,6 @@ function migrateToV8 (style) {
9322
9549
  return style;
9323
9550
  }
9324
9551
 
9325
- //
9326
9552
  function extend (output, ...inputs) {
9327
9553
  for (const input of inputs) {
9328
9554
  for (const k in input) {
@@ -9332,7 +9558,6 @@ function extend (output, ...inputs) {
9332
9558
  return output;
9333
9559
  }
9334
9560
 
9335
- //
9336
9561
  let ParsingError$1 = class ParsingError extends Error {
9337
9562
  constructor(key, message) {
9338
9563
  super(message);
@@ -9341,11 +9566,6 @@ let ParsingError$1 = class ParsingError extends Error {
9341
9566
  }
9342
9567
  };
9343
9568
 
9344
- //
9345
- /**
9346
- * Tracks `let` bindings during expression parsing.
9347
- * @private
9348
- */
9349
9569
  class Scope {
9350
9570
  constructor(parent, bindings = []) {
9351
9571
  this.parent = parent;
@@ -9373,7 +9593,6 @@ class Scope {
9373
9593
  }
9374
9594
  }
9375
9595
 
9376
- //
9377
9596
  const NullType = { kind: 'null' };
9378
9597
  const NumberType = { kind: 'number' };
9379
9598
  const StringType = { kind: 'string' };
@@ -9411,14 +9630,8 @@ const valueMemberTypes = [
9411
9630
  array$1(ValueType),
9412
9631
  ResolvedImageType
9413
9632
  ];
9414
- /**
9415
- * Returns null if `t` is a subtype of `expected`; otherwise returns an
9416
- * error message.
9417
- * @private
9418
- */
9419
9633
  function checkSubtype(expected, t) {
9420
9634
  if (t.kind === 'error') {
9421
- // Error is a subtype of every type
9422
9635
  return null;
9423
9636
  } else if (expected.kind === 'array') {
9424
9637
  if (t.kind === 'array' && (t.N === 0 && t.itemType.kind === 'value' || !checkSubtype(expected.itemType, t.itemType)) && (typeof expected.N !== 'number' || expected.N === t.N)) {
@@ -10502,18 +10715,25 @@ try {
10502
10715
  } catch (e) {
10503
10716
  }
10504
10717
 
10505
- //
10506
- /**
10507
- * An RGBA color value. Create instances from color strings using the static
10508
- * method `Color.parse`. The constructor accepts RGB channel values in the range
10509
- * `[0, 1]`, premultiplied by A.
10510
- *
10511
- * @param {number} r The red channel.
10512
- * @param {number} g The green channel.
10513
- * @param {number} b The blue channel.
10514
- * @param {number} a The alpha channel.
10515
- * @private
10516
- */
10718
+ function number(a, b, t) {
10719
+ return a * (1 - t) + b * t;
10720
+ }
10721
+ function color(from, to, t) {
10722
+ return new Color(number(from.r, to.r, t), number(from.g, to.g, t), number(from.b, to.b, t), number(from.a, to.a, t));
10723
+ }
10724
+ function array(from, to, t) {
10725
+ return from.map((d, i) => {
10726
+ return number(d, to[i], t);
10727
+ });
10728
+ }
10729
+
10730
+ var interpolate$1 = /*#__PURE__*/Object.freeze({
10731
+ __proto__: null,
10732
+ array: array,
10733
+ color: color,
10734
+ number: number
10735
+ });
10736
+
10517
10737
  class Color {
10518
10738
  constructor(r, g, b, a = 1) {
10519
10739
  this.r = r;
@@ -10522,44 +10742,99 @@ class Color {
10522
10742
  this.a = a;
10523
10743
  }
10524
10744
  /**
10525
- * Parses valid CSS color strings and returns a `Color` instance.
10526
- * @returns A `Color` instance, or `undefined` if the input is not a valid color string.
10527
- */
10745
+ * Parses valid CSS color strings and returns a `Color` instance.
10746
+ * @returns A `Color` instance, or `undefined` if the input is not a valid color string.
10747
+ */
10528
10748
  static parse(input) {
10529
10749
  if (!input) {
10530
- return undefined;
10750
+ return void 0;
10531
10751
  }
10532
10752
  if (input instanceof Color) {
10533
10753
  return input;
10534
10754
  }
10535
10755
  if (typeof input !== 'string') {
10536
- return undefined;
10756
+ return void 0;
10537
10757
  }
10538
10758
  const rgba = parseCSSColor_1(input);
10539
10759
  if (!rgba) {
10540
- return undefined;
10760
+ return void 0;
10541
10761
  }
10542
10762
  return new Color(rgba[0] / 255 * rgba[3], rgba[1] / 255 * rgba[3], rgba[2] / 255 * rgba[3], rgba[3]);
10543
10763
  }
10544
10764
  /**
10545
- * Returns an RGBA string representing the color value.
10546
- *
10547
- * @returns An RGBA string.
10548
- * @example
10549
- * var purple = new Color.parse('purple');
10550
- * purple.toString; // = "rgba(128,0,128,1)"
10551
- * var translucentGreen = new Color.parse('rgba(26, 207, 26, .73)');
10552
- * translucentGreen.toString(); // = "rgba(26,207,26,0.73)"
10553
- */
10765
+ * Returns an RGBA string representing the color value.
10766
+ *
10767
+ * @returns An RGBA string.
10768
+ * @example
10769
+ * var purple = new Color.parse('purple');
10770
+ * purple.toString; // = "rgba(128,0,128,1)"
10771
+ * var translucentGreen = new Color.parse('rgba(26, 207, 26, .73)');
10772
+ * translucentGreen.toString(); // = "rgba(26,207,26,0.73)"
10773
+ */
10554
10774
  toString() {
10555
- const [r, g, b, a] = this.toArray();
10775
+ const [r, g, b, a] = this.a === 0 ? [
10776
+ 0,
10777
+ 0,
10778
+ 0,
10779
+ 0
10780
+ ] : [
10781
+ this.r * 255 / this.a,
10782
+ this.g * 255 / this.a,
10783
+ this.b * 255 / this.a,
10784
+ this.a
10785
+ ];
10556
10786
  return `rgba(${ Math.round(r) },${ Math.round(g) },${ Math.round(b) },${ a })`;
10557
10787
  }
10788
+ toRenderColor(lut) {
10789
+ const {r, g, b, a} = this;
10790
+ return new RenderColor(lut, r, g, b, a);
10791
+ }
10792
+ }
10793
+ class RenderColor {
10794
+ constructor(lut, r, g, b, a) {
10795
+ if (!lut) {
10796
+ this.r = r;
10797
+ this.g = g;
10798
+ this.b = b;
10799
+ this.a = a;
10800
+ } else {
10801
+ const N = lut.image.height;
10802
+ const N2 = N * N;
10803
+ r = a === 0 ? 0 : r / a * (N - 1);
10804
+ g = a === 0 ? 0 : g / a * (N - 1);
10805
+ b = a === 0 ? 0 : b / a * (N - 1);
10806
+ const r0 = Math.floor(r);
10807
+ const g0 = Math.floor(g);
10808
+ const b0 = Math.floor(b);
10809
+ const r1 = Math.ceil(r);
10810
+ const g1 = Math.ceil(g);
10811
+ const b1 = Math.ceil(b);
10812
+ const rw = r - r0;
10813
+ const gw = g - g0;
10814
+ const bw = b - b0;
10815
+ const data = lut.image.data;
10816
+ const i0 = (r0 + g0 * N2 + b0 * N) * 4;
10817
+ const i1 = (r0 + g0 * N2 + b1 * N) * 4;
10818
+ const i2 = (r0 + g1 * N2 + b0 * N) * 4;
10819
+ const i3 = (r0 + g1 * N2 + b1 * N) * 4;
10820
+ const i4 = (r1 + g0 * N2 + b0 * N) * 4;
10821
+ const i5 = (r1 + g0 * N2 + b1 * N) * 4;
10822
+ const i6 = (r1 + g1 * N2 + b0 * N) * 4;
10823
+ const i7 = (r1 + g1 * N2 + b1 * N) * 4;
10824
+ if (i0 < 0 || i7 >= data.length) {
10825
+ throw new Error('out of range');
10826
+ }
10827
+ this.r = number(number(number(data[i0], data[i1], bw), number(data[i2], data[i3], bw), gw), number(number(data[i4], data[i5], bw), number(data[i6], data[i7], bw), gw), rw) / 255 * a;
10828
+ this.g = number(number(number(data[i0 + 1], data[i1 + 1], bw), number(data[i2 + 1], data[i3 + 1], bw), gw), number(number(data[i4 + 1], data[i5 + 1], bw), number(data[i6 + 1], data[i7 + 1], bw), gw), rw) / 255 * a;
10829
+ this.b = number(number(number(data[i0 + 2], data[i1 + 2], bw), number(data[i2 + 2], data[i3 + 2], bw), gw), number(number(data[i4 + 2], data[i5 + 2], bw), number(data[i6 + 2], data[i7 + 2], bw), gw), rw) / 255 * a;
10830
+ this.a = a;
10831
+ }
10832
+ }
10558
10833
  /**
10559
- * Returns an RGBA array of values representing the color, unpremultiplied by A.
10560
- *
10561
- * @returns An array of RGBA color values in the range [0, 255].
10562
- */
10834
+ * Returns an RGBA array of values representing the color, unpremultiplied by A.
10835
+ *
10836
+ * @returns An array of RGBA color values in the range [0, 255].
10837
+ */
10563
10838
  toArray() {
10564
10839
  const {r, g, b, a} = this;
10565
10840
  return a === 0 ? [
@@ -10575,10 +10850,10 @@ class Color {
10575
10850
  ];
10576
10851
  }
10577
10852
  /**
10578
- * Returns a RGBA array of float values representing the color, unpremultiplied by A.
10579
- *
10580
- * @returns An array of RGBA color values in the range [0, 1].
10581
- */
10853
+ * Returns a RGBA array of float values representing the color, unpremultiplied by A.
10854
+ *
10855
+ * @returns An array of RGBA color values in the range [0, 1].
10856
+ */
10582
10857
  toArray01() {
10583
10858
  const {r, g, b, a} = this;
10584
10859
  return a === 0 ? [
@@ -10594,11 +10869,11 @@ class Color {
10594
10869
  ];
10595
10870
  }
10596
10871
  /**
10597
- * Returns an RGB array of values representing the color, unpremultiplied by A and multiplied by a scalar.
10598
- *
10599
- * @param {number} scale A scale to apply to the unpremultiplied-alpha values.
10600
- * @returns An array of RGB color values in the range [0, 1].
10601
- */
10872
+ * Returns an RGB array of values representing the color, unpremultiplied by A and multiplied by a scalar.
10873
+ *
10874
+ * @param {number} scale A scale to apply to the unpremultiplied-alpha values.
10875
+ * @returns An array of RGB color values in the range [0, 1].
10876
+ */
10602
10877
  toArray01Scaled(scale) {
10603
10878
  const {r, g, b, a} = this;
10604
10879
  return a === 0 ? [
@@ -10612,10 +10887,10 @@ class Color {
10612
10887
  ];
10613
10888
  }
10614
10889
  /**
10615
- * Returns an RGBA array of values representing the color, premultiplied by A.
10616
- *
10617
- * @returns An array of RGBA color values in the range [0, 1].
10618
- */
10890
+ * Returns an RGBA array of values representing the color, premultiplied by A.
10891
+ *
10892
+ * @returns An array of RGBA color values in the range [0, 1].
10893
+ */
10619
10894
  toArray01PremultipliedAlpha() {
10620
10895
  const {r, g, b, a} = this;
10621
10896
  return [
@@ -10626,11 +10901,11 @@ class Color {
10626
10901
  ];
10627
10902
  }
10628
10903
  /**
10629
- * Returns an RGBA array of values representing the color, unpremultiplied by A, and converted to linear color space.
10630
- * The color is defined by sRGB primaries, but the sRGB transfer function is reversed to obtain linear energy.
10631
- *
10632
- * @returns An array of RGBA color values in the range [0, 1].
10633
- */
10904
+ * Returns an RGBA array of values representing the color, unpremultiplied by A, and converted to linear color space.
10905
+ * The color is defined by sRGB primaries, but the sRGB transfer function is reversed to obtain linear energy.
10906
+ *
10907
+ * @returns An array of RGBA color values in the range [0, 1].
10908
+ */
10634
10909
  toArray01Linear() {
10635
10910
  const {r, g, b, a} = this;
10636
10911
  return a === 0 ? [
@@ -10651,9 +10926,7 @@ Color.white = new Color(1, 1, 1, 1);
10651
10926
  Color.transparent = new Color(0, 0, 0, 0);
10652
10927
  Color.red = new Color(1, 0, 0, 1);
10653
10928
  Color.blue = new Color(0, 0, 1, 1);
10654
- var Color$1 = Color;
10655
10929
 
10656
- //
10657
10930
  class Collator {
10658
10931
  constructor(caseSensitive, diacriticSensitive, locale) {
10659
10932
  if (caseSensitive)
@@ -10670,16 +10943,12 @@ class Collator {
10670
10943
  return this.collator.compare(lhs, rhs);
10671
10944
  }
10672
10945
  resolvedLocale() {
10673
- // We create a Collator without "usage: search" because we don't want
10674
- // the search options encoded in our result (e.g. "en-u-co-search")
10675
10946
  return new Intl.Collator(this.locale ? this.locale : []).resolvedOptions().locale;
10676
10947
  }
10677
10948
  }
10678
10949
 
10679
- //
10680
10950
  class FormattedSection {
10681
10951
  constructor(text, image, scale, fontStack, textColor) {
10682
- // combine characters so that diacritic marks are not separate code points
10683
10952
  this.text = text.normalize ? text.normalize() : text;
10684
10953
  this.image = image;
10685
10954
  this.scale = scale;
@@ -10733,7 +11002,7 @@ class Formatted {
10733
11002
  options['font-scale'] = section.scale;
10734
11003
  }
10735
11004
  if (section.textColor) {
10736
- options['text-color'] = ['rgba'].concat(section.textColor.toArray());
11005
+ options['text-color'] = ['rgba'].concat(section.textColor.toRenderColor(null).toArray());
10737
11006
  }
10738
11007
  serialized.push(options);
10739
11008
  }
@@ -10741,7 +11010,6 @@ class Formatted {
10741
11010
  }
10742
11011
  }
10743
11012
 
10744
- //
10745
11013
  class ResolvedImage {
10746
11014
  constructor(options) {
10747
11015
  this.namePrimary = options.namePrimary;
@@ -10759,7 +11027,6 @@ class ResolvedImage {
10759
11027
  static fromString(namePrimary, nameSecondary) {
10760
11028
  if (!namePrimary)
10761
11029
  return null;
10762
- // treat empty values as no image
10763
11030
  return new ResolvedImage({
10764
11031
  namePrimary,
10765
11032
  nameSecondary,
@@ -10851,7 +11118,7 @@ function isValue(mixed) {
10851
11118
  return true;
10852
11119
  } else if (typeof mixed === 'number') {
10853
11120
  return true;
10854
- } else if (mixed instanceof Color$1) {
11121
+ } else if (mixed instanceof Color) {
10855
11122
  return true;
10856
11123
  } else if (mixed instanceof Collator) {
10857
11124
  return true;
@@ -10886,7 +11153,7 @@ function typeOf(value) {
10886
11153
  return BooleanType;
10887
11154
  } else if (typeof value === 'number') {
10888
11155
  return NumberType;
10889
- } else if (value instanceof Color$1) {
11156
+ } else if (value instanceof Color) {
10890
11157
  return ColorType;
10891
11158
  } else if (value instanceof Collator) {
10892
11159
  return CollatorType;
@@ -10919,7 +11186,7 @@ function toString(value) {
10919
11186
  return '';
10920
11187
  } else if (type === 'string' || type === 'number' || type === 'boolean') {
10921
11188
  return String(value);
10922
- } else if (value instanceof Color$1 || value instanceof Formatted || value instanceof ResolvedImage) {
11189
+ } else if (value instanceof Color || value instanceof Formatted || value instanceof ResolvedImage) {
10923
11190
  return value.toString();
10924
11191
  } else {
10925
11192
  return JSON.stringify(value);
@@ -10938,7 +11205,6 @@ class Literal {
10938
11205
  return context.error(`invalid value`);
10939
11206
  const value = args[1];
10940
11207
  let type = typeOf(value);
10941
- // special case: infer the item type if possible for zero-length arrays
10942
11208
  const expected = context.expectedType;
10943
11209
  if (type.kind === 'array' && type.N === 0 && expected && expected.kind === 'array' && (typeof expected.N !== 'number' || expected.N === 0)) {
10944
11210
  type = expected;
@@ -10959,13 +11225,9 @@ class Literal {
10959
11225
  'literal',
10960
11226
  this.value
10961
11227
  ];
10962
- } else if (this.value instanceof Color$1) {
10963
- // Constant-folding can generate Literal expressions that you
10964
- // couldn't actually generate with a "literal" expression,
10965
- // so we have to implement an equivalent serialization here
10966
- return ['rgba'].concat(this.value.toArray());
11228
+ } else if (this.value instanceof Color) {
11229
+ return ['rgba'].concat(this.value.toRenderColor(null).toArray());
10967
11230
  } else if (this.value instanceof Formatted) {
10968
- // Same as Color
10969
11231
  return this.value.serialize();
10970
11232
  } else {
10971
11233
  return this.value;
@@ -10973,7 +11235,6 @@ class Literal {
10973
11235
  }
10974
11236
  }
10975
11237
 
10976
- //
10977
11238
  class RuntimeError {
10978
11239
  constructor(message) {
10979
11240
  this.name = 'ExpressionEvaluationError';
@@ -11004,10 +11265,10 @@ class Assertion {
11004
11265
  if (name === 'array') {
11005
11266
  let itemType;
11006
11267
  if (args.length > 2) {
11007
- const type = args[1];
11008
- if (typeof type !== 'string' || !(type in types$1) || type === 'object')
11268
+ const type2 = args[1];
11269
+ if (typeof type2 !== 'string' || !(type2 in types$1) || type2 === 'object')
11009
11270
  return context.error('The item type argument of "array" must be one of string, number, boolean', 1);
11010
- itemType = types$1[type];
11271
+ itemType = types$1[type2];
11011
11272
  i++;
11012
11273
  } else {
11013
11274
  itemType = ValueType;
@@ -11068,7 +11329,6 @@ class Assertion {
11068
11329
  }
11069
11330
  }
11070
11331
 
11071
- //
11072
11332
  class FormatExpression {
11073
11333
  constructor(sections) {
11074
11334
  this.type = FormattedType;
@@ -11153,8 +11413,6 @@ class FormatExpression {
11153
11413
  }
11154
11414
  }
11155
11415
  outputDefined() {
11156
- // Technically the combinatoric set of all children
11157
- // Usually, this.text will be undefined anyway
11158
11416
  return false;
11159
11417
  }
11160
11418
  serialize() {
@@ -11177,7 +11435,6 @@ class FormatExpression {
11177
11435
  }
11178
11436
  }
11179
11437
 
11180
- //
11181
11438
  class ImageExpression {
11182
11439
  constructor(inputPrimary, inputSecondary) {
11183
11440
  this.type = ResolvedImageType;
@@ -11200,10 +11457,9 @@ class ImageExpression {
11200
11457
  return new ImageExpression(namePrimary, nameSecondary);
11201
11458
  }
11202
11459
  evaluate(ctx) {
11203
- const value = ResolvedImage.fromString(this.inputPrimary.evaluate(ctx), this.inputSecondary ? this.inputSecondary.evaluate(ctx) : undefined);
11460
+ const value = ResolvedImage.fromString(this.inputPrimary.evaluate(ctx), this.inputSecondary ? this.inputSecondary.evaluate(ctx) : void 0);
11204
11461
  if (value && ctx.availableImages) {
11205
11462
  value.available = ctx.availableImages.indexOf(value.namePrimary) > -1;
11206
- // If there's a secondary variant, only mark it available if both are present
11207
11463
  if (value.nameSecondary && value.available && ctx.availableImages) {
11208
11464
  value.available = ctx.availableImages.indexOf(value.nameSecondary) > -1;
11209
11465
  }
@@ -11217,12 +11473,10 @@ class ImageExpression {
11217
11473
  }
11218
11474
  }
11219
11475
  outputDefined() {
11220
- // The output of image is determined by the list of available images in the evaluation context
11221
11476
  return false;
11222
11477
  }
11223
11478
  serialize() {
11224
11479
  if (this.inputSecondary) {
11225
- // $FlowIgnore
11226
11480
  return [
11227
11481
  'image',
11228
11482
  this.inputPrimary.serialize(),
@@ -11236,7 +11490,6 @@ class ImageExpression {
11236
11490
  }
11237
11491
  }
11238
11492
 
11239
- //
11240
11493
  function getType(val) {
11241
11494
  if (val instanceof Number) {
11242
11495
  return 'number';
@@ -11259,13 +11512,6 @@ const types = {
11259
11512
  'to-number': NumberType,
11260
11513
  'to-string': StringType
11261
11514
  };
11262
- /**
11263
- * Special form for error-coalescing coercion expressions "to-number",
11264
- * "to-color". Since these coercions can fail at runtime, they accept multiple
11265
- * arguments, only evaluating one at a time until one succeeds.
11266
- *
11267
- * @private
11268
- */
11269
11515
  class Coercion {
11270
11516
  constructor(type, args) {
11271
11517
  this.type = type;
@@ -11295,11 +11541,10 @@ class Coercion {
11295
11541
  return null;
11296
11542
  }
11297
11543
  for (let i = 0; i < arrayLength; i++) {
11298
- // $FlowIgnore
11299
11544
  const member = args[1][i];
11300
11545
  let parsedMember;
11301
11546
  if (getType(member) === 'array') {
11302
- parsedMember = context.parse(member, undefined, type.itemType);
11547
+ parsedMember = context.parse(member, void 0, type.itemType);
11303
11548
  } else {
11304
11549
  const memberType = getType(member);
11305
11550
  if (memberType !== type.itemType.kind) {
@@ -11307,7 +11552,7 @@ class Coercion {
11307
11552
  }
11308
11553
  parsedMember = context.registry['literal'].parse([
11309
11554
  'literal',
11310
- member === undefined ? null : member
11555
+ member === void 0 ? null : member
11311
11556
  ], context);
11312
11557
  }
11313
11558
  if (!parsedMember)
@@ -11336,7 +11581,7 @@ class Coercion {
11336
11581
  for (const arg of this.args) {
11337
11582
  input = arg.evaluate(ctx);
11338
11583
  error = null;
11339
- if (input instanceof Color$1) {
11584
+ if (input instanceof Color) {
11340
11585
  return input;
11341
11586
  } else if (typeof input === 'string') {
11342
11587
  const c = ctx.parseColor(input);
@@ -11349,7 +11594,7 @@ class Coercion {
11349
11594
  error = validateRGBA(input[0], input[1], input[2], input[3]);
11350
11595
  }
11351
11596
  if (!error) {
11352
- return new Color$1(input[0] / 255, input[1] / 255, input[2] / 255, input[3]);
11597
+ return new Color(input[0] / 255, input[1] / 255, input[2] / 255, input[3]);
11353
11598
  }
11354
11599
  }
11355
11600
  }
@@ -11367,8 +11612,6 @@ class Coercion {
11367
11612
  }
11368
11613
  throw new RuntimeError(`Could not convert ${ JSON.stringify(value) } to number.`);
11369
11614
  } else if (this.type.kind === 'formatted') {
11370
- // There is no explicit 'to-formatted' but this coercion can be implicitly
11371
- // created by properties that expect the 'formatted' type.
11372
11615
  return Formatted.fromString(toString(this.args[0].evaluate(ctx)));
11373
11616
  } else if (this.type.kind === 'resolvedImage') {
11374
11617
  return ResolvedImage.fromString(toString(this.args[0].evaluate(ctx)));
@@ -11406,7 +11649,6 @@ class Coercion {
11406
11649
  }
11407
11650
  }
11408
11651
 
11409
- //
11410
11652
  const geometryTypes = [
11411
11653
  'Unknown',
11412
11654
  'Point',
@@ -11428,7 +11670,7 @@ class EvaluationContext {
11428
11670
  this.options = options;
11429
11671
  }
11430
11672
  id() {
11431
- return this.feature && this.feature.id !== undefined ? this.feature.id : null;
11673
+ return this.feature && this.feature.id !== void 0 ? this.feature.id : null;
11432
11674
  }
11433
11675
  geometryType() {
11434
11676
  return this.feature ? typeof this.feature.type === 'number' ? geometryTypes[this.feature.type] : this.feature.type : null;
@@ -11450,13 +11692,10 @@ class EvaluationContext {
11450
11692
  const c = this.featureDistanceData.center;
11451
11693
  const scale = this.featureDistanceData.scale;
11452
11694
  const {x, y} = this.featureTileCoord;
11453
- // Calculate the distance vector `d` (left handed)
11454
11695
  const dX = x * scale - c[0];
11455
11696
  const dY = y * scale - c[1];
11456
- // The bearing vector `b` (left handed)
11457
11697
  const bX = this.featureDistanceData.bearing[0];
11458
11698
  const bY = this.featureDistanceData.bearing[1];
11459
- // Distance is calculated as `dot(d, v)`
11460
11699
  const dist = bX * dX + bY * dY;
11461
11700
  return dist;
11462
11701
  }
@@ -11465,7 +11704,7 @@ class EvaluationContext {
11465
11704
  parseColor(input) {
11466
11705
  let cached = this._parseColorCache[input];
11467
11706
  if (!cached) {
11468
- cached = this._parseColorCache[input] = Color$1.parse(input);
11707
+ cached = this._parseColorCache[input] = Color.parse(input);
11469
11708
  }
11470
11709
  return cached;
11471
11710
  }
@@ -11474,7 +11713,6 @@ class EvaluationContext {
11474
11713
  }
11475
11714
  }
11476
11715
 
11477
- //
11478
11716
  class CompoundExpression {
11479
11717
  constructor(name, type, evaluate, args, overloadIndex) {
11480
11718
  this.name = name;
@@ -11485,7 +11723,6 @@ class CompoundExpression {
11485
11723
  }
11486
11724
  evaluate(ctx) {
11487
11725
  if (!this._evaluate) {
11488
- // restore evaluate function after transfer between threads
11489
11726
  const definition = CompoundExpression.definitions[this.name];
11490
11727
  this._evaluate = Array.isArray(definition) ? definition[2] : definition.overloads[this._overloadIndex][1];
11491
11728
  }
@@ -11506,7 +11743,6 @@ class CompoundExpression {
11506
11743
  if (!definition) {
11507
11744
  return context.error(`Unknown expression "${ op }". If you wanted a literal array, use ["literal", [...]].`, 0);
11508
11745
  }
11509
- // Now check argument types against each signature
11510
11746
  const type = Array.isArray(definition) ? definition[0] : definition.type;
11511
11747
  const availableOverloads = Array.isArray(definition) ? [[
11512
11748
  definition[1],
@@ -11518,19 +11754,15 @@ class CompoundExpression {
11518
11754
  for (const [params, evaluate] of availableOverloads) {
11519
11755
  if (Array.isArray(params) && params.length !== args.length - 1)
11520
11756
  continue;
11521
- // param count doesn't match
11522
11757
  overloadParams.push(params);
11523
11758
  overloadIndex++;
11524
- // Use a fresh context for each attempted signature so that, if
11525
- // we eventually succeed, we haven't polluted `context.errors`.
11526
- signatureContext = new ParsingContext(context.registry, context.path, null, context.scope, undefined, context._scope, context.options);
11527
- // First parse all the args, potentially coercing to the
11528
- // types expected by this overload.
11759
+ signatureContext = new ParsingContext$1(context.registry, context.path, null, context.scope, void 0, context._scope, context.options);
11529
11760
  const parsedArgs = [];
11530
11761
  let argParseFailed = false;
11531
11762
  for (let i = 1; i < args.length; i++) {
11532
11763
  const arg = args[i];
11533
- const expectedType = Array.isArray(params) ? params[i - 1] : params.type;
11764
+ const expectedType = Array.isArray(params) ? params[i - 1] : // @ts-expect-error - TS2339 - Property 'type' does not exist on type 'Varargs | Evaluate'.
11765
+ params.type;
11534
11766
  const parsed = signatureContext.parse(arg, 1 + parsedArgs.length, expectedType);
11535
11767
  if (!parsed) {
11536
11768
  argParseFailed = true;
@@ -11539,8 +11771,6 @@ class CompoundExpression {
11539
11771
  parsedArgs.push(parsed);
11540
11772
  }
11541
11773
  if (argParseFailed) {
11542
- // Couldn't coerce args of this overload to expected type, move
11543
- // on to next one.
11544
11774
  continue;
11545
11775
  }
11546
11776
  if (Array.isArray(params)) {
@@ -11564,8 +11794,6 @@ class CompoundExpression {
11564
11794
  const expected = overloadParams.length ? overloadParams : availableOverloads.map(([params]) => params);
11565
11795
  const signatures = expected.map(stringifySignature).join(' | ');
11566
11796
  const actualTypes = [];
11567
- // For error message, re-parse arguments without trying to
11568
- // apply any coercions
11569
11797
  for (let i = 1; i < args.length; i++) {
11570
11798
  const parsed = context.parse(args[i], 1 + actualTypes.length);
11571
11799
  if (!parsed)
@@ -11579,7 +11807,6 @@ class CompoundExpression {
11579
11807
  static register(registry, definitions) {
11580
11808
  CompoundExpression.definitions = definitions;
11581
11809
  for (const name in definitions) {
11582
- // $FlowFixMe[method-unbinding]
11583
11810
  registry[name] = CompoundExpression;
11584
11811
  }
11585
11812
  }
@@ -11592,7 +11819,6 @@ function stringifySignature(signature) {
11592
11819
  }
11593
11820
  }
11594
11821
 
11595
- //
11596
11822
  class CollatorExpression {
11597
11823
  constructor(caseSensitive, diacriticSensitive, locale) {
11598
11824
  this.type = CollatorType;
@@ -11606,10 +11832,10 @@ class CollatorExpression {
11606
11832
  const options = args[1];
11607
11833
  if (typeof options !== 'object' || Array.isArray(options))
11608
11834
  return context.error(`Collator options argument must be an object.`);
11609
- const caseSensitive = context.parse(options['case-sensitive'] === undefined ? false : options['case-sensitive'], 1, BooleanType);
11835
+ const caseSensitive = context.parse(options['case-sensitive'] === void 0 ? false : options['case-sensitive'], 1, BooleanType);
11610
11836
  if (!caseSensitive)
11611
11837
  return null;
11612
- const diacriticSensitive = context.parse(options['diacritic-sensitive'] === undefined ? false : options['diacritic-sensitive'], 1, BooleanType);
11838
+ const diacriticSensitive = context.parse(options['diacritic-sensitive'] === void 0 ? false : options['diacritic-sensitive'], 1, BooleanType);
11613
11839
  if (!diacriticSensitive)
11614
11840
  return null;
11615
11841
  let locale = null;
@@ -11631,10 +11857,6 @@ class CollatorExpression {
11631
11857
  }
11632
11858
  }
11633
11859
  outputDefined() {
11634
- // Technically the set of possible outputs is the combinatoric set of Collators produced
11635
- // by all possible outputs of locale/caseSensitive/diacriticSensitive
11636
- // But for the primary use of Collators in comparison operators, we ignore the Collator's
11637
- // possible outputs anyway, so we can get away with leaving this false for now.
11638
11860
  return false;
11639
11861
  }
11640
11862
  serialize() {
@@ -11651,13 +11873,6 @@ class CollatorExpression {
11651
11873
  }
11652
11874
  }
11653
11875
 
11654
- //
11655
- // minX, minY, maxX, maxY
11656
- /**
11657
- * Returns the signed area for the polygon ring. Postive areas are exterior rings and
11658
- * have a clockwise winding. Negative areas are interior rings and have a counter clockwise
11659
- * ordering.
11660
- */
11661
11876
  function calculateSignedArea(ring) {
11662
11877
  let sum = 0;
11663
11878
  for (let i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {
@@ -11667,7 +11882,6 @@ function calculateSignedArea(ring) {
11667
11882
  }
11668
11883
  return sum;
11669
11884
  }
11670
- // classifies an array of rings into polygons with outer rings and holes
11671
11885
  function classifyRings(rings, maxRings) {
11672
11886
  const len = rings.length;
11673
11887
  if (len <= 1)
@@ -11679,7 +11893,7 @@ function classifyRings(rings, maxRings) {
11679
11893
  if (area === 0)
11680
11894
  continue;
11681
11895
  rings[i].area = Math.abs(area);
11682
- if (ccw === undefined)
11896
+ if (ccw === void 0)
11683
11897
  ccw = area < 0;
11684
11898
  if (ccw === area < 0) {
11685
11899
  if (polygon)
@@ -11720,7 +11934,6 @@ function onBoundary(p, p1, p2) {
11720
11934
  function rayIntersect(p, p1, p2) {
11721
11935
  return p1[1] > p[1] !== p2[1] > p[1] && p[0] < (p2[0] - p1[0]) * (p[1] - p1[1]) / (p2[1] - p1[1]) + p1[0];
11722
11936
  }
11723
- // ray casting algorithm for detecting if point is in polygon
11724
11937
  function pointWithinPolygon(point, rings, trueOnBoundary = false) {
11725
11938
  let inside = false;
11726
11939
  for (let i = 0, len = rings.length; i < len; i++) {
@@ -11739,9 +11952,7 @@ function pointWithinPolygon(point, rings, trueOnBoundary = false) {
11739
11952
  function perp(v1, v2) {
11740
11953
  return v1[0] * v2[1] - v1[1] * v2[0];
11741
11954
  }
11742
- // check if p1 and p2 are in different sides of line segment q1->q2
11743
11955
  function twoSided(p1, p2, q1, q2) {
11744
- // q1->p1 (x1, y1), q1->p2 (x2, y2), q1->q2 (x3, y3)
11745
11956
  const x1 = p1[0] - q1[0];
11746
11957
  const y1 = p1[1] - q1[1];
11747
11958
  const x2 = p2[0] - q1[0];
@@ -11754,11 +11965,7 @@ function twoSided(p1, p2, q1, q2) {
11754
11965
  return true;
11755
11966
  return false;
11756
11967
  }
11757
- // a, b are end points for line segment1, c and d are end points for line segment2
11758
11968
  function segmentIntersectSegment(a, b, c, d) {
11759
- // check if two segments are parallel or not
11760
- // precondition is end point a, b is inside polygon, if line a->b is
11761
- // parallel to polygon edge c->d, then a->b won't intersect with c->d
11762
11969
  const vectorP = [
11763
11970
  b[0] - a[0],
11764
11971
  b[1] - a[1]
@@ -11769,15 +11976,11 @@ function segmentIntersectSegment(a, b, c, d) {
11769
11976
  ];
11770
11977
  if (perp(vectorQ, vectorP) === 0)
11771
11978
  return false;
11772
- // If lines are intersecting with each other, the relative location should be:
11773
- // a and b lie in different sides of segment c->d
11774
- // c and d lie in different sides of segment a->b
11775
11979
  if (twoSided(a, b, c, d) && twoSided(c, d, a, b))
11776
11980
  return true;
11777
11981
  return false;
11778
11982
  }
11779
11983
 
11780
- //
11781
11984
  const EXTENT$1 = 8192;
11782
11985
  function mercatorXfromLng(lng) {
11783
11986
  return (180 + lng) / 360;
@@ -11803,7 +12006,6 @@ function pointWithinPolygons(point, polygons) {
11803
12006
  }
11804
12007
  function lineIntersectPolygon(p1, p2, polygon) {
11805
12008
  for (const ring of polygon) {
11806
- // loop through every edge of the ring
11807
12009
  for (let j = 0, len = ring.length, k = len - 1; j < len; k = j++) {
11808
12010
  const q1 = ring[k];
11809
12011
  const q2 = ring[j];
@@ -11815,13 +12017,11 @@ function lineIntersectPolygon(p1, p2, polygon) {
11815
12017
  return false;
11816
12018
  }
11817
12019
  function lineStringWithinPolygon(line, polygon) {
11818
- // First, check if geometry points of line segments are all inside polygon
11819
12020
  for (let i = 0; i < line.length; ++i) {
11820
12021
  if (!pointWithinPolygon(line[i], polygon)) {
11821
12022
  return false;
11822
12023
  }
11823
12024
  }
11824
- // Second, check if there is line segment intersecting polygon edge
11825
12025
  for (let i = 0; i < line.length - 1; ++i) {
11826
12026
  if (lineIntersectPolygon(line[i], line[i + 1], polygon)) {
11827
12027
  return false;
@@ -12054,7 +12254,6 @@ class Within {
12054
12254
  }
12055
12255
  }
12056
12256
 
12057
- /* */
12058
12257
  const factors = {
12059
12258
  kilometers: 1,
12060
12259
  miles: 1000 / 1609.344,
@@ -12074,13 +12273,6 @@ const E2 = FE * (2 - FE);
12074
12273
  const RAD = Math.PI / 180;
12075
12274
  /**
12076
12275
  * A collection of very fast approximations to common geodesic measurements. Useful for performance-sensitive code that measures things on a city scale.
12077
- *
12078
- * @param {number} lat latitude
12079
- * @param {string} [units='kilometers']
12080
- * @returns {CheapRuler}
12081
- * @example
12082
- * const ruler = cheapRuler(35.05, 'miles');
12083
- * //=ruler
12084
12276
  */
12085
12277
  class CheapRuler {
12086
12278
  /**
@@ -12088,7 +12280,7 @@ class CheapRuler {
12088
12280
  *
12089
12281
  * @param {number} y
12090
12282
  * @param {number} z
12091
- * @param {string} [units='kilometers']
12283
+ * @param {keyof typeof factors} [units='kilometers']
12092
12284
  * @returns {CheapRuler}
12093
12285
  * @example
12094
12286
  * const ruler = cheapRuler.fromTile(1567, 12);
@@ -12113,8 +12305,7 @@ class CheapRuler {
12113
12305
  * Creates a ruler instance for very fast approximations to common geodesic measurements around a certain latitude.
12114
12306
  *
12115
12307
  * @param {number} lat latitude
12116
- * @param {string} [units='kilometers']
12117
- * @returns {CheapRuler}
12308
+ * @param {keyof typeof factors} [units='kilometers']
12118
12309
  * @example
12119
12310
  * const ruler = cheapRuler(35.05, 'miles');
12120
12311
  * //=ruler
@@ -12137,8 +12328,8 @@ class CheapRuler {
12137
12328
  /**
12138
12329
  * Given two points of the form [longitude, latitude], returns the distance.
12139
12330
  *
12140
- * @param {Array<number>} a point [longitude, latitude]
12141
- * @param {Array<number>} b point [longitude, latitude]
12331
+ * @param {[number, number]} a point [longitude, latitude]
12332
+ * @param {[number, number]} b point [longitude, latitude]
12142
12333
  * @returns {number} distance
12143
12334
  * @example
12144
12335
  * const distance = ruler.distance([30.5, 50.5], [30.51, 50.49]);
@@ -12152,8 +12343,8 @@ class CheapRuler {
12152
12343
  /**
12153
12344
  * Returns the bearing between two points in angles.
12154
12345
  *
12155
- * @param {Array<number>} a point [longitude, latitude]
12156
- * @param {Array<number>} b point [longitude, latitude]
12346
+ * @param {[number, number]} a point [longitude, latitude]
12347
+ * @param {[number, number]} b point [longitude, latitude]
12157
12348
  * @returns {number} bearing
12158
12349
  * @example
12159
12350
  * const bearing = ruler.bearing([30.5, 50.5], [30.51, 50.49]);
@@ -12167,10 +12358,10 @@ class CheapRuler {
12167
12358
  /**
12168
12359
  * Returns a new point given distance and bearing from the starting point.
12169
12360
  *
12170
- * @param {Array<number>} p point [longitude, latitude]
12361
+ * @param {[number, number]} p point [longitude, latitude]
12171
12362
  * @param {number} dist distance
12172
12363
  * @param {number} bearing
12173
- * @returns {Array<number>} point [longitude, latitude]
12364
+ * @returns {[number, number]} point [longitude, latitude]
12174
12365
  * @example
12175
12366
  * const point = ruler.destination([30.5, 50.5], 0.1, 90);
12176
12367
  * //=point
@@ -12182,10 +12373,10 @@ class CheapRuler {
12182
12373
  /**
12183
12374
  * Returns a new point given easting and northing offsets (in ruler units) from the starting point.
12184
12375
  *
12185
- * @param {Array<number>} p point [longitude, latitude]
12376
+ * @param {[number, number]} p point [longitude, latitude]
12186
12377
  * @param {number} dx easting
12187
12378
  * @param {number} dy northing
12188
- * @returns {Array<number>} point [longitude, latitude]
12379
+ * @returns {[number, number]} point [longitude, latitude]
12189
12380
  * @example
12190
12381
  * const point = ruler.offset([30.5, 50.5], 10, 10);
12191
12382
  * //=point
@@ -12199,7 +12390,7 @@ class CheapRuler {
12199
12390
  /**
12200
12391
  * Given a line (an array of points), returns the total line distance.
12201
12392
  *
12202
- * @param {Array<Array<number>>} points [longitude, latitude]
12393
+ * @param {[number, number][]} points [longitude, latitude]
12203
12394
  * @returns {number} total line distance
12204
12395
  * @example
12205
12396
  * const length = ruler.lineDistance([
@@ -12218,7 +12409,7 @@ class CheapRuler {
12218
12409
  /**
12219
12410
  * Given a polygon (an array of rings, where each ring is an array of points), returns the area.
12220
12411
  *
12221
- * @param {Array<Array<Array<number>>>} polygon
12412
+ * @param {[number, number][][]} polygon
12222
12413
  * @returns {number} area value in the specified units (square kilometers by default)
12223
12414
  * @example
12224
12415
  * const area = ruler.area([[
@@ -12240,9 +12431,9 @@ class CheapRuler {
12240
12431
  /**
12241
12432
  * Returns the point at a specified distance along the line.
12242
12433
  *
12243
- * @param {Array<Array<number>>} line
12434
+ * @param {[number, number][]} line
12244
12435
  * @param {number} dist distance
12245
- * @returns {Array<number>} point [longitude, latitude]
12436
+ * @returns {[number, number]} point [longitude, latitude]
12246
12437
  * @example
12247
12438
  * const point = ruler.along(line, 2.5);
12248
12439
  * //=point
@@ -12257,7 +12448,7 @@ class CheapRuler {
12257
12448
  const d = this.distance(p0, p1);
12258
12449
  sum += d;
12259
12450
  if (sum > dist)
12260
- return interpolate$1(p0, p1, (dist - (sum - d)) / d);
12451
+ return interpolate(p0, p1, (dist - (sum - d)) / d);
12261
12452
  }
12262
12453
  return line[line.length - 1];
12263
12454
  }
@@ -12265,9 +12456,9 @@ class CheapRuler {
12265
12456
  * Returns the distance from a point `p` to a line segment `a` to `b`.
12266
12457
  *
12267
12458
  * @pointToSegmentDistance
12268
- * @param {Array<number>} p point [longitude, latitude]
12269
- * @param {Array<number>} p1 segment point 1 [longitude, latitude]
12270
- * @param {Array<number>} p2 segment point 2 [longitude, latitude]
12459
+ * @param {[number, number]} p point [longitude, latitude]
12460
+ * @param {[number, number]} a segment point 1 [longitude, latitude]
12461
+ * @param {[number, number]} b segment point 2 [longitude, latitude]
12271
12462
  * @returns {number} distance
12272
12463
  * @example
12273
12464
  * const distance = ruler.pointToSegmentDistance([-67.04, 50.5], [-67.05, 50.57], [-67.03, 50.54]);
@@ -12277,9 +12468,8 @@ class CheapRuler {
12277
12468
  let [x, y] = a;
12278
12469
  let dx = wrap(b[0] - x) * this.kx;
12279
12470
  let dy = (b[1] - y) * this.ky;
12280
- let t = 0;
12281
12471
  if (dx !== 0 || dy !== 0) {
12282
- t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
12472
+ const t = (wrap(p[0] - x) * this.kx * dx + (p[1] - y) * this.ky * dy) / (dx * dx + dy * dy);
12283
12473
  if (t > 1) {
12284
12474
  x = b[0];
12285
12475
  y = b[1];
@@ -12297,16 +12487,19 @@ class CheapRuler {
12297
12487
  * from the given point, index is the start index of the segment with the closest point,
12298
12488
  * and t is a parameter from 0 to 1 that indicates where the closest point is on that segment.
12299
12489
  *
12300
- * @param {Array<Array<number>>} line
12301
- * @param {Array<number>} p point [longitude, latitude]
12302
- * @returns {Object} {point, index, t}
12490
+ * @param {[number, number][]} line
12491
+ * @param {[number, number]} p point [longitude, latitude]
12492
+ * @returns {{point: [number, number], index: number, t: number}} {point, index, t}
12303
12493
  * @example
12304
12494
  * const point = ruler.pointOnLine(line, [-67.04, 50.5]).point;
12305
12495
  * //=point
12306
12496
  */
12307
12497
  pointOnLine(line, p) {
12308
12498
  let minDist = Infinity;
12309
- let minX, minY, minI, minT;
12499
+ let minX = line[0][0];
12500
+ let minY = line[0][1];
12501
+ let minI = 0;
12502
+ let minT = 0;
12310
12503
  for (let i = 0; i < line.length - 1; i++) {
12311
12504
  let x = line[i][0];
12312
12505
  let y = line[i][1];
@@ -12346,10 +12539,10 @@ class CheapRuler {
12346
12539
  /**
12347
12540
  * Returns a part of the given line between the start and the stop points (or their closest points on the line).
12348
12541
  *
12349
- * @param {Array<number>} start point [longitude, latitude]
12350
- * @param {Array<number>} stop point [longitude, latitude]
12351
- * @param {Array<Array<number>>} line
12352
- * @returns {Array<Array<number>>} line part of a line
12542
+ * @param {[number, number]} start point [longitude, latitude]
12543
+ * @param {[number, number]} stop point [longitude, latitude]
12544
+ * @param {[number, number][]} line
12545
+ * @returns {[number, number][]} line part of a line
12353
12546
  * @example
12354
12547
  * const line2 = ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line1);
12355
12548
  * //=line2
@@ -12377,10 +12570,10 @@ class CheapRuler {
12377
12570
  /**
12378
12571
  * Returns a part of the given line between the start and the stop points indicated by distance along the line.
12379
12572
  *
12380
- * @param {number} start distance
12381
- * @param {number} stop distance
12382
- * @param {Array<Array<number>>} line
12383
- * @returns {Array<Array<number>>} line part of a line
12573
+ * @param {number} start start distance
12574
+ * @param {number} stop stop distance
12575
+ * @param {[number, number][]} line
12576
+ * @returns {[number, number][]} part of a line
12384
12577
  * @example
12385
12578
  * const line2 = ruler.lineSliceAlong(10, 20, line1);
12386
12579
  * //=line2
@@ -12394,10 +12587,10 @@ class CheapRuler {
12394
12587
  const d = this.distance(p0, p1);
12395
12588
  sum += d;
12396
12589
  if (sum > start && slice.length === 0) {
12397
- slice.push(interpolate$1(p0, p1, (start - (sum - d)) / d));
12590
+ slice.push(interpolate(p0, p1, (start - (sum - d)) / d));
12398
12591
  }
12399
12592
  if (sum >= stop) {
12400
- slice.push(interpolate$1(p0, p1, (stop - (sum - d)) / d));
12593
+ slice.push(interpolate(p0, p1, (stop - (sum - d)) / d));
12401
12594
  return slice;
12402
12595
  }
12403
12596
  if (sum > start)
@@ -12408,9 +12601,9 @@ class CheapRuler {
12408
12601
  /**
12409
12602
  * Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance.
12410
12603
  *
12411
- * @param {Array<number>} p point [longitude, latitude]
12604
+ * @param {[number, number]} p point [longitude, latitude]
12412
12605
  * @param {number} buffer
12413
- * @returns {Array<number>} box object ([w, s, e, n])
12606
+ * @returns {[number, number, number, number]} bbox ([w, s, e, n])
12414
12607
  * @example
12415
12608
  * const bbox = ruler.bufferPoint([30.5, 50.5], 0.01);
12416
12609
  * //=bbox
@@ -12428,9 +12621,9 @@ class CheapRuler {
12428
12621
  /**
12429
12622
  * Given a bounding box, returns the box buffered by a given distance.
12430
12623
  *
12431
- * @param {Array<number>} box object ([w, s, e, n])
12624
+ * @param {[number, number, number, number]} bbox ([w, s, e, n])
12432
12625
  * @param {number} buffer
12433
- * @returns {Array<number>} box object ([w, s, e, n])
12626
+ * @returns {[number, number, number, number]} bbox ([w, s, e, n])
12434
12627
  * @example
12435
12628
  * const bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2);
12436
12629
  * //=bbox
@@ -12448,21 +12641,32 @@ class CheapRuler {
12448
12641
  /**
12449
12642
  * Returns true if the given point is inside in the given bounding box, otherwise false.
12450
12643
  *
12451
- * @param {Array<number>} p point [longitude, latitude]
12452
- * @param {Array<number>} box object ([w, s, e, n])
12644
+ * @param {[number, number]} p point [longitude, latitude]
12645
+ * @param {[number, number, number, number]} bbox ([w, s, e, n])
12453
12646
  * @returns {boolean}
12454
12647
  * @example
12455
12648
  * const inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]);
12456
12649
  * //=inside
12457
12650
  */
12458
12651
  insideBBox(p, bbox) {
12652
+ // eslint-disable-line
12459
12653
  return wrap(p[0] - bbox[0]) >= 0 && wrap(p[0] - bbox[2]) <= 0 && p[1] >= bbox[1] && p[1] <= bbox[3];
12460
12654
  }
12461
12655
  }
12656
+ /**
12657
+ * @param {[number, number]} a
12658
+ * @param {[number, number]} b
12659
+ */
12462
12660
  function equals(a, b) {
12463
12661
  return a[0] === b[0] && a[1] === b[1];
12464
12662
  }
12465
- function interpolate$1(a, b, t) {
12663
+ /**
12664
+ * @param {[number, number]} a
12665
+ * @param {[number, number]} b
12666
+ * @param {number} t
12667
+ * @returns {[number, number]}
12668
+ */
12669
+ function interpolate(a, b, t) {
12466
12670
  const dx = wrap(b[0] - a[0]);
12467
12671
  const dy = b[1] - a[1];
12468
12672
  return [
@@ -12470,7 +12674,10 @@ function interpolate$1(a, b, t) {
12470
12674
  a[1] + dy * t
12471
12675
  ];
12472
12676
  }
12473
- // normalize a degree value into [-180..180] range
12677
+ /**
12678
+ * normalize a degree value into [-180..180] range
12679
+ * @param {number} deg
12680
+ */
12474
12681
  function wrap(deg) {
12475
12682
  while (deg < -180)
12476
12683
  deg += 360;
@@ -12835,26 +13042,8 @@ function defaultCompare(a, b) {
12835
13042
  return a < b ? -1 : a > b ? 1 : 0;
12836
13043
  }
12837
13044
 
12838
- //
12839
- /**
12840
- * The maximum value of a coordinate in the internal tile coordinate system. Coordinates of
12841
- * all source features normalized to this extent upon load.
12842
- *
12843
- * The value is a consequence of the following:
12844
- *
12845
- * * Vertex buffer store positions as signed 16 bit integers.
12846
- * * One bit is lost for signedness to support tile buffers.
12847
- * * One bit is lost because the line vertex buffer used to pack 1 bit of other data into the int.
12848
- * * One bit is lost to support features extending past the extent on the right edge of the tile.
12849
- * * This leaves us with 2^13 = 8192
12850
- *
12851
- * @private
12852
- * @readonly
12853
- */
12854
13045
  var EXTENT = 8192;
12855
13046
 
12856
- //
12857
- // Inclusive index range for multipoint or linestring container
12858
13047
  function compareMax(a, b) {
12859
13048
  return b.dist - a.dist;
12860
13049
  }
@@ -12887,9 +13076,6 @@ function isRangeSafe(range, threshold) {
12887
13076
  }
12888
13077
  return ret;
12889
13078
  }
12890
- // Split the point set(points or linestring) into two halves, using IndexRange to do in-place splitting.
12891
- // If geometry is a line, the last point(here is the second index) of range1 needs to be included as the first point(here is the first index) of range2.
12892
- // If geometry are points, just split the points equally(if possible) into two new point sets(here are two index ranges).
12893
13079
  function splitRange(range, isLine) {
12894
13080
  if (range[0] > range[1])
12895
13081
  return [
@@ -12967,28 +13153,21 @@ function getPolygonBBox(polygon) {
12967
13153
  }
12968
13154
  return bbox;
12969
13155
  }
12970
- // Calculate the distance between two bounding boxes.
12971
- // Calculate the delta in x and y direction, and use two fake points {0.0, 0.0} and {dx, dy} to calculate the distance.
12972
- // Distance will be 0.0 if bounding box are overlapping.
12973
13156
  function bboxToBBoxDistance(bbox1, bbox2, ruler) {
12974
13157
  if (isDefaultBBOX(bbox1) || isDefaultBBOX(bbox2)) {
12975
13158
  return NaN;
12976
13159
  }
12977
13160
  let dx = 0;
12978
13161
  let dy = 0;
12979
- // bbox1 in left side
12980
13162
  if (bbox1[2] < bbox2[0]) {
12981
13163
  dx = bbox2[0] - bbox1[2];
12982
13164
  }
12983
- // bbox1 in right side
12984
13165
  if (bbox1[0] > bbox2[2]) {
12985
13166
  dx = bbox1[0] - bbox2[2];
12986
13167
  }
12987
- // bbox1 in above side
12988
13168
  if (bbox1[1] > bbox2[3]) {
12989
13169
  dy = bbox1[1] - bbox2[3];
12990
13170
  }
12991
- // bbox1 in down side
12992
13171
  if (bbox1[3] < bbox2[1]) {
12993
13172
  dy = bbox2[1] - bbox1[3];
12994
13173
  }
@@ -13036,10 +13215,13 @@ function pointsToLineDistance(points, rangeA, line, rangeB, ruler) {
13036
13215
  }
13037
13216
  return dist;
13038
13217
  }
13039
- // precondition is two segments are not intersecting with each other
13040
13218
  function segmentToSegmentDistance(p1, p2, q1, q2, ruler) {
13041
- const dist1 = Math.min(ruler.pointToSegmentDistance(p1, q1, q2), ruler.pointToSegmentDistance(p2, q1, q2));
13042
- const dist2 = Math.min(ruler.pointToSegmentDistance(q1, p1, p2), ruler.pointToSegmentDistance(q2, p1, p2));
13219
+ const dist1 = Math.min(// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
13220
+ ruler.pointToSegmentDistance(p1, q1, q2), // @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
13221
+ ruler.pointToSegmentDistance(p2, q1, q2));
13222
+ const dist2 = Math.min(// @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
13223
+ ruler.pointToSegmentDistance(q1, p1, p2), // @ts-expect-error - TS2345 - Argument of type 'Position' is not assignable to parameter of type 'Point'.
13224
+ ruler.pointToSegmentDistance(q2, p1, p2));
13043
13225
  return Math.min(dist1, dist2);
13044
13226
  }
13045
13227
  function lineToLineDistance(line1, range1, line2, range2, ruler) {
@@ -13147,7 +13329,6 @@ function updateQueue(distQueue, miniDist, ruler, pointSet1, pointSet2, r1, r2) {
13147
13329
  if (r1 === null || r2 === null)
13148
13330
  return;
13149
13331
  const tempDist = bboxToBBoxDistance(getBBox(pointSet1, r1), getBBox(pointSet2, r2), ruler);
13150
- // Insert new pair to the queue if the bbox distance is less than miniDist, the pair with biggest distance will be at the top
13151
13332
  if (tempDist < miniDist)
13152
13333
  distQueue.push({
13153
13334
  dist: tempDist,
@@ -13155,8 +13336,6 @@ function updateQueue(distQueue, miniDist, ruler, pointSet1, pointSet2, r1, r2) {
13155
13336
  range2: r2
13156
13337
  });
13157
13338
  }
13158
- // Divide and conquer, the time complexity is O(n*lgn), faster than Brute force O(n*n)
13159
- // Most of the time, use index for in-place processing.
13160
13339
  function pointSetToPolygonDistance(pointSets, isLine, polygon, ruler, currentMiniDist = Infinity) {
13161
13340
  let miniDist = Math.min(ruler.distance(pointSets[0], polygon[0][0]), currentMiniDist);
13162
13341
  if (miniDist === 0)
@@ -13180,7 +13359,6 @@ function pointSetToPolygonDistance(pointSets, isLine, polygon, ruler, currentMin
13180
13359
  if (distPair.dist >= miniDist)
13181
13360
  continue;
13182
13361
  const range = distPair.range1;
13183
- // In case the set size are relatively small, we could use brute-force directly
13184
13362
  if (getRangeSize(range) <= setThreshold) {
13185
13363
  if (!isRangeSafe(range, pointSets.length))
13186
13364
  return NaN;
@@ -13249,7 +13427,6 @@ function pointSetsDistance(pointSet1, isLine1, pointSet2, isLine2, ruler, curren
13249
13427
  continue;
13250
13428
  const rangeA = distPair.range1;
13251
13429
  const rangeB = distPair.range2;
13252
- // In case the set size are relatively small, we could use brute-force directly
13253
13430
  if (getRangeSize(rangeA) <= set1Threshold && getRangeSize(rangeB) <= set2Threshold) {
13254
13431
  if (!isRangeSafe(rangeA, pointSet1.length) || !isRangeSafe(rangeB, pointSet2.length)) {
13255
13432
  return NaN;
@@ -13288,7 +13465,7 @@ function pointSetToLinesDistance(pointSet, isLine, lines, ruler, currentMiniDist
13288
13465
  line.length - 1
13289
13466
  ]), ruler) >= dist)
13290
13467
  continue;
13291
- dist = Math.min(dist, pointSetsDistance(pointSet, isLine, line, true /*isLine*/, ruler, dist));
13468
+ dist = Math.min(dist, pointSetsDistance(pointSet, isLine, line, true, ruler, dist));
13292
13469
  if (dist === 0)
13293
13470
  return dist;
13294
13471
  }
@@ -13333,13 +13510,13 @@ function pointsToGeometryDistance(originGeometry, canonical, geometry) {
13333
13510
  }
13334
13511
  const ruler = new CheapRuler(lngLatPoints[0][1], 'meters');
13335
13512
  if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
13336
- return pointSetsDistance(lngLatPoints, false /*isLine*/, geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString' /*isLine*/, ruler);
13513
+ return pointSetsDistance(lngLatPoints, false, geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', ruler);
13337
13514
  }
13338
13515
  if (geometry.type === 'MultiLineString') {
13339
- return pointSetToLinesDistance(lngLatPoints, false /*isLine*/, geometry.coordinates, ruler);
13516
+ return pointSetToLinesDistance(lngLatPoints, false, geometry.coordinates, ruler);
13340
13517
  }
13341
13518
  if (geometry.type === 'Polygon' || geometry.type === 'MultiPolygon') {
13342
- return pointSetToPolygonsDistance(lngLatPoints, false /*isLine*/, geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates, ruler);
13519
+ return pointSetToPolygonsDistance(lngLatPoints, false, geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates, ruler);
13343
13520
  }
13344
13521
  return null;
13345
13522
  }
@@ -13354,12 +13531,12 @@ function linesToGeometryDistance(originGeometry, canonical, geometry) {
13354
13531
  }
13355
13532
  const ruler = new CheapRuler(lngLatLines[0][0][1], 'meters');
13356
13533
  if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
13357
- return pointSetToLinesDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString' /*isLine*/, lngLatLines, ruler);
13534
+ return pointSetToLinesDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', lngLatLines, ruler);
13358
13535
  }
13359
13536
  if (geometry.type === 'MultiLineString') {
13360
13537
  let dist = Infinity;
13361
13538
  for (let i = 0; i < geometry.coordinates.length; i++) {
13362
- const tempDist = pointSetToLinesDistance(geometry.coordinates[i], true /*isLine*/, lngLatLines, ruler, dist);
13539
+ const tempDist = pointSetToLinesDistance(geometry.coordinates[i], true, lngLatLines, ruler, dist);
13363
13540
  if (isNaN(tempDist))
13364
13541
  return tempDist;
13365
13542
  if ((dist = Math.min(dist, tempDist)) === 0)
@@ -13370,7 +13547,7 @@ function linesToGeometryDistance(originGeometry, canonical, geometry) {
13370
13547
  if (geometry.type === 'Polygon' || geometry.type === 'MultiPolygon') {
13371
13548
  let dist = Infinity;
13372
13549
  for (let i = 0; i < lngLatLines.length; i++) {
13373
- const tempDist = pointSetToPolygonsDistance(lngLatLines[i], true /*isLine*/, geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates, ruler, dist);
13550
+ const tempDist = pointSetToPolygonsDistance(lngLatLines[i], true, geometry.type === 'Polygon' ? [geometry.coordinates] : geometry.coordinates, ruler, dist);
13374
13551
  if (isNaN(tempDist))
13375
13552
  return tempDist;
13376
13553
  if ((dist = Math.min(dist, tempDist)) === 0)
@@ -13391,12 +13568,12 @@ function polygonsToGeometryDistance(originGeometry, canonical, geometry) {
13391
13568
  }
13392
13569
  const ruler = new CheapRuler(lngLatPolygons[0][0][0][1], 'meters');
13393
13570
  if (geometry.type === 'Point' || geometry.type === 'MultiPoint' || geometry.type === 'LineString') {
13394
- return pointSetToPolygonsDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString' /*isLine*/, lngLatPolygons, ruler);
13571
+ return pointSetToPolygonsDistance(geometry.type === 'Point' ? [geometry.coordinates] : geometry.coordinates, geometry.type === 'LineString', lngLatPolygons, ruler);
13395
13572
  }
13396
13573
  if (geometry.type === 'MultiLineString') {
13397
13574
  let dist = Infinity;
13398
13575
  for (let i = 0; i < geometry.coordinates.length; i++) {
13399
- const tempDist = pointSetToPolygonsDistance(geometry.coordinates[i], true /*isLine*/, lngLatPolygons, ruler, dist);
13576
+ const tempDist = pointSetToPolygonsDistance(geometry.coordinates[i], true, lngLatPolygons, ruler, dist);
13400
13577
  if (isNaN(tempDist))
13401
13578
  return tempDist;
13402
13579
  if ((dist = Math.min(dist, tempDist)) === 0)
@@ -13472,7 +13649,6 @@ class Distance {
13472
13649
  }
13473
13650
  }
13474
13651
 
13475
- //
13476
13652
  function coerceValue(type, value) {
13477
13653
  switch (type) {
13478
13654
  case 'string':
@@ -13482,7 +13658,7 @@ function coerceValue(type, value) {
13482
13658
  case 'boolean':
13483
13659
  return !!value;
13484
13660
  case 'color':
13485
- return Color$1.parse(value);
13661
+ return Color.parse(value);
13486
13662
  case 'formatted': {
13487
13663
  return Formatted.fromString(toString(value));
13488
13664
  }
@@ -13493,13 +13669,13 @@ function coerceValue(type, value) {
13493
13669
  return value;
13494
13670
  }
13495
13671
  function clampToAllowedNumber(value, min, max, step) {
13496
- if (step !== undefined) {
13672
+ if (step !== void 0) {
13497
13673
  value = step * Math.round(value / step);
13498
13674
  }
13499
- if (min !== undefined && value < min) {
13675
+ if (min !== void 0 && value < min) {
13500
13676
  value = min;
13501
13677
  }
13502
- if (max !== undefined && value > max) {
13678
+ if (max !== void 0 && value > max) {
13503
13679
  value = max;
13504
13680
  }
13505
13681
  return value;
@@ -13512,7 +13688,7 @@ class Config {
13512
13688
  }
13513
13689
  static parse(args, context) {
13514
13690
  let type = context.expectedType;
13515
- if (type === null || type === undefined) {
13691
+ if (type === null || type === void 0) {
13516
13692
  type = ValueType;
13517
13693
  }
13518
13694
  if (args.length < 2 || args.length > 3) {
@@ -13545,7 +13721,6 @@ class Config {
13545
13721
  const defaultValue = config.default.evaluate(ctx);
13546
13722
  let result = defaultValue;
13547
13723
  if (value) {
13548
- // temporarily override scope to parent to evaluate config expressions passed from the parent
13549
13724
  const originalScope = ctx.scope;
13550
13725
  ctx.scope = (originalScope || '').split(FQIDSeparator).slice(1).join(FQIDSeparator);
13551
13726
  result = value.evaluate(ctx);
@@ -13554,21 +13729,20 @@ class Config {
13554
13729
  if (type) {
13555
13730
  result = coerceValue(type, result);
13556
13731
  }
13557
- if (result !== undefined && (minValue !== undefined || maxValue !== undefined || stepValue !== undefined)) {
13732
+ if (result !== void 0 && (minValue !== void 0 || maxValue !== void 0 || stepValue !== void 0)) {
13558
13733
  if (typeof result === 'number') {
13559
13734
  result = clampToAllowedNumber(result, minValue, maxValue, stepValue);
13560
13735
  } else if (Array.isArray(result)) {
13561
13736
  result = result.map(item => typeof item === 'number' ? clampToAllowedNumber(item, minValue, maxValue, stepValue) : item);
13562
13737
  }
13563
13738
  }
13564
- if (value !== undefined && result !== undefined && values && !values.includes(result)) {
13565
- // The result is not among the allowed values. Instead, use the default value from the option.
13739
+ if (value !== void 0 && result !== void 0 && values && !values.includes(result)) {
13566
13740
  result = defaultValue;
13567
13741
  if (type) {
13568
13742
  result = coerceValue(type, result);
13569
13743
  }
13570
13744
  }
13571
- if (type && type !== this.type || result !== undefined && typeOf(result) !== this.type) {
13745
+ if (type && type !== this.type || result !== void 0 && typeOf(result) !== this.type) {
13572
13746
  result = coerceValue(this.type.kind, result);
13573
13747
  }
13574
13748
  return result;
@@ -13590,7 +13764,6 @@ class Config {
13590
13764
  }
13591
13765
  }
13592
13766
 
13593
- //
13594
13767
  function isFeatureConstant(e) {
13595
13768
  if (e instanceof CompoundExpression) {
13596
13769
  if (e.name === 'get' && e.args.length === 1) {
@@ -13658,7 +13831,6 @@ function isGlobalPropertyConstant(e, properties) {
13658
13831
  return result;
13659
13832
  }
13660
13833
 
13661
- //
13662
13834
  class Var {
13663
13835
  constructor(name, boundExpression) {
13664
13836
  this.type = boundExpression.type;
@@ -13690,16 +13862,7 @@ class Var {
13690
13862
  }
13691
13863
  }
13692
13864
 
13693
- //
13694
- /**
13695
- * State associated parsing at a given point in an expression tree.
13696
- * @private
13697
- */
13698
13865
  class ParsingContext {
13699
- // The expected type of this expression. Provided only to allow Expression
13700
- // implementations to infer argument types: Expression#parse() need not
13701
- // check that the output type of the parsed expression matches
13702
- // `expectedType`.
13703
13866
  constructor(registry, path = [], expectedType, scope = new Scope(), errors = [], _scope, options) {
13704
13867
  this.registry = registry;
13705
13868
  this.path = path;
@@ -13711,12 +13874,12 @@ class ParsingContext {
13711
13874
  this.options = options;
13712
13875
  }
13713
13876
  /**
13714
- * @param expr the JSON expression to parse
13715
- * @param index the optional argument index if this expression is an argument of a parent expression that's being parsed
13716
- * @param options
13717
- * @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.
13718
- * @private
13719
- */
13877
+ * @param expr the JSON expression to parse
13878
+ * @param index the optional argument index if this expression is an argument of a parent expression that's being parsed
13879
+ * @param options
13880
+ * @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.
13881
+ * @private
13882
+ */
13720
13883
  parse(expr, index, expectedType, bindings, options = {}) {
13721
13884
  if (index || expectedType) {
13722
13885
  return this.concat(index, expectedType, bindings)._parse(expr, options);
@@ -13743,7 +13906,7 @@ class ParsingContext {
13743
13906
  if (expr.length === 0) {
13744
13907
  return this.error(`Expected an array with at least one element. If you wanted a literal array, use ["literal", []].`);
13745
13908
  }
13746
- const Expr = typeof expr[0] === 'string' ? this.registry[expr[0]] : undefined;
13909
+ const Expr = typeof expr[0] === 'string' ? this.registry[expr[0]] : void 0;
13747
13910
  if (Expr) {
13748
13911
  let parsed = Expr.parse(expr, this);
13749
13912
  if (!parsed)
@@ -13751,14 +13914,6 @@ class ParsingContext {
13751
13914
  if (this.expectedType) {
13752
13915
  const expected = this.expectedType;
13753
13916
  const actual = parsed.type;
13754
- // When we expect a number, string, boolean, or array but have a value, wrap it in an assertion.
13755
- // When we expect a color or formatted string, but have a string or value, wrap it in a coercion.
13756
- // Otherwise, we do static type-checking.
13757
- //
13758
- // These behaviors are overridable for:
13759
- // * The "coalesce" operator, which needs to omit type annotations.
13760
- // * String-valued properties (e.g. `text-field`), where coercion is more convenient than assertion.
13761
- //
13762
13917
  if ((expected.kind === 'string' || expected.kind === 'number' || expected.kind === 'boolean' || expected.kind === 'object' || expected.kind === 'array') && actual.kind === 'value') {
13763
13918
  parsed = annotate(parsed, expected, options.typeAnnotation || 'assert');
13764
13919
  } else if ((expected.kind === 'color' || expected.kind === 'formatted' || expected.kind === 'resolvedImage') && (actual.kind === 'value' || actual.kind === 'string')) {
@@ -13767,10 +13922,6 @@ class ParsingContext {
13767
13922
  return null;
13768
13923
  }
13769
13924
  }
13770
- // If an expression's arguments are all literals, we can evaluate
13771
- // it immediately and replace it with a literal value in the
13772
- // parsed/compiled result. Expressions that expect an image should
13773
- // not be resolved here so we can later get the available images.
13774
13925
  if (!(parsed instanceof Literal) && parsed.type.kind !== 'resolvedImage' && isConstant(parsed)) {
13775
13926
  const ec = new EvaluationContext(this._scope, this.options);
13776
13927
  try {
@@ -13782,7 +13933,6 @@ class ParsingContext {
13782
13933
  }
13783
13934
  return parsed;
13784
13935
  }
13785
- // Try to parse as array
13786
13936
  return Coercion.parse([
13787
13937
  'to-array',
13788
13938
  expr
@@ -13796,33 +13946,33 @@ class ParsingContext {
13796
13946
  }
13797
13947
  }
13798
13948
  /**
13799
- * Returns a copy of this context suitable for parsing the subexpression at
13800
- * index `index`, optionally appending to 'let' binding map.
13801
- *
13802
- * Note that `errors` property, intended for collecting errors while
13803
- * parsing, is copied by reference rather than cloned.
13804
- * @private
13805
- */
13949
+ * Returns a copy of this context suitable for parsing the subexpression at
13950
+ * index `index`, optionally appending to 'let' binding map.
13951
+ *
13952
+ * Note that `errors` property, intended for collecting errors while
13953
+ * parsing, is copied by reference rather than cloned.
13954
+ * @private
13955
+ */
13806
13956
  concat(index, expectedType, bindings) {
13807
13957
  const path = typeof index === 'number' ? this.path.concat(index) : this.path;
13808
13958
  const scope = bindings ? this.scope.concat(bindings) : this.scope;
13809
13959
  return new ParsingContext(this.registry, path, expectedType || null, scope, this.errors, this._scope, this.options);
13810
13960
  }
13811
13961
  /**
13812
- * Push a parsing (or type checking) error into the `this.errors`
13813
- * @param error The message
13814
- * @param keys Optionally specify the source of the error at a child
13815
- * of the current expression at `this.key`.
13816
- * @private
13817
- */
13962
+ * Push a parsing (or type checking) error into the `this.errors`
13963
+ * @param error The message
13964
+ * @param keys Optionally specify the source of the error at a child
13965
+ * of the current expression at `this.key`.
13966
+ * @private
13967
+ */
13818
13968
  error(error, ...keys) {
13819
13969
  const key = `${ this.key }${ keys.map(k => `[${ k }]`).join('') }`;
13820
13970
  this.errors.push(new ParsingError$1(key, error));
13821
13971
  }
13822
13972
  /**
13823
- * Returns null if `t` is a subtype of `expected`; otherwise returns an
13824
- * error message and also pushes it to `this.errors`.
13825
- */
13973
+ * Returns null if `t` is a subtype of `expected`; otherwise returns an
13974
+ * error message and also pushes it to `this.errors`.
13975
+ */
13826
13976
  checkSubtype(expected, t) {
13827
13977
  const error = checkSubtype(expected, t);
13828
13978
  if (error)
@@ -13830,15 +13980,13 @@ class ParsingContext {
13830
13980
  return error;
13831
13981
  }
13832
13982
  }
13983
+ var ParsingContext$1 = ParsingContext;
13833
13984
  function isConstant(expression) {
13834
13985
  if (expression instanceof Var) {
13835
13986
  return isConstant(expression.boundExpression);
13836
13987
  } else if (expression instanceof CompoundExpression && expression.name === 'error') {
13837
13988
  return false;
13838
13989
  } else if (expression instanceof CollatorExpression) {
13839
- // Although the results of a Collator expression with fixed arguments
13840
- // generally shouldn't change between executions, we can't serialize them
13841
- // as constant expressions because results change based on environment.
13842
13990
  return false;
13843
13991
  } else if (expression instanceof Within) {
13844
13992
  return false;
@@ -13850,12 +13998,6 @@ function isConstant(expression) {
13850
13998
  const isTypeAnnotation = expression instanceof Coercion || expression instanceof Assertion;
13851
13999
  let childrenConstant = true;
13852
14000
  expression.eachChild(child => {
13853
- // We can _almost_ assume that if `expressions` children are constant,
13854
- // they would already have been evaluated to Literal values when they
13855
- // were parsed. Type annotations are the exception, because they might
13856
- // have been inferred and added after a child was parsed.
13857
- // So we recurse into isConstant() for the children of type annotations,
13858
- // but otherwise simply check whether they are Literals.
13859
14001
  if (isTypeAnnotation) {
13860
14002
  childrenConstant = childrenConstant && isConstant(child);
13861
14003
  } else {
@@ -13880,11 +14022,6 @@ function isConstant(expression) {
13880
14022
  ]);
13881
14023
  }
13882
14024
 
13883
- //
13884
- /**
13885
- * Returns the index of the last stop <= input, or 0 if it doesn't exist.
13886
- * @private
13887
- */
13888
14025
  function findStopLessThanOrEqualTo(stops, input) {
13889
14026
  const lastIndex = stops.length - 1;
13890
14027
  let lowerIndex = 0;
@@ -13897,7 +14034,6 @@ function findStopLessThanOrEqualTo(stops, input) {
13897
14034
  nextValue = stops[currentIndex + 1];
13898
14035
  if (currentValue <= input) {
13899
14036
  if (currentIndex === lastIndex || input < nextValue) {
13900
- // Search complete
13901
14037
  return currentIndex;
13902
14038
  }
13903
14039
  lowerIndex = currentIndex + 1;
@@ -13910,7 +14046,6 @@ function findStopLessThanOrEqualTo(stops, input) {
13910
14046
  return 0;
13911
14047
  }
13912
14048
 
13913
- //
13914
14049
  class Step {
13915
14050
  constructor(type, input, stops) {
13916
14051
  this.type = type;
@@ -14067,32 +14202,7 @@ UnitBezier.prototype = {
14067
14202
 
14068
14203
  var UnitBezier$1 = /*@__PURE__*/getDefaultExportFromCjs(unitbezier);
14069
14204
 
14070
- //
14071
- function number(a, b, t) {
14072
- return a * (1 - t) + b * t;
14073
- }
14074
- function color(from, to, t) {
14075
- return new Color$1(number(from.r, to.r, t), number(from.g, to.g, t), number(from.b, to.b, t), number(from.a, to.a, t));
14076
- }
14077
- function array(from, to, t) {
14078
- return from.map((d, i) => {
14079
- return number(d, to[i], t);
14080
- });
14081
- }
14082
-
14083
- var interpolate = /*#__PURE__*/Object.freeze({
14084
- __proto__: null,
14085
- array: array,
14086
- color: color,
14087
- number: number
14088
- });
14089
-
14090
- //
14091
- // Constants
14092
- const Xn = 0.95047,
14093
- // D65 standard referent
14094
- Yn = 1, Zn = 1.08883, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI;
14095
- // Utilities
14205
+ const Xn = 0.95047, Yn = 1, Zn = 1.08883, t0 = 4 / 29, t1 = 6 / 29, t2 = 3 * t1 * t1, t3 = t1 * t1 * t1, deg2rad = Math.PI / 180, rad2deg = 180 / Math.PI;
14096
14206
  function xyz2lab(t) {
14097
14207
  return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
14098
14208
  }
@@ -14106,7 +14216,6 @@ function rgb2xyz(x) {
14106
14216
  x /= 255;
14107
14217
  return x <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
14108
14218
  }
14109
- // LAB
14110
14219
  function rgbToLab(rgbColor) {
14111
14220
  const b = rgb2xyz(rgbColor.r), a = rgb2xyz(rgbColor.g), l = rgb2xyz(rgbColor.b), x = xyz2lab((0.4124564 * b + 0.3575761 * a + 0.1804375 * l) / Xn), y = xyz2lab((0.2126729 * b + 0.7151522 * a + 0.072175 * l) / Yn), z = xyz2lab((0.0193339 * b + 0.119192 * a + 0.9503041 * l) / Zn);
14112
14221
  return {
@@ -14121,7 +14230,7 @@ function labToRgb(labColor) {
14121
14230
  y = Yn * lab2xyz(y);
14122
14231
  x = Xn * lab2xyz(x);
14123
14232
  z = Zn * lab2xyz(z);
14124
- return new Color$1(xyz2rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z), // D65 -> sRGB
14233
+ return new Color(xyz2rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z), // D65 -> sRGB
14125
14234
  xyz2rgb(-0.969266 * x + 1.8760108 * y + 0.041556 * z), xyz2rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z), labColor.alpha);
14126
14235
  }
14127
14236
  function interpolateLab(from, to, t) {
@@ -14132,7 +14241,6 @@ function interpolateLab(from, to, t) {
14132
14241
  alpha: number(from.alpha, to.alpha, t)
14133
14242
  };
14134
14243
  }
14135
- // HCL
14136
14244
  function rgbToHcl(rgbColor) {
14137
14245
  const {l, a, b} = rgbToLab(rgbColor);
14138
14246
  const h = Math.atan2(b, a) * rad2deg;
@@ -14181,7 +14289,6 @@ var colorSpaces = /*#__PURE__*/Object.freeze({
14181
14289
  lab: lab
14182
14290
  });
14183
14291
 
14184
- //
14185
14292
  class Interpolate {
14186
14293
  constructor(type, operator, interpolation, input, stops) {
14187
14294
  this.type = type;
@@ -14230,7 +14337,7 @@ class Interpolate {
14230
14337
  }
14231
14338
  interpolation = {
14232
14339
  name: 'cubic-bezier',
14233
- controlPoints: controlPoints
14340
+ controlPoints
14234
14341
  };
14235
14342
  } else {
14236
14343
  return context.error(`Unknown interpolation type ${ String(interpolation[0]) }`, 1, 0);
@@ -14297,7 +14404,7 @@ class Interpolate {
14297
14404
  const outputLower = outputs[index].evaluate(ctx);
14298
14405
  const outputUpper = outputs[index + 1].evaluate(ctx);
14299
14406
  if (this.operator === 'interpolate') {
14300
- return interpolate[this.type.kind.toLowerCase()](outputLower, outputUpper, t); // eslint-disable-line import/namespace
14407
+ return interpolate$1[this.type.kind.toLowerCase()](outputLower, outputUpper, t);
14301
14408
  } else if (this.operator === 'interpolate-hcl') {
14302
14409
  return hcl.reverse(hcl.interpolate(hcl.forward(outputLower), hcl.forward(outputUpper), t));
14303
14410
  } else {
@@ -14340,41 +14447,6 @@ class Interpolate {
14340
14447
  return serialized;
14341
14448
  }
14342
14449
  }
14343
- /**
14344
- * Returns a ratio that can be used to interpolate between exponential function
14345
- * stops.
14346
- * 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,
14347
- * and `a` and `b` are constants affording sufficient degrees of freedom to fit
14348
- * the function to the given stops.
14349
- *
14350
- * Here's a bit of algebra that lets us compute `f(x)` directly from the stop
14351
- * values without explicitly solving for `a` and `b`:
14352
- *
14353
- * First stop value: `f(x0) = y0 = a * base^x0 + b`
14354
- * Second stop value: `f(x1) = y1 = a * base^x1 + b`
14355
- * => `y1 - y0 = a(base^x1 - base^x0)`
14356
- * => `a = (y1 - y0)/(base^x1 - base^x0)`
14357
- *
14358
- * Desired value: `f(x) = y = a * base^x + b`
14359
- * => `f(x) = y0 + a * (base^x - base^x0)`
14360
- *
14361
- * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a
14362
- * little algebra:
14363
- * ```
14364
- * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)
14365
- * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)
14366
- * ```
14367
- *
14368
- * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have
14369
- * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as
14370
- * an interpolation factor between the two stops' output values.
14371
- *
14372
- * (Note: a slightly different form for `ratio`,
14373
- * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer
14374
- * expensive `Math.pow()` operations.)
14375
- *
14376
- * @private
14377
- */
14378
14450
  function exponentialInterpolation(input, base, lowerValue, upperValue) {
14379
14451
  const difference = upperValue - lowerValue;
14380
14452
  const progress = input - lowerValue;
@@ -14403,17 +14475,12 @@ class Coalesce {
14403
14475
  }
14404
14476
  const parsedArgs = [];
14405
14477
  for (const arg of args.slice(1)) {
14406
- const parsed = context.parse(arg, 1 + parsedArgs.length, outputType, undefined, { typeAnnotation: 'omit' });
14478
+ const parsed = context.parse(arg, 1 + parsedArgs.length, outputType, void 0, { typeAnnotation: 'omit' });
14407
14479
  if (!parsed)
14408
14480
  return null;
14409
14481
  outputType = outputType || parsed.type;
14410
14482
  parsedArgs.push(parsed);
14411
14483
  }
14412
- // Above, we parse arguments without inferred type annotation so that
14413
- // they don't produce a runtime error for `null` input, which would
14414
- // preempt the desired null-coalescing behavior.
14415
- // Thus, if any of our arguments would have needed an annotation, we
14416
- // need to wrap the enclosing coalesce expression with it instead.
14417
14484
  const needsAnnotation = expectedType && parsedArgs.some(arg => checkSubtype(expectedType, arg.type));
14418
14485
  return needsAnnotation ? new Coalesce(ValueType, parsedArgs) : new Coalesce(outputType, parsedArgs);
14419
14486
  }
@@ -14424,15 +14491,11 @@ class Coalesce {
14424
14491
  for (const arg of this.args) {
14425
14492
  argCount++;
14426
14493
  result = arg.evaluate(ctx);
14427
- // we need to keep track of the first requested image in a coalesce statement
14428
- // if coalesce can't find a valid image, we return the first image so styleimagemissing can fire
14429
14494
  if (result && result instanceof ResolvedImage && !result.available) {
14430
- // set to first image
14431
14495
  if (!firstImage) {
14432
14496
  firstImage = result;
14433
14497
  }
14434
14498
  result = null;
14435
- // if we reach the end, return the first image
14436
14499
  if (argCount === this.args.length) {
14437
14500
  return firstImage;
14438
14501
  }
@@ -14457,7 +14520,6 @@ class Coalesce {
14457
14520
  }
14458
14521
  }
14459
14522
 
14460
- //
14461
14523
  class Let {
14462
14524
  constructor(bindings, result) {
14463
14525
  this.type = result.type;
@@ -14511,7 +14573,6 @@ class Let {
14511
14573
  }
14512
14574
  }
14513
14575
 
14514
- //
14515
14576
  class At {
14516
14577
  constructor(type, index, input) {
14517
14578
  this.type = type;
@@ -14530,17 +14591,17 @@ class At {
14530
14591
  }
14531
14592
  evaluate(ctx) {
14532
14593
  const index = this.index.evaluate(ctx);
14533
- const array = this.input.evaluate(ctx);
14594
+ const array2 = this.input.evaluate(ctx);
14534
14595
  if (index < 0) {
14535
14596
  throw new RuntimeError(`Array index out of bounds: ${ index } < 0.`);
14536
14597
  }
14537
- if (index >= array.length) {
14538
- throw new RuntimeError(`Array index out of bounds: ${ index } > ${ array.length - 1 }.`);
14598
+ if (index >= array2.length) {
14599
+ throw new RuntimeError(`Array index out of bounds: ${ index } > ${ array2.length - 1 }.`);
14539
14600
  }
14540
14601
  if (index !== Math.floor(index)) {
14541
14602
  throw new RuntimeError(`Array index must be an integer, but found ${ index } instead.`);
14542
14603
  }
14543
- return array[index];
14604
+ return array2[index];
14544
14605
  }
14545
14606
  eachChild(fn) {
14546
14607
  fn(this.index);
@@ -14558,7 +14619,6 @@ class At {
14558
14619
  }
14559
14620
  }
14560
14621
 
14561
- //
14562
14622
  class In {
14563
14623
  constructor(needle, haystack) {
14564
14624
  this.type = BooleanType;
@@ -14621,7 +14681,6 @@ class In {
14621
14681
  }
14622
14682
  }
14623
14683
 
14624
- //
14625
14684
  class IndexOf {
14626
14685
  constructor(needle, haystack, fromIndex) {
14627
14686
  this.type = NumberType;
@@ -14689,7 +14748,7 @@ class IndexOf {
14689
14748
  return false;
14690
14749
  }
14691
14750
  serialize() {
14692
- if (this.fromIndex != null && this.fromIndex !== undefined) {
14751
+ if (this.fromIndex != null && this.fromIndex !== void 0) {
14693
14752
  const fromIndex = this.fromIndex.serialize();
14694
14753
  return [
14695
14754
  'index-of',
@@ -14706,7 +14765,6 @@ class IndexOf {
14706
14765
  }
14707
14766
  }
14708
14767
 
14709
- // Map input label values to output expression index
14710
14768
  class Match {
14711
14769
  constructor(inputType, outputType, input, cases, outputs, otherwise) {
14712
14770
  this.inputType = inputType;
@@ -14790,35 +14848,26 @@ class Match {
14790
14848
  'match',
14791
14849
  this.input.serialize()
14792
14850
  ];
14793
- // Sort so serialization has an arbitrary defined order, even though
14794
- // branch order doesn't affect evaluation
14795
14851
  const sortedLabels = Object.keys(this.cases).sort();
14796
- // Group branches by unique match expression to support condensed
14797
- // serializations of the form [case1, case2, ...] -> matchExpression
14798
14852
  const groupedByOutput = [];
14799
14853
  const outputLookup = {};
14800
- // lookup index into groupedByOutput for a given output expression
14801
14854
  for (const label of sortedLabels) {
14802
14855
  const outputIndex = outputLookup[this.cases[label]];
14803
- if (outputIndex === undefined) {
14804
- // First time seeing this output, add it to the end of the grouped list
14856
+ if (outputIndex === void 0) {
14805
14857
  outputLookup[this.cases[label]] = groupedByOutput.length;
14806
14858
  groupedByOutput.push([
14807
14859
  this.cases[label],
14808
14860
  [label]
14809
14861
  ]);
14810
14862
  } else {
14811
- // We've seen this expression before, add the label to that output's group
14812
14863
  groupedByOutput[outputIndex][1].push(label);
14813
14864
  }
14814
14865
  }
14815
14866
  const coerceLabel = label => this.inputType.kind === 'number' ? Number(label) : label;
14816
14867
  for (const [outputIndex, labels] of groupedByOutput) {
14817
14868
  if (labels.length === 1) {
14818
- // Only a single label matches this output expression
14819
14869
  serialized.push(coerceLabel(labels[0]));
14820
14870
  } else {
14821
- // Array of literal labels pointing to this output expression
14822
14871
  serialized.push(labels.map(coerceLabel));
14823
14872
  }
14824
14873
  serialized.push(this.outputs[outputIndex].serialize());
@@ -14889,7 +14938,6 @@ class Case {
14889
14938
  }
14890
14939
  }
14891
14940
 
14892
- //
14893
14941
  class Slice {
14894
14942
  constructor(type, input, beginIndex, endIndex) {
14895
14943
  this.type = type;
@@ -14947,7 +14995,7 @@ class Slice {
14947
14995
  return false;
14948
14996
  }
14949
14997
  serialize() {
14950
- if (this.endIndex != null && this.endIndex !== undefined) {
14998
+ if (this.endIndex != null && this.endIndex !== void 0) {
14951
14999
  const endIndex = this.endIndex.serialize();
14952
15000
  return [
14953
15001
  'slice',
@@ -14964,13 +15012,10 @@ class Slice {
14964
15012
  }
14965
15013
  }
14966
15014
 
14967
- //
14968
15015
  function isComparableType(op, type) {
14969
15016
  if (op === '==' || op === '!=') {
14970
- // equality operator
14971
15017
  return type.kind === 'boolean' || type.kind === 'string' || type.kind === 'number' || type.kind === 'null' || type.kind === 'value';
14972
15018
  } else {
14973
- // ordering operator
14974
15019
  return type.kind === 'string' || type.kind === 'number' || type.kind === 'value';
14975
15020
  }
14976
15021
  }
@@ -15010,26 +15055,8 @@ function lteqCollate(ctx, a, b, c) {
15010
15055
  function gteqCollate(ctx, a, b, c) {
15011
15056
  return c.compare(a, b) >= 0;
15012
15057
  }
15013
- /**
15014
- * Special form for comparison operators, implementing the signatures:
15015
- * - (T, T, ?Collator) => boolean
15016
- * - (T, value, ?Collator) => boolean
15017
- * - (value, T, ?Collator) => boolean
15018
- *
15019
- * For inequalities, T must be either value, string, or number. For ==/!=, it
15020
- * can also be boolean or null.
15021
- *
15022
- * Equality semantics are equivalent to Javascript's strict equality (===/!==)
15023
- * -- i.e., when the arguments' types don't match, == evaluates to false, != to
15024
- * true.
15025
- *
15026
- * When types don't match in an ordering comparison, a runtime error is thrown.
15027
- *
15028
- * @private
15029
- */
15030
15058
  function makeComparison(op, compareBasic, compareWithCollator) {
15031
15059
  const isOrderComparison = op !== '==' && op !== '!=';
15032
- // $FlowFixMe[method-unbinding]
15033
15060
  return class Comparison {
15034
15061
  constructor(lhs, rhs, collator) {
15035
15062
  this.type = BooleanType;
@@ -15038,33 +15065,29 @@ function makeComparison(op, compareBasic, compareWithCollator) {
15038
15065
  this.collator = collator;
15039
15066
  this.hasUntypedArgument = lhs.type.kind === 'value' || rhs.type.kind === 'value';
15040
15067
  }
15041
- // $FlowFixMe[method-unbinding]
15042
15068
  static parse(args, context) {
15043
15069
  if (args.length !== 3 && args.length !== 4)
15044
15070
  return context.error(`Expected two or three arguments.`);
15045
- const op = args[0];
15071
+ const op2 = args[0];
15046
15072
  let lhs = context.parse(args[1], 1, ValueType);
15047
15073
  if (!lhs)
15048
15074
  return null;
15049
- if (!isComparableType(op, lhs.type)) {
15050
- return context.concat(1).error(`"${ op }" comparisons are not supported for type '${ toString$1(lhs.type) }'.`);
15075
+ if (!isComparableType(op2, lhs.type)) {
15076
+ return context.concat(1).error(`"${ op2 }" comparisons are not supported for type '${ toString$1(lhs.type) }'.`);
15051
15077
  }
15052
15078
  let rhs = context.parse(args[2], 2, ValueType);
15053
15079
  if (!rhs)
15054
15080
  return null;
15055
- if (!isComparableType(op, rhs.type)) {
15056
- return context.concat(2).error(`"${ op }" comparisons are not supported for type '${ toString$1(rhs.type) }'.`);
15081
+ if (!isComparableType(op2, rhs.type)) {
15082
+ return context.concat(2).error(`"${ op2 }" comparisons are not supported for type '${ toString$1(rhs.type) }'.`);
15057
15083
  }
15058
15084
  if (lhs.type.kind !== rhs.type.kind && lhs.type.kind !== 'value' && rhs.type.kind !== 'value') {
15059
15085
  return context.error(`Cannot compare types '${ toString$1(lhs.type) }' and '${ toString$1(rhs.type) }'.`);
15060
15086
  }
15061
15087
  if (isOrderComparison) {
15062
- // typing rules specific to less/greater than operators
15063
15088
  if (lhs.type.kind === 'value' && rhs.type.kind !== 'value') {
15064
- // (value, T)
15065
15089
  lhs = new Assertion(rhs.type, [lhs]);
15066
15090
  } else if (lhs.type.kind !== 'value' && rhs.type.kind === 'value') {
15067
- // (T, value)
15068
15091
  rhs = new Assertion(lhs.type, [rhs]);
15069
15092
  }
15070
15093
  }
@@ -15083,17 +15106,16 @@ function makeComparison(op, compareBasic, compareWithCollator) {
15083
15106
  const lhs = this.lhs.evaluate(ctx);
15084
15107
  const rhs = this.rhs.evaluate(ctx);
15085
15108
  if (isOrderComparison && this.hasUntypedArgument) {
15086
- const lt = typeOf(lhs);
15109
+ const lt2 = typeOf(lhs);
15087
15110
  const rt = typeOf(rhs);
15088
- // check that type is string or number, and equal
15089
- if (lt.kind !== rt.kind || !(lt.kind === 'string' || lt.kind === 'number')) {
15090
- throw new RuntimeError(`Expected arguments for "${ op }" to be (string, string) or (number, number), but found (${ lt.kind }, ${ rt.kind }) instead.`);
15111
+ if (lt2.kind !== rt.kind || !(lt2.kind === 'string' || lt2.kind === 'number')) {
15112
+ throw new RuntimeError(`Expected arguments for "${ op }" to be (string, string) or (number, number), but found (${ lt2.kind }, ${ rt.kind }) instead.`);
15091
15113
  }
15092
15114
  }
15093
15115
  if (this.collator && !isOrderComparison && this.hasUntypedArgument) {
15094
- const lt = typeOf(lhs);
15116
+ const lt2 = typeOf(lhs);
15095
15117
  const rt = typeOf(rhs);
15096
- if (lt.kind !== 'string' || rt.kind !== 'string') {
15118
+ if (lt2.kind !== 'string' || rt.kind !== 'string') {
15097
15119
  return compareBasic(ctx, lhs, rhs);
15098
15120
  }
15099
15121
  }
@@ -15125,12 +15147,7 @@ const GreaterThan = makeComparison('>', gt, gtCollate);
15125
15147
  const LessThanOrEqual = makeComparison('<=', lteq, lteqCollate);
15126
15148
  const GreaterThanOrEqual = makeComparison('>=', gteq, gteqCollate);
15127
15149
 
15128
- //
15129
15150
  class NumberFormat {
15130
- // BCP 47 language tag
15131
- // ISO 4217 currency code, required if style=currency
15132
- // Simple units sanctioned for use in ECMAScript, required if style=unit. https://tc39.es/proposal-unified-intl-numberformat/section6/locales-currencies-tz_proposed_out.html#sec-issanctionedsimpleunitidentifier
15133
- // Default 0
15134
15151
  // Default 3
15135
15152
  constructor(number, locale, currency, unit, minFractionDigits, maxFractionDigits) {
15136
15153
  this.type = StringType;
@@ -15185,10 +15202,10 @@ class NumberFormat {
15185
15202
  evaluate(ctx) {
15186
15203
  return new Intl.NumberFormat(this.locale ? this.locale.evaluate(ctx) : [], {
15187
15204
  style: this.currency && 'currency' || this.unit && 'unit' || 'decimal',
15188
- currency: this.currency ? this.currency.evaluate(ctx) : undefined,
15189
- unit: this.unit ? this.unit.evaluate(ctx) : undefined,
15190
- minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) : undefined,
15191
- maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) : undefined
15205
+ currency: this.currency ? this.currency.evaluate(ctx) : void 0,
15206
+ unit: this.unit ? this.unit.evaluate(ctx) : void 0,
15207
+ minimumFractionDigits: this.minFractionDigits ? this.minFractionDigits.evaluate(ctx) : void 0,
15208
+ maximumFractionDigits: this.maxFractionDigits ? this.maxFractionDigits.evaluate(ctx) : void 0
15192
15209
  }).format(this.number.evaluate(ctx));
15193
15210
  }
15194
15211
  eachChild(fn) {
@@ -15237,7 +15254,6 @@ class NumberFormat {
15237
15254
  }
15238
15255
  }
15239
15256
 
15240
- //
15241
15257
  class Length {
15242
15258
  constructor(input) {
15243
15259
  this.type = NumberType;
@@ -15278,8 +15294,6 @@ class Length {
15278
15294
  }
15279
15295
  }
15280
15296
 
15281
- //
15282
- // Seeded pseudo random generator function
15283
15297
  function mulberry32(a) {
15284
15298
  return function () {
15285
15299
  a |= 0;
@@ -15290,7 +15304,6 @@ function mulberry32(a) {
15290
15304
  };
15291
15305
  }
15292
15306
 
15293
- //
15294
15307
  const expressions = {
15295
15308
  // special forms
15296
15309
  '==': Equals,
@@ -15299,58 +15312,36 @@ const expressions = {
15299
15312
  '<': LessThan,
15300
15313
  '>=': GreaterThanOrEqual,
15301
15314
  '<=': LessThanOrEqual,
15302
- // $FlowFixMe[method-unbinding]
15303
15315
  'array': Assertion,
15304
- // $FlowFixMe[method-unbinding]
15305
15316
  'at': At,
15306
15317
  'boolean': Assertion,
15307
- // $FlowFixMe[method-unbinding]
15308
15318
  'case': Case,
15309
- // $FlowFixMe[method-unbinding]
15310
15319
  'coalesce': Coalesce,
15311
- // $FlowFixMe[method-unbinding]
15312
15320
  'collator': CollatorExpression,
15313
- // $FlowFixMe[method-unbinding]
15314
15321
  'format': FormatExpression,
15315
- // $FlowFixMe[method-unbinding]
15316
15322
  'image': ImageExpression,
15317
- // $FlowFixMe[method-unbinding]
15318
15323
  'in': In,
15319
- // $FlowFixMe[method-unbinding]
15320
15324
  'index-of': IndexOf,
15321
- // $FlowFixMe[method-unbinding]
15322
15325
  'interpolate': Interpolate,
15323
15326
  'interpolate-hcl': Interpolate,
15324
15327
  'interpolate-lab': Interpolate,
15325
- // $FlowFixMe[method-unbinding]
15326
15328
  'length': Length,
15327
- // $FlowFixMe[method-unbinding]
15328
15329
  'let': Let,
15329
- // $FlowFixMe[method-unbinding]
15330
15330
  'literal': Literal,
15331
- // $FlowFixMe[method-unbinding]
15332
15331
  'match': Match,
15333
15332
  'number': Assertion,
15334
- // $FlowFixMe[method-unbinding]
15335
15333
  'number-format': NumberFormat,
15336
15334
  'object': Assertion,
15337
- // $FlowFixMe[method-unbinding]
15338
15335
  'slice': Slice,
15339
- // $FlowFixMe[method-unbinding]
15340
15336
  'step': Step,
15341
15337
  'string': Assertion,
15342
- // $FlowFixMe[method-unbinding]
15343
15338
  'to-boolean': Coercion,
15344
15339
  'to-color': Coercion,
15345
15340
  'to-number': Coercion,
15346
15341
  'to-string': Coercion,
15347
- // $FlowFixMe[method-unbinding]
15348
15342
  'var': Var,
15349
- // $FlowFixMe[method-unbinding]
15350
15343
  'within': Within,
15351
- // $FlowFixMe[method-unbinding]
15352
15344
  'distance': Distance,
15353
- // $FlowFixMe[method-unbinding]
15354
15345
  'config': Config
15355
15346
  };
15356
15347
  function rgba(ctx, [r, g, b, a]) {
@@ -15361,7 +15352,7 @@ function rgba(ctx, [r, g, b, a]) {
15361
15352
  const error = validateRGBA(r, g, b, alpha);
15362
15353
  if (error)
15363
15354
  throw new RuntimeError(error);
15364
- return new Color$1(r / 255 * alpha, g / 255 * alpha, b / 255 * alpha, alpha);
15355
+ return new Color(r / 255 * alpha, g / 255 * alpha, b / 255 * alpha, alpha);
15365
15356
  }
15366
15357
  function hsla(ctx, [h, s, l, a]) {
15367
15358
  h = h.evaluate(ctx);
@@ -15372,7 +15363,7 @@ function hsla(ctx, [h, s, l, a]) {
15372
15363
  if (error)
15373
15364
  throw new RuntimeError(error);
15374
15365
  const colorFunction = `hsla(${ h }, ${ s }%, ${ l }%, ${ alpha })`;
15375
- const color = Color$1.parse(colorFunction);
15366
+ const color = Color.parse(colorFunction);
15376
15367
  if (!color)
15377
15368
  throw new RuntimeError(`Failed to parse HSLA color: ${ colorFunction }`);
15378
15369
  return color;
@@ -15428,7 +15419,7 @@ CompoundExpression.register(expressions, {
15428
15419
  array$1(NumberType, 4),
15429
15420
  [ColorType],
15430
15421
  (ctx, [v]) => {
15431
- return v.evaluate(ctx).toArray();
15422
+ return v.evaluate(ctx).toRenderColor(null).toArray();
15432
15423
  }
15433
15424
  ],
15434
15425
  'rgb': [
@@ -15569,7 +15560,7 @@ CompoundExpression.register(expressions, {
15569
15560
  'accumulated': [
15570
15561
  ValueType,
15571
15562
  [],
15572
- ctx => ctx.globals.accumulated === undefined ? null : ctx.globals.accumulated
15563
+ ctx => ctx.globals.accumulated === void 0 ? null : ctx.globals.accumulated
15573
15564
  ],
15574
15565
  '+': [
15575
15566
  NumberType,
@@ -15718,9 +15709,6 @@ CompoundExpression.register(expressions, {
15718
15709
  [NumberType],
15719
15710
  (ctx, [n]) => {
15720
15711
  const v = n.evaluate(ctx);
15721
- // Javascript's Math.round() rounds towards +Infinity for halfway
15722
- // values, even when they're negative. It's more common to round
15723
- // away from 0 (e.g., this is what python and C++ do)
15724
15712
  return v < 0 ? -Math.round(-v) : Math.round(v);
15725
15713
  }
15726
15714
  ],
@@ -15844,7 +15832,7 @@ CompoundExpression.register(expressions, {
15844
15832
  'filter-has-id': [
15845
15833
  BooleanType,
15846
15834
  [],
15847
- ctx => ctx.id() !== null && ctx.id() !== undefined
15835
+ ctx => ctx.id() !== null && ctx.id() !== void 0
15848
15836
  ],
15849
15837
  'filter-type-in': [
15850
15838
  BooleanType,
@@ -15984,13 +15972,6 @@ CompoundExpression.register(expressions, {
15984
15972
  ]
15985
15973
  });
15986
15974
 
15987
- //
15988
- /**
15989
- * A type used for returning and propagating errors. The first element of the union
15990
- * represents success and contains a value, and the second represents an error and
15991
- * contains an error value.
15992
- * @private
15993
- */
15994
15975
  function success(value) {
15995
15976
  return {
15996
15977
  result: 'success',
@@ -16004,7 +15985,6 @@ function error(value) {
16004
15985
  };
16005
15986
  }
16006
15987
 
16007
- //
16008
15988
  function expressionHasParameter(expression, parameter) {
16009
15989
  return !!expression && !!expression.parameters && expression.parameters.indexOf(parameter) > -1;
16010
15990
  }
@@ -16021,7 +16001,6 @@ function supportsInterpolation(spec) {
16021
16001
  return !!spec.expression && spec.expression.interpolated;
16022
16002
  }
16023
16003
 
16024
- //
16025
16004
  function isFunction(value) {
16026
16005
  return typeof value === 'object' && value !== null && !Array.isArray(value);
16027
16006
  }
@@ -16031,7 +16010,7 @@ function identityFunction(x) {
16031
16010
  function createFunction(parameters, propertySpec) {
16032
16011
  const isColor = propertySpec.type === 'color';
16033
16012
  const zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === 'object';
16034
- const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;
16013
+ const featureDependent = zoomAndFeatureDependent || parameters.property !== void 0;
16035
16014
  const zoomDependent = zoomAndFeatureDependent || !featureDependent;
16036
16015
  const type = parameters.type || (supportsInterpolation(propertySpec) ? 'exponential' : 'interval');
16037
16016
  if (isColor) {
@@ -16040,18 +16019,17 @@ function createFunction(parameters, propertySpec) {
16040
16019
  parameters.stops = parameters.stops.map(stop => {
16041
16020
  return [
16042
16021
  stop[0],
16043
- Color$1.parse(stop[1])
16022
+ Color.parse(stop[1])
16044
16023
  ];
16045
16024
  });
16046
16025
  }
16047
16026
  if (parameters.default) {
16048
- parameters.default = Color$1.parse(parameters.default);
16027
+ parameters.default = Color.parse(parameters.default);
16049
16028
  } else {
16050
- parameters.default = Color$1.parse(propertySpec.default);
16029
+ parameters.default = Color.parse(propertySpec.default);
16051
16030
  }
16052
16031
  }
16053
16032
  if (parameters.colorSpace && parameters.colorSpace !== 'rgb' && !colorSpaces[parameters.colorSpace]) {
16054
- // eslint-disable-line import/namespace
16055
16033
  throw new Error(`Unknown color space: ${ parameters.colorSpace }`);
16056
16034
  }
16057
16035
  let innerFun;
@@ -16063,12 +16041,11 @@ function createFunction(parameters, propertySpec) {
16063
16041
  innerFun = evaluateIntervalFunction;
16064
16042
  } else if (type === 'categorical') {
16065
16043
  innerFun = evaluateCategoricalFunction;
16066
- // For categorical functions, generate an Object as a hashmap of the stops for fast searching
16067
- hashedStops = Object.create(null);
16044
+ hashedStops = /* @__PURE__ */
16045
+ Object.create(null);
16068
16046
  for (const stop of parameters.stops) {
16069
16047
  hashedStops[stop[0]] = stop[1];
16070
16048
  }
16071
- // Infer key type based on first stop key-- used to encforce strict type checking later
16072
16049
  categoricalKeyType = typeof parameters.stops[0][0];
16073
16050
  } else if (type === 'identity') {
16074
16051
  innerFun = evaluateIdentityFunction;
@@ -16081,7 +16058,7 @@ function createFunction(parameters, propertySpec) {
16081
16058
  for (let s = 0; s < parameters.stops.length; s++) {
16082
16059
  const stop = parameters.stops[s];
16083
16060
  const zoom = stop[0].zoom;
16084
- if (featureFunctions[zoom] === undefined) {
16061
+ if (featureFunctions[zoom] === void 0) {
16085
16062
  featureFunctions[zoom] = {
16086
16063
  zoom,
16087
16064
  type: parameters.type,
@@ -16107,7 +16084,7 @@ function createFunction(parameters, propertySpec) {
16107
16084
  return {
16108
16085
  kind: 'composite',
16109
16086
  interpolationType,
16110
- interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),
16087
+ interpolationFactor: Interpolate.interpolationFactor.bind(void 0, interpolationType),
16111
16088
  zoomStops: featureFunctionStops.map(s => s[0]),
16112
16089
  evaluate({zoom}, properties) {
16113
16090
  return evaluateExponentialFunction({
@@ -16119,12 +16096,12 @@ function createFunction(parameters, propertySpec) {
16119
16096
  } else if (zoomDependent) {
16120
16097
  const interpolationType = type === 'exponential' ? {
16121
16098
  name: 'exponential',
16122
- base: parameters.base !== undefined ? parameters.base : 1
16099
+ base: parameters.base !== void 0 ? parameters.base : 1
16123
16100
  } : null;
16124
16101
  return {
16125
16102
  kind: 'camera',
16126
16103
  interpolationType,
16127
- interpolationFactor: Interpolate.interpolationFactor.bind(undefined, interpolationType),
16104
+ interpolationFactor: Interpolate.interpolationFactor.bind(void 0, interpolationType),
16128
16105
  zoomStops: parameters.stops.map(s => s[0]),
16129
16106
  evaluate: ({zoom}) => innerFun(parameters, propertySpec, zoom, hashedStops, categoricalKeyType)
16130
16107
  };
@@ -16132,8 +16109,8 @@ function createFunction(parameters, propertySpec) {
16132
16109
  return {
16133
16110
  kind: 'source',
16134
16111
  evaluate(_, feature) {
16135
- const value = feature && feature.properties ? feature.properties[parameters.property] : undefined;
16136
- if (value === undefined) {
16112
+ const value = feature && feature.properties ? feature.properties[parameters.property] : void 0;
16113
+ if (value === void 0) {
16137
16114
  return coalesce$1(parameters.default, propertySpec.default);
16138
16115
  }
16139
16116
  return innerFun(parameters, propertySpec, value, hashedStops, categoricalKeyType);
@@ -16142,20 +16119,18 @@ function createFunction(parameters, propertySpec) {
16142
16119
  }
16143
16120
  }
16144
16121
  function coalesce$1(a, b, c) {
16145
- if (a !== undefined)
16122
+ if (a !== void 0)
16146
16123
  return a;
16147
- if (b !== undefined)
16124
+ if (b !== void 0)
16148
16125
  return b;
16149
- if (c !== undefined)
16126
+ if (c !== void 0)
16150
16127
  return c;
16151
16128
  }
16152
16129
  function evaluateCategoricalFunction(parameters, propertySpec, input, hashedStops, keyType) {
16153
- const evaluated = typeof input === keyType ? hashedStops[input] : undefined;
16154
- // Enforce strict typing on input
16130
+ const evaluated = typeof input === keyType ? hashedStops[input] : void 0;
16155
16131
  return coalesce$1(evaluated, parameters.default, propertySpec.default);
16156
16132
  }
16157
16133
  function evaluateIntervalFunction(parameters, propertySpec, input) {
16158
- // Edge cases
16159
16134
  if (getType(input) !== 'number')
16160
16135
  return coalesce$1(parameters.default, propertySpec.default);
16161
16136
  const n = parameters.stops.length;
@@ -16169,8 +16144,7 @@ function evaluateIntervalFunction(parameters, propertySpec, input) {
16169
16144
  return parameters.stops[index][1];
16170
16145
  }
16171
16146
  function evaluateExponentialFunction(parameters, propertySpec, input) {
16172
- const base = parameters.base !== undefined ? parameters.base : 1;
16173
- // Edge cases
16147
+ const base = parameters.base !== void 0 ? parameters.base : 1;
16174
16148
  if (getType(input) !== 'number')
16175
16149
  return coalesce$1(parameters.default, propertySpec.default);
16176
16150
  const n = parameters.stops.length;
@@ -16184,21 +16158,18 @@ function evaluateExponentialFunction(parameters, propertySpec, input) {
16184
16158
  const t = interpolationFactor(input, base, parameters.stops[index][0], parameters.stops[index + 1][0]);
16185
16159
  const outputLower = parameters.stops[index][1];
16186
16160
  const outputUpper = parameters.stops[index + 1][1];
16187
- let interp = interpolate[propertySpec.type] || identityFunction;
16188
- // eslint-disable-line import/namespace
16161
+ let interp = interpolate$1[propertySpec.type] || identityFunction;
16189
16162
  if (parameters.colorSpace && parameters.colorSpace !== 'rgb') {
16190
16163
  const colorspace = colorSpaces[parameters.colorSpace];
16191
- // eslint-disable-line import/namespace
16192
16164
  interp = (a, b) => colorspace.reverse(colorspace.interpolate(colorspace.forward(a), colorspace.forward(b), t));
16193
16165
  }
16194
16166
  if (typeof outputLower.evaluate === 'function') {
16195
16167
  return {
16196
16168
  evaluate(...args) {
16197
- const evaluatedLower = outputLower.evaluate.apply(undefined, args);
16198
- const evaluatedUpper = outputUpper.evaluate.apply(undefined, args);
16199
- // Special case for fill-outline-color, which has no spec default.
16200
- if (evaluatedLower === undefined || evaluatedUpper === undefined) {
16201
- return undefined;
16169
+ const evaluatedLower = outputLower.evaluate.apply(void 0, args);
16170
+ const evaluatedUpper = outputUpper.evaluate.apply(void 0, args);
16171
+ if (evaluatedLower === void 0 || evaluatedUpper === void 0) {
16172
+ return void 0;
16202
16173
  }
16203
16174
  return interp(evaluatedLower, evaluatedUpper, t);
16204
16175
  }
@@ -16208,54 +16179,16 @@ function evaluateExponentialFunction(parameters, propertySpec, input) {
16208
16179
  }
16209
16180
  function evaluateIdentityFunction(parameters, propertySpec, input) {
16210
16181
  if (propertySpec.type === 'color') {
16211
- input = Color$1.parse(input);
16182
+ input = Color.parse(input);
16212
16183
  } else if (propertySpec.type === 'formatted') {
16213
16184
  input = Formatted.fromString(input.toString());
16214
16185
  } else if (propertySpec.type === 'resolvedImage') {
16215
16186
  input = ResolvedImage.fromString(input.toString());
16216
16187
  } else if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values[input])) {
16217
- input = undefined;
16188
+ input = void 0;
16218
16189
  }
16219
16190
  return coalesce$1(input, parameters.default, propertySpec.default);
16220
16191
  }
16221
- /**
16222
- * Returns a ratio that can be used to interpolate between exponential function
16223
- * stops.
16224
- *
16225
- * How it works:
16226
- * Two consecutive stop values define a (scaled and shifted) exponential
16227
- * function `f(x) = a * base^x + b`, where `base` is the user-specified base,
16228
- * and `a` and `b` are constants affording sufficient degrees of freedom to fit
16229
- * the function to the given stops.
16230
- *
16231
- * Here's a bit of algebra that lets us compute `f(x)` directly from the stop
16232
- * values without explicitly solving for `a` and `b`:
16233
- *
16234
- * First stop value: `f(x0) = y0 = a * base^x0 + b`
16235
- * Second stop value: `f(x1) = y1 = a * base^x1 + b`
16236
- * => `y1 - y0 = a(base^x1 - base^x0)`
16237
- * => `a = (y1 - y0)/(base^x1 - base^x0)`
16238
- *
16239
- * Desired value: `f(x) = y = a * base^x + b`
16240
- * => `f(x) = y0 + a * (base^x - base^x0)`
16241
- *
16242
- * From the above, we can replace the `a` in `a * (base^x - base^x0)` and do a
16243
- * little algebra:
16244
- * ```
16245
- * a * (base^x - base^x0) = (y1 - y0)/(base^x1 - base^x0) * (base^x - base^x0)
16246
- * = (y1 - y0) * (base^x - base^x0) / (base^x1 - base^x0)
16247
- * ```
16248
- *
16249
- * If we let `(base^x - base^x0) / (base^x1 base^x0)`, then we have
16250
- * `f(x) = y0 + (y1 - y0) * ratio`. In other words, `ratio` may be treated as
16251
- * an interpolation factor between the two stops' output values.
16252
- *
16253
- * (Note: a slightly different form for `ratio`,
16254
- * `(base^(x-x0) - 1) / (base^(x1-x0) - 1) `, is equivalent, but requires fewer
16255
- * expensive `Math.pow()` operations.)
16256
- *
16257
- * @private
16258
- */
16259
16192
  function interpolationFactor(input, base, lowerValue, upperValue) {
16260
16193
  const difference = upperValue - lowerValue;
16261
16194
  const progress = input - lowerValue;
@@ -16298,8 +16231,7 @@ class StyleExpression {
16298
16231
  this._evaluator.featureDistanceData = featureDistanceData || null;
16299
16232
  try {
16300
16233
  const val = this.expression.evaluate(this._evaluator);
16301
- // eslint-disable-next-line no-self-compare
16302
- if (val === null || val === undefined || typeof val === 'number' && val !== val) {
16234
+ if (val === null || val === void 0 || typeof val === 'number' && val !== val) {
16303
16235
  return this._defaultValue;
16304
16236
  }
16305
16237
  if (this._enumValues && !(val in this._enumValues)) {
@@ -16320,19 +16252,9 @@ class StyleExpression {
16320
16252
  function isExpression(expression) {
16321
16253
  return Array.isArray(expression) && expression.length > 0 && typeof expression[0] === 'string' && expression[0] in expressions;
16322
16254
  }
16323
- /**
16324
- * Parse and typecheck the given style spec JSON expression. If
16325
- * options.defaultValue is provided, then the resulting StyleExpression's
16326
- * `evaluate()` method will handle errors by logging a warning (once per
16327
- * message) and returning the default value. Otherwise, it will throw
16328
- * evaluation errors.
16329
- *
16330
- * @private
16331
- */
16332
16255
  function createExpression(expression, propertySpec, scope, options) {
16333
- const parser = new ParsingContext(expressions, [], propertySpec ? getExpectedType(propertySpec) : undefined, undefined, undefined, scope, options);
16334
- // For string-valued properties, coerce to string at the top level rather than asserting.
16335
- const parsed = parser.parse(expression, undefined, undefined, undefined, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : undefined);
16256
+ const parser = new ParsingContext$1(expressions, [], propertySpec ? getExpectedType(propertySpec) : void 0, void 0, void 0, scope, options);
16257
+ const parsed = parser.parse(expression, void 0, void 0, void 0, propertySpec && propertySpec.type === 'string' ? { typeAnnotation: 'coerce' } : void 0);
16336
16258
  if (!parsed) {
16337
16259
  return error(parser.errors);
16338
16260
  }
@@ -16409,13 +16331,15 @@ function createPropertyExpression(expression, propertySpec, scope, options) {
16409
16331
  return error([new ParsingError$1('', '"interpolate" expressions cannot be used with this property')]);
16410
16332
  }
16411
16333
  if (!zoomCurve) {
16412
- return success(isFeatureConstant$1 ? new ZoomConstantExpression('constant', expression.value, isLightConstant) : new ZoomConstantExpression('source', expression.value, isLightConstant));
16334
+ return success(isFeatureConstant$1 ? // @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
16335
+ new ZoomConstantExpression('constant', expression.value, isLightConstant) : // @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
16336
+ new ZoomConstantExpression('source', expression.value, isLightConstant));
16413
16337
  }
16414
- const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : undefined;
16415
- return success(isFeatureConstant$1 ? new ZoomDependentExpression('camera', expression.value, zoomCurve.labels, interpolationType, isLightConstant) : new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType, isLightConstant));
16338
+ const interpolationType = zoomCurve instanceof Interpolate ? zoomCurve.interpolation : void 0;
16339
+ return success(isFeatureConstant$1 ? // @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
16340
+ new ZoomDependentExpression('camera', expression.value, zoomCurve.labels, interpolationType, isLightConstant) : // @ts-expect-error - TS2339 - Property 'value' does not exist on type 'unknown'.
16341
+ new ZoomDependentExpression('composite', expression.value, zoomCurve.labels, interpolationType, isLightConstant));
16416
16342
  }
16417
- // serialization wrapper for old-style stop functions normalized to the
16418
- // expression interface
16419
16343
  class StylePropertyFunction {
16420
16344
  constructor(parameters, specification) {
16421
16345
  this._parameters = parameters;
@@ -16438,14 +16362,13 @@ function normalizePropertyExpression(value, specification, scope, options) {
16438
16362
  } else if (isExpression(value) || Array.isArray(value) && value.length > 0) {
16439
16363
  const expression = createPropertyExpression(value, specification, scope, options);
16440
16364
  if (expression.result === 'error') {
16441
- // this should have been caught in validation
16442
16365
  throw new Error(expression.value.map(err => `${ err.key }: ${ err.message }`).join(', '));
16443
16366
  }
16444
16367
  return expression.value;
16445
16368
  } else {
16446
16369
  let constant = value;
16447
16370
  if (typeof value === 'string' && specification.type === 'color') {
16448
- constant = Color$1.parse(value);
16371
+ constant = Color.parse(value);
16449
16372
  }
16450
16373
  return {
16451
16374
  kind: 'constant',
@@ -16454,9 +16377,6 @@ function normalizePropertyExpression(value, specification, scope, options) {
16454
16377
  };
16455
16378
  }
16456
16379
  }
16457
- // Zoom-dependent expressions may only use ["zoom"] as the input to a top-level "step" or "interpolate"
16458
- // expression (collectively referred to as a "curve"). The curve may be wrapped in one or more "let" or
16459
- // "coalesce" expressions.
16460
16380
  function findZoomCurve(expression) {
16461
16381
  let result = null;
16462
16382
  if (expression instanceof Let) {
@@ -16501,13 +16421,10 @@ function getExpectedType(spec) {
16501
16421
  }
16502
16422
  function getDefaultValue(spec) {
16503
16423
  if (spec.type === 'color' && (isFunction(spec.default) || Array.isArray(spec.default))) {
16504
- // Special case for heatmap-color: it uses the 'default:' to define a
16505
- // default color ramp, but createExpression expects a simple value to fall
16506
- // back to in case of runtime errors
16507
- return new Color$1(0, 0, 0, 0);
16424
+ return new Color(0, 0, 0, 0);
16508
16425
  } else if (spec.type === 'color') {
16509
- return Color$1.parse(spec.default) || null;
16510
- } else if (spec.default === undefined) {
16426
+ return Color.parse(spec.default) || null;
16427
+ } else if (spec.default === void 0) {
16511
16428
  return null;
16512
16429
  } else {
16513
16430
  return spec.default;
@@ -16523,11 +16440,10 @@ function convertLiteral(value) {
16523
16440
  function convertFunction(parameters, propertySpec) {
16524
16441
  let stops = parameters.stops;
16525
16442
  if (!stops) {
16526
- // identity function
16527
16443
  return convertIdentityFunction(parameters, propertySpec);
16528
16444
  }
16529
16445
  const zoomAndFeatureDependent = stops && typeof stops[0][0] === 'object';
16530
- const featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;
16446
+ const featureDependent = zoomAndFeatureDependent || parameters.property !== void 0;
16531
16447
  const zoomDependent = zoomAndFeatureDependent || !featureDependent;
16532
16448
  stops = stops.map(stop => {
16533
16449
  if (!featureDependent && propertySpec.tokens && typeof stop[1] === 'string') {
@@ -16554,9 +16470,7 @@ function convertIdentityFunction(parameters, propertySpec) {
16554
16470
  'get',
16555
16471
  parameters.property
16556
16472
  ];
16557
- if (parameters.default === undefined) {
16558
- // By default, expressions for string-valued properties get coerced. To preserve
16559
- // legacy function semantics, insert an explicit assertion instead.
16473
+ if (parameters.default === void 0) {
16560
16474
  return propertySpec.type === 'string' ? [
16561
16475
  'string',
16562
16476
  get
@@ -16598,7 +16512,7 @@ function convertZoomAndPropertyFunction(parameters, propertySpec, stops) {
16598
16512
  for (let s = 0; s < stops.length; s++) {
16599
16513
  const stop = stops[s];
16600
16514
  const zoom = stop[0].zoom;
16601
- if (featureFunctionParameters[zoom] === undefined) {
16515
+ if (featureFunctionParameters[zoom] === void 0) {
16602
16516
  featureFunctionParameters[zoom] = {
16603
16517
  zoom,
16604
16518
  type: parameters.type,
@@ -16613,10 +16527,6 @@ function convertZoomAndPropertyFunction(parameters, propertySpec, stops) {
16613
16527
  stop[1]
16614
16528
  ]);
16615
16529
  }
16616
- // the interpolation type for the zoom dimension of a zoom-and-property
16617
- // function is determined directly from the style property specification
16618
- // for which it's being used: linear for interpolatable properties, step
16619
- // otherwise.
16620
16530
  const functionType = getFunctionType({}, propertySpec);
16621
16531
  if (functionType === 'exponential') {
16622
16532
  const expression = [
@@ -16643,20 +16553,14 @@ function convertZoomAndPropertyFunction(parameters, propertySpec, stops) {
16643
16553
  }
16644
16554
  }
16645
16555
  function coalesce(a, b) {
16646
- if (a !== undefined)
16556
+ if (a !== void 0)
16647
16557
  return a;
16648
- if (b !== undefined)
16558
+ if (b !== void 0)
16649
16559
  return b;
16650
16560
  }
16651
16561
  function getFallback(parameters, propertySpec) {
16652
16562
  const defaultValue = convertLiteral(coalesce(parameters.default, propertySpec.default));
16653
- /*
16654
- * Some fields with type: resolvedImage have an undefined default.
16655
- * Because undefined is an invalid value for resolvedImage, set fallback to
16656
- * an empty string instead of undefined to ensure output
16657
- * passes validation.
16658
- */
16659
- if (defaultValue === undefined && propertySpec.type === 'resolvedImage') {
16563
+ if (defaultValue === void 0 && propertySpec.type === 'resolvedImage') {
16660
16564
  return '';
16661
16565
  }
16662
16566
  return defaultValue;
@@ -16700,7 +16604,7 @@ function convertPropertyFunction(parameters, propertySpec, stops) {
16700
16604
  appendStopPair(expression, stop[0], stop[1], true);
16701
16605
  }
16702
16606
  fixupDegenerateStepCurve(expression);
16703
- return parameters.default === undefined ? expression : [
16607
+ return parameters.default === void 0 ? expression : [
16704
16608
  'case',
16705
16609
  [
16706
16610
  '==',
@@ -16714,7 +16618,7 @@ function convertPropertyFunction(parameters, propertySpec, stops) {
16714
16618
  convertLiteral(parameters.default)
16715
16619
  ];
16716
16620
  } else if (type === 'exponential') {
16717
- const base = parameters.base !== undefined ? parameters.base : 1;
16621
+ const base = parameters.base !== void 0 ? parameters.base : 1;
16718
16622
  const expression = [
16719
16623
  getInterpolateOperator(parameters),
16720
16624
  base === 1 ? ['linear'] : [
@@ -16729,7 +16633,7 @@ function convertPropertyFunction(parameters, propertySpec, stops) {
16729
16633
  for (const stop of stops) {
16730
16634
  appendStopPair(expression, stop[0], stop[1], false);
16731
16635
  }
16732
- return parameters.default === undefined ? expression : [
16636
+ return parameters.default === void 0 ? expression : [
16733
16637
  'case',
16734
16638
  [
16735
16639
  '==',
@@ -16757,7 +16661,7 @@ function convertZoomFunction(parameters, propertySpec, stops, input = ['zoom'])
16757
16661
  ];
16758
16662
  isStep = true;
16759
16663
  } else if (type === 'exponential') {
16760
- const base = parameters.base !== undefined ? parameters.base : 1;
16664
+ const base = parameters.base !== void 0 ? parameters.base : 1;
16761
16665
  expression = [
16762
16666
  getInterpolateOperator(parameters),
16763
16667
  base === 1 ? ['linear'] : [
@@ -16776,19 +16680,15 @@ function convertZoomFunction(parameters, propertySpec, stops, input = ['zoom'])
16776
16680
  return expression;
16777
16681
  }
16778
16682
  function fixupDegenerateStepCurve(expression) {
16779
- // degenerate step curve (i.e. a constant function): add a noop stop
16780
16683
  if (expression[0] === 'step' && expression.length === 3) {
16781
16684
  expression.push(0);
16782
16685
  expression.push(expression[3]);
16783
16686
  }
16784
16687
  }
16785
16688
  function appendStopPair(curve, input, output, isStep) {
16786
- // Skip duplicate stop values. They were not validated for functions, but they are for expressions.
16787
- // https://github.com/mapbox/mapbox-gl-js/issues/4107
16788
16689
  if (curve.length > 3 && input === curve[curve.length - 2]) {
16789
16690
  return;
16790
16691
  }
16791
- // step curves don't get the first input value, as it is redundant.
16792
16692
  if (!(isStep && curve.length === 2)) {
16793
16693
  curve.push(input);
16794
16694
  }
@@ -16801,7 +16701,6 @@ function getFunctionType(parameters, propertySpec) {
16801
16701
  return propertySpec.expression.interpolated ? 'exponential' : 'interval';
16802
16702
  }
16803
16703
  }
16804
- // "String with {name} token" => ["concat", "String with ", ["get", "name"], " token"]
16805
16704
  function convertTokenString(s) {
16806
16705
  const result = ['concat'];
16807
16706
  const re = /{([^{}]+)}/g;
@@ -16830,8 +16729,6 @@ function convertTokenString(s) {
16830
16729
  return result;
16831
16730
  }
16832
16731
 
16833
- //
16834
- // Turn jsonlint-lines-primitives objects into primitive objects
16835
16732
  function unbundle(value) {
16836
16733
  if (value instanceof Number || value instanceof String || value instanceof Boolean) {
16837
16734
  return value.valueOf();
@@ -16852,7 +16749,6 @@ function deepUnbundle(value) {
16852
16749
  return unbundle(value);
16853
16750
  }
16854
16751
 
16855
- //
16856
16752
  function isExpressionFilter(filter) {
16857
16753
  if (filter === true || filter === false) {
16858
16754
  return true;
@@ -16888,18 +16784,8 @@ function isExpressionFilter(filter) {
16888
16784
  return true;
16889
16785
  }
16890
16786
  }
16891
- /**
16892
- * Given a filter expressed as nested arrays, return a new function
16893
- * that evaluates whether a given feature (with a .properties or .tags property)
16894
- * passes its test.
16895
- *
16896
- * @private
16897
- * @param {Array} filter mapbox gl filter
16898
- * @param {string} layerType the type of the layer this filter will be applied to.
16899
- * @returns {Function} filter-evaluating function
16900
- */
16901
16787
  function createFilter(filter, layerType = 'fill') {
16902
- if (filter === null || filter === undefined) {
16788
+ if (filter === null || filter === void 0) {
16903
16789
  return {
16904
16790
  filter: () => true,
16905
16791
  needGeometry: false,
@@ -16907,7 +16793,6 @@ function createFilter(filter, layerType = 'fill') {
16907
16793
  };
16908
16794
  }
16909
16795
  if (!isExpressionFilter(filter)) {
16910
- // $FlowFixMe[incompatible-call]
16911
16796
  filter = convertFilter$1(filter);
16912
16797
  }
16913
16798
  const filterExp = filter;
@@ -16923,7 +16808,6 @@ Filter Expression:
16923
16808
  ${ JSON.stringify(filterExp, null, 2) }
16924
16809
  `);
16925
16810
  }
16926
- // Compile the static component of the filter
16927
16811
  const filterSpec = v8[`filter_${ layerType }`];
16928
16812
  const compiledStaticFilter = createExpression(staticFilter, filterSpec);
16929
16813
  let filterFunc = null;
@@ -16932,8 +16816,6 @@ ${ JSON.stringify(filterExp, null, 2) }
16932
16816
  } else {
16933
16817
  filterFunc = (globalProperties, feature, canonical) => compiledStaticFilter.value.evaluate(globalProperties, feature, {}, canonical);
16934
16818
  }
16935
- // If the static component is not equal to the entire filter then we have a dynamic component
16936
- // Compile the dynamic component separately
16937
16819
  let dynamicFilterFunc = null;
16938
16820
  let needFeature = null;
16939
16821
  if (staticFilter !== filterExp) {
@@ -16941,7 +16823,7 @@ ${ JSON.stringify(filterExp, null, 2) }
16941
16823
  if (compiledDynamicFilter.result === 'error') {
16942
16824
  throw new Error(compiledDynamicFilter.value.map(err => `${ err.key }: ${ err.message }`).join(', '));
16943
16825
  } else {
16944
- dynamicFilterFunc = (globalProperties, feature, canonical, featureTileCoord, featureDistanceData) => compiledDynamicFilter.value.evaluate(globalProperties, feature, {}, canonical, undefined, undefined, featureTileCoord, featureDistanceData);
16826
+ dynamicFilterFunc = (globalProperties, feature, canonical, featureTileCoord, featureDistanceData) => compiledDynamicFilter.value.evaluate(globalProperties, feature, {}, canonical, void 0, void 0, featureTileCoord, featureDistanceData);
16945
16827
  needFeature = !isFeatureConstant(compiledDynamicFilter.value.expression);
16946
16828
  }
16947
16829
  }
@@ -16949,7 +16831,7 @@ ${ JSON.stringify(filterExp, null, 2) }
16949
16831
  const needGeometry = geometryNeeded(staticFilter);
16950
16832
  return {
16951
16833
  filter: filterFunc,
16952
- dynamicFilter: dynamicFilterFunc ? dynamicFilterFunc : undefined,
16834
+ dynamicFilter: dynamicFilterFunc ? dynamicFilterFunc : void 0,
16953
16835
  needGeometry,
16954
16836
  needFeature: !!needFeature
16955
16837
  };
@@ -16958,11 +16840,8 @@ function extractStaticFilter(filter) {
16958
16840
  if (!isDynamicFilter(filter)) {
16959
16841
  return filter;
16960
16842
  }
16961
- // Shallow copy so we can replace expressions in-place
16962
16843
  let result = deepUnbundle(filter);
16963
- // 1. Union branches
16964
16844
  unionDynamicBranches(result);
16965
- // 2. Collapse dynamic conditions to `true`
16966
16845
  result = collapseDynamicBooleanExpressions(result);
16967
16846
  return result;
16968
16847
  }
@@ -16977,15 +16856,6 @@ function collapseDynamicBooleanExpressions(expression) {
16977
16856
  return collapsed.map(subExpression => collapseDynamicBooleanExpressions(subExpression));
16978
16857
  }
16979
16858
  }
16980
- /**
16981
- * Traverses the expression and replaces all instances of branching on a
16982
- * `dynamic` conditional (such as `['pitch']` or `['distance-from-center']`)
16983
- * into an `any` expression.
16984
- * This ensures that all possible outcomes of a `dynamic` branch are considered
16985
- * when evaluating the expression upfront during filtering.
16986
- *
16987
- * @param {Array<any>} filter the filter expression mutated in-place.
16988
- */
16989
16859
  function unionDynamicBranches(filter) {
16990
16860
  let isBranchingDynamically = false;
16991
16861
  const branches = [];
@@ -17011,13 +16881,11 @@ function unionDynamicBranches(filter) {
17011
16881
  filter.length = 0;
17012
16882
  filter.push('any', ...branches);
17013
16883
  }
17014
- // traverse and recurse into children
17015
16884
  for (let i = 1; i < filter.length; i++) {
17016
16885
  unionDynamicBranches(filter[i]);
17017
16886
  }
17018
16887
  }
17019
16888
  function isDynamicFilter(filter) {
17020
- // Base Cases
17021
16889
  if (!Array.isArray(filter)) {
17022
16890
  return false;
17023
16891
  }
@@ -17035,7 +16903,8 @@ function isDynamicFilter(filter) {
17035
16903
  function isRootExpressionDynamic(expression) {
17036
16904
  return expression === 'pitch' || expression === 'distance-from-center';
17037
16905
  }
17038
- const dynamicConditionExpressions = new Set([
16906
+ const dynamicConditionExpressions = /* @__PURE__ */
16907
+ new Set([
17039
16908
  'in',
17040
16909
  '==',
17041
16910
  '!=',
@@ -17056,7 +16925,6 @@ function collapsedExpression(expression) {
17056
16925
  }
17057
16926
  return expression;
17058
16927
  }
17059
- // Comparison function to sort numbers and strings
17060
16928
  function compare(a, b) {
17061
16929
  return a < b ? -1 : a > b ? 1 : 0;
17062
16930
  }
@@ -17077,7 +16945,9 @@ function convertFilter$1(filter) {
17077
16945
  const op = filter[0];
17078
16946
  if (filter.length <= 1)
17079
16947
  return op !== 'any';
17080
- const converted = op === '==' ? convertComparisonOp$1(filter[1], filter[2], '==') : op === '!=' ? convertNegation(convertComparisonOp$1(filter[1], filter[2], '==')) : op === '<' || op === '>' || op === '<=' || op === '>=' ? convertComparisonOp$1(filter[1], filter[2], op) : op === 'any' ? convertDisjunctionOp(filter.slice(1)) : op === 'all' ? ['all'].concat(filter.slice(1).map(convertFilter$1)) : op === 'none' ? ['all'].concat(filter.slice(1).map(convertFilter$1).map(convertNegation)) : op === 'in' ? convertInOp$1(filter[1], filter.slice(2)) : op === '!in' ? convertNegation(convertInOp$1(filter[1], filter.slice(2))) : op === 'has' ? convertHasOp$1(filter[1]) : op === '!has' ? convertNegation(convertHasOp$1(filter[1])) : true;
16948
+ const converted = op === '==' ? convertComparisonOp$1(filter[1], filter[2], '==') : op === '!=' ? convertNegation(convertComparisonOp$1(filter[1], filter[2], '==')) : op === '<' || op === '>' || op === '<=' || op === '>=' ? convertComparisonOp$1(filter[1], filter[2], op) : op === 'any' ? convertDisjunctionOp(filter.slice(1)) : // @ts-expect-error - TS2769 - No overload matches this call.
16949
+ op === 'all' ? ['all'].concat(filter.slice(1).map(convertFilter$1)) : // @ts-expect-error - TS2769 - No overload matches this call.
16950
+ op === 'none' ? ['all'].concat(filter.slice(1).map(convertFilter$1).map(convertNegation)) : op === 'in' ? convertInOp$1(filter[1], filter.slice(2)) : op === '!in' ? convertNegation(convertInOp$1(filter[1], filter.slice(2))) : op === 'has' ? convertHasOp$1(filter[1]) : op === '!has' ? convertNegation(convertHasOp$1(filter[1])) : true;
17081
16951
  return converted;
17082
16952
  }
17083
16953
  function convertComparisonOp$1(property, value, op) {
@@ -17166,63 +17036,9 @@ function convertNegation(filter) {
17166
17036
  ];
17167
17037
  }
17168
17038
 
17169
- //
17170
- /**
17171
- * Convert the given legacy filter to (the JSON representation of) an
17172
- * equivalent expression
17173
- * @private
17174
- */
17175
17039
  function convertFilter(filter) {
17176
17040
  return _convertFilter(filter, {});
17177
17041
  }
17178
- /*
17179
- * Convert the given filter to an expression, storing the expected types for
17180
- * any feature properties referenced in expectedTypes.
17181
- *
17182
- * These expected types are needed in order to construct preflight type checks
17183
- * needed for handling 'any' filters. A preflight type check is necessary in
17184
- * order to mimic legacy filters' semantics around expected type mismatches.
17185
- * For example, consider the legacy filter:
17186
- *
17187
- * ["any", ["all", [">", "y", 0], [">", "y", 0]], [">", "x", 0]]
17188
- *
17189
- * Naively, we might convert this to the expression:
17190
- *
17191
- * ["any", ["all", [">", ["get", "y"], 0], [">", ["get", "z"], 0]], [">", ["get", "x"], 0]]
17192
- *
17193
- * But if we tried to evaluate this against, say `{x: 1, y: null, z: 0}`, the
17194
- * [">", ["get", "y"], 0] would cause an evaluation error, leading to the
17195
- * entire filter returning false. Legacy filter semantics, though, ask for
17196
- * [">", "y", 0] to simply return `false` when `y` is of the wrong type,
17197
- * allowing the subsequent terms of the outer "any" expression to be evaluated
17198
- * (resulting, in this case, in a `true` value, because x > 0).
17199
- *
17200
- * We account for this by inserting a preflight type-checking expression before
17201
- * each "any" term, allowing us to avoid evaluating the actual converted filter
17202
- * if any type mismatches would cause it to produce an evalaution error:
17203
- *
17204
- * ["any",
17205
- * ["case",
17206
- * ["all", ["==", ["typeof", ["get", "y"]], "number"], ["==", ["typeof", ["get", "z"], "number]],
17207
- * ["all", [">", ["get", "y"], 0], [">", ["get", "z"], 0]],
17208
- * false
17209
- * ],
17210
- * ["case",
17211
- * ["==", ["typeof", ["get", "x"], "number"]],
17212
- * [">", ["get", "x"], 0],
17213
- * false
17214
- * ]
17215
- * ]
17216
- *
17217
- * An alternative, possibly more direct approach would be to use type checks
17218
- * in the conversion of each comparison operator, so that the converted version
17219
- * of each individual ==, >=, etc. would mimic the legacy filter semantics. The
17220
- * downside of this approach is that it can lead to many more type checks than
17221
- * would otherwise be necessary: outside the context of an "any" expression,
17222
- * bailing out due to a runtime type error (expression semantics) and returning
17223
- * false (legacy filter semantics) are equivalent: they cause the filter to
17224
- * produce a `false` result.
17225
- */
17226
17042
  function _convertFilter(filter, expectedTypes) {
17227
17043
  if (isExpressionFilter(filter)) {
17228
17044
  return filter;
@@ -17273,14 +17089,6 @@ function _convertFilter(filter, expectedTypes) {
17273
17089
  }
17274
17090
  return converted;
17275
17091
  }
17276
- // Given a set of feature properties and an expected type for each one,
17277
- // construct an boolean expression that tests whether each property has the
17278
- // right type.
17279
- // E.g.: for {name: 'string', population: 'number'}, return
17280
- // [ 'all',
17281
- // ['==', ['typeof', ['get', 'name'], 'string']],
17282
- // ['==', ['typeof', ['get', 'population'], 'number]]
17283
- // ]
17284
17092
  function runtimeTypeChecks(expectedTypes) {
17285
17093
  const conditions = [];
17286
17094
  for (const property in expectedTypes) {
@@ -17375,10 +17183,6 @@ function convertInOp(property, values, negate = false) {
17375
17183
  property
17376
17184
  ];
17377
17185
  }
17378
- // Determine if the list of values to be searched is homogenously typed.
17379
- // If so (and if the type is string or number), then we can use a
17380
- // [match, input, [...values], true, false] construction rather than a
17381
- // bunch of `==` tests.
17382
17186
  let uniformTypes = true;
17383
17187
  const type = typeof values[0];
17384
17188
  for (const value of values) {
@@ -17388,7 +17192,6 @@ function convertInOp(property, values, negate = false) {
17388
17192
  }
17389
17193
  }
17390
17194
  if (uniformTypes && (type === 'string' || type === 'number')) {
17391
- // Match expressions must have unique values.
17392
17195
  const uniqueValues = values.sort().filter((v, i) => i === 0 || values[i - 1] !== v);
17393
17196
  return [
17394
17197
  'match',
@@ -17398,7 +17201,8 @@ function convertInOp(property, values, negate = false) {
17398
17201
  negate
17399
17202
  ];
17400
17203
  }
17401
- return [negate ? 'all' : 'any'].concat(values.map(v => [
17204
+ return [negate ? 'all' : 'any'].concat(// @ts-expect-error - TS2769 - No overload matches this call.
17205
+ values.map(v => [
17402
17206
  negate ? '!=' : '==',
17403
17207
  get,
17404
17208
  v
@@ -17421,12 +17225,6 @@ function convertHasOp(property) {
17421
17225
  }
17422
17226
  }
17423
17227
 
17424
- //
17425
- /**
17426
- * Migrate the given style object in place to use expressions. Specifically,
17427
- * this will convert (a) "stop" functions, and (b) legacy filters to their
17428
- * expression equivalents.
17429
- */
17430
17228
  function migrateToExpressions (style) {
17431
17229
  const converted = [];
17432
17230
  eachLayer(style, layer => {
@@ -17441,9 +17239,6 @@ function migrateToExpressions (style) {
17441
17239
  if (isExpression(value))
17442
17240
  return;
17443
17241
  if (typeof value === 'object' && !Array.isArray(value)) {
17444
- // $FlowFixMe[prop-missing]
17445
- // $FlowFixMe[incompatible-call]
17446
- // $FlowFixMe[incompatible-variance]
17447
17242
  set(convertFunction(value, reference));
17448
17243
  converted.push(path.join('.'));
17449
17244
  } else if (reference.tokens && typeof value === 'string') {
@@ -17453,20 +17248,6 @@ function migrateToExpressions (style) {
17453
17248
  return style;
17454
17249
  }
17455
17250
 
17456
- //
17457
- /**
17458
- * Migrate a Mapbox GL Style to the latest version.
17459
- *
17460
- * @private
17461
- * @alias migrate
17462
- * @param {object} style a Mapbox GL Style
17463
- * @returns {Object} a migrated style
17464
- * @example
17465
- * var fs = require('fs');
17466
- * var migrate = require('mapbox-gl-style-spec').migrate;
17467
- * var style = fs.readFileSync('./style.json', 'utf8');
17468
- * fs.writeFileSync('./style.json', JSON.stringify(migrate(style)));
17469
- */
17470
17251
  function migrate (style) {
17471
17252
  let migrated = false;
17472
17253
  if (style.version === 7) {
@@ -17483,7 +17264,6 @@ function migrate (style) {
17483
17264
  return style;
17484
17265
  }
17485
17266
 
17486
- //
17487
17267
  function composite (style) {
17488
17268
  const styleIDs = [];
17489
17269
  const sourceIDs = [];
@@ -17523,7 +17303,6 @@ function composite (style) {
17523
17303
  return style;
17524
17304
  }
17525
17305
 
17526
- //
17527
17306
  var refProperties = [
17528
17307
  'type',
17529
17308
  'source',
@@ -17534,7 +17313,6 @@ var refProperties = [
17534
17313
  'layout'
17535
17314
  ];
17536
17315
 
17537
- //
17538
17316
  function deref(layer, parent) {
17539
17317
  const result = {};
17540
17318
  for (const k in layer) {
@@ -17549,22 +17327,10 @@ function deref(layer, parent) {
17549
17327
  });
17550
17328
  return result;
17551
17329
  }
17552
- /**
17553
- * Given an array of layers, some of which may contain `ref` properties
17554
- * whose value is the `id` of another property, return a new array where
17555
- * such layers have been augmented with the 'type', 'source', etc. properties
17556
- * from the parent layer, and the `ref` property has been removed.
17557
- *
17558
- * The input is not modified. The output may contain references to portions
17559
- * of the input.
17560
- *
17561
- * @private
17562
- * @param {Array<Layer>} layers
17563
- * @returns {Array<Layer>}
17564
- */
17565
17330
  function derefLayers(layers) {
17566
17331
  layers = layers.slice();
17567
- const map = Object.create(null);
17332
+ const map = /* @__PURE__ */
17333
+ Object.create(null);
17568
17334
  for (let i = 0; i < layers.length; i++) {
17569
17335
  map[layers[i].id] = layers[i];
17570
17336
  }
@@ -17576,12 +17342,6 @@ function derefLayers(layers) {
17576
17342
  return layers;
17577
17343
  }
17578
17344
 
17579
- //
17580
- /**
17581
- * Deeply compares two object literals.
17582
- *
17583
- * @private
17584
- */
17585
17345
  function deepEqual(a, b) {
17586
17346
  if (Array.isArray(a)) {
17587
17347
  if (!Array.isArray(b) || a.length !== b.length)
@@ -17607,119 +17367,118 @@ function deepEqual(a, b) {
17607
17367
  return a === b;
17608
17368
  }
17609
17369
 
17610
- //
17611
17370
  const operations = {
17612
17371
  /*
17613
- * { command: 'setStyle', args: [stylesheet] }
17614
- */
17372
+ * { command: 'setStyle', args: [stylesheet] }
17373
+ */
17615
17374
  setStyle: 'setStyle',
17616
17375
  /*
17617
- * { command: 'addLayer', args: [layer, 'beforeLayerId'] }
17618
- */
17376
+ * { command: 'addLayer', args: [layer, 'beforeLayerId'] }
17377
+ */
17619
17378
  addLayer: 'addLayer',
17620
17379
  /*
17621
- * { command: 'removeLayer', args: ['layerId'] }
17622
- */
17380
+ * { command: 'removeLayer', args: ['layerId'] }
17381
+ */
17623
17382
  removeLayer: 'removeLayer',
17624
17383
  /*
17625
- * { command: 'setPaintProperty', args: ['layerId', 'prop', value] }
17626
- */
17384
+ * { command: 'setPaintProperty', args: ['layerId', 'prop', value] }
17385
+ */
17627
17386
  setPaintProperty: 'setPaintProperty',
17628
17387
  /*
17629
- * { command: 'setLayoutProperty', args: ['layerId', 'prop', value] }
17630
- */
17388
+ * { command: 'setLayoutProperty', args: ['layerId', 'prop', value] }
17389
+ */
17631
17390
  setLayoutProperty: 'setLayoutProperty',
17632
17391
  /*
17633
- * { command: 'setSlot', args: ['layerId', slot] }
17634
- */
17392
+ * { command: 'setSlot', args: ['layerId', slot] }
17393
+ */
17635
17394
  setSlot: 'setSlot',
17636
17395
  /*
17637
- * { command: 'setFilter', args: ['layerId', filter] }
17638
- */
17396
+ * { command: 'setFilter', args: ['layerId', filter] }
17397
+ */
17639
17398
  setFilter: 'setFilter',
17640
17399
  /*
17641
- * { command: 'addSource', args: ['sourceId', source] }
17642
- */
17400
+ * { command: 'addSource', args: ['sourceId', source] }
17401
+ */
17643
17402
  addSource: 'addSource',
17644
17403
  /*
17645
- * { command: 'removeSource', args: ['sourceId'] }
17646
- */
17404
+ * { command: 'removeSource', args: ['sourceId'] }
17405
+ */
17647
17406
  removeSource: 'removeSource',
17648
17407
  /*
17649
- * { command: 'setGeoJSONSourceData', args: ['sourceId', data] }
17650
- */
17408
+ * { command: 'setGeoJSONSourceData', args: ['sourceId', data] }
17409
+ */
17651
17410
  setGeoJSONSourceData: 'setGeoJSONSourceData',
17652
17411
  /*
17653
- * { command: 'setLayerZoomRange', args: ['layerId', 0, 22] }
17654
- */
17412
+ * { command: 'setLayerZoomRange', args: ['layerId', 0, 22] }
17413
+ */
17655
17414
  setLayerZoomRange: 'setLayerZoomRange',
17656
17415
  /*
17657
- * { command: 'setLayerProperty', args: ['layerId', 'prop', value] }
17658
- */
17416
+ * { command: 'setLayerProperty', args: ['layerId', 'prop', value] }
17417
+ */
17659
17418
  setLayerProperty: 'setLayerProperty',
17660
17419
  /*
17661
- * { command: 'setCenter', args: [[lon, lat]] }
17662
- */
17420
+ * { command: 'setCenter', args: [[lon, lat]] }
17421
+ */
17663
17422
  setCenter: 'setCenter',
17664
17423
  /*
17665
- * { command: 'setZoom', args: [zoom] }
17666
- */
17424
+ * { command: 'setZoom', args: [zoom] }
17425
+ */
17667
17426
  setZoom: 'setZoom',
17668
17427
  /*
17669
- * { command: 'setBearing', args: [bearing] }
17670
- */
17428
+ * { command: 'setBearing', args: [bearing] }
17429
+ */
17671
17430
  setBearing: 'setBearing',
17672
17431
  /*
17673
- * { command: 'setPitch', args: [pitch] }
17674
- */
17432
+ * { command: 'setPitch', args: [pitch] }
17433
+ */
17675
17434
  setPitch: 'setPitch',
17676
17435
  /*
17677
- * { command: 'setSprite', args: ['spriteUrl'] }
17678
- */
17436
+ * { command: 'setSprite', args: ['spriteUrl'] }
17437
+ */
17679
17438
  setSprite: 'setSprite',
17680
17439
  /*
17681
- * { command: 'setGlyphs', args: ['glyphsUrl'] }
17682
- */
17440
+ * { command: 'setGlyphs', args: ['glyphsUrl'] }
17441
+ */
17683
17442
  setGlyphs: 'setGlyphs',
17684
17443
  /*
17685
- * { command: 'setTransition', args: [transition] }
17686
- */
17444
+ * { command: 'setTransition', args: [transition] }
17445
+ */
17687
17446
  setTransition: 'setTransition',
17688
17447
  /*
17689
- * { command: 'setLighting', args: [lightProperties] }
17690
- */
17448
+ * { command: 'setLighting', args: [lightProperties] }
17449
+ */
17691
17450
  setLight: 'setLight',
17692
17451
  /*
17693
- * { command: 'setTerrain', args: [terrainProperties] }
17694
- */
17452
+ * { command: 'setTerrain', args: [terrainProperties] }
17453
+ */
17695
17454
  setTerrain: 'setTerrain',
17696
17455
  /*
17697
- * { command: 'setFog', args: [fogProperties] }
17698
- */
17456
+ * { command: 'setFog', args: [fogProperties] }
17457
+ */
17699
17458
  setFog: 'setFog',
17700
17459
  /*
17701
- * { command: 'setCamera', args: [cameraProperties] }
17702
- */
17460
+ * { command: 'setCamera', args: [cameraProperties] }
17461
+ */
17703
17462
  setCamera: 'setCamera',
17704
17463
  /*
17705
- * { command: 'setLights', args: [{light-3d},...] }
17706
- */
17464
+ * { command: 'setLights', args: [{light-3d},...] }
17465
+ */
17707
17466
  setLights: 'setLights',
17708
17467
  /*
17709
- * { command: 'setProjection', args: [projectionProperties] }
17710
- */
17468
+ * { command: 'setProjection', args: [projectionProperties] }
17469
+ */
17711
17470
  setProjection: 'setProjection',
17712
17471
  /*
17713
- * { command: 'addImport', args: [import] }
17714
- */
17472
+ * { command: 'addImport', args: [import] }
17473
+ */
17715
17474
  addImport: 'addImport',
17716
17475
  /*
17717
- * { command: 'removeImport', args: [importId] }
17718
- */
17476
+ * { command: 'removeImport', args: [importId] }
17477
+ */
17719
17478
  removeImport: 'removeImport',
17720
17479
  /**
17721
- * { command: 'updateImport', args: [importId, importSpecification | styleUrl] }
17722
- */
17480
+ * { command: 'updateImport', args: [importId, importSpecification | styleUrl] }
17481
+ */
17723
17482
  updateImport: 'updateImport'
17724
17483
  };
17725
17484
  function addSource(sourceId, after, commands) {
@@ -17764,7 +17523,6 @@ function diffSources(before, after, commands, sourcesRemoved) {
17764
17523
  before = before || {};
17765
17524
  after = after || {};
17766
17525
  let sourceId;
17767
- // look for sources to remove
17768
17526
  for (sourceId in before) {
17769
17527
  if (!before.hasOwnProperty(sourceId))
17770
17528
  continue;
@@ -17772,7 +17530,6 @@ function diffSources(before, after, commands, sourcesRemoved) {
17772
17530
  removeSource(sourceId, commands, sourcesRemoved);
17773
17531
  }
17774
17532
  }
17775
- // look for sources to add/update
17776
17533
  for (sourceId in after) {
17777
17534
  if (!after.hasOwnProperty(sourceId))
17778
17535
  continue;
@@ -17789,7 +17546,6 @@ function diffSources(before, after, commands, sourcesRemoved) {
17789
17546
  ]
17790
17547
  });
17791
17548
  } else {
17792
- // no update command, must remove then add
17793
17549
  updateSource(sourceId, after, commands, sourcesRemoved);
17794
17550
  }
17795
17551
  }
@@ -17840,18 +17596,14 @@ function indexById(group, item) {
17840
17596
  function diffLayers(before, after, commands) {
17841
17597
  before = before || [];
17842
17598
  after = after || [];
17843
- // order of layers by id
17844
17599
  const beforeOrder = before.map(pluckId);
17845
17600
  const afterOrder = after.map(pluckId);
17846
- // index of layer by id
17847
17601
  const beforeIndex = before.reduce(indexById, {});
17848
17602
  const afterIndex = after.reduce(indexById, {});
17849
- // track order of layers as if they have been mutated
17850
17603
  const tracker = beforeOrder.slice();
17851
- // layers that have been added do not need to be diffed
17852
- const clean = Object.create(null);
17604
+ const clean = /* @__PURE__ */
17605
+ Object.create(null);
17853
17606
  let i, d, layerId, beforeLayer, afterLayer, insertBeforeLayerId, prop;
17854
- // remove layers
17855
17607
  for (i = 0, d = 0; i < beforeOrder.length; i++) {
17856
17608
  layerId = beforeOrder[i];
17857
17609
  if (!afterIndex.hasOwnProperty(layerId)) {
@@ -17861,28 +17613,22 @@ function diffLayers(before, after, commands) {
17861
17613
  });
17862
17614
  tracker.splice(tracker.indexOf(layerId, d), 1);
17863
17615
  } else {
17864
- // limit where in tracker we need to look for a match
17865
17616
  d++;
17866
17617
  }
17867
17618
  }
17868
- // add/reorder layers
17869
17619
  for (i = 0, d = 0; i < afterOrder.length; i++) {
17870
- // work backwards as insert is before an existing layer
17871
17620
  layerId = afterOrder[afterOrder.length - 1 - i];
17872
17621
  if (tracker[tracker.length - 1 - i] === layerId)
17873
17622
  continue;
17874
17623
  if (beforeIndex.hasOwnProperty(layerId)) {
17875
- // remove the layer before we insert at the correct position
17876
17624
  commands.push({
17877
17625
  command: operations.removeLayer,
17878
17626
  args: [layerId]
17879
17627
  });
17880
17628
  tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1);
17881
17629
  } else {
17882
- // limit where in tracker we need to look for a match
17883
17630
  d++;
17884
17631
  }
17885
- // add layer at correct position
17886
17632
  insertBeforeLayerId = tracker[tracker.length - i];
17887
17633
  commands.push({
17888
17634
  command: operations.addLayer,
@@ -17894,24 +17640,17 @@ function diffLayers(before, after, commands) {
17894
17640
  tracker.splice(tracker.length - i, 0, layerId);
17895
17641
  clean[layerId] = true;
17896
17642
  }
17897
- // update layers
17898
17643
  for (i = 0; i < afterOrder.length; i++) {
17899
17644
  layerId = afterOrder[i];
17900
17645
  beforeLayer = beforeIndex[layerId];
17901
17646
  afterLayer = afterIndex[layerId];
17902
- // no need to update if previously added (new or moved)
17903
17647
  if (clean[layerId] || deepEqual(beforeLayer, afterLayer))
17904
17648
  continue;
17905
- // If source, source-layer, or type have changes, then remove the layer
17906
- // and add it back 'from scratch'.
17907
- // $FlowFixMe[prop-missing] - there is no `source-layer` in background and sky layers
17908
17649
  if (!deepEqual(beforeLayer.source, afterLayer.source) || !deepEqual(beforeLayer['source-layer'], afterLayer['source-layer']) || !deepEqual(beforeLayer.type, afterLayer.type)) {
17909
17650
  commands.push({
17910
17651
  command: operations.removeLayer,
17911
17652
  args: [layerId]
17912
17653
  });
17913
- // we add the layer back at the same position it was already in, so
17914
- // there's no need to update the `tracker`
17915
17654
  insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1];
17916
17655
  commands.push({
17917
17656
  command: operations.addLayer,
@@ -17922,7 +17661,6 @@ function diffLayers(before, after, commands) {
17922
17661
  });
17923
17662
  continue;
17924
17663
  }
17925
- // layout, paint, filter, minzoom, maxzoom
17926
17664
  diffLayerPropertyChanges(beforeLayer.layout, afterLayer.layout, commands, layerId, null, operations.setLayoutProperty);
17927
17665
  diffLayerPropertyChanges(beforeLayer.paint, afterLayer.paint, commands, layerId, null, operations.setPaintProperty);
17928
17666
  if (!deepEqual(beforeLayer.slot, afterLayer.slot)) {
@@ -17953,7 +17691,6 @@ function diffLayers(before, after, commands) {
17953
17691
  ]
17954
17692
  });
17955
17693
  }
17956
- // handle all other layer props, including paint.*
17957
17694
  for (prop in beforeLayer) {
17958
17695
  if (!beforeLayer.hasOwnProperty(prop))
17959
17696
  continue;
@@ -17995,16 +17732,12 @@ function diffLayers(before, after, commands) {
17995
17732
  function diffImports(before = [], after = [], commands) {
17996
17733
  before = before || [];
17997
17734
  after = after || [];
17998
- // order imports by id
17999
17735
  const beforeOrder = before.map(pluckId);
18000
17736
  const afterOrder = after.map(pluckId);
18001
- // index imports by id
18002
17737
  const beforeIndex = before.reduce(indexById, {});
18003
17738
  const afterIndex = after.reduce(indexById, {});
18004
- // track order of imports as if they have been mutated
18005
17739
  const tracker = beforeOrder.slice();
18006
17740
  let i, d, importId, insertBefore;
18007
- // remove imports
18008
17741
  for (i = 0, d = 0; i < beforeOrder.length; i++) {
18009
17742
  importId = beforeOrder[i];
18010
17743
  if (!afterIndex.hasOwnProperty(importId)) {
@@ -18014,28 +17747,22 @@ function diffImports(before = [], after = [], commands) {
18014
17747
  });
18015
17748
  tracker.splice(tracker.indexOf(importId, d), 1);
18016
17749
  } else {
18017
- // limit where in tracker we need to look for a match
18018
17750
  d++;
18019
17751
  }
18020
17752
  }
18021
- // add/reorder imports
18022
17753
  for (i = 0, d = 0; i < afterOrder.length; i++) {
18023
- // work backwards as insert is before an existing import
18024
17754
  importId = afterOrder[afterOrder.length - 1 - i];
18025
17755
  if (tracker[tracker.length - 1 - i] === importId)
18026
17756
  continue;
18027
17757
  if (beforeIndex.hasOwnProperty(importId)) {
18028
- // remove the import before we insert at the correct position
18029
17758
  commands.push({
18030
17759
  command: operations.removeImport,
18031
17760
  args: [importId]
18032
17761
  });
18033
17762
  tracker.splice(tracker.lastIndexOf(importId, tracker.length - d), 1);
18034
17763
  } else {
18035
- // limit where in tracker we need to look for a match
18036
17764
  d++;
18037
17765
  }
18038
- // add import at correct position
18039
17766
  insertBefore = tracker[tracker.length - i];
18040
17767
  commands.push({
18041
17768
  command: operations.addImport,
@@ -18046,7 +17773,6 @@ function diffImports(before = [], after = [], commands) {
18046
17773
  });
18047
17774
  tracker.splice(tracker.length - i, 0, importId);
18048
17775
  }
18049
- // update imports
18050
17776
  for (const afterImport of after) {
18051
17777
  const beforeImport = beforeIndex[afterImport.id];
18052
17778
  if (!beforeImport || deepEqual(beforeImport, afterImport))
@@ -18060,24 +17786,6 @@ function diffImports(before = [], after = [], commands) {
18060
17786
  });
18061
17787
  }
18062
17788
  }
18063
- /**
18064
- * Diff two stylesheet
18065
- *
18066
- * Creates semanticly aware diffs that can easily be applied at runtime.
18067
- * Operations produced by the diff closely resemble the mapbox-gl-js API. Any
18068
- * error creating the diff will fall back to the 'setStyle' operation.
18069
- *
18070
- * Example diff:
18071
- * [
18072
- * { command: 'setConstant', args: ['@water', '#0000FF'] },
18073
- * { command: 'setPaintProperty', args: ['background', 'background-color', 'black'] }
18074
- * ]
18075
- *
18076
- * @private
18077
- * @param {*} [before] stylesheet to compare from
18078
- * @param {*} after stylesheet to compare to
18079
- * @returns Array list of changes
18080
- */
18081
17789
  function diffStyles(before, after) {
18082
17790
  if (!before)
18083
17791
  return [{
@@ -18086,7 +17794,6 @@ function diffStyles(before, after) {
18086
17794
  }];
18087
17795
  let commands = [];
18088
17796
  try {
18089
- // Handle changes to top-level properties
18090
17797
  if (!deepEqual(before.version, after.version)) {
18091
17798
  return [{
18092
17799
  command: operations.setStyle,
@@ -18129,7 +17836,6 @@ function diffStyles(before, after) {
18129
17836
  args: [after.glyphs]
18130
17837
  });
18131
17838
  }
18132
- // Handle changes to `imports` before other mergable top-level properties
18133
17839
  if (!deepEqual(before.imports, after.imports)) {
18134
17840
  diffImports(before.imports, after.imports, commands);
18135
17841
  }
@@ -18169,18 +17875,15 @@ function diffStyles(before, after) {
18169
17875
  args: [after.camera]
18170
17876
  });
18171
17877
  }
18172
- // Handle changes to `sources`
18173
- // If a source is to be removed, we also--before the removeSource
18174
- // command--need to remove all the style layers that depend on it.
17878
+ if (!deepEqual(before['color-theme'], after['color-theme'])) {
17879
+ return [{
17880
+ command: operations.setStyle,
17881
+ args: [after]
17882
+ }];
17883
+ }
18175
17884
  const sourcesRemoved = {};
18176
- // First collect the {add,remove}Source commands
18177
17885
  const removeOrAddSourceCommands = [];
18178
17886
  diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved);
18179
- // Push a removeLayer command for each style layer that depends on a
18180
- // source that's being removed.
18181
- // Also, exclude any such layers them from the input to `diffLayers`
18182
- // below, so that diffLayers produces the appropriate `addLayers`
18183
- // command
18184
17887
  const beforeLayers = [];
18185
17888
  if (before.layers) {
18186
17889
  before.layers.forEach(layer => {
@@ -18194,30 +17897,25 @@ function diffStyles(before, after) {
18194
17897
  }
18195
17898
  });
18196
17899
  }
18197
- // Remove the terrain if the source for that terrain is being removed
18198
17900
  let beforeTerrain = before.terrain;
18199
17901
  if (beforeTerrain) {
18200
17902
  if (sourcesRemoved[beforeTerrain.source]) {
18201
17903
  commands.push({
18202
17904
  command: operations.setTerrain,
18203
- args: [undefined]
17905
+ args: [void 0]
18204
17906
  });
18205
- beforeTerrain = undefined;
17907
+ beforeTerrain = void 0;
18206
17908
  }
18207
17909
  }
18208
17910
  commands = commands.concat(removeOrAddSourceCommands);
18209
- // Even though terrain is a top-level property
18210
- // Its like a layer in the sense that it depends on a source being present.
18211
17911
  if (!deepEqual(beforeTerrain, after.terrain)) {
18212
17912
  commands.push({
18213
17913
  command: operations.setTerrain,
18214
17914
  args: [after.terrain]
18215
17915
  });
18216
17916
  }
18217
- // Handle changes to `layers`
18218
17917
  diffLayers(beforeLayers, after.layers, commands);
18219
17918
  } catch (e) {
18220
- // fall back to setStyle
18221
17919
  console.warn('Unable to compute style diff:', e);
18222
17920
  commands = [{
18223
17921
  command: operations.setStyle,
@@ -18227,14 +17925,12 @@ function diffStyles(before, after) {
18227
17925
  return commands;
18228
17926
  }
18229
17927
 
18230
- //
18231
- // Note: Do not inherit from Error. It breaks when transpiling to ES5.
18232
17928
  class ValidationError {
18233
17929
  constructor(key, value, message, identifier) {
18234
17930
  this.message = (key ? `${ key }: ` : '') + message;
18235
17931
  if (identifier)
18236
17932
  this.identifier = identifier;
18237
- if (value !== null && value !== undefined && value.__line__) {
17933
+ if (value !== null && value !== void 0 && value.__line__) {
18238
17934
  this.line = value.__line__;
18239
17935
  }
18240
17936
  }
@@ -18242,8 +17938,6 @@ class ValidationError {
18242
17938
  class ValidationWarning extends ValidationError {
18243
17939
  }
18244
17940
 
18245
- //
18246
- // Note: Do not inherit from Error. It breaks when transpiling to ES5.
18247
17941
  class ParsingError {
18248
17942
  constructor(error) {
18249
17943
  this.error = error;
@@ -18253,7 +17947,6 @@ class ParsingError {
18253
17947
  }
18254
17948
  }
18255
17949
 
18256
- //
18257
17950
  function validateObject(options) {
18258
17951
  const key = options.key;
18259
17952
  const object = options.value;
@@ -18268,7 +17961,6 @@ function validateObject(options) {
18268
17961
  }
18269
17962
  for (const objectKey in object) {
18270
17963
  const elementSpecKey = objectKey.split('.')[0];
18271
- // treat 'paint.*' as 'paint'
18272
17964
  const elementSpec = elementSpecs[elementSpecKey] || elementSpecs['*'];
18273
17965
  let validateElement;
18274
17966
  if (elementValidators[elementSpecKey]) {
@@ -18291,26 +17983,23 @@ function validateObject(options) {
18291
17983
  style,
18292
17984
  styleSpec,
18293
17985
  object,
18294
- objectKey // $FlowFixMe[extra-arg]
17986
+ objectKey
18295
17987
  }, object));
18296
17988
  }
18297
17989
  for (const elementSpecKey in elementSpecs) {
18298
- // Don't check `required` when there's a custom validator for that property.
18299
17990
  if (elementValidators[elementSpecKey]) {
18300
17991
  continue;
18301
17992
  }
18302
- if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === undefined && object[elementSpecKey] === undefined) {
17993
+ if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === void 0 && object[elementSpecKey] === void 0) {
18303
17994
  errors.push(new ValidationError(key, object, `missing required property "${ elementSpecKey }"`));
18304
17995
  }
18305
17996
  }
18306
17997
  return errors;
18307
17998
  }
18308
17999
 
18309
- //
18310
18000
  function validateImport(options) {
18311
18001
  const {value, styleSpec} = options;
18312
18002
  const {data, ...importSpec} = value;
18313
- // Preserve __line__ from the value
18314
18003
  Object.defineProperty(importSpec, '__line__', {
18315
18004
  value: value.__line__,
18316
18005
  enumerable: false
@@ -18319,7 +18008,6 @@ function validateImport(options) {
18319
18008
  value: importSpec,
18320
18009
  valueSpec: styleSpec.import
18321
18010
  }));
18322
- // Empty string is reserved for the root style id
18323
18011
  if (unbundle(importSpec.id) === '') {
18324
18012
  const key = `${ options.key }.id`;
18325
18013
  errors.push(new ValidationError(key, importSpec, `import id can't be an empty string`));
@@ -18331,7 +18019,6 @@ function validateImport(options) {
18331
18019
  return errors;
18332
18020
  }
18333
18021
 
18334
- //
18335
18022
  function validateArray(options) {
18336
18023
  const array = options.value;
18337
18024
  const arraySpec = options.valueSpec;
@@ -18353,7 +18040,7 @@ function validateArray(options) {
18353
18040
  'values': arraySpec.values,
18354
18041
  'minimum': arraySpec.minimum,
18355
18042
  'maximum': arraySpec.maximum,
18356
- function: undefined
18043
+ function: void 0
18357
18044
  };
18358
18045
  if (styleSpec.$version < 7) {
18359
18046
  arrayElementSpec.function = arraySpec.function;
@@ -18376,13 +18063,11 @@ function validateArray(options) {
18376
18063
  return errors;
18377
18064
  }
18378
18065
 
18379
- //
18380
18066
  function validateNumber(options) {
18381
18067
  const key = options.key;
18382
18068
  const value = options.value;
18383
18069
  const valueSpec = options.valueSpec;
18384
18070
  let type = getType(value);
18385
- // eslint-disable-next-line no-self-compare
18386
18071
  if (type === 'number' && value !== value) {
18387
18072
  type = 'NaN';
18388
18073
  }
@@ -18412,7 +18097,6 @@ function validateNumber(options) {
18412
18097
  return [];
18413
18098
  }
18414
18099
 
18415
- //
18416
18100
  function validateFunction(options) {
18417
18101
  const functionValueSpec = options.valueSpec;
18418
18102
  const functionType = unbundle(options.value.type);
@@ -18420,7 +18104,7 @@ function validateFunction(options) {
18420
18104
  let stopDomainValues = {};
18421
18105
  let previousStopDomainValue;
18422
18106
  let previousStopDomainZoom;
18423
- const isZoomFunction = functionType !== 'categorical' && options.value.property === undefined;
18107
+ const isZoomFunction = functionType !== 'categorical' && options.value.property === void 0;
18424
18108
  const isPropertyFunction = !isZoomFunction;
18425
18109
  const isZoomAndPropertyFunction = getType(options.value.stops) === 'array' && getType(options.value.stops[0]) === 'array' && getType(options.value.stops[0][0]) === 'object';
18426
18110
  const errors = validateObject({
@@ -18450,33 +18134,33 @@ function validateFunction(options) {
18450
18134
  errors.push(new ValidationError(options.key, options.value, 'zoom functions not supported'));
18451
18135
  }
18452
18136
  }
18453
- if ((functionType === 'categorical' || isZoomAndPropertyFunction) && options.value.property === undefined) {
18137
+ if ((functionType === 'categorical' || isZoomAndPropertyFunction) && options.value.property === void 0) {
18454
18138
  errors.push(new ValidationError(options.key, options.value, '"property" property is required'));
18455
18139
  }
18456
18140
  return errors;
18457
- function validateFunctionStops(options) {
18141
+ function validateFunctionStops(options2) {
18458
18142
  if (functionType === 'identity') {
18459
- return [new ValidationError(options.key, options.value, 'identity function may not have a "stops" property')];
18143
+ return [new ValidationError(options2.key, options2.value, 'identity function may not have a "stops" property')];
18460
18144
  }
18461
- let errors = [];
18462
- const value = options.value;
18463
- errors = errors.concat(validateArray({
18464
- key: options.key,
18145
+ let errors2 = [];
18146
+ const value = options2.value;
18147
+ errors2 = errors2.concat(validateArray({
18148
+ key: options2.key,
18465
18149
  value,
18466
- valueSpec: options.valueSpec,
18467
- style: options.style,
18468
- styleSpec: options.styleSpec,
18150
+ valueSpec: options2.valueSpec,
18151
+ style: options2.style,
18152
+ styleSpec: options2.styleSpec,
18469
18153
  arrayElementValidator: validateFunctionStop
18470
18154
  }));
18471
18155
  if (getType(value) === 'array' && value.length === 0) {
18472
- errors.push(new ValidationError(options.key, value, 'array must have at least one stop'));
18156
+ errors2.push(new ValidationError(options2.key, value, 'array must have at least one stop'));
18473
18157
  }
18474
- return errors;
18158
+ return errors2;
18475
18159
  }
18476
- function validateFunctionStop(options) {
18477
- let errors = [];
18478
- const value = options.value;
18479
- const key = options.key;
18160
+ function validateFunctionStop(options2) {
18161
+ let errors2 = [];
18162
+ const value = options2.value;
18163
+ const key = options2.key;
18480
18164
  if (getType(value) !== 'array') {
18481
18165
  return [new ValidationError(key, value, `array expected, ${ getType(value) } found`)];
18482
18166
  }
@@ -18487,10 +18171,10 @@ function validateFunction(options) {
18487
18171
  if (getType(value[0]) !== 'object') {
18488
18172
  return [new ValidationError(key, value, `object expected, ${ getType(value[0]) } found`)];
18489
18173
  }
18490
- if (value[0].zoom === undefined) {
18174
+ if (value[0].zoom === void 0) {
18491
18175
  return [new ValidationError(key, value, 'object stop key must have zoom')];
18492
18176
  }
18493
- if (value[0].value === undefined) {
18177
+ if (value[0].value === void 0) {
18494
18178
  return [new ValidationError(key, value, 'object stop key must have value')];
18495
18179
  }
18496
18180
  const nextStopDomainZoom = unbundle(value[0].zoom);
@@ -18502,86 +18186,85 @@ function validateFunction(options) {
18502
18186
  }
18503
18187
  if (nextStopDomainZoom !== previousStopDomainZoom) {
18504
18188
  previousStopDomainZoom = nextStopDomainZoom;
18505
- previousStopDomainValue = undefined;
18189
+ previousStopDomainValue = void 0;
18506
18190
  stopDomainValues = {};
18507
18191
  }
18508
- errors = errors.concat(validateObject({
18192
+ errors2 = errors2.concat(validateObject({
18509
18193
  key: `${ key }[0]`,
18510
18194
  value: value[0],
18511
18195
  valueSpec: { zoom: {} },
18512
- style: options.style,
18513
- styleSpec: options.styleSpec,
18196
+ style: options2.style,
18197
+ styleSpec: options2.styleSpec,
18514
18198
  objectElementValidators: {
18515
18199
  zoom: validateNumber,
18516
18200
  value: validateStopDomainValue
18517
18201
  }
18518
18202
  }));
18519
18203
  } else {
18520
- errors = errors.concat(validateStopDomainValue({
18204
+ errors2 = errors2.concat(validateStopDomainValue({
18521
18205
  key: `${ key }[0]`,
18522
18206
  value: value[0],
18523
18207
  valueSpec: {},
18524
- style: options.style,
18525
- styleSpec: options.styleSpec
18208
+ style: options2.style,
18209
+ styleSpec: options2.styleSpec
18526
18210
  }, value));
18527
18211
  }
18528
18212
  if (isExpression(deepUnbundle(value[1]))) {
18529
- return errors.concat([new ValidationError(`${ key }[1]`, value[1], 'expressions are not allowed in function stops.')]);
18213
+ return errors2.concat([new ValidationError(`${ key }[1]`, value[1], 'expressions are not allowed in function stops.')]);
18530
18214
  }
18531
- return errors.concat(validate({
18215
+ return errors2.concat(validate({
18532
18216
  key: `${ key }[1]`,
18533
18217
  value: value[1],
18534
18218
  valueSpec: functionValueSpec,
18535
- style: options.style,
18536
- styleSpec: options.styleSpec
18219
+ style: options2.style,
18220
+ styleSpec: options2.styleSpec
18537
18221
  }));
18538
18222
  }
18539
- function validateStopDomainValue(options, stop) {
18540
- const type = getType(options.value);
18541
- const value = unbundle(options.value);
18542
- const reportValue = options.value !== null ? options.value : stop;
18223
+ function validateStopDomainValue(options2, stop) {
18224
+ const type = getType(options2.value);
18225
+ const value = unbundle(options2.value);
18226
+ const reportValue = options2.value !== null ? options2.value : stop;
18543
18227
  if (!stopKeyType) {
18544
18228
  stopKeyType = type;
18545
18229
  } else if (type !== stopKeyType) {
18546
- return [new ValidationError(options.key, reportValue, `${ type } stop domain type must match previous stop domain type ${ stopKeyType }`)];
18230
+ return [new ValidationError(options2.key, reportValue, `${ type } stop domain type must match previous stop domain type ${ stopKeyType }`)];
18547
18231
  }
18548
18232
  if (type !== 'number' && type !== 'string' && type !== 'boolean' && typeof value !== 'number' && typeof value !== 'string' && typeof value !== 'boolean') {
18549
- return [new ValidationError(options.key, reportValue, 'stop domain value must be a number, string, or boolean')];
18233
+ return [new ValidationError(options2.key, reportValue, 'stop domain value must be a number, string, or boolean')];
18550
18234
  }
18551
18235
  if (type !== 'number' && functionType !== 'categorical') {
18552
18236
  let message = `number expected, ${ type } found`;
18553
- if (supportsPropertyExpression(functionValueSpec) && functionType === undefined) {
18237
+ if (supportsPropertyExpression(functionValueSpec) && functionType === void 0) {
18554
18238
  message += '\nIf you intended to use a categorical function, specify `"type": "categorical"`.';
18555
18239
  }
18556
- return [new ValidationError(options.key, reportValue, message)];
18240
+ return [new ValidationError(options2.key, reportValue, message)];
18557
18241
  }
18558
18242
  if (functionType === 'categorical' && type === 'number' && (typeof value !== 'number' || !isFinite(value) || Math.floor(value) !== value)) {
18559
- return [new ValidationError(options.key, reportValue, `integer expected, found ${ String(value) }`)];
18243
+ return [new ValidationError(options2.key, reportValue, `integer expected, found ${ String(value) }`)];
18560
18244
  }
18561
- if (functionType !== 'categorical' && type === 'number' && typeof value === 'number' && typeof previousStopDomainValue === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) {
18562
- return [new ValidationError(options.key, reportValue, 'stop domain values must appear in ascending order')];
18245
+ if (functionType !== 'categorical' && type === 'number' && typeof value === 'number' && typeof previousStopDomainValue === 'number' && previousStopDomainValue !== void 0 && value < previousStopDomainValue) {
18246
+ return [new ValidationError(options2.key, reportValue, 'stop domain values must appear in ascending order')];
18563
18247
  } else {
18564
18248
  previousStopDomainValue = value;
18565
18249
  }
18566
18250
  if (functionType === 'categorical' && value in stopDomainValues) {
18567
- return [new ValidationError(options.key, reportValue, 'stop domain values must be unique')];
18251
+ return [new ValidationError(options2.key, reportValue, 'stop domain values must be unique')];
18568
18252
  } else {
18569
18253
  stopDomainValues[value] = true;
18570
18254
  }
18571
18255
  return [];
18572
18256
  }
18573
- function validateFunctionDefault(options) {
18257
+ function validateFunctionDefault(options2) {
18574
18258
  return validate({
18575
- key: options.key,
18576
- value: options.value,
18259
+ key: options2.key,
18260
+ value: options2.value,
18577
18261
  valueSpec: functionValueSpec,
18578
- style: options.style,
18579
- styleSpec: options.styleSpec
18262
+ style: options2.style,
18263
+ styleSpec: options2.styleSpec
18580
18264
  });
18581
18265
  }
18582
18266
  }
18583
18267
 
18584
- //
18585
18268
  function validateExpression(options) {
18586
18269
  const expression = (options.expressionContext === 'property' ? createPropertyExpression : createExpression)(deepUnbundle(options.value), options.valueSpec);
18587
18270
  if (expression.result === 'error') {
@@ -18613,7 +18296,8 @@ function validateExpression(options) {
18613
18296
  return [];
18614
18297
  }
18615
18298
  function disallowedFilterParameters(e, options) {
18616
- const disallowedParameters = new Set([
18299
+ const disallowedParameters = /* @__PURE__ */
18300
+ new Set([
18617
18301
  'zoom',
18618
18302
  'feature-state',
18619
18303
  'pitch',
@@ -18639,7 +18323,6 @@ function disallowedFilterParameters(e, options) {
18639
18323
  return errors;
18640
18324
  }
18641
18325
 
18642
- //
18643
18326
  function validateBoolean(options) {
18644
18327
  const value = options.value;
18645
18328
  const key = options.key;
@@ -18650,7 +18333,6 @@ function validateBoolean(options) {
18650
18333
  return [];
18651
18334
  }
18652
18335
 
18653
- //
18654
18336
  function validateColor(options) {
18655
18337
  const key = options.key;
18656
18338
  const value = options.value;
@@ -18664,19 +18346,16 @@ function validateColor(options) {
18664
18346
  return [];
18665
18347
  }
18666
18348
 
18667
- //
18668
18349
  function validateEnum(options) {
18669
18350
  const key = options.key;
18670
18351
  const value = options.value;
18671
18352
  const valueSpec = options.valueSpec;
18672
18353
  const errors = [];
18673
18354
  if (Array.isArray(valueSpec.values)) {
18674
- // <=v7
18675
18355
  if (valueSpec.values.indexOf(unbundle(value)) === -1) {
18676
18356
  errors.push(new ValidationError(key, value, `expected one of [${ valueSpec.values.join(', ') }], ${ JSON.stringify(value) } found`));
18677
18357
  }
18678
18358
  } else {
18679
- // >=v8
18680
18359
  if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) {
18681
18360
  errors.push(new ValidationError(key, value, `expected one of [${ Object.keys(valueSpec.values).join(', ') }], ${ JSON.stringify(value) } found`));
18682
18361
  }
@@ -18684,10 +18363,8 @@ function validateEnum(options) {
18684
18363
  return errors;
18685
18364
  }
18686
18365
 
18687
- //
18688
18366
  function validateFilter(options) {
18689
18367
  if (isExpressionFilter(deepUnbundle(options.value))) {
18690
- // We default to a layerType of `fill` because that points to a non-dynamic filter definition within the style-spec.
18691
18368
  const layerType = options.layerType || 'fill';
18692
18369
  return validateExpression(extend({}, options, {
18693
18370
  expressionContext: 'filter',
@@ -18724,13 +18401,11 @@ function validateNonExpressionFilter(options) {
18724
18401
  if (value.length >= 2 && unbundle(value[1]) === '$type') {
18725
18402
  errors.push(new ValidationError(key, value, `"$type" cannot be use with operator "${ value[0] }"`));
18726
18403
  }
18727
- /* falls through */
18728
18404
  case '==':
18729
18405
  case '!=':
18730
18406
  if (value.length !== 3) {
18731
18407
  errors.push(new ValidationError(key, value, `filter array for operator "${ value[0] }" must have 3 elements`));
18732
18408
  }
18733
- /* falls through */
18734
18409
  case 'in':
18735
18410
  case '!in':
18736
18411
  if (value.length >= 2) {
@@ -18779,7 +18454,6 @@ function validateNonExpressionFilter(options) {
18779
18454
  return errors;
18780
18455
  }
18781
18456
 
18782
- //
18783
18457
  function validateProperty(options, propertyType) {
18784
18458
  const key = options.key;
18785
18459
  const style = options.style;
@@ -18807,7 +18481,8 @@ function validateProperty(options, propertyType) {
18807
18481
  let tokenMatch;
18808
18482
  if (getType(value) === 'string' && supportsPropertyExpression(valueSpec) && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) {
18809
18483
  const example = `\`{ "type": "identity", "property": ${ tokenMatch ? JSON.stringify(tokenMatch[1]) : '"_"' } }\``;
18810
- return [new ValidationError(key, value, `"${ propertyKey }" does not support interpolation syntax\n` + `Use an identity property function instead: ${ example }.`)];
18484
+ return [new ValidationError(key, value, `"${ propertyKey }" does not support interpolation syntax
18485
+ Use an identity property function instead: ${ example }.`)];
18811
18486
  }
18812
18487
  const errors = [];
18813
18488
  if (options.layerType === 'symbol') {
@@ -18819,7 +18494,6 @@ function validateProperty(options, propertyType) {
18819
18494
  }
18820
18495
  } else if (options.layerType === 'model' && propertyType === 'paint' && layer && layer.layout && layer.layout.hasOwnProperty('model-id')) {
18821
18496
  if (supportsPropertyExpression(valueSpec) && (supportsLightExpression(valueSpec) || supportsZoomExpression(valueSpec))) {
18822
- // Performance related style spec limitation: zoom and light expressions are not allowed for e.g. trees.
18823
18497
  const expression = createPropertyExpression(deepUnbundle(value), valueSpec);
18824
18498
  const expressionObj = expression.value.expression || expression.value._styleExpression.expression;
18825
18499
  if (expressionObj && !isGlobalPropertyConstant(expressionObj, ['measure-light'])) {
@@ -18835,23 +18509,21 @@ function validateProperty(options, propertyType) {
18835
18509
  valueSpec,
18836
18510
  style,
18837
18511
  styleSpec,
18512
+ // @ts-expect-error - TS2353 - Object literal may only specify known properties, and 'expressionContext' does not exist in type 'ValidationOptions'.
18838
18513
  expressionContext: 'property',
18839
18514
  propertyType,
18840
18515
  propertyKey
18841
18516
  }));
18842
18517
  }
18843
18518
 
18844
- //
18845
18519
  function validatePaintProperty(options) {
18846
18520
  return validateProperty(options, 'paint');
18847
18521
  }
18848
18522
 
18849
- //
18850
18523
  function validateLayoutProperty(options) {
18851
18524
  return validateProperty(options, 'layout');
18852
18525
  }
18853
18526
 
18854
- //
18855
18527
  function validateLayer(options) {
18856
18528
  let errors = [];
18857
18529
  const layer = options.value;
@@ -18868,7 +18540,6 @@ function validateLayer(options) {
18868
18540
  for (let i = 0; i < options.arrayIndex; i++) {
18869
18541
  const otherLayer = style.layers[i];
18870
18542
  if (unbundle(otherLayer.id) === layerId) {
18871
- // $FlowFixMe[prop-missing] - id.__line__ is added dynamically during the readStyle step
18872
18543
  errors.push(new ValidationError(key, layer.id, `duplicate layer id "${ layer.id }", previously used at line ${ otherLayer.id.__line__ }`));
18873
18544
  }
18874
18545
  }
@@ -18886,13 +18557,13 @@ function validateLayer(options) {
18886
18557
  }
18887
18558
  });
18888
18559
  let parent;
18889
- style.layers.forEach(layer => {
18890
- if (unbundle(layer.id) === ref)
18891
- parent = layer;
18560
+ style.layers.forEach(layer2 => {
18561
+ if (unbundle(layer2.id) === ref)
18562
+ parent = layer2;
18892
18563
  });
18893
18564
  if (!parent) {
18894
18565
  if (typeof ref === 'string')
18895
- errors.push(new ValidationError(key, layer.ref, `ref layer "${ ref }" not found`)); // $FlowFixMe[prop-missing] - ref is not defined on the LayerSpecification subtypes
18566
+ errors.push(new ValidationError(key, layer.ref, `ref layer "${ ref }" not found`));
18896
18567
  } else if (parent.ref) {
18897
18568
  errors.push(new ValidationError(key, layer.ref, 'ref cannot reference another ref layer'));
18898
18569
  } else {
@@ -18918,11 +18589,11 @@ function validateLayer(options) {
18918
18589
  'raster',
18919
18590
  'raster-particle'
18920
18591
  ].includes(type)) {
18921
- errors.push(new ValidationError(key, layer.source, `raster-array source can only be used with layer type \'raster\'.`));
18592
+ errors.push(new ValidationError(key, layer.source, `raster-array source can only be used with layer type 'raster'.`));
18922
18593
  } else if (type === 'line' && layer.paint && (layer.paint['line-gradient'] || layer.paint['line-trim-offset']) && (sourceType !== 'geojson' || !source.lineMetrics)) {
18923
18594
  errors.push(new ValidationError(key, layer, `layer "${ layer.id }" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`));
18924
18595
  } else if (type === 'raster-particle' && sourceType !== 'raster-array') {
18925
- errors.push(new ValidationError(key, layer.source, `layer "${ layer.id }" requires a \'raster-array\' source.`));
18596
+ errors.push(new ValidationError(key, layer.source, `layer "${ layer.id }" requires a 'raster-array' source.`));
18926
18597
  }
18927
18598
  }
18928
18599
  }
@@ -18945,42 +18616,45 @@ function validateLayer(options) {
18945
18616
  valueSpec: styleSpec.layer.type,
18946
18617
  style: options.style,
18947
18618
  styleSpec: options.styleSpec,
18619
+ // @ts-expect-error - TS2353 - Object literal may only specify known properties, and 'object' does not exist in type 'ValidationOptions'.
18948
18620
  object: layer,
18949
18621
  objectKey: 'type'
18950
18622
  });
18951
18623
  },
18952
- filter(options) {
18953
- return validateFilter(extend({ layerType: type }, options));
18624
+ filter(options2) {
18625
+ return validateFilter(extend({ layerType: type }, options2));
18954
18626
  },
18955
- layout(options) {
18627
+ layout(options2) {
18956
18628
  return validateObject({
18629
+ // @ts-expect-error - TS2353 - Object literal may only specify known properties, and 'layer' does not exist in type 'Options'.
18957
18630
  layer,
18958
- key: options.key,
18959
- value: options.value,
18631
+ key: options2.key,
18632
+ value: options2.value,
18960
18633
  valueSpec: {},
18961
- style: options.style,
18962
- styleSpec: options.styleSpec,
18634
+ style: options2.style,
18635
+ styleSpec: options2.styleSpec,
18963
18636
  objectElementValidators: {
18964
- '*'(options) {
18965
- return validateLayoutProperty(extend({ layerType: type }, options));
18637
+ '*'(options3) {
18638
+ return validateLayoutProperty(extend({ layerType: type }, options3));
18966
18639
  }
18967
18640
  }
18968
18641
  });
18969
18642
  },
18970
- paint(options) {
18643
+ paint(options2) {
18971
18644
  return validateObject({
18645
+ // @ts-expect-error - TS2353 - Object literal may only specify known properties, and 'layer' does not exist in type 'Options'.
18972
18646
  layer,
18973
- key: options.key,
18974
- value: options.value,
18647
+ key: options2.key,
18648
+ value: options2.value,
18975
18649
  valueSpec: {},
18976
- style: options.style,
18977
- styleSpec: options.styleSpec,
18650
+ style: options2.style,
18651
+ styleSpec: options2.styleSpec,
18978
18652
  objectElementValidators: {
18979
- '*'(options) {
18653
+ '*'(options3) {
18980
18654
  return validatePaintProperty(extend({
18981
18655
  layerType: type,
18982
18656
  layer
18983
- }, options));
18657
+ }, options3));
18984
18658
  }
18985
18659
  }
18986
18660
  });
@@ -18990,7 +18664,6 @@ function validateLayer(options) {
18990
18664
  return errors;
18991
18665
  }
18992
18666
 
18993
- //
18994
18667
  function validateString(options) {
18995
18668
  const value = options.value;
18996
18669
  const key = options.key;
@@ -19001,7 +18674,6 @@ function validateString(options) {
19001
18674
  return [];
19002
18675
  }
19003
18676
 
19004
- //
19005
18677
  const objectElementValidators = { promoteId: validatePromoteId };
19006
18678
  function validateSource(options) {
19007
18679
  const value = options.value;
@@ -19125,12 +18797,10 @@ function validatePromoteId({key, value}) {
19125
18797
  }
19126
18798
  }
19127
18799
 
19128
- //
19129
- // Allow any URL, use dummy base, if it's a relative URL
19130
18800
  function isValidUrl(str, allowRelativeUrls) {
19131
18801
  const isRelative = str.indexOf('://') === -1;
19132
18802
  try {
19133
- new URL(str, isRelative && allowRelativeUrls ? 'http://example.com' : undefined);
18803
+ new URL(str, isRelative && allowRelativeUrls ? 'http://example.com' : void 0);
19134
18804
  return true;
19135
18805
  } catch (_) {
19136
18806
  return false;
@@ -19153,7 +18823,6 @@ function validateModel(options) {
19153
18823
  return errors;
19154
18824
  }
19155
18825
 
19156
- //
19157
18826
  function validateLight(options) {
19158
18827
  const light = options.value;
19159
18828
  const styleSpec = options.styleSpec;
@@ -19161,7 +18830,7 @@ function validateLight(options) {
19161
18830
  const style = options.style;
19162
18831
  let errors = [];
19163
18832
  const rootType = getType(light);
19164
- if (light === undefined) {
18833
+ if (light === void 0) {
19165
18834
  return errors;
19166
18835
  } else if (rootType !== 'object') {
19167
18836
  errors = errors.concat([new ValidationError('light', light, `object expected, ${ rootType } found`)]);
@@ -19192,7 +18861,6 @@ function validateLight(options) {
19192
18861
  return errors;
19193
18862
  }
19194
18863
 
19195
- //
19196
18864
  function validateLights(options) {
19197
18865
  const light = options.value;
19198
18866
  let errors = [];
@@ -19209,21 +18877,20 @@ function validateLights(options) {
19209
18877
  const key = options.key;
19210
18878
  const style = options.style;
19211
18879
  const lights = options.style.lights;
19212
- for (const key of [
18880
+ for (const key2 of [
19213
18881
  'type',
19214
18882
  'id'
19215
18883
  ]) {
19216
- if (!(key in light)) {
19217
- errors = errors.concat([new ValidationError('light-3d', light, `missing property ${ key } on light`)]);
18884
+ if (!(key2 in light)) {
18885
+ errors = errors.concat([new ValidationError('light-3d', light, `missing property ${ key2 } on light`)]);
19218
18886
  return errors;
19219
18887
  }
19220
18888
  }
19221
18889
  if (light.type && lights) {
19222
18890
  for (let i = 0; i < options.arrayIndex; i++) {
19223
- const lightType = unbundle(light.type);
18891
+ const lightType2 = unbundle(light.type);
19224
18892
  const otherLight = lights[i];
19225
- if (unbundle(otherLight.type) === lightType) {
19226
- // $FlowFixMe[prop-missing] - id.__line__ is added dynamically during the readStyle step
18893
+ if (unbundle(otherLight.type) === lightType2) {
19227
18894
  errors.push(new ValidationError(key, light.id, `duplicate light type "${ light.type }", previously defined at line ${ otherLight.id.__line__ }`));
19228
18895
  }
19229
18896
  }
@@ -19234,9 +18901,9 @@ function validateLights(options) {
19234
18901
  return errors;
19235
18902
  }
19236
18903
  const lightPropertySpec = styleSpec[lightType];
19237
- for (const key in light) {
19238
- if (key === 'properties') {
19239
- const properties = light[key];
18904
+ for (const key2 in light) {
18905
+ if (key2 === 'properties') {
18906
+ const properties = light[key2];
19240
18907
  const propertiesType = getType(properties);
19241
18908
  if (propertiesType !== 'object') {
19242
18909
  errors = errors.concat([new ValidationError('properties', properties, `object expected, ${ propertiesType } found`)]);
@@ -19256,32 +18923,31 @@ function validateLights(options) {
19256
18923
  }
19257
18924
  }
19258
18925
  } else {
19259
- const transitionMatch = key.match(/^(.*)-transition$/);
18926
+ const transitionMatch = key2.match(/^(.*)-transition$/);
19260
18927
  if (transitionMatch && lightSpec[transitionMatch[1]] && lightSpec[transitionMatch[1]].transition) {
19261
18928
  errors = errors.concat(validate({
19262
- key,
19263
- value: light[key],
18929
+ key: key2,
18930
+ value: light[key2],
19264
18931
  valueSpec: styleSpec.transition,
19265
18932
  style,
19266
18933
  styleSpec
19267
18934
  }));
19268
- } else if (lightSpec[key]) {
18935
+ } else if (lightSpec[key2]) {
19269
18936
  errors = errors.concat(validate({
19270
- key,
19271
- value: light[key],
19272
- valueSpec: lightSpec[key],
18937
+ key: key2,
18938
+ value: light[key2],
18939
+ valueSpec: lightSpec[key2],
19273
18940
  style,
19274
18941
  styleSpec
19275
18942
  }));
19276
18943
  } else {
19277
- errors = errors.concat([new ValidationWarning(key, light[key], `unknown property "${ key }"`)]);
18944
+ errors = errors.concat([new ValidationWarning(key2, light[key2], `unknown property "${ key2 }"`)]);
19278
18945
  }
19279
18946
  }
19280
18947
  }
19281
18948
  return errors;
19282
18949
  }
19283
18950
 
19284
- //
19285
18951
  function validateTerrain(options) {
19286
18952
  const terrain = options.value;
19287
18953
  const key = options.key;
@@ -19290,7 +18956,7 @@ function validateTerrain(options) {
19290
18956
  const terrainSpec = styleSpec.terrain;
19291
18957
  let errors = [];
19292
18958
  const rootType = getType(terrain);
19293
- if (terrain === undefined) {
18959
+ if (terrain === void 0) {
19294
18960
  return errors;
19295
18961
  } else if (rootType === 'null') {
19296
18962
  return errors;
@@ -19298,26 +18964,26 @@ function validateTerrain(options) {
19298
18964
  errors = errors.concat([new ValidationError('terrain', terrain, `object expected, ${ rootType } found`)]);
19299
18965
  return errors;
19300
18966
  }
19301
- for (const key in terrain) {
19302
- const transitionMatch = key.match(/^(.*)-transition$/);
18967
+ for (const key2 in terrain) {
18968
+ const transitionMatch = key2.match(/^(.*)-transition$/);
19303
18969
  if (transitionMatch && terrainSpec[transitionMatch[1]] && terrainSpec[transitionMatch[1]].transition) {
19304
18970
  errors = errors.concat(validate({
19305
- key,
19306
- value: terrain[key],
18971
+ key: key2,
18972
+ value: terrain[key2],
19307
18973
  valueSpec: styleSpec.transition,
19308
18974
  style,
19309
18975
  styleSpec
19310
18976
  }));
19311
- } else if (terrainSpec[key]) {
18977
+ } else if (terrainSpec[key2]) {
19312
18978
  errors = errors.concat(validate({
19313
- key,
19314
- value: terrain[key],
19315
- valueSpec: terrainSpec[key],
18979
+ key: key2,
18980
+ value: terrain[key2],
18981
+ valueSpec: terrainSpec[key2],
19316
18982
  style,
19317
18983
  styleSpec
19318
18984
  }));
19319
18985
  } else {
19320
- errors = errors.concat([new ValidationWarning(key, terrain[key], `unknown property "${ key }"`)]);
18986
+ errors = errors.concat([new ValidationWarning(key2, terrain[key2], `unknown property "${ key2 }"`)]);
19321
18987
  }
19322
18988
  }
19323
18989
  if (!terrain.source) {
@@ -19334,7 +19000,6 @@ function validateTerrain(options) {
19334
19000
  return errors;
19335
19001
  }
19336
19002
 
19337
- //
19338
19003
  function validateFog(options) {
19339
19004
  const fog = options.value;
19340
19005
  const style = options.style;
@@ -19342,7 +19007,7 @@ function validateFog(options) {
19342
19007
  const fogSpec = styleSpec.fog;
19343
19008
  let errors = [];
19344
19009
  const rootType = getType(fog);
19345
- if (fog === undefined) {
19010
+ if (fog === void 0) {
19346
19011
  return errors;
19347
19012
  } else if (rootType !== 'object') {
19348
19013
  errors = errors.concat([new ValidationError('fog', fog, `object expected, ${ rootType } found`)]);
@@ -19373,7 +19038,6 @@ function validateFog(options) {
19373
19038
  return errors;
19374
19039
  }
19375
19040
 
19376
- //
19377
19041
  function validateFormatted(options) {
19378
19042
  if (validateString(options).length === 0) {
19379
19043
  return [];
@@ -19381,7 +19045,6 @@ function validateFormatted(options) {
19381
19045
  return validateExpression(options);
19382
19046
  }
19383
19047
 
19384
- //
19385
19048
  function validateImage(options) {
19386
19049
  if (validateString(options).length === 0) {
19387
19050
  return [];
@@ -19389,7 +19052,6 @@ function validateImage(options) {
19389
19052
  return validateExpression(options);
19390
19053
  }
19391
19054
 
19392
- //
19393
19055
  function validateProjection(options) {
19394
19056
  const projection = options.value;
19395
19057
  const styleSpec = options.styleSpec;
@@ -19413,7 +19075,6 @@ function validateProjection(options) {
19413
19075
  return errors;
19414
19076
  }
19415
19077
 
19416
- //
19417
19078
  const VALIDATORS = {
19418
19079
  '*'() {
19419
19080
  return [];
@@ -19439,15 +19100,6 @@ const VALIDATORS = {
19439
19100
  'projection': validateProjection,
19440
19101
  'import': validateImport
19441
19102
  };
19442
- // Main recursive validation function. Tracks:
19443
- //
19444
- // - key: string representing location of validation in style tree. Used only
19445
- // for more informative error reporting.
19446
- // - value: current value from style being evaluated. May be anything from a
19447
- // high level object that needs to be descended into deeper or a simple
19448
- // scalar value.
19449
- // - valueSpec: current spec being evaluated. Tracks value.
19450
- // - styleSpec: current full spec being evaluated.
19451
19103
  function validate(options, arrayAsExpression = false) {
19452
19104
  const value = options.value;
19453
19105
  const valueSpec = options.valueSpec;
@@ -19459,7 +19111,6 @@ function validate(options, arrayAsExpression = false) {
19459
19111
  } else if (valueSpec.type && VALIDATORS[valueSpec.type]) {
19460
19112
  const valid = VALIDATORS[valueSpec.type](options);
19461
19113
  if (arrayAsExpression === true && valid.length > 0 && getType(options.value) === 'array') {
19462
- // Try to validate as an expression
19463
19114
  return validateExpression(options);
19464
19115
  } else {
19465
19116
  return valid;
@@ -19470,7 +19121,6 @@ function validate(options, arrayAsExpression = false) {
19470
19121
  }
19471
19122
  }
19472
19123
 
19473
- //
19474
19124
  function validateGlyphsURL (options) {
19475
19125
  const value = options.value;
19476
19126
  const key = options.key;
@@ -19486,7 +19136,6 @@ function validateGlyphsURL (options) {
19486
19136
  return errors;
19487
19137
  }
19488
19138
 
19489
- //
19490
19139
  function validateStyle$2(style, styleSpec = v8, options = {}) {
19491
19140
  const errors = validate({
19492
19141
  key: options.key || '',
@@ -19494,6 +19143,7 @@ function validateStyle$2(style, styleSpec = v8, options = {}) {
19494
19143
  valueSpec: styleSpec.$root,
19495
19144
  styleSpec,
19496
19145
  style,
19146
+ // @ts-expect-error - TS2353 - Object literal may only specify known properties, and 'objectElementValidators' does not exist in type 'ValidationOptions'.
19497
19147
  objectElementValidators: {
19498
19148
  glyphs: validateGlyphsURL,
19499
19149
  '*': () => []
@@ -19502,22 +19152,6 @@ function validateStyle$2(style, styleSpec = v8, options = {}) {
19502
19152
  return errors;
19503
19153
  }
19504
19154
 
19505
- //
19506
- /**
19507
- * Validate a Mapbox GL style against the style specification. This entrypoint,
19508
- * `mapbox-gl-style-spec/lib/validate_style.min`, is designed to produce as
19509
- * small a browserify bundle as possible by omitting unnecessary functionality
19510
- * and legacy style specifications.
19511
- *
19512
- * @private
19513
- * @param {Object} style The style to be validated.
19514
- * @param {Object} [styleSpec] The style specification to validate against.
19515
- * If omitted, the latest style spec is used.
19516
- * @returns {Array<ValidationError>}
19517
- * @example
19518
- * var validate = require('mapbox-gl-style-spec/lib/validate_style.min');
19519
- * var errors = validate(style);
19520
- */
19521
19155
  function validateStyle$1(style, styleSpec = v8) {
19522
19156
  const errors = validateStyle$2(style, styleSpec);
19523
19157
  return sortErrors(errors);
@@ -20588,9 +20222,8 @@ var jsonlint$1 = {};
20588
20222
 
20589
20223
  var jsonlint = /*@__PURE__*/getDefaultExportFromCjs(jsonlint$1);
20590
20224
 
20591
- //
20592
20225
  function readStyle(style) {
20593
- if (style instanceof String || typeof style === 'string' || style instanceof Buffer) {
20226
+ if (style instanceof String || typeof style === 'string' || ArrayBuffer.isView(style)) {
20594
20227
  try {
20595
20228
  return jsonlint.parse(style.toString());
20596
20229
  } catch (e) {
@@ -20600,22 +20233,6 @@ function readStyle(style) {
20600
20233
  return style;
20601
20234
  }
20602
20235
 
20603
- //
20604
- /**
20605
- * Validate a Mapbox GL style against the style specification.
20606
- *
20607
- * @private
20608
- * @alias validate
20609
- * @param {Object|String|Buffer} style The style to be validated. If a `String`
20610
- * or `Buffer` is provided, the returned errors will contain line numbers.
20611
- * @param {Object} [styleSpec] The style specification to validate against.
20612
- * If omitted, the spec version is inferred from the stylesheet.
20613
- * @returns {Array<ValidationError|ParsingError>}
20614
- * @example
20615
- * var validate = require('mapbox-gl-style-spec').validate;
20616
- * var style = fs.readFileSync('./style.json', 'utf8');
20617
- * var errors = validate(style);
20618
- */
20619
20236
  function validateStyle(style, styleSpec = v8) {
20620
20237
  let s = style;
20621
20238
  try {
@@ -20626,7 +20243,6 @@ function validateStyle(style, styleSpec = v8) {
20626
20243
  return validateStyle$1(s, styleSpec);
20627
20244
  }
20628
20245
 
20629
- //
20630
20246
  const SUPPORTED_SPEC_VERSION = 8;
20631
20247
  const MAX_SOURCES_IN_STYLE = 15;
20632
20248
  function isValid(value, regex) {
@@ -20652,7 +20268,8 @@ function getAllowedKeyErrors(obj, keys, path) {
20652
20268
  });
20653
20269
  return errors;
20654
20270
  }
20655
- const acceptedSourceTypes = new Set([
20271
+ const acceptedSourceTypes = /* @__PURE__ */
20272
+ new Set([
20656
20273
  'vector',
20657
20274
  'raster',
20658
20275
  'raster-dem',
@@ -20662,28 +20279,15 @@ const acceptedSourceTypes = new Set([
20662
20279
  ]);
20663
20280
  function getSourceErrors(source, i) {
20664
20281
  const errors = [];
20665
- /*
20666
- * Inlined sources are not supported by the Mapbox Styles API, so only
20667
- * "type", "url", and "tileSize" properties are valid
20668
- */
20669
20282
  const sourceKeys = [
20670
20283
  'type',
20671
20284
  'url',
20672
20285
  'tileSize'
20673
20286
  ];
20674
20287
  errors.push(...getAllowedKeyErrors(source, sourceKeys, 'source'));
20675
- /*
20676
- * "type" is required and must be one of "vector", "raster", "raster-dem", "raster-array"
20677
- */
20678
20288
  if (!acceptedSourceTypes.has(String(source.type))) {
20679
20289
  errors.push(new ValidationError(`sources[${ i }].type`, source.type, `Expected one of [${ Array.from(acceptedSourceTypes).join(', ') }]`));
20680
20290
  }
20681
- /*
20682
- * "source" is required. Valid examples:
20683
- * mapbox://mapbox.abcd1234
20684
- * mapbox://penny.abcd1234
20685
- * mapbox://mapbox.abcd1234,penny.abcd1234
20686
- */
20687
20291
  const sourceUrlPattern = /^mapbox:\/\/([^/]*)$/;
20688
20292
  if (!source.url || !isValid(source.url, sourceUrlPattern)) {
20689
20293
  errors.push(new ValidationError(`sources[${ i }].url`, source.url, 'Expected a valid Mapbox tileset url'));
@@ -20702,7 +20306,6 @@ function getSourcesErrors(sources) {
20702
20306
  let sourcesCount = 0;
20703
20307
  Object.keys(sources).forEach((s, i) => {
20704
20308
  const sourceErrors = getSourceErrors(sources[s], i);
20705
- // If source has errors, skip counting
20706
20309
  if (!sourceErrors.length) {
20707
20310
  sourcesCount = sourcesCount + getSourceCount(sources[s]);
20708
20311
  }
@@ -20716,8 +20319,8 @@ function getSourcesErrors(sources) {
20716
20319
  function getImportErrors(imports = []) {
20717
20320
  let errors = [];
20718
20321
  let sourcesCount = 0;
20719
- const validateImports = (imports = []) => {
20720
- for (const importSpec of imports) {
20322
+ const validateImports = (imports2 = []) => {
20323
+ for (const importSpec of imports2) {
20721
20324
  const style = importSpec.data;
20722
20325
  if (!style)
20723
20326
  continue;
@@ -20743,14 +20346,6 @@ function getImportErrors(imports = []) {
20743
20346
  }
20744
20347
  function getRootErrors(style, specKeys) {
20745
20348
  const errors = [];
20746
- /*
20747
- * The following keys are optional but fully managed by the Mapbox Styles
20748
- * API. Values on stylesheet on POST or PATCH will be ignored: "owner",
20749
- * "id", "cacheControl", "draft", "created", "modified", "protected"
20750
- *
20751
- * The following keys are optional. The Mapbox Styles API respects value on
20752
- * stylesheet on PATCH, but ignores the value on POST: "visibility"
20753
- */
20754
20349
  const optionalRootProperties = [
20755
20350
  'owner',
20756
20351
  'id',
@@ -20771,49 +20366,23 @@ function getRootErrors(style, specKeys) {
20771
20366
  if (style.version > SUPPORTED_SPEC_VERSION || style.version < SUPPORTED_SPEC_VERSION) {
20772
20367
  errors.push(new ValidationError('version', style.version, `Style version must be ${ SUPPORTED_SPEC_VERSION }`));
20773
20368
  }
20774
- /*
20775
- * "glyphs" is optional. If present, valid examples:
20776
- * mapbox://fonts/penny/{fontstack}/{range}.pbf
20777
- * mapbox://fonts/mapbox/{fontstack}/{range}.pbf
20778
- */
20779
20369
  const glyphUrlPattern = /^mapbox:\/\/fonts\/([^/]*)\/{fontstack}\/{range}.pbf$/;
20780
20370
  if (!isValid(style.glyphs, glyphUrlPattern)) {
20781
20371
  errors.push(new ValidationError('glyphs', style.glyphs, 'Styles must reference glyphs hosted by Mapbox'));
20782
20372
  }
20783
- /*
20784
- * "sprite" is optional. If present, valid examples:
20785
- * mapbox://sprites/penny/abcd1234
20786
- * mapbox://sprites/mapbox/abcd1234/draft
20787
- * mapbox://sprites/cyrus/abcd1234/abcd1234
20788
- */
20789
20373
  const spriteUrlPattern = /^mapbox:\/\/sprites\/([^/]*)\/([^/]*)\/?([^/]*)?$/;
20790
20374
  if (!isValid(style.sprite, spriteUrlPattern)) {
20791
20375
  errors.push(new ValidationError('sprite', style.sprite, 'Styles must reference sprites hosted by Mapbox'));
20792
20376
  }
20793
- /*
20794
- * "visibility" is optional. If present, valid examples:
20795
- * "private"
20796
- * "public"
20797
- */
20798
20377
  const visibilityPattern = /^(public|private)$/;
20799
20378
  if (!isValid(style.visibility, visibilityPattern)) {
20800
20379
  errors.push(new ValidationError('visibility', style.visibility, 'Style visibility must be public or private'));
20801
20380
  }
20802
- if (style.protected !== undefined && getType(style.protected) !== 'boolean') {
20381
+ if (style.protected !== void 0 && getType(style.protected) !== 'boolean') {
20803
20382
  errors.push(new ValidationError('protected', style.protected, 'Style protection must be true or false'));
20804
20383
  }
20805
20384
  return errors;
20806
20385
  }
20807
- /**
20808
- * Validate a Mapbox GL style against the style specification and check for
20809
- * compatibility with the Mapbox Styles API.
20810
- *
20811
- * @param {Object} style The style to be validated.
20812
- * @returns {Array<ValidationError>}
20813
- * @example
20814
- * var validateMapboxApiSupported = require('mapbox-gl-style-spec/lib/validate_style_mapbox_api_supported.js');
20815
- * var errors = validateMapboxApiSupported(style);
20816
- */
20817
20386
  function validateMapboxApiSupported(style, styleSpec = v8) {
20818
20387
  let s = style;
20819
20388
  try {
@@ -20837,7 +20406,6 @@ function validateMapboxApiSupported(style, styleSpec = v8) {
20837
20406
  return errors;
20838
20407
  }
20839
20408
 
20840
- //
20841
20409
  const expression = {
20842
20410
  StyleExpression,
20843
20411
  isExpression,
@@ -20860,5 +20428,5 @@ const visit = {
20860
20428
  eachProperty
20861
20429
  };
20862
20430
 
20863
- export { Color$1 as Color, ParsingError, ValidationError, composite, convertFilter, derefLayers, diffStyles as diff, expression, createFilter as featureFilter, format, styleFunction as function, v8 as latest, migrate, v8, validateStyle as validate, validateMapboxApiSupported, visit };
20431
+ export { Color, ParsingError, ValidationError, composite, convertFilter, derefLayers, diffStyles as diff, expression, createFilter as featureFilter, format, styleFunction as function, v8 as latest, migrate, v8, validateStyle as validate, validateMapboxApiSupported, visit };
20864
20432
  //# sourceMappingURL=index.es.js.map