diff --git a/README.md b/README.md index b72fcac2..4ac63941 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,16 @@ pip install git+https://github.com/eodaGmbH/py-maplibregl@dev pip install "maplibre[all] @ git+https://github.com/eodaGmbH/py-maplibregl@dev" ``` -## Getting started +## Quickstart -```bash -docker run --rm -p 8050:8050 ghcr.io/eodagmbh/py-maplibregl/vancouver-blocks:latest +```python +from maplibre import Map, MapOptions + +m = Map(MapOptions(center=(-123.1256, 49.24658), zoom=9)) ``` +## Documentation + * [Basic usage](https://eodagmbh.github.io/py-maplibregl/) * [API Documentation](https://eodagmbh.github.io/py-maplibregl/api/map/) * [Examples](https://eodagmbh.github.io/py-maplibregl/examples/every_person_in_manhattan/) diff --git a/.github/workflows/docker-image-animation.yml b/_obsolete/github_workflows/docker-image-animation.yml similarity index 100% rename from .github/workflows/docker-image-animation.yml rename to _obsolete/github_workflows/docker-image-animation.yml diff --git a/.github/workflows/docker-image.yml b/_obsolete/github_workflows/docker-image.yml similarity index 100% rename from .github/workflows/docker-image.yml rename to _obsolete/github_workflows/docker-image.yml diff --git a/.github/workflows/docker-image2.yml b/_obsolete/github_workflows/docker-image2.yml similarity index 100% rename from .github/workflows/docker-image2.yml rename to _obsolete/github_workflows/docker-image2.yml diff --git a/docs/deckgl.md b/docs/deckgl.md new file mode 100644 index 00000000..38b91284 --- /dev/null +++ b/docs/deckgl.md @@ -0,0 +1,44 @@ +Deck.GL layers can be added to the map with `Map.add_deck_layers`. + +They are defined as a dictionary, where classes got the `@@type` prefix and getter props +the `@@=` prefix. They are inserted into the layer stack of the maplibre context. Therefore, +you can also pass a `beforeId` prop. + +Here is an example corresponding to the [Deck.GL GridLayer API Example](https://deck.gl/docs/api-reference/aggregation-layers/grid-layer): + +```python +grid_layer = { + "@@type": "GridLayer", # JS: new GridLayer + "id": "my-awsome-grid-layer", + "data": "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-bike-parking.json", + "extruded": True, + "getPosition": "@@=COORDINATES", # JS: d => d.COORDINATES + "getColorWeight": "@@=SPACES", # JS: d => d.SPACES + "getElevationWeight": "@@=SPACES", # JS: d => d.SPACES + "elevationScale": 4, + "cellSize": 200, + "pickable": True, + "beforeId": "first-labels-layer" # optional + } +``` + +The Code above will generate the following JavaScript code: + +```javascript +const gridLayer = new GridLayer({ + id: 'GridLayer', + data: 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-bike-parking.json', + extruded: true, + getPosition: d => d.COORDINATES, + getColorWeight: d => d.SPACES, + getElevationWeight: d => d.SPACES, + elevationScale: 4, + cellSize: 200, + pickable: true +}); +``` + +See also: + +- [Deck.GL Layer](../examples/deckgl_layer) +- [Deck.GL Multiple Layers](../examples/deckgl_multiple_layers) diff --git a/docs/examples/deckgl_layer/app.html b/docs/examples/deckgl_layer/app.html new file mode 100644 index 00000000..8c2db951 --- /dev/null +++ b/docs/examples/deckgl_layer/app.html @@ -0,0 +1,33 @@ + + + +My Awesome Map + + + + + + +
+ + + \ No newline at end of file diff --git a/docs/examples/deckgl_layer/app.py b/docs/examples/deckgl_layer/app.py new file mode 100644 index 00000000..128fc0f7 --- /dev/null +++ b/docs/examples/deckgl_layer/app.py @@ -0,0 +1,56 @@ +# Shiny Express App + +import json + +from maplibre import Map, MapOptions, render_maplibregl +from maplibre.basemaps import Carto +from maplibre.ui import use_deckgl + +# from shiny import reactive +from shiny.express import input, render, ui + +m = Map( + MapOptions( + style=Carto.POSITRON, + center=(-122.4, 37.74), + zoom=12, + hash=True, + pitch=40, + ) +) + + +deck_grid_layer = { + "@@type": "GridLayer", + "id": "GridLayer", + "data": "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-bike-parking.json", + "extruded": True, + "getPosition": "@@=COORDINATES", + "getColorWeight": "@@=SPACES", + "getElevationWeight": "@@=SPACES", + "elevationScale": 4, + "cellSize": 200, + "pickable": True, +} + +m.add_deck_layers([deck_grid_layer], tooltip="Number of points: {{ count }}") + +# Shiny Express +use_deckgl() + + +@render_maplibregl +def render_map(): + return m + + +@render.code +def picking_object(): + obj = input.render_map_layer_GridLayer() + print(obj) + return json.dumps(obj["points"], indent=2) if obj else "Pick a feature!" + + +if __name__ == "__main__": + with open("docs/examples/deckgl_layer/app.html", "w") as f: + f.write(m.to_html()) diff --git a/docs/examples/deckgl_layer/app_update_layer.py b/docs/examples/deckgl_layer/app_update_layer.py new file mode 100644 index 00000000..8a25e32e --- /dev/null +++ b/docs/examples/deckgl_layer/app_update_layer.py @@ -0,0 +1,78 @@ +# Shiny Express App + +import json + +from maplibre import Map, MapContext, MapOptions, render_maplibregl +from maplibre.basemaps import Carto +from maplibre.ui import use_deckgl +from shiny import reactive +from shiny.express import input, render, ui + +m = Map( + MapOptions( + style=Carto.POSITRON, + center=(-122.4, 37.74), + zoom=12, + hash=True, + pitch=40, + ) +) + +layer_id = "GridLayer" + +CELL_SIZES = [100, 200, 300] +DEFAULT_CELL_SIZE = CELL_SIZES[1] + + +def deck_grid_layer(cell_size: int = DEFAULT_CELL_SIZE): + return { + "@@type": layer_id, + "id": "GridLayer", + "data": "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-bike-parking.json", + "extruded": True, + "getPosition": "@@=COORDINATES", + "getColorWeight": "@@=SPACES", + "getElevationWeight": "@@=SPACES", + "elevationScale": 4, + "cellSize": cell_size, + "pickable": True, + } + + +tooltip = "Number of points: {{ count }}" +m.add_deck_layers([deck_grid_layer()], tooltip=tooltip) + +# Shiny Express +use_deckgl() + +ui.input_select( + "cell_size", "Cell size", choices=CELL_SIZES, selected=DEFAULT_CELL_SIZE +) +ui.input_action_button("update_layer", "Update layer") + + +@render_maplibregl +def render_map(): + return m + + +@render.code +def picking_object(): + obj = input.render_map_layer_GridLayer() + print(obj) + # return json.dumps(obj, indent=2) if obj else "Pick a feature!" + # return f"{obj['count']}" if obj else "Pick a feature!" + return json.dumps(obj["points"], indent=2) if obj else "Pick a feature!" + + +@reactive.Effect +@reactive.event(input.update_layer) +async def update_layer(): + print(input.update_layer()) + async with MapContext("render_map") as m: + m.set_deck_layers([deck_grid_layer(input.cell_size())], tooltip) + + +if __name__ == "__main__": + with open("docs/examples/deckgl_layer/app.html", "w") as f: + f.write(m.to_html()) diff --git a/docs/examples/deckgl_layer/column_layer.py b/docs/examples/deckgl_layer/column_layer.py new file mode 100644 index 00000000..c126ea72 --- /dev/null +++ b/docs/examples/deckgl_layer/column_layer.py @@ -0,0 +1,58 @@ +# Shiny Express App + +import json + +from maplibre import Map, MapOptions, render_maplibregl +from maplibre.basemaps import Carto +from maplibre.ui import use_deckgl + +# from shiny import reactive +from shiny.express import input, render, ui + +m = Map( + MapOptions( + style=Carto.POSITRON, + center=(-122.4, 37.74), + zoom=11, + hash=True, + pitch=40, + ) +) + + +deck_column_layer = { + "@@type": "ColumnLayer", + "id": "ColumnLayer", + "data": "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/hexagons.json", + "diskResolution": 12, + "extruded": True, + "radius": 250, + "elevationScale": 5000, + "getElevation": "@@=value", + "getFillColor": "@@=[48, 128, value * 255, 255]", + "getPosition": "@@=centroid", + "pickable": True, +} +tooltip = "Centroid: {{ centroid }}\nValue: {{ value }}" +m.add_deck_layers([deck_column_layer], tooltip=tooltip) + +# Shiny Express +use_deckgl() + + +@render_maplibregl +def render_map(): + return m + + +@render.code +def picking_object(): + obj = input.render_map_layer_ColumnLayer() + print(obj) + return obj.keys() + # return json.dumps(obj["points"], indent=2) if obj else "Pick a feature!" + + +if __name__ == "__main__": + with open("docs/examples/deckgl_layer/column_layer.html", "w") as f: + f.write(m.to_html()) diff --git a/docs/examples/deckgl_layer/index.md b/docs/examples/deckgl_layer/index.md new file mode 100644 index 00000000..895cc843 --- /dev/null +++ b/docs/examples/deckgl_layer/index.md @@ -0,0 +1,14 @@ + + + + +```python +-8<-- "deckgl_layer/app.py" +``` + +Run example: + +``` bash +# Run Shiny app +shiny run docs/examples/deckgl_layer/app.py +``` diff --git a/docs/examples/deckgl_layer/mixing_deck_and_maplibre_layers.py b/docs/examples/deckgl_layer/mixing_deck_and_maplibre_layers.py new file mode 100644 index 00000000..3babb132 --- /dev/null +++ b/docs/examples/deckgl_layer/mixing_deck_and_maplibre_layers.py @@ -0,0 +1,72 @@ +# Shiny Express App + +import requests as req +from maplibre import Layer, LayerType, Map, MapOptions, render_maplibregl +from maplibre.basemaps import Carto +from maplibre.sources import GeoJSONSource +from maplibre.ui import use_deckgl +from shiny.express import input, render, ui + +data = req.get( + "https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_airports.geojson" +).json() + +m = Map( + MapOptions( + style=Carto.POSITRON, + center=(0.45, 51.47), + zoom=4, + hash=True, + pitch=30, + ) +) + +maplibre_circle_layer = Layer( + type=LayerType.CIRCLE, + id="circles", + paint={ + "circle-color": "orange", + "circle-opacity": 0.7, + "circle-radius": ["-", 11, ["get", "scalerank"]], + }, + source=GeoJSONSource(data=data), +) + +deck_arc_layer = { + "@@type": "ArcLayer", + "id": "arcs", + "data": [ + feature + for feature in data["features"] + if feature["properties"]["scalerank"] < 4 + ], + "getSourcePosition": [-0.4531566, 51.4709959], # London + "getTargetPosition": "@@=geometry.coordinates", + "getSourceColor": [0, 128, 200], + "getTargetColor": [200, 0, 80], + "getWidth": 2, + "pickable": True, + "beforeId": "circles", +} + +m.add_layer(maplibre_circle_layer) +m.add_tooltip("circles", "name") +m.add_deck_layers( + [deck_arc_layer], + tooltip={ + "arcs": "gps_code: {{ properties.gps_code }}", + }, +) + +# Shiny Express +use_deckgl() + + +@render_maplibregl +def render_map(): + return m + + +if __name__ == "__main__": + with open("docs/examples/deckgl_layer/app.html", "w") as f: + f.write(m.to_html()) diff --git a/docs/examples/deckgl_layer/screen_grid_layer.py b/docs/examples/deckgl_layer/screen_grid_layer.py new file mode 100644 index 00000000..4552a625 --- /dev/null +++ b/docs/examples/deckgl_layer/screen_grid_layer.py @@ -0,0 +1,63 @@ +# Shiny Express App + +import json + +from maplibre import Map, MapOptions, render_maplibregl +from maplibre.basemaps import Carto +from maplibre.ui import use_deckgl + +# from shiny import reactive +from shiny.express import input, render, ui + +m = Map( + MapOptions( + style=Carto.POSITRON, + center=(-122.4, 37.74), + zoom=11, + hash=True, + pitch=40, + ) +) + + +deck_screen_grid_layer = { + "@@type": "ScreenGridLayer", + "id": "MyAwesomeScreenGridLayer", + "data": "https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/sf-bike-parking.json", + "cellSizePixels": 50, + "colorRange": [ + [0, 25, 0, 25], + [0, 85, 0, 85], + [0, 127, 0, 127], + [0, 170, 0, 170], + [0, 190, 0, 190], + [0, 255, 0, 255], + ], + "getPosition": "@@=COORDINATES", + "getWeight": "@@=SPACES", + "opacity": 0.8, + "pickable": True, + # "gpuAggregation": False, +} +tooltip = "{{ weight }}" +m.add_deck_layers([deck_screen_grid_layer], tooltip=tooltip) + +# Shiny Express +use_deckgl() + + +@render_maplibregl +def render_map(): + return m + + +@render.code +def picking_object(): + obj = input.render_map_layer_MyAwesomeScreenGridLayer() + print(obj) + return json.dumps(obj["points"], indent=2) if obj else "Pick a feature!" + + +if __name__ == "__main__": + with open("docs/examples/deckgl_layer/app.html", "w") as f: + f.write(m.to_html()) diff --git a/docs/examples/deckgl_multiple_layers/app.html b/docs/examples/deckgl_multiple_layers/app.html new file mode 100644 index 00000000..5755f2f8 --- /dev/null +++ b/docs/examples/deckgl_multiple_layers/app.html @@ -0,0 +1,33 @@ + + + +My Awesome Map + + + + + + +
+ + + \ No newline at end of file diff --git a/docs/examples/deckgl_multiple_layers/app.py b/docs/examples/deckgl_multiple_layers/app.py new file mode 100644 index 00000000..3dc8a585 --- /dev/null +++ b/docs/examples/deckgl_multiple_layers/app.py @@ -0,0 +1,71 @@ +# Shiny Express App + +import requests as req +from maplibre import Map, MapOptions, render_maplibregl +from maplibre.basemaps import Carto +from maplibre.ui import use_deckgl +from shiny.express import input, render, ui + +data = req.get( + "https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_airports.geojson" +).json() + +m = Map( + MapOptions( + style=Carto.POSITRON, + center=(0.45, 51.47), + zoom=4, + hash=True, + pitch=30, + ) +) + +deck_geojson_layer = { + "@@type": "GeoJsonLayer", + "id": "airports", + "data": data, + "filled": True, + "pointRadiusMinPixels": 2, + "pointRadiusScale": 2000, + "getPointRadius": "@@=11 - properties.scalerank", + "getFillColor": [200, 0, 80, 180], + "autoHighlight": True, + "pickable": True, +} + +deck_arc_layer = { + "@@type": "ArcLayer", + "id": "arcs", + "data": [ + feature + for feature in data["features"] + if feature["properties"]["scalerank"] < 4 + ], + "getSourcePosition": [-0.4531566, 51.4709959], # London + "getTargetPosition": "@@=geometry.coordinates", + "getSourceColor": [0, 128, 200], + "getTargetColor": [200, 0, 80], + "getWidth": 2, + "pickable": True, +} + +m.add_deck_layers( + [deck_geojson_layer, deck_arc_layer], + tooltip={ + "airports": "{{ &properties.name }}", + "arcs": "gps_code: {{ properties.gps_code }}", + }, +) + +# Shiny Express +use_deckgl() + + +@render_maplibregl +def render_map(): + return m + + +if __name__ == "__main__": + with open("docs/examples/deckgl_multiple_layers/app.html", "w") as f: + f.write(m.to_html()) diff --git a/docs/examples/deckgl_multiple_layers/index.md b/docs/examples/deckgl_multiple_layers/index.md new file mode 100644 index 00000000..a7a34d9f --- /dev/null +++ b/docs/examples/deckgl_multiple_layers/index.md @@ -0,0 +1,14 @@ + + + + +```python +-8<-- "deckgl_multiple_layers/app.py" +``` + +Run example: + +``` bash +# Run Shiny app +poetry run shiny run docs/examples/deckgl_multiple_layers/app.py +``` diff --git a/docs/examples/every_person_in_manhattan/app.py b/docs/examples/every_person_in_manhattan/app.py index 89ea6278..95baf286 100644 --- a/docs/examples/every_person_in_manhattan/app.py +++ b/docs/examples/every_person_in_manhattan/app.py @@ -51,6 +51,7 @@ style=Carto.POSITRON, bounds=tuple(bbox), fit_bounds_options={"padding": 20}, + hash=True, ) diff --git a/docs/examples/jupyter/getting_started.ipynb b/docs/examples/jupyter/getting_started.ipynb index 1d293c23..ebc3515b 100644 --- a/docs/examples/jupyter/getting_started.ipynb +++ b/docs/examples/jupyter/getting_started.ipynb @@ -5,7 +5,6 @@ "execution_count": 1, "id": "8ae5dd75-d944-4304-88c6-ec2db700dcec", "metadata": {}, - "outputs": [], "source": [ "import ipywidgets as widgets\n", "\n", @@ -13,7 +12,8 @@ "from maplibre.sources import GeoJSONSource\n", "from maplibre.controls import ScaleControl, Marker\n", "from maplibre.ipywidget import MapWidget as Map" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -28,12 +28,12 @@ "execution_count": 2, "id": "e7395a31-1f92-4100-abbe-bc0eae14ff83", "metadata": {}, - "outputs": [], "source": [ "earthquakes = GeoJSONSource(\n", " data=\"https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson\"\n", ")" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -48,7 +48,6 @@ "execution_count": 3, "id": "d715d455-2d0b-4415-9ed7-722cd6e6ad21", "metadata": {}, - "outputs": [], "source": [ "layer_id = \"earthquakes\"\n", "\n", @@ -58,7 +57,8 @@ " source=earthquakes,\n", " paint={\"circle-color\": \"yellow\"}\n", ")" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -73,23 +73,6 @@ "execution_count": 27, "id": "e6e2284c-1862-4697-ad94-f535b3682197", "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "8424f04853ea4a41ac6a3697349bbd3e", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "MapWidget(calls=[['addControl', ('ScaleControl', {'unit': 'metric'}, 'bottom-left')], ['addLayer', ({'id': 'ea…" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "m = Map()\n", "m.add_control(ScaleControl(), position=\"bottom-left\")\n", @@ -97,7 +80,8 @@ "m.add_tooltip(layer_id)\n", "m.add_marker(Marker(lng_lat=(100.507, 13.745)))\n", "m" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -112,28 +96,13 @@ "execution_count": 28, "id": "356960fa-b866-42c8-a58e-0c9a417c28eb", "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "7998e7feb14045d6a8dfc637d6775c98", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "interactive(children=(IntSlider(value=4, description='radius', max=8, min=1), Output()), _dom_classes=('widget…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], "source": [ "change_radius = widgets.interact(\n", " lambda radius: m.set_paint_property(layer_id, \"circle-radius\", radius),\n", " radius=(1, 8, 1)\n", ")" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -148,28 +117,13 @@ "execution_count": 21, "id": "8ecd93a6-f471-4350-a052-7a9171fa1606", "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "ca7ad45e679d479795b3c05014c8e6b4", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "interactive(children=(Dropdown(description='color', options=('green', 'yellow', 'orange', 'red'), value='green…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], "source": [ "change_color = widgets.interact(\n", " lambda color: m.set_paint_property(layer_id, \"circle-color\", color),\n", " color=[\"green\", \"yellow\", \"orange\", \"red\"]\n", ")" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -184,28 +138,13 @@ "execution_count": 31, "id": "0b73f056-f35a-46bb-a092-d899c64cd67e", "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "405b4aba579b42248573eaf356f629d4", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "interactive(children=(IntSlider(value=4, description='mag_min', max=7, min=1), Output()), _dom_classes=('widge…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], "source": [ "filter_mag = widgets.interact(\n", " lambda mag_min: m.set_filter(layer_id, [\">=\", [\"get\", \"mag\"], mag_min]),\n", " mag_min=(1,7,1)\n", ")" - ] + ], + "outputs": [] }, { "cell_type": "markdown", @@ -220,23 +159,6 @@ "execution_count": 32, "id": "a9c5ddf7-074e-45b0-8cfe-15750fd0b4d5", "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "3957fc738b2643cfa207f9b62edbfdda", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Output()" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "from IPython.display import clear_output\n", "\n", @@ -250,23 +172,24 @@ "\n", "m.observe(log_lng_lat, names=\"lng_lat\")\n", "output" - ] + ], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "7ad74d91-1137-45b4-8791-83dc3546535e", "metadata": {}, - "outputs": [], - "source": [] + "source": [], + "outputs": [] }, { "cell_type": "code", "execution_count": null, "id": "9d34e0d6-7ff9-4f72-9af7-e8a19d51604a", "metadata": {}, - "outputs": [], - "source": [] + "source": [], + "outputs": [] } ], "metadata": { diff --git a/maplibre/_templates.py b/maplibre/_templates.py index c9918b1e..989c3450 100644 --- a/maplibre/_templates.py +++ b/maplibre/_templates.py @@ -1,10 +1,13 @@ html_template = """ -Pymaplibregl +{{ title|default('My MapLibre Map')}} +{% for header in headers|default([]) -%} +{{ header }} +{% endfor -%}
', + '', + ] + if add_deckgl_headers + else [] + ) output = Template(html_template).render( - js="\n".join([js_lib, js_snippet]), **kwargs + js="\n".join([js_lib, js_snippet]), title=title, headers=headers, **kwargs ) return output + + def add_deck_layers(self, layers: list[dict], tooltip: str | dict = None) -> None: + """Add Deck.GL layers to the layer stack + + Args: + layers (list[dict]): A list of dictionaries containing the Deck.GL layers to be added. + tooltip (str | dict): Either a single mustache template string applied to all layers + or a dictionary where keys are layer ids and values are mustache template strings. + """ + self.add_call("addDeckOverlay", layers, tooltip) + + def set_deck_layers(self, layers: list[dict], tooltip: str | dict = None) -> None: + """Update Deck.GL layers + + Args: + layers (list[dict]): A list of dictionaries containing the Deck.GL layers to be updated. + New layers will be added. Missing layers will be removed. + tooltip (str | dict): Must be set to keep tooltip even if it did not change. + """ + self.add_call("setDeckLayers", layers, tooltip) diff --git a/maplibre/srcjs/index.js b/maplibre/srcjs/index.js index 0ae85447..da0ed1d1 100644 --- a/maplibre/srcjs/index.js +++ b/maplibre/srcjs/index.js @@ -1,7 +1,7 @@ -(()=>{var B=Object.prototype.toString,_=Array.isArray||function(e){return B.call(e)==="[object Array]"};function R(r){return typeof r=="function"}function D(r){return _(r)?"array":typeof r}function P(r){return r.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function j(r,e){return r!=null&&typeof r=="object"&&e in r}function F(r,e){return r!=null&&typeof r!="object"&&r.hasOwnProperty&&r.hasOwnProperty(e)}var H=RegExp.prototype.test;function N(r,e){return H.call(r,e)}var W=/\S/;function q(r){return!N(W,r)}var G={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function K(r){return String(r).replace(/[&<>"'`=\/]/g,function(t){return G[t]})}var V=/\s*/,z=/\s+/,I=/\s*=/,J=/\s*\}/,Q=/#|\^|\/|>|\{|&|=|!/;function X(r,e){if(!r)return[];var t=!1,n=[],a=[],s=[],o=!1,i=!1,p="",u=0;function h(){if(o&&!i)for(;s.length;)delete a[s.pop()];else s=[];o=!1,i=!1}var v,m,x;function U(y){if(typeof y=="string"&&(y=y.split(z,2)),!_(y)||y.length!==2)throw new Error("Invalid tags: "+y);v=new RegExp(P(y[0])+"\\s*"),m=new RegExp("\\s*"+P(y[1])),x=new RegExp("\\s*"+P("}"+y[1]))}U(e||g.tags);for(var l=new E(r),w,f,d,k,L,b;!l.eos();){if(w=l.pos,d=l.scanUntil(v),d)for(var M=0,A=d.length;M"?L=[f,d,w,l.pos,p,u,t]:L=[f,d,w,l.pos],u++,a.push(L),f==="#"||f==="^")n.push(L);else if(f==="/"){if(b=n.pop(),!b)throw new Error('Unopened section "'+d+'" at '+w);if(b[1]!==d)throw new Error('Unclosed section "'+b[1]+'" at '+w)}else f==="name"||f==="{"||f==="&"?i=!0:f==="="&&U(d)}if(h(),b=n.pop(),b)throw new Error('Unclosed section "'+b[1]+'" at '+l.pos);return Z(Y(a))}function Y(r){for(var e=[],t,n,a=0,s=r.length;a0?n[n.length-1][4]:e;break;default:t.push(a)}return e}function E(r){this.string=r,this.tail=r,this.pos=0}E.prototype.eos=function(){return this.tail===""};E.prototype.scan=function(e){var t=this.tail.match(e);if(!t||t.index!==0)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n};E.prototype.scanUntil=function(e){var t=this.tail.search(e),n;switch(t){case-1:n=this.tail,this.tail="";break;case 0:n="";break;default:n=this.tail.substring(0,t),this.tail=this.tail.substring(t)}return this.pos+=n.length,n};function C(r,e){this.view=r,this.cache={".":this.view},this.parent=e}C.prototype.push=function(e){return new C(e,this)};C.prototype.lookup=function(e){var t=this.cache,n;if(t.hasOwnProperty(e))n=t[e];else{for(var a=this,s,o,i,p=!1;a;){if(e.indexOf(".")>0)for(s=a.view,o=e.split("."),i=0;s!=null&&i"?u=this.renderPartial(i,t,n,s):p==="&"?u=this.unescapedValue(i,t):p==="name"?u=this.escapedValue(i,t,s):p==="text"&&(u=this.rawValue(i)),u!==void 0&&(o+=u);return o};c.prototype.renderSection=function(e,t,n,a,s){var o=this,i="",p=t.lookup(e[1]);function u(m){return o.render(m,t,n,s)}if(p){if(_(p))for(var h=0,v=p.length;h0||!n)&&(s[o]=a+s[o]);return s.join(` -`)};c.prototype.renderPartial=function(e,t,n,a){if(n){var s=this.getConfigTags(a),o=R(n)?n(e[1]):n[e[1]];if(o!=null){var i=e[6],p=e[5],u=e[4],h=o;p==0&&u&&(h=this.indentPartial(o,u,i));var v=this.parse(h,s);return this.renderTokens(v,t,n,h,a)}}};c.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);if(n!=null)return n};c.prototype.escapedValue=function(e,t,n){var a=this.getConfigEscape(n)||g.escape,s=t.lookup(e[1]);if(s!=null)return typeof s=="number"&&a===g.escape?String(s):a(s)};c.prototype.rawValue=function(e){return e[1]};c.prototype.getConfigTags=function(e){return _(e)?e:e&&typeof e=="object"?e.tags:void 0};c.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!_(e))return e.escape};var g={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(r){T.templateCache=r},get templateCache(){return T.templateCache}},T=new c;g.clearCache=function(){return T.clearCache()};g.parse=function(e,t){return T.parse(e,t)};g.render=function(e,t,n,a){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+D(e)+'" was given as the first argument for mustache#render(template, view, partials)');return T.render(e,t,n,a)};g.escape=K;g.Scanner=E;g.Context=C;g.Writer=c;var $=g;function O(r,e,t){return t!==null?$.render(t,r.properties):e===null?Object.keys(r.properties).map(a=>`${a}: ${r.properties[a]}`).join("
"):r.properties[e]}var S=class{constructor(e){this._id=e.container,this._map=new maplibregl.Map(e),this._map.on("mouseover",()=>{this._map.getCanvas().style.cursor="pointer"}),this._map.on("mouseout",()=>{this._map.getCanvas().style.cursor=""}),this._map.addControl(new maplibregl.NavigationControl)}getMap(){return this._map}applyMapMethod(e,t){this._map[e](...t)}addControl(e,t,n){this._map.addControl(new maplibregl[e](t),n)}addMarker({lngLat:e,popup:t,options:n}){let a=new maplibregl.Marker(n).setLngLat(e);if(t){let s=new maplibregl.Popup(t.options).setHTML(t.text);a.setPopup(s)}a.addTo(this._map)}addLayer(e,t){this._map.addLayer(e,t),typeof Shiny<"u"&&this._map.on("click",e.id,n=>{console.log(n,n.features[0]);let a=e.id.replaceAll("-","_"),s=`${this._id}_layer_${a}`,o={props:n.features[0].properties,layer_id:e.id};console.log(s,o),Shiny.onInputChange(s,o)})}addPopup(e,t=null,n=null){let a={closeButton:!1},s=new maplibregl.Popup(a);this._map.on("click",e,o=>{let i=o.features[0],p=O(i,t,n);s.setLngLat(o.lngLat).setHTML(p).addTo(this._map)})}addTooltip(e,t=null,n=null){let a={closeButton:!1,closeOnClick:!1},s=new maplibregl.Popup(a);this._map.on("mousemove",e,o=>{let i=o.features[0],p=O(i,t,n);s.setLngLat(o.lngLat).setHTML(p).addTo(this._map)}),this._map.on("mouseleave",e,()=>{s.remove()})}setSourceData(e,t){this._map.getSource(e).setData(t)}render(e){e.forEach(([t,n])=>{if(["addLayer","addPopup","addTooltip","addMarker","addPopup","addControl","setSourceData"].includes(t)){console.log("Custom method",t,n),this[t](...n);return}console.log("Map method",t),this.applyMapMethod(t,n)})}};var ee="0.1.0";console.log("pymaplibregl",ee);typeof Shiny>"u"&&(window.pymaplibregl=function({mapOptions:r,calls:e}){let t="pymaplibregl",n=document.getElementById(t),a=new S(Object.assign({container:n.id},r));a.getMap().on("load",()=>{a.render(e)})});if(typeof Shiny<"u"){class r extends Shiny.OutputBinding{find(t){return t.find(".shiny-maplibregl-output")}renderValue(t,n){console.log("id:",t.id,"payload:",n);let a=new S(Object.assign({container:t.id},n.mapData.mapOptions)),s=a.getMap();s.on("load",()=>{a.render(n.mapData.calls)}),s.on("click",i=>{console.log(i);let p=`${t.id}`,u={coords:i.lngLat,point:i.point};console.log(p,u),Shiny.onInputChange(p,u)});let o=`pymaplibregl-${t.id}`;console.log(o),Shiny.addCustomMessageHandler(o,({id:i,calls:p})=>{console.log(i,p),a.render(p)})}}Shiny.outputBindings.register(new r,"shiny-maplibregl-output")}})(); +(()=>{var B=Object.prototype.toString,k=Array.isArray||function(e){return B.call(e)==="[object Array]"};function E(r){return typeof r=="function"}function H(r){return k(r)?"array":typeof r}function P(r){return r.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function U(r,e){return r!=null&&typeof r=="object"&&e in r}function A(r,e){return r!=null&&typeof r!="object"&&r.hasOwnProperty&&r.hasOwnProperty(e)}var J=RegExp.prototype.test;function F(r,e){return J.call(r,e)}var W=/\S/;function q(r){return!F(W,r)}var G={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function K(r){return String(r).replace(/[&<>"'`=\/]/g,function(t){return G[t]})}var V=/\s*/,z=/\s+/,I=/\s*=/,Q=/\s*\}/,X=/#|\^|\/|>|\{|&|=|!/;function Y(r,e){if(!r)return[];var t=!1,n=[],s=[],a=[],o=!1,p=!1,i="",l=0;function f(){if(o&&!p)for(;a.length;)delete s[a.pop()];else a=[];o=!1,p=!1}var v,m,x;function N(y){if(typeof y=="string"&&(y=y.split(z,2)),!k(y)||y.length!==2)throw new Error("Invalid tags: "+y);v=new RegExp(P(y[0])+"\\s*"),m=new RegExp("\\s*"+P(y[1])),x=new RegExp("\\s*"+P("}"+y[1]))}N(e||g.tags);for(var u=new L(r),w,h,d,S,O,b;!u.eos();){if(w=u.pos,d=u.scanUntil(v),d)for(var M=0,j=d.length;M"?O=[h,d,w,u.pos,i,l,t]:O=[h,d,w,u.pos],l++,s.push(O),h==="#"||h==="^")n.push(O);else if(h==="/"){if(b=n.pop(),!b)throw new Error('Unopened section "'+d+'" at '+w);if(b[1]!==d)throw new Error('Unclosed section "'+b[1]+'" at '+w)}else h==="name"||h==="{"||h==="&"?p=!0:h==="="&&N(d)}if(f(),b=n.pop(),b)throw new Error('Unclosed section "'+b[1]+'" at '+u.pos);return ee(Z(s))}function Z(r){for(var e=[],t,n,s=0,a=r.length;s0?n[n.length-1][4]:e;break;default:t.push(s)}return e}function L(r){this.string=r,this.tail=r,this.pos=0}L.prototype.eos=function(){return this.tail===""};L.prototype.scan=function(e){var t=this.tail.match(e);if(!t||t.index!==0)return"";var n=t[0];return this.tail=this.tail.substring(n.length),this.pos+=n.length,n};L.prototype.scanUntil=function(e){var t=this.tail.search(e),n;switch(t){case-1:n=this.tail,this.tail="";break;case 0:n="";break;default:n=this.tail.substring(0,t),this.tail=this.tail.substring(t)}return this.pos+=n.length,n};function _(r,e){this.view=r,this.cache={".":this.view},this.parent=e}_.prototype.push=function(e){return new _(e,this)};_.prototype.lookup=function(e){var t=this.cache,n;if(t.hasOwnProperty(e))n=t[e];else{for(var s=this,a,o,p,i=!1;s;){if(e.indexOf(".")>0)for(a=s.view,o=e.split("."),p=0;a!=null&&p"?l=this.renderPartial(p,t,n,a):i==="&"?l=this.unescapedValue(p,t):i==="name"?l=this.escapedValue(p,t,a):i==="text"&&(l=this.rawValue(p)),l!==void 0&&(o+=l);return o};c.prototype.renderSection=function(e,t,n,s,a){var o=this,p="",i=t.lookup(e[1]);function l(m){return o.render(m,t,n,a)}if(i){if(k(i))for(var f=0,v=i.length;f0||!n)&&(a[o]=s+a[o]);return a.join(` +`)};c.prototype.renderPartial=function(e,t,n,s){if(n){var a=this.getConfigTags(s),o=E(n)?n(e[1]):n[e[1]];if(o!=null){var p=e[6],i=e[5],l=e[4],f=o;i==0&&l&&(f=this.indentPartial(o,l,p));var v=this.parse(f,a);return this.renderTokens(v,t,n,f,s)}}};c.prototype.unescapedValue=function(e,t){var n=t.lookup(e[1]);if(n!=null)return n};c.prototype.escapedValue=function(e,t,n){var s=this.getConfigEscape(n)||g.escape,a=t.lookup(e[1]);if(a!=null)return typeof a=="number"&&s===g.escape?String(a):s(a)};c.prototype.rawValue=function(e){return e[1]};c.prototype.getConfigTags=function(e){return k(e)?e:e&&typeof e=="object"?e.tags:void 0};c.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!k(e))return e.escape};var g={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(r){T.templateCache=r},get templateCache(){return T.templateCache}},T=new c;g.clearCache=function(){return T.clearCache()};g.parse=function(e,t){return T.parse(e,t)};g.render=function(e,t,n,s){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+H(e)+'" was given as the first argument for mustache#render(template, view, partials)');return T.render(e,t,n,s)};g.escape=K;g.Scanner=L;g.Context=_;g.Writer=c;var D=g;function R(r,e,t){return t!==null?D.render(t,r.properties):e===null?Object.keys(r.properties).map(s=>`${s}: ${r.properties[s]}`).join("
"):r.properties[e]}function $(r,e){let t=new maplibregl.Popup({closeOnClick:!1,closeButton:!1});return r.on("mouseout",n=>t.remove()),({coordinate:n,object:s})=>{s?(t.setHTML(D.render(e,s)).setLngLat(n),t.addTo(r)):t.remove()}}function te(){if(typeof deck>"u")return;let r=new deck.JSONConfiguration({classes:deck});return new deck.JSONConverter({configuration:r})}var C=class{constructor(e){this._id=e.container,this._map=new maplibregl.Map(e),this._map.on("mouseover",()=>{this._map.getCanvas().style.cursor="pointer"}),this._map.on("mouseout",()=>{this._map.getCanvas().style.cursor=""}),this._map.addControl(new maplibregl.NavigationControl),this._JSONConverter=te()}getMap(){return this._map}applyMapMethod(e,t){this._map[e](...t)}addControl(e,t,n){this._map.addControl(new maplibregl[e](t),n)}addMarker({lngLat:e,popup:t,options:n}){let s=new maplibregl.Marker(n).setLngLat(e);if(t){let a=new maplibregl.Popup(t.options).setHTML(t.text);s.setPopup(a)}s.addTo(this._map)}addLayer(e,t){this._map.addLayer(e,t),typeof Shiny<"u"&&this._map.on("click",e.id,n=>{console.log(n,n.features[0]);let s=e.id.replaceAll("-","_"),a=`${this._id}_layer_${s}`,o={props:n.features[0].properties,layer_id:e.id};console.log(a,o),Shiny.onInputChange(a,o)})}addPopup(e,t=null,n=null){let s={closeButton:!1},a=new maplibregl.Popup(s);this._map.on("click",e,o=>{let p=o.features[0],i=R(p,t,n);a.setLngLat(o.lngLat).setHTML(i).addTo(this._map)})}addTooltip(e,t=null,n=null){let s={closeButton:!1,closeOnClick:!1},a=new maplibregl.Popup(s);this._map.on("mousemove",e,o=>{let p=o.features[0],i=R(p,t,n);a.setLngLat(o.lngLat).setHTML(i).addTo(this._map)}),this._map.on("mouseleave",e,()=>{a.remove()})}setSourceData(e,t){this._map.getSource(e).setData(t)}addDeckOverlay(e,t=null){if(typeof this._JSONConverter>"u"){console.log("deck or JSONConverter is undefined");return}let n=this._convertDeckLayers(e,t);this._deckOverlay=new deck.MapboxOverlay({interleaved:!0,layers:n}),this._map.addControl(this._deckOverlay)}_convertDeckLayers(e,t=null){return e.map(n=>{let s=t&&typeof t=="object"?t[n.id]:t,a=$(this._map,s);return n.onHover=({layer:o,coordinate:p,object:i})=>{if(s&&a({coordinate:p,object:i}),typeof Shiny<"u"){let l=`${this._id}_layer_${n.id}`;Shiny.onInputChange(l,i)}},this._JSONConverter.convert(n)})}setDeckLayers(e,t=null){console.log("Updating Deck.GL layers");let n=this._convertDeckLayers(e,t);this._deckOverlay.setProps({layers:n})}render(e){e.forEach(([t,n])=>{if(["addLayer","addPopup","addTooltip","addMarker","addPopup","addControl","setSourceData","addDeckOverlay","setDeckLayers"].includes(t)){console.log("Custom method",t,n),this[t](...n);return}console.log("Map method",t),this.applyMapMethod(t,n)})}};var ne="0.1.0";console.log("pymaplibregl",ne);typeof Shiny>"u"&&(window.pymaplibregl=function({mapOptions:r,calls:e}){let t="pymaplibregl",n=document.getElementById(t),s=new C(Object.assign({container:n.id},r));s.getMap().on("load",()=>{s.render(e)})});if(typeof Shiny<"u"){class r extends Shiny.OutputBinding{find(t){return t.find(".shiny-maplibregl-output")}renderValue(t,n){console.log("id:",t.id,"payload:",n);let s=window._maplibreWidget=new C(Object.assign({container:t.id},n.mapData.mapOptions)),a=s.getMap();a.on("load",()=>{s.render(n.mapData.calls)}),a.on("click",p=>{console.log(p);let i=`${t.id}`,l={coords:p.lngLat,point:p.point};console.log(i,l),Shiny.onInputChange(i,l)});let o=`pymaplibregl-${t.id}`;console.log(o),Shiny.addCustomMessageHandler(o,({id:p,calls:i})=>{console.log(p,i),s.render(i)})}}Shiny.outputBindings.register(new r,"shiny-maplibregl-output")}})(); /*! Bundled license information: mustache/mustache.mjs: diff --git a/maplibre/srcjs/ipywidget.js b/maplibre/srcjs/ipywidget.js index f7dbaabf..1f94fe97 100644 --- a/maplibre/srcjs/ipywidget.js +++ b/maplibre/srcjs/ipywidget.js @@ -1,9 +1,2478 @@ -import R from"https://esm.sh/maplibre-gl@3.6.2";var H=Object.prototype.toString,T=Array.isArray||function(e){return H.call(e)==="[object Array]"};function U(n){return typeof n=="function"}function N(n){return T(n)?"array":typeof n}function L(n){return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function _(n,e){return n!=null&&typeof n=="object"&&e in n}function $(n,e){return n!=null&&typeof n!="object"&&n.hasOwnProperty&&n.hasOwnProperty(e)}var B=RegExp.prototype.test;function D(n,e){return B.call(n,e)}var z=/\S/;function K(n){return!D(z,n)}var G={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function J(n){return String(n).replace(/[&<>"'`=\/]/g,function(t){return G[t]})}var Q=/\s*/,V=/\s+/,A=/\s*=/,X=/\s*\}/,Y=/#|\^|\/|>|\{|&|=|!/;function Z(n,e){if(!n)return[];var t=!1,r=[],s=[],a=[],o=!1,i=!1,c="",u=0;function p(){if(o&&!i)for(;a.length;)delete s[a.pop()];else a=[];o=!1,i=!1}var g,C,m;function O(y){if(typeof y=="string"&&(y=y.split(V,2)),!T(y)||y.length!==2)throw new Error("Invalid tags: "+y);g=new RegExp(L(y[0])+"\\s*"),C=new RegExp("\\s*"+L(y[1])),m=new RegExp("\\s*"+L("}"+y[1]))}O(e||v.tags);for(var l=new S(n),w,h,d,E,P,b;!l.eos();){if(w=l.pos,d=l.scanUntil(g),d)for(var x=0,q=d.length;x"?P=[h,d,w,l.pos,c,u,t]:P=[h,d,w,l.pos],u++,s.push(P),h==="#"||h==="^")r.push(P);else if(h==="/"){if(b=r.pop(),!b)throw new Error('Unopened section "'+d+'" at '+w);if(b[1]!==d)throw new Error('Unclosed section "'+b[1]+'" at '+w)}else h==="name"||h==="{"||h==="&"?i=!0:h==="="&&O(d)}if(p(),b=r.pop(),b)throw new Error('Unclosed section "'+b[1]+'" at '+l.pos);return te(ee(s))}function ee(n){for(var e=[],t,r,s=0,a=n.length;s0?r[r.length-1][4]:e;break;default:t.push(s)}return e}function S(n){this.string=n,this.tail=n,this.pos=0}S.prototype.eos=function(){return this.tail===""};S.prototype.scan=function(e){var t=this.tail.match(e);if(!t||t.index!==0)return"";var r=t[0];return this.tail=this.tail.substring(r.length),this.pos+=r.length,r};S.prototype.scanUntil=function(e){var t=this.tail.search(e),r;switch(t){case-1:r=this.tail,this.tail="";break;case 0:r="";break;default:r=this.tail.substring(0,t),this.tail=this.tail.substring(t)}return this.pos+=r.length,r};function k(n,e){this.view=n,this.cache={".":this.view},this.parent=e}k.prototype.push=function(e){return new k(e,this)};k.prototype.lookup=function(e){var t=this.cache,r;if(t.hasOwnProperty(e))r=t[e];else{for(var s=this,a,o,i,c=!1;s;){if(e.indexOf(".")>0)for(a=s.view,o=e.split("."),i=0;a!=null&&i"?u=this.renderPartial(i,t,r,a):c==="&"?u=this.unescapedValue(i,t):c==="name"?u=this.escapedValue(i,t,a):c==="text"&&(u=this.rawValue(i)),u!==void 0&&(o+=u);return o};f.prototype.renderSection=function(e,t,r,s,a){var o=this,i="",c=t.lookup(e[1]);function u(C){return o.render(C,t,r,a)}if(c){if(T(c))for(var p=0,g=c.length;p0||!r)&&(a[o]=s+a[o]);return a.join(` -`)};f.prototype.renderPartial=function(e,t,r,s){if(r){var a=this.getConfigTags(s),o=U(r)?r(e[1]):r[e[1]];if(o!=null){var i=e[6],c=e[5],u=e[4],p=o;c==0&&u&&(p=this.indentPartial(o,u,i));var g=this.parse(p,a);return this.renderTokens(g,t,r,p,s)}}};f.prototype.unescapedValue=function(e,t){var r=t.lookup(e[1]);if(r!=null)return r};f.prototype.escapedValue=function(e,t,r){var s=this.getConfigEscape(r)||v.escape,a=t.lookup(e[1]);if(a!=null)return typeof a=="number"&&s===v.escape?String(a):s(a)};f.prototype.rawValue=function(e){return e[1]};f.prototype.getConfigTags=function(e){return T(e)?e:e&&typeof e=="object"?e.tags:void 0};f.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!T(e))return e.escape};var v={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(n){M.templateCache=n},get templateCache(){return M.templateCache}},M=new f;v.clearCache=function(){return M.clearCache()};v.parse=function(e,t){return M.parse(e,t)};v.render=function(e,t,r,s){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+N(e)+'" was given as the first argument for mustache#render(template, view, partials)');return M.render(e,t,r,s)};v.escape=J;v.Scanner=S;v.Context=k;v.Writer=f;var F=v;function j(n,e,t){return t!==null?F.render(t,n.properties):e===null?Object.keys(n.properties).map(s=>`${s}: ${n.properties[s]}`).join("
"):n.properties[e]}function I(n,e){let[t,r]=e;console.log(t,r),n[t](...r)}function W(n,e){return{addTooltip:function(t,r=null,s=null){let a={closeButton:!1,closeOnClick:!1},o=new n.Popup(a);e.on("mousemove",t,i=>{let c=i.features[0],u=j(c,r,s);o.setLngLat(i.lngLat).setHTML(u).addTo(e)}),e.on("mouseleave",t,()=>{o.remove()})},addControl:function(t,r,s){e.addControl(new n[t](r),s)},addPopup:function(t,r=null,s=null){let a={closeButton:!1},o=new n.Popup(a);e.on("click",t,i=>{let c=i.features[0],u=j(c,r,s);o.setLngLat(i.lngLat).setHTML(u).addTo(e)})},addMarker:function({lngLat:t,popup:r,options:s}){let a=new n.Marker(s).setLngLat(t);if(r){let o=new n.Popup(r.options).setHTML(r.text);a.setPopup(o)}a.addTo(e)},setSourceData:function(t,r){e.getSource(t).setData(r)}}}function ne(n){let e="pymaplibregl",t=document.createElement("div");return t.id=e,t.style.height=n.get("height"),t}function re(n,e){let t=new R.Map(n);return n.navigationControl===void 0&&(n.navigationControl=!0),n.navigationControl&&t.addControl(new R.NavigationControl),t.on("mouseover",()=>{t.getCanvas().style.cursor="pointer"}),t.on("mouseout",()=>{t.getCanvas().style.cursor=""}),t.on("click",r=>{e.set("lng_lat",r.lngLat),e.save_changes()}),t.once("load",()=>{t.resize()}),t}function pe({model:n,el:e}){console.log("maplibregl",R.version);let t=ne(n),r=Object.assign({container:t},n.get("map_options"));console.log(r);let s=re(r,n),a=W(R,s),o=c=>{c.forEach(u=>{if(Object.keys(a).includes(u[0])){console.log("internal call",u);let[p,g]=u;a[p](...g);return}I(s,u)})},i=n.get("calls");s.on("load",()=>{console.log("init calls",i),o(i),n.set("_rendered",!0),n.save_changes()}),n.on("msg:custom",c=>{console.log("custom msg",c),o(c.calls)}),e.appendChild(t)}export{pe as render}; +var xb=Object.create;var Eu=Object.defineProperty;var Tb=Object.getOwnPropertyDescriptor;var vb=Object.getOwnPropertyNames;var bb=Object.getPrototypeOf,Sb=Object.prototype.hasOwnProperty;var wu=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ui=(t,e)=>{for(var r in e)Eu(t,r,{get:e[r],enumerable:!0})},Ab=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of vb(e))!Sb.call(t,s)&&s!==r&&Eu(t,s,{get:()=>e[s],enumerable:!(i=Tb(e,s))||i.enumerable});return t};var ja=(t,e,r)=>(r=t!=null?xb(bb(t)):{},Ab(e||!t||!t.__esModule?Eu(r,"default",{value:t,enumerable:!0}):r,t));var Yy=wu((rj,Al)=>{(function(t,e,r,i){"use strict";var s=["","webkit","Moz","MS","ms","o"],n=e.createElement("div"),o="function",a=Math.round,c=Math.abs,l=Date.now;function u(m,y,S){return setTimeout(v(m,S),y)}function f(m,y,S){return Array.isArray(m)?(h(m,S[y],S),!0):!1}function h(m,y,S){var R;if(m)if(m.forEach)m.forEach(y,S);else if(m.length!==i)for(R=0;R\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",re=t.console&&(t.console.warn||t.console.log);return re&&re.call(t.console,R,H),m.apply(this,arguments)}}var p;typeof Object.assign!="function"?p=function(y){if(y===i||y===null)throw new TypeError("Cannot convert undefined or null to object");for(var S=Object(y),R=1;R-1}function D(m){return m.trim().split(/\s+/g)}function L(m,y,S){if(m.indexOf&&!S)return m.indexOf(y);for(var R=0;RHe[y]}):R=R.sort()),R}function $(m,y){for(var S,R,k=y[0].toUpperCase()+y.slice(1),H=0;H1&&!S.firstMultiple?S.firstMultiple=K(y):k===1&&(S.firstMultiple=!1);var H=S.firstInput,re=S.firstMultiple,Ce=re?re.center:H.center,Ne=y.center=G(R);y.timeStamp=l(),y.deltaTime=y.timeStamp-H.timeStamp,y.angle=ut(Ce,Ne),y.distance=We(Ce,Ne),Da(S,y),y.offsetDirection=we(y.deltaX,y.deltaY);var He=Se(y.deltaTime,y.deltaX,y.deltaY);y.overallVelocityX=He.x,y.overallVelocityY=He.y,y.overallVelocity=c(He.x)>c(He.y)?He.x:He.y,y.scale=re?Or(re.pointers,R):1,y.rotation=re?ci(re.pointers,R):0,y.maxPointers=S.prevInput?y.pointers.length>S.prevInput.maxPointers?y.pointers.length:S.prevInput.maxPointers:y.pointers.length,V(S,y);var jt=m.element;F(y.srcEvent.target,jt)&&(jt=y.srcEvent.target),y.target=jt}function Da(m,y){var S=y.center,R=m.offsetDelta||{},k=m.prevDelta||{},H=m.prevInput||{};(y.eventType===ye||H.eventType===J)&&(k=m.prevDelta={x:H.deltaX||0,y:H.deltaY||0},R=m.offsetDelta={x:S.x,y:S.y}),y.deltaX=k.x+(S.x-R.x),y.deltaY=k.y+(S.y-R.y)}function V(m,y){var S=m.lastInterval||y,R=y.timeStamp-S.timeStamp,k,H,re,Ce;if(y.eventType!=be&&(R>at||S.velocity===i)){var Ne=y.deltaX-S.deltaX,He=y.deltaY-S.deltaY,jt=Se(R,Ne,He);H=jt.x,re=jt.y,k=c(jt.x)>c(jt.y)?jt.x:jt.y,Ce=we(Ne,He),m.lastInterval=y}else k=S.velocity,H=S.velocityX,re=S.velocityY,Ce=S.direction;y.velocity=k,y.velocityX=H,y.velocityY=re,y.direction=Ce}function K(m){for(var y=[],S=0;S=c(y)?m<0?ct:Ir:y<0?ai:Wt}function We(m,y,S){S||(S=dn);var R=y[S[0]]-m[S[0]],k=y[S[1]]-m[S[1]];return Math.sqrt(R*R+k*k)}function ut(m,y,S){S||(S=dn);var R=y[S[0]]-m[S[0]],k=y[S[1]]-m[S[1]];return Math.atan2(k,R)*180/Math.PI}function ci(m,y){return ut(y[1],y[0],ts)+ut(m[1],m[0],ts)}function Or(m,y){return We(y[0],y[1],ts)/We(m[0],m[1],ts)}var La={mousedown:ye,mousemove:me,mouseup:J},eb="mousedown",tb="mousemove mouseup";function ka(){this.evEl=eb,this.evWin=tb,this.pressed=!1,Ke.apply(this,arguments)}x(ka,Ke,{handler:function(y){var S=La[y.type];S&ye&&y.button===0&&(this.pressed=!0),S&me&&y.which!==1&&(S=J),this.pressed&&(S&J&&(this.pressed=!1),this.callback(this.manager,S,{pointers:[y],changedPointers:[y],pointerType:j,srcEvent:y}))}});var rb={pointerdown:ye,pointermove:me,pointerup:J,pointercancel:be,pointerout:be},ib={2:he,3:pu,4:j,5:B},Pp="pointerdown",Rp="pointermove pointerup pointercancel";t.MSPointerEvent&&!t.PointerEvent&&(Pp="MSPointerDown",Rp="MSPointerMove MSPointerUp MSPointerCancel");function mu(){this.evEl=Pp,this.evWin=Rp,Ke.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}x(mu,Ke,{handler:function(y){var S=this.store,R=!1,k=y.type.toLowerCase().replace("ms",""),H=rb[k],re=ib[y.pointerType]||y.pointerType,Ce=re==he,Ne=L(S,y.pointerId,"pointerId");H&ye&&(y.button===0||Ce)?Ne<0&&(S.push(y),Ne=S.length-1):H&(J|be)&&(R=!0),!(Ne<0)&&(S[Ne]=y,this.callback(this.manager,H,{pointers:S,changedPointers:[y],pointerType:re,srcEvent:y}),R&&S.splice(Ne,1))}});var sb={touchstart:ye,touchmove:me,touchend:J,touchcancel:be},nb="touchstart",ob="touchstart touchmove touchend touchcancel";function Cp(){this.evTarget=nb,this.evWin=ob,this.started=!1,Ke.apply(this,arguments)}x(Cp,Ke,{handler:function(y){var S=sb[y.type];if(S===ye&&(this.started=!0),!!this.started){var R=ab.call(this,y,S);S&(J|be)&&R[0].length-R[1].length===0&&(this.started=!1),this.callback(this.manager,S,{pointers:R[0],changedPointers:R[1],pointerType:he,srcEvent:y})}}});function ab(m,y){var S=Y(m.touches),R=Y(m.changedTouches);return y&(J|be)&&(S=X(S.concat(R),"identifier",!0)),[S,R]}var cb={touchstart:ye,touchmove:me,touchend:J,touchcancel:be},lb="touchstart touchmove touchend touchcancel";function Ba(){this.evTarget=lb,this.targetIds={},Ke.apply(this,arguments)}x(Ba,Ke,{handler:function(y){var S=cb[y.type],R=ub.call(this,y,S);R&&this.callback(this.manager,S,{pointers:R[0],changedPointers:R[1],pointerType:he,srcEvent:y})}});function ub(m,y){var S=Y(m.touches),R=this.targetIds;if(y&(ye|me)&&S.length===1)return R[S[0].identifier]=!0,[S,S];var k,H,re=Y(m.changedTouches),Ce=[],Ne=this.target;if(H=S.filter(function(He){return F(He.target,Ne)}),y===ye)for(k=0;k-1&&R.splice(H,1)};setTimeout(k,fb)}}function db(m){for(var y=m.srcEvent.clientX,S=m.srcEvent.clientY,R=0;R-1&&this.requireFail.splice(y,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(m){return!!this.simultaneous[m.id]},emit:function(m){var y=this,S=this.state;function R(k){y.manager.emit(k,m)}S=Nr&&R(y.options.event+Lp(S))},tryEmit:function(m){if(this.canEmit())return this.emit(m);this.state=Ht},canEmit:function(){for(var m=0;my.threshold&&k&y.direction},attrTest:function(m){return Rt.prototype.attrTest.call(this,m)&&(this.state&ft||!(this.state&ft)&&this.directionTest(m))},emit:function(m){this.pX=m.deltaX,this.pY=m.deltaY;var y=kp(m.direction);y&&(m.additionalEvent=this.options.event+y),this._super.emit.call(this,m)}});function Tu(){Rt.apply(this,arguments)}x(Tu,Rt,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[li]},attrTest:function(m){return this._super.attrTest.call(this,m)&&(Math.abs(m.scale-1)>this.options.threshold||this.state&ft)},emit:function(m){if(m.scale!==1){var y=m.scale<1?"in":"out";m.additionalEvent=this.options.event+y}this._super.emit.call(this,m)}});function vu(){ur.apply(this,arguments),this._timer=null,this._input=null}x(vu,ur,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[Dp]},process:function(m){var y=this.options,S=m.pointers.length===y.pointers,R=m.distancey.time;if(this._input=m,!R||!S||m.eventType&(J|be)&&!k)this.reset();else if(m.eventType&ye)this.reset(),this._timer=u(function(){this.state=lr,this.tryEmit()},y.time,this);else if(m.eventType&J)return lr;return Ht},reset:function(){clearTimeout(this._timer)},emit:function(m){this.state===lr&&(m&&m.eventType&J?this.manager.emit(this.options.event+"up",m):(this._input.timeStamp=l(),this.manager.emit(this.options.event,this._input)))}});function bu(){Rt.apply(this,arguments)}x(bu,Rt,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[li]},attrTest:function(m){return this._super.attrTest.call(this,m)&&(Math.abs(m.rotation)>this.options.threshold||this.state&ft)}});function Su(){Rt.apply(this,arguments)}x(Su,Rt,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:lt|cr,pointers:1},getTouchAction:function(){return Wa.prototype.getTouchAction.call(this)},attrTest:function(m){var y=this.options.direction,S;return y&(lt|cr)?S=m.overallVelocity:y<?S=m.overallVelocityX:y&cr&&(S=m.overallVelocityY),this._super.attrTest.call(this,m)&&y&m.offsetDirection&&m.distance>this.options.threshold&&m.maxPointers==this.options.pointers&&c(S)>this.options.velocity&&m.eventType&J},emit:function(m){var y=kp(m.offsetDirection);y&&this.manager.emit(this.options.event+y,m),this.manager.emit(this.options.event,m)}});function Ha(){ur.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}x(Ha,ur,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[yu]},process:function(m){var y=this.options,S=m.pointers.length===y.pointers,R=m.distance{(function(t){"use strict";var e="Compound",r="Identifier",i="MemberExpression",s="Literal",n="ThisExpression",o="CallExpression",a="UnaryExpression",c="BinaryExpression",l="LogicalExpression",u="ConditionalExpression",f="ArrayExpression",h=46,d=44,p=39,g=34,_=40,x=41,v=91,b=93,A=63,C=59,M=58,F=function(j,B){var at=new Error(j+" at character "+B);throw at.index=B,at.description=j,at},N=!0,D={"-":N,"!":N,"~":N,"+":N},L={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},Y=function(j){var B=0,at;for(var ye in j)(at=ye.length)>B&&j.hasOwnProperty(ye)&&(B=at);return B},X=Y(D),$=Y(L),Z={true:!0,false:!1,null:null},ge="this",rt=function(j){return L[j]||0},ot=function(j,B,at){var ye=j==="||"||j==="&&"?l:c;return{type:ye,operator:j,left:B,right:at}},Pt=function(j){return j>=48&&j<=57},Vt=function(j){return j===36||j===95||j>=65&&j<=90||j>=97&&j<=122||j>=128&&!L[String.fromCharCode(j)]},fn=function(j){return j===36||j===95||j>=65&&j<=90||j>=97&&j<=122||j>=48&&j<=57||j>=128&&!L[String.fromCharCode(j)]},he=function(j){for(var B=0,at=j.charAt,ye=j.charCodeAt,me=function(V){return at.call(j,V)},J=function(V){return ye.call(j,V)},be=j.length,Ve=function(){for(var V=J(B);V===32||V===9||V===10||V===13;)V=J(++B)},ct=function(){var V=ai(),K,G;if(Ve(),J(B)===A){if(B++,K=ct(),K||F("Expected expression",B),Ve(),J(B)===M)return B++,G=ct(),G||F("Expected expression",B),{type:u,test:V,consequent:K,alternate:G};F("Expected :",B)}else return V},Ir=function(){Ve();for(var V,K=j.substr(B,$),G=K.length;G>0;){if(L.hasOwnProperty(K)&&(!Vt(J(B))||B+K.length2&&Se<=we[we.length-2].prec;)ci=we.pop(),G=we.pop().value,ut=we.pop(),K=ot(G,ut,ci),we.push(K);K=Wt(),K||F("Expected expression after "+La,B),we.push(We,K)}for(Or=we.length-1,K=we[Or];Or>1;)K=ot(we[Or-1].value,we[Or-2],K),Or-=2;return K},Wt=function(){var V,K,G;if(Ve(),V=J(B),Pt(V)||V===h)return lt();if(V===p||V===g)return cr();if(V===v)return gu();for(K=j.substr(B,X),G=K.length;G>0;){if(D.hasOwnProperty(K)&&(!Vt(J(B))||B+K.length=G.length&&F("Unexpected token "+String.fromCharCode(V),B);break}else if(K===d){if(B++,We++,We!==G.length){if(V===x)F("Unexpected token ,",B);else if(V===b)for(var ut=G.length;ut"u"){var pu=t.jsep;t.jsep=he,he.noConflict=function(){return t.jsep===he&&(t.jsep=pu),he}}else typeof Ll<"u"&&Ll.exports?Qo=Ll.exports=he:Qo.parse=he})(Qo)});var z0=wu((uK,sp)=>{"use strict";sp.exports=Yl;sp.exports.default=Yl;function Yl(t,e,r){r=r||2;var i=e&&e.length,s=i?e[0]*r:t.length,n=k0(t,0,s,r,!0),o=[];if(!n||n.next===n.prev)return o;var a,c,l,u,f,h,d;if(i&&(n=X3(t,e,n,r)),t.length>80*r){a=l=t[0],c=u=t[1];for(var p=r;pl&&(l=f),h>u&&(u=h);d=Math.max(l-a,u-c),d=d!==0?32767/d:0}return da(n,o,r,a,c,d,0),o}function k0(t,e,r,i,s){var n,o;if(s===ip(t,e,r,i)>0)for(n=e;n=e;n-=i)o=L0(n,t[n],t[n+1],o);return o&&Kl(o,o.next)&&(ga(o),o=o.next),o}function qi(t,e){if(!t)return t;e||(e=t);var r=t,i;do if(i=!1,!r.steiner&&(Kl(r,r.next)||_e(r.prev,r,r.next)===0)){if(ga(r),r=e=r.prev,r===r.next)break;i=!0}else r=r.next;while(i||r!==e);return e}function da(t,e,r,i,s,n,o){if(t){!o&&n&&G3(t,i,s,n);for(var a=t,c,l;t.prev!==t.next;){if(c=t.prev,l=t.next,n?W3(t,i,s,n):V3(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),ga(t),t=l.next,a=l.next;continue}if(t=l,t===a){o?o===1?(t=H3(qi(t),e,r),da(t,e,r,i,s,n,2)):o===2&&j3(t,e,r,i,s,n):da(qi(t),e,r,i,s,n,1);break}}}}function V3(t){var e=t.prev,r=t,i=t.next;if(_e(e,r,i)>=0)return!1;for(var s=e.x,n=r.x,o=i.x,a=e.y,c=r.y,l=i.y,u=sn?s>o?s:o:n>o?n:o,d=a>c?a>l?a:l:c>l?c:l,p=i.next;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=f&&p.y<=d&&Hs(s,a,n,c,o,l,p.x,p.y)&&_e(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function W3(t,e,r,i){var s=t.prev,n=t,o=t.next;if(_e(s,n,o)>=0)return!1;for(var a=s.x,c=n.x,l=o.x,u=s.y,f=n.y,h=o.y,d=ac?a>l?a:l:c>l?c:l,_=u>f?u>h?u:h:f>h?f:h,x=tp(d,p,e,r,i),v=tp(g,_,e,r,i),b=t.prevZ,A=t.nextZ;b&&b.z>=x&&A&&A.z<=v;){if(b.x>=d&&b.x<=g&&b.y>=p&&b.y<=_&&b!==s&&b!==o&&Hs(a,u,c,f,l,h,b.x,b.y)&&_e(b.prev,b,b.next)>=0||(b=b.prevZ,A.x>=d&&A.x<=g&&A.y>=p&&A.y<=_&&A!==s&&A!==o&&Hs(a,u,c,f,l,h,A.x,A.y)&&_e(A.prev,A,A.next)>=0))return!1;A=A.nextZ}for(;b&&b.z>=x;){if(b.x>=d&&b.x<=g&&b.y>=p&&b.y<=_&&b!==s&&b!==o&&Hs(a,u,c,f,l,h,b.x,b.y)&&_e(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;A&&A.z<=v;){if(A.x>=d&&A.x<=g&&A.y>=p&&A.y<=_&&A!==s&&A!==o&&Hs(a,u,c,f,l,h,A.x,A.y)&&_e(A.prev,A,A.next)>=0)return!1;A=A.nextZ}return!0}function H3(t,e,r){var i=t;do{var s=i.prev,n=i.next.next;!Kl(s,n)&&B0(s,i,i.next,n)&&pa(s,n)&&pa(n,s)&&(e.push(s.i/r|0),e.push(i.i/r|0),e.push(n.i/r|0),ga(i),ga(i.next),i=t=n),i=i.next}while(i!==t);return qi(i)}function j3(t,e,r,i,s,n){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Q3(o,a)){var c=U0(o,a);o=qi(o,o.next),c=qi(c,c.next),da(o,e,r,i,s,n,0),da(c,e,r,i,s,n,0);return}a=a.next}o=o.next}while(o!==t)}function X3(t,e,r,i){var s=[],n,o,a,c,l;for(n=0,o=e.length;n=r.next.y&&r.next.y!==r.y){var a=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>n&&(n=a,o=r.x=r.x&&r.x>=l&&i!==r.x&&Hs(so.x||r.x===o.x&&q3(o,r)))&&(o=r,f=h)),r=r.next;while(r!==c);return o}function q3(t,e){return _e(t.prev,t,e.prev)<0&&_e(e.next,t,t.next)<0}function G3(t,e,r,i){var s=t;do s.z===0&&(s.z=tp(s.x,s.y,e,r,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,Z3(s)}function Z3(t){var e,r,i,s,n,o,a,c,l=1;do{for(r=t,t=null,n=null,o=0;r;){for(o++,i=r,a=0,e=0;e0||c>0&&i;)a!==0&&(c===0||!i||r.z<=i.z)?(s=r,r=r.nextZ,a--):(s=i,i=i.nextZ,c--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;r=i}n.nextZ=null,l*=2}while(o>1);return t}function tp(t,e,r,i,s){return t=(t-r)*s|0,e=(e-i)*s|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function J3(t){var e=t,r=t;do(e.x=(t-o)*(n-a)&&(t-o)*(i-a)>=(r-o)*(e-a)&&(r-o)*(n-a)>=(s-o)*(i-a)}function Q3(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!e2(t,e)&&(pa(t,e)&&pa(e,t)&&t2(t,e)&&(_e(t.prev,t,e.prev)||_e(t,e.prev,e))||Kl(t,e)&&_e(t.prev,t,t.next)>0&&_e(e.prev,e,e.next)>0)}function _e(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Kl(t,e){return t.x===e.x&&t.y===e.y}function B0(t,e,r,i){var s=$l(_e(t,e,r)),n=$l(_e(t,e,i)),o=$l(_e(r,i,t)),a=$l(_e(r,i,e));return!!(s!==n&&o!==a||s===0&&Xl(t,r,e)||n===0&&Xl(t,i,e)||o===0&&Xl(r,t,i)||a===0&&Xl(r,e,i))}function Xl(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function $l(t){return t>0?1:t<0?-1:0}function e2(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&B0(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function pa(t,e){return _e(t.prev,t,t.next)<0?_e(t,e,t.next)>=0&&_e(t,t.prev,e)>=0:_e(t,e,t.prev)<0||_e(t,t.next,e)<0}function t2(t,e){var r=t,i=!1,s=(t.x+e.x)/2,n=(t.y+e.y)/2;do r.y>n!=r.next.y>n&&r.next.y!==r.y&&s<(r.next.x-r.x)*(n-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next;while(r!==t);return i}function U0(t,e){var r=new rp(t.i,t.x,t.y),i=new rp(e.i,e.x,e.y),s=t.next,n=e.prev;return t.next=e,e.prev=t,r.next=s,s.prev=r,i.next=r,r.prev=i,n.next=i,i.prev=n,i}function L0(t,e,r,i){var s=new rp(t,e,r);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function ga(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function rp(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}Yl.deviation=function(t,e,r,i){var s=e&&e.length,n=s?e[0]*r:t.length,o=Math.abs(ip(t,0,n,r));if(s)for(var a=0,c=e.length;a0&&(i+=t[s-1].length,r.holes.push(i))}return r}});import du from"https://esm.sh/maplibre-gl@3.6.2";function Fr(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var Xt={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Eb=Xt.self||Xt.window||Xt.global||{},wb=Xt.window||Xt.self||Xt.global||{},Pb=Xt.global||Xt.self||Xt.window||{},Rb=Xt.document||{};var fi=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser);var zp=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Cb=zp&&parseFloat(zp[1])||0;var Xa=globalThis,Mb=globalThis.document||{},$a=globalThis.process||{},Ib=globalThis.console,Vp=globalThis.navigator||{};function Ya(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return!!(r&&r.indexOf("Electron")>=0)}function ke(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Ya()}function Pu(t){return!t&&!ke()?"Node":Ya(t)?"Electron":(t||Vp.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var Ru="4.0.7";function Nb(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var Ka=class{constructor(e,r,i="sessionStorage"){this.storage=Nb(i),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}};function Wp(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function Hp(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var qa;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(qa||(qa={}));var Fb=10;function jp(t){return typeof t!="string"?t:(t=t.toUpperCase(),qa[t]||qa.WHITE)}function Xp(t,e,r){return!ke&&typeof t=="string"&&(e&&(t=`\x1B[${jp(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${jp(r)+Fb}m${t}\x1B[49m`)),t}function $p(t,e=["constructor"]){let r=Object.getPrototypeOf(t),i=Object.getOwnPropertyNames(r),s=t;for(let n of i){let o=s[n];typeof o=="function"&&(e.find(a=>n===a)||(s[n]=o.bind(t)))}}function yn(t,e){if(!t)throw new Error(e||"Assertion failed")}function hi(){let t;if(ke()&&Xa.performance)t=Xa?.performance?.now?.();else if("hrtime"in $a){let e=$a?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var ss={debug:ke()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Db={enabled:!0,level:0};function ns(){}var Yp={},Kp={once:!0},qe=class{constructor({id:e}={id:""}){this.VERSION=Ru,this._startTs=hi(),this._deltaTs=hi(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Ka(`__probe-${this.id}__`,Db),this.timeStamp(`${this.id} started`),$p(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((hi()-this._startTs).toPrecision(10))}getDelta(){return Number((hi()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,r){this._storage.setConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e){return this._getLogFunction(0,e,ss.warn,arguments,Kp)}error(e){return this._getLogFunction(0,e,ss.error,arguments)}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r){return this._getLogFunction(e,r,ss.log,arguments,{time:!0,once:!0})}log(e,r){return this._getLogFunction(e,r,ss.debug,arguments)}info(e,r){return this._getLogFunction(e,r,console.info,arguments)}once(e,r){return this._getLogFunction(e,r,ss.debug||ss.info,arguments,Kp)}table(e,r,i){return r?this._getLogFunction(e,r,console.table||ns,i&&[i],{tag:kb(r)}):ns}time(e,r){return this._getLogFunction(e,r,console.time?console.time:console.info)}timeEnd(e,r){return this._getLogFunction(e,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,r){return this._getLogFunction(e,r,console.timeStamp||ns)}group(e,r,i={collapsed:!1}){let s=qp({logLevel:e,message:r,opts:i}),{collapsed:n}=i;return s.method=(n?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,r,i={}){return this.group(e,r,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||ns)}withGroup(e,r,i){this.group(e,r)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Gp(e)}_getLogFunction(e,r,i,s,n){if(this._shouldLog(e)){n=qp({logLevel:e,message:r,args:s,opts:n}),i=i||n.method,yn(i),n.total=this.getTotal(),n.delta=this.getDelta(),this._deltaTs=hi();let o=n.tag||n.message;if(n.once&&o)if(!Yp[o])Yp[o]=hi();else return ns;return r=Lb(this.id,n.message,n),i.bind(console,r,...n.args)}return ns}};qe.VERSION=Ru;function Gp(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return yn(Number.isFinite(e)&&e>=0),e}function qp(t){let{logLevel:e,message:r}=t;t.logLevel=Gp(e);let i=t.args?Array.from(t.args):[];for(;i.length&&i.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&i.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let s=typeof t.message;return yn(s==="string"||s==="object"),Object.assign(t,{args:i},t.opts)}function Lb(t,e,r){if(typeof e=="string"){let i=r.time?Hp(Wp(r.total)):"";e=r.time?`${t}: ${i} ${e}`:`${t}: ${e}`,e=Xp(e,r.color,r.background)}return e}function kb(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}globalThis.probe={};var kO=new qe({id:"@probe.gl/log"});function Cu(t,e){return Zp(t||{},e)}function Zp(t,e,r=0){if(r>3)return e;let i={...t};for(let[s,n]of Object.entries(e))n&&typeof n=="object"&&!Array.isArray(n)?i[s]=Zp(i[s]||{},e[s],r+1):i[s]=e[s];return i}var Jp="latest";function Bb(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.1"),globalThis._loadersgl_.version}var Mu=Bb();function je(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var $t={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},jO=$t.self||$t.window||$t.global||{},XO=$t.window||$t.self||$t.global||{},$O=$t.global||$t.self||$t.window||{},YO=$t.document||{};var ht=typeof process!="object"||String(process)!=="[object process]"||process.browser;var eg=typeof window<"u"&&typeof window.orientation<"u",Qp=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),KO=Qp&&parseFloat(Qp[1])||0;var xn=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,r){this.name=e,this.workerThread=r,this.result=new Promise((i,s)=>{this._resolve=i,this._reject=s})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){je(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){je(this.isRunning),this.isRunning=!1,this._reject(e)}};var os=class{terminate(){}};var Iu=new Map;function tg(t){je(t.source&&!t.url||!t.source&&t.url);let e=Iu.get(t.source||t.url);return e||(t.url&&(e=Ub(t.url),Iu.set(t.url,e)),t.source&&(e=rg(t.source),Iu.set(t.source,e))),je(e),e}function Ub(t){if(!t.startsWith("http"))return t;let e=zb(t);return rg(e)}function rg(t){let e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function zb(t){return`try { + importScripts('${t}'); +} catch (error) { + console.error(error); + throw error; +}`}function Ou(t,e=!0,r){let i=r||new Set;if(t){if(ig(t))i.add(t);else if(ig(t.buffer))i.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let s in t)Ou(t[s],e,i)}}return r===void 0?Array.from(i):[]}function ig(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}var Nu=()=>{},Dr=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&ht||typeof os<"u"&&!ht}constructor(e){let{name:r,source:i,url:s}=e;je(i||s),this.name=r,this.source=i,this.url=s,this.onMessage=Nu,this.onError=n=>console.log(n),this.worker=ht?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Nu,this.onError=Nu,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,r){r=r||Ou(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=tg({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new os(i,{eval:!1})}else if(this.source)e=new os(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}};var Tn=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Dr.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,r=(s,n,o)=>s.done(o),i=(s,n)=>s.error(n)){let s=new Promise(n=>(this.jobQueue.push({name:e,onMessage:r,onError:i,onStart:n}),this));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});let i=new xn(r.name,e);e.onMessage=s=>r.onMessage(i,s.type,s.payload),e.onError=s=>r.onError(i,s),r.onStart(i);try{await i.result}catch(s){console.error(`Worker exception: ${s}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!ht||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}},di=class t{props;workerPools=new Map;static _workerFarm;static isSupported(){return Dr.isSupported()}static getWorkerFarm(e={}){return t._workerFarm=t._workerFarm||new t({}),t._workerFarm.setProps(e),t._workerFarm}constructor(e){this.props={...Vb},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:r,source:i,url:s}=e,n=this.workerPools.get(r);return n||(n=new Tn({name:r,source:i,url:s}),n.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,n)),n}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};function Fu(t,e={}){let r=e[t.id]||{},i=ht?`${t.id}-worker.js`:`${t.id}-worker-node.js`,s=r.workerUrl;if(!s&&t.id==="compression"&&(s=e.workerUrl),e._workerType==="test"&&(ht?s=`modules/${t.module}/dist/${i}`:s=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!s){let n=t.version;n==="latest"&&(n=Jp);let o=n?`@${n}`:"";s=`https://unpkg.com/@loaders.gl/${t.module}${o}/dist/${i}`}return je(s),s}function Du(t,e=Mu){je(t,"no worker provided");let r=t.version;return!(!e||!r)}function Lu(t,e){return!di.isSupported()||!ht&&!e?._nodeWorkers?!1:t.worker&&e?.worker}async function ku(t,e,r,i,s){let n=t.id,o=Fu(t,r),c=di.getWorkerFarm(r).getWorkerPool({name:n,url:o});r=JSON.parse(JSON.stringify(r)),i=JSON.parse(JSON.stringify(i||{}));let l=await c.startJob("process-on-worker",Wb.bind(null,s));return l.postMessage("process",{input:e,options:r,context:i}),await(await l.result).result}async function Wb(t,e,r,i){switch(r){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":let{id:s,input:n,options:o}=i;try{let a=await t(n,o);e.postMessage("done",{id:s,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:s,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function Bu(t,e,r){if(r=r||t.byteLength,t.byteLengthn instanceof ArrayBuffer?new Uint8Array(n):n),r=e.reduce((n,o)=>n+o.byteLength,0),i=new Uint8Array(r),s=0;for(let n of e)i.set(n,s),s+=n.byteLength;return i.buffer}async function zu(t){let e=[];for await(let r of t)e.push(r);return Uu(...e)}function vn(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var pi=class{constructor(e,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=vn(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(vn()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var dt=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:i}=e,s=this.stats[r];return s||(e instanceof pi?s=e:s=new pi(r,i),this.stats[r]=s),s}};var Hb="",ng={};function Vu(t){for(let e in ng)if(t.startsWith(e)){let r=ng[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${Hb}${t}`),t}function og(t){return t&&typeof t=="object"&&t.isBuffer}function Ga(t){if(og(t))return t;if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t))return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);if(typeof t=="string"){let e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}var gi={};ui(gi,{dirname:()=>Xb,filename:()=>jb,join:()=>$b,resolve:()=>Yb});function ag(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function jb(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):""}function Xb(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function $b(...t){let e="/";return t=t.map((r,i)=>(i&&(r=r.replace(new RegExp(`^${e}`),"")),i!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function Yb(...t){let e=[];for(let n=0;n=-1&&!i;n--){let o;n>=0?o=e[n]:(s===void 0&&(s=ag()),o=s),o.length!==0&&(r=`${o}/${r}`,i=o.charCodeAt(0)===bn)}return r=Kb(r,!i),i?`/${r}`:r.length>0?r:"."}var bn=47,Wu=46;function Kb(t,e){let r="",i=-1,s=0,n,o=!1;for(let a=0;a<=t.length;++a){if(a2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==bn;--l);if(l!==c){r=l===-1?"":r.slice(0,l),i=a,s=0,o=!1;continue}}else if(r.length===2||r.length===1){r="",i=a,s=0,o=!1;continue}}e&&(r.length>0?r+="/..":r="..",o=!0)}else{let c=t.slice(i+1,a);r.length>0?r+=`/${c}`:r=c,o=!1}i=a,s=0}else n===Wu&&s!==-1?++s:s=-1}return r}var qb=t=>typeof t=="boolean",Sn=t=>typeof t=="function",mi=t=>t!==null&&typeof t=="object",Hu=t=>mi(t)&&t.constructor==={}.constructor;var cg=t=>!!t&&typeof t[Symbol.iterator]=="function",lg=t=>t&&typeof t[Symbol.asyncIterator]=="function";var pt=t=>typeof Response<"u"&&t instanceof Response||t&&t.arrayBuffer&&t.text&&t.json;var gt=t=>typeof Blob<"u"&&t instanceof Blob,ug=t=>t&&typeof t=="object"&&t.isBuffer;var Gb=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||mi(t)&&Sn(t.tee)&&Sn(t.cancel)&&Sn(t.getReader);var Zb=t=>mi(t)&&Sn(t.read)&&Sn(t.pipe)&&qb(t.readable),Za=t=>Gb(t)||Zb(t);var Ja=class extends Error{constructor(e,r){super(e),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var Jb=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Qb=/^([-\w.]+\/[-\w.+]+)/;function ju(t,e){return t.toLowerCase()===e.toLowerCase()}function fg(t){let e=Qb.exec(t);return e?e[1]:t}function Xu(t){let e=Jb.exec(t);return e?e[1]:""}var hg=/\?.*/;function dg(t){let e=t.match(hg);return e&&e[0]}function as(t){return t.replace(hg,"")}function pg(t){if(t.length<50)return t;let e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function _i(t){return pt(t)?t.url:gt(t)?t.name||"":typeof t=="string"?t:""}function An(t){if(pt(t)){let e=t,r=e.headers.get("content-type")||"",i=as(e.url);return fg(r)||Xu(i)}return gt(t)?t.type||"":typeof t=="string"?Xu(t):""}function gg(t){return pt(t)?t.headers["content-length"]||-1:gt(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function Qa(t){if(pt(t))return t;let e={},r=gg(t);r>=0&&(e["content-length"]=String(r));let i=_i(t),s=An(t);s&&(e["content-type"]=s);let n=await tS(t);n&&(e["x-first-bytes"]=n),typeof t=="string"&&(t=new TextEncoder().encode(t));let o=new Response(t,{headers:e});return Object.defineProperty(o,"url",{value:i}),o}async function mg(t){if(!t.ok)throw await eS(t)}async function eS(t){let e=pg(t.url),r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;let i={reason:t.statusText,url:t.url,response:t};try{let s=t.headers.get("Content-Type");i.reason=s?.includes("application/json")?await t.json():t.text()}catch{}return new Ja(r,i)}async function tS(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){let r=t.slice(0,5);return await new Promise(i=>{let s=new FileReader;s.onload=n=>i(n?.target?.result),s.readAsDataURL(r)})}if(t instanceof ArrayBuffer){let r=t.slice(0,5);return`data:base64,${rS(r)}`}return null}function rS(t){let e="",r=new Uint8Array(t);for(let i=0;i{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},tc=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var Ku={fetch:null,mimeType:void 0,nothrow:!1,log:new tc,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:fi,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},_g={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function qu(){globalThis.loaders=globalThis.loaders||{};let{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function Gu(){let t=qu();return t.globalOptions=t.globalOptions||{...Ku},t.globalOptions}function Tg(t,e,r,i){return r=r||[],r=Array.isArray(r)?r:[r],oS(t,r),cS(e,t,i)}function oS(t,e){yg(t,null,Ku,_g,e);for(let r of e){let i=t&&t[r.id]||{},s=r.options&&r.options[r.id]||{},n=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};yg(i,r.id,s,n,e)}}function yg(t,e,r,i,s){let n=e||"Top level",o=e?`${e}.`:"";for(let a in t){let c=!e&&mi(t[a]),l=a==="baseUri"&&!e,u=a==="workerUrl"&&e;if(!(a in r)&&!l&&!u){if(a in i)Yu.warn(`${n} loader option '${o}${a}' no longer supported, use '${i[a]}'`)();else if(!c){let f=aS(a,s);Yu.warn(`${n} loader option '${o}${a}' not recognized. ${f}`)()}}}}function aS(t,e){let r=t.toLowerCase(),i="";for(let s of e)for(let n in s.options){if(t===n)return`Did you mean '${s.id}.${n}'?`;let o=n.toLowerCase();(r.startsWith(o)||o.startsWith(r))&&(i=i||`Did you mean '${s.id}.${n}'?`)}return i}function cS(t,e,r){let s={...t.options||{}};return lS(s,r),s.log===null&&(s.log=new ec),xg(s,Gu()),xg(s,e),s}function xg(t,e){for(let r in e)if(r in e){let i=e[r];Hu(i)&&Hu(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function lS(t,e){e&&!("baseUri"in t)&&(t.baseUri=e)}function En(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t?.extensions)):!1}function wn(t){Fr(t,"null loader"),Fr(En(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t?.parseTextSync||t?.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}var vg=()=>{let t=qu();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function Zu(t){let e=vg();t=Array.isArray(t)?t:[t];for(let r of t){let i=wn(r);e.find(s=>i===s)||e.unshift(i)}}function bg(){return vg()}var Sg=new qe({id:"loaders.gl"});var uS=/\.([^.]+)$/;async function wg(t,e=[],r,i){if(!Pg(t))return null;let s=Ag(t,e,{...r,nothrow:!0},i);if(s)return s;if(gt(t)&&(t=await t.slice(0,10).arrayBuffer(),s=Ag(t,e,r,i)),!s&&!r?.nothrow)throw new Error(Rg(t));return s}function Ag(t,e=[],r,i){if(!Pg(t))return null;if(e&&!Array.isArray(e))return wn(e);let s=[];e&&(s=s.concat(e)),r?.ignoreRegisteredLoaders||s.push(...bg()),hS(s);let n=fS(t,s,r,i);if(!n&&!r?.nothrow)throw new Error(Rg(t));return n}function fS(t,e,r,i){let s=_i(t),n=An(t),o=as(s)||i?.url,a=null,c="";return r?.mimeType&&(a=Ju(e,r?.mimeType),c=`match forced by supplied MIME type ${r?.mimeType}`),a=a||dS(e,o),c=c||(a?`matched url ${o}`:""),a=a||Ju(e,n),c=c||(a?`matched MIME type ${n}`:""),a=a||gS(e,t),c=c||(a?`matched initial data ${Cg(t)}`:""),r?.fallbackMimeType&&(a=a||Ju(e,r?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${n}`:"")),c&&Sg.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function Pg(t){return!(t instanceof Response&&t.status===204)}function Rg(t){let e=_i(t),r=An(t),i="No valid loader found (";i+=e?`${gi.filename(e)}, `:"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let s=t?Cg(t):"";return i+=s?` first bytes: "${s}"`:"first bytes: not available",i+=")",i}function hS(t){for(let e of t)wn(e)}function dS(t,e){let r=e&&uS.exec(e),i=r&&r[1];return i?pS(t,i):null}function pS(t,e){e=e.toLowerCase();for(let r of t)for(let i of r.extensions)if(i.toLowerCase()===e)return r;return null}function Ju(t,e){for(let r of t)if(r.mimeTypes?.some(i=>ju(e,i))||ju(e,`application/x.${r.id}`))return r;return null}function gS(t,e){if(!e)return null;for(let r of t)if(typeof e=="string"){if(mS(e,r))return r}else if(ArrayBuffer.isView(e)){if(Eg(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&Eg(e,0,r))return r;return null}function mS(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(i=>t.startsWith(i))}function Eg(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(s=>_S(t,e,r,s))}function _S(t,e,r,i){if(i instanceof ArrayBuffer)return Bu(i,t,i.byteLength);switch(typeof i){case"function":return i(t);case"string":let s=Qu(t,e,i.length);return i===s;default:return!1}}function Cg(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?Qu(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?Qu(t,0,e):""}function Qu(t,e,r){if(t.byteLength$u(s,i.fetch):e?.fetch?e?.fetch:$u}function Lg(t,e,r){if(r)return r;let i={fetch:rc(e,t),...t};if(i.url){let s=as(i.url);i.baseUrl=s,i.queryString=dg(i.url),i.filename=gi.filename(s),i.baseUrl=gi.dirname(s)}return Array.isArray(i.loaders)||(i.loaders=null),i}function kg(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){let i=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...i]:i}return r&&r.length?r:void 0}async function Pn(t,e,r,i){e&&!Array.isArray(e)&&!En(e)&&(i=void 0,r=e,e=void 0),t=await t,r=r||{};let s=_i(t),o=kg(e,i),a=await wg(t,o,r);return a?(r=Tg(r,a,o,s),i=Lg({url:s,_parse:Pn,loaders:o},r,i||null),await vS(a,t,r,i)):null}async function vS(t,e,r,i){if(Du(t),r=Cu(t.options,r),pt(e)){let n=e,{ok:o,redirected:a,status:c,statusText:l,type:u,url:f}=n,h=Object.fromEntries(n.headers.entries());i.response={headers:h,ok:o,redirected:a,status:c,statusText:l,type:u,url:f}}e=await Dg(e,t,r);let s=t;if(s.parseTextSync&&typeof e=="string")return s.parseTextSync(e,r,i);if(Lu(t,r))return await ku(t,e,r,i,Pn);if(s.parseText&&typeof e=="string")return await s.parseText(e,r,i);if(s.parse)return await s.parse(e,r,i);throw je(!s.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}async function Lr(t,e,r,i){let s,n;!Array.isArray(e)&&!En(e)?(s=[],n=e,i=void 0):(s=e,n=r);let o=rc(n),a=t;return typeof t=="string"&&(a=await o(t)),gt(t)&&(a=await o(t)),Array.isArray(s)?await Pn(a,s,n):await Pn(a,s,n)}var Bg="4.2.1";var bS=globalThis.loaders?.parseImageNode,tf=typeof Image<"u",rf=typeof ImageBitmap<"u",SS=!!bS,sf=fi?!0:SS;function Ug(t){switch(t){case"auto":return rf||tf||sf;case"imagebitmap":return rf;case"image":return tf;case"data":return sf;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function zg(){if(rf)return"imagebitmap";if(tf)return"image";if(sf)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function AS(t){let e=ES(t);if(!e)throw new Error("Not an image");return e}function Vg(t){switch(AS(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function ES(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var wS=/^data:image\/svg\+xml/,PS=/\.svg((\?|#).*)?$/;function ic(t){return t&&(wS.test(t)||PS.test(t))}function Wg(t,e){if(ic(e)){let i=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(n){throw new Error(n.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return nf(t,e)}function nf(t,e){if(ic(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function sc(t,e,r){let i=Wg(t,r),s=self.URL||self.webkitURL,n=typeof i!="string"&&s.createObjectURL(i);try{return await RS(n||i,e)}finally{n&&s.revokeObjectURL(n)}}async function RS(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((i,s)=>{try{r.onload=()=>i(r),r.onerror=n=>{let o=n instanceof Error?n.message:"error";s(new Error(o))}}catch(n){s(n)}})}var CS={},Hg=!0;async function jg(t,e,r){let i;ic(r)?i=await sc(t,e,r):i=nf(t,r);let s=e&&e.imagebitmap;return await MS(i,s)}async function MS(t,e=null){if((IS(e)||!Hg)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),Hg=!1}return await createImageBitmap(t)}function IS(t){for(let e in t||CS)return!1;return!0}function Xg(t){return!DS(t,"ftyp",4)||!(t[8]&96)?null:OS(t)}function OS(t){switch(NS(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function NS(t,e,r){return String.fromCharCode(...t.slice(e,r))}function FS(t){return[...t].map(e=>e.charCodeAt(0))}function DS(t,e,r=0){let i=FS(e);for(let s=0;s=24&&e.getUint32(0,Yt)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Yt),height:e.getUint32(20,Yt)}:null}function BS(t){let e=Cn(t);return e.byteLength>=10&&e.getUint32(0,Yt)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,Rn),height:e.getUint16(8,Rn)}:null}function US(t){let e=Cn(t);return e.byteLength>=14&&e.getUint16(0,Yt)===16973&&e.getUint32(2,Rn)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,Rn),height:e.getUint32(22,Rn)}:null}function zS(t){let e=Cn(t);if(!(e.byteLength>=3&&e.getUint16(0,Yt)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:s}=VS(),n=2;for(;n+9!!nc(new DataView(t))],options:XS};var $S=new qe({id:"deck"}),U=$S;var af={};function Kg(t){af=t}function xe(t,e,r,i){U.level>0&&af[t]&&af[t].call(null,e,r,i)}function YS(t){let e=t[0],r=t[t.length-1];return e==="{"&&r==="}"||e==="["&&r==="]"}var qg={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:YS,parseTextSync:JSON.parse};function KS(){let t="9.0.16",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(U.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:U,_registerLoggers:Kg},Zu([qg,[of,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}var Gg=KS();function Kt(t,e){if(!t)throw new Error(e||"shadertools: assertion failed.")}var cf={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function Jg(t){let e={};for(let[r,i]of Object.entries(t))e[r]=qS(i);return e}function Qg(t,e,r){let i={};for(let[s,n]of Object.entries(e))t&&s in t&&!n.private?(n.validate&&Kt(n.validate(t[s],n),`${r}: invalid ${s}`),i[s]=t[s]):i[s]=n.value;return i}function qS(t){let e=Zg(t);if(e!=="object")return{value:t,...cf[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...cf[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=Zg(t.value),{...t,...cf[e],type:e}):{type:"object",value:null};throw new Error("props")}function Zg(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var em=`#ifdef MODULE_LOGDEPTH +logdepth_adjustPosition(gl_Position); +#endif +`,tm=`#ifdef MODULE_MATERIAL +gl_FragColor = material_filterColor(gl_FragColor); +#endif +#ifdef MODULE_LIGHTING +gl_FragColor = lighting_filterColor(gl_FragColor); +#endif +#ifdef MODULE_FOG +gl_FragColor = fog_filterColor(gl_FragColor); +#endif +#ifdef MODULE_PICKING +gl_FragColor = picking_filterHighlightColor(gl_FragColor); +gl_FragColor = picking_filterPickingColor(gl_FragColor); +#endif +#ifdef MODULE_LOGDEPTH +logdepth_setFragDepth(); +#endif +`;var GS={vertex:em,fragment:tm},rm=/void\s+main\s*\([^)]*\)\s*\{\n?/,im=/}\n?[^{}]*$/,lf=[],Mn="__LUMA_INJECT_DECLARATIONS__";function sm(t){let e={vertex:{},fragment:{}};for(let r in t){let i=t[r],s=ZS(r);typeof i=="string"&&(i={order:0,injection:i}),e[s][r]=i}return e}function ZS(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function In(t,e,r,i=!1){let s=e==="vertex";for(let n in r){let o=r[n];o.sort((c,l)=>c.order-l.order),lf.length=o.length;for(let c=0,l=o.length;cc+a));break;case"vs:#main-end":s&&(t=t.replace(im,c=>a+c));break;case"fs:#decl":s||(t=t.replace(Mn,a));break;case"fs:#main-start":s||(t=t.replace(rm,c=>c+a));break;case"fs:#main-end":s||(t=t.replace(im,c=>a+c));break;default:t=t.replace(n,c=>c+a)}}return t=t.replace(Mn,""),i&&(t=t.replace(/\}\s*$/,n=>n+GS[e])),t}var JS=1,cs=class t{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(r=>{if(r instanceof t)return r;Kt(typeof r!="string",`Shader module use by name is deprecated. Import shader module '${JSON.stringify(r)}' and use it directly.`),r.name||(console.warn("shader module has no name"),r.name=`shader-module-${JS++}`);let i=new t(r);return i.dependencies=t.instantiateModules(r.dependencies||[]),i})}constructor(e){let{name:r,vs:i,fs:s,dependencies:n=[],uniformTypes:o={},uniformPropTypes:a={},getUniforms:c,deprecations:l=[],defines:u={},inject:f={}}=e;Kt(typeof r=="string"),this.name=r,this.vs=i,this.fs=s,this.getModuleUniforms=c,this.dependencies=t.instantiateModules(n),this.deprecations=this._parseDeprecationDefinitions(l),this.defines=u,this.injections=sm(f),this.uniformTypes=o,a&&(this.uniforms=Jg(a))}getModuleSource(e){let r;switch(e){case"vertex":r=this.vs||"";break;case"fragment":r=this.fs||"";break;default:Kt(!1)}let i=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} --------------- + +#define MODULE_${i} +${r} + +`}getUniforms(e,r){return this.getModuleUniforms?this.getModuleUniforms(e,r):Qg(e,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(e,r){this.deprecations.forEach(i=>{i.regex?.test(e)&&(i.deprecated?r.deprecated(i.old,i.new)():r.removed(i.old,i.new)())})}_parseDeprecationDefinitions(e){return e.forEach(r=>{switch(r.type){case"function":r.regex=new RegExp(`\\b${r.old}\\(`);break;default:r.regex=new RegExp(`${r.type} ${r.old};`)}}),e}_defaultGetUniforms(e={}){let r={},i=this.uniforms;for(let s in i){let n=i[s];s in e&&!n.private?(n.validate&&Kt(n.validate(e[s],n),`${this.name}: invalid ${s}`),r[s]=e[s]):r[s]=n.value}return r}};function uf(t){if(t.source&&t.platformInfo.type==="webgpu")return{...t,vs:void 0,fs:void 0};if(!t.vs)throw new Error("no vertex shader");let e=nm(t.platformInfo,t.vs),r;return t.fs&&(r=nm(t.platformInfo,t.fs)),{...t,vs:e,fs:r}}function nm(t,e){if(typeof e=="string")return e;switch(t.type){case"webgpu":if(e?.wgsl)return e.wgsl;throw new Error("WebGPU does not support GLSL shaders");default:if(e?.glsl)return e.glsl;throw new Error("WebGL does not support WGSL shaders")}}function yi(t){let e=cs.instantiateModules(t);return QS(e)}function QS(t){let e={},r={};return om({modules:t,level:0,moduleMap:e,moduleDepth:r}),Object.keys(r).sort((i,s)=>r[s]-r[i]).map(i=>e[i])}function om(t){let{modules:e,level:r,moduleMap:i,moduleDepth:s}=t;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let n of e)i[n.name]=n,(s[n.name]===void 0||s[n.name]o.order-a.order);for(let o of n)r+=` ${o.injection} +`}s.footer&&(r+=` ${s.footer}`),r+=`} +`}return r}function df(t){let e={vertex:{},fragment:{}};for(let r of t){let i,s;typeof r!="string"?(i=r,s=i.hook):(i={},s=r),s=s.trim();let[n,o]=s.split(":"),a=s.replace(/\(.+/,""),c=Object.assign(i,{signature:o});switch(n){case"vs":e.vertex[a]=c;break;case"fs":e.fragment[a]=c;break;default:throw new Error(n)}}return e}function fm(t,e){return{name:r1(t,e),language:"glsl",version:i1(t)}}function r1(t,e="unnamed"){let i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(t);return i?i[1]:e}function i1(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let i=parseInt(r[1],10);Number.isFinite(i)&&(e=i)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var dm=` + +${Mn} +`,s1=`precision highp float; +`;function pm(t){let e=yi(t.modules||[]);return{source:pf(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e}),getUniforms:gf(e)}}function gm(t){let e=yi(t.modules||[]);return{vs:pf(t.platformInfo,{...t,source:t.vs,stage:"vertex",modules:e}),fs:pf(t.platformInfo,{...t,source:t.fs,stage:"fragment",modules:e}),getUniforms:gf(e)}}function mm(t){let{vs:e,fs:r}=t,i=yi(t.modules||[]);return{vs:hm(t.platformInfo,{...t,source:e,stage:"vertex",modules:i}),fs:hm(t.platformInfo,{...t,source:r,stage:"fragment",modules:i}),getUniforms:gf(i)}}function pf(t,e){let{source:r,stage:i,modules:s,hookFunctions:n=[],inject:o={},log:a}=e;Kt(typeof r=="string","shader source must be a string");let c=r,l="",u=df(n),f={},h={},d={};for(let g in o){let _=typeof o[g]=="string"?{injection:o[g],order:0}:o[g],x=/^(v|f)s:(#)?([\w-]+)$/.exec(g);if(x){let v=x[2],b=x[3];v?b==="decl"?h[g]=[_]:d[g]=[_]:f[g]=[_]}else d[g]=[_]}let p=t.type!=="webgpu"?s:[];for(let g of p){a&&g.checkDeprecations(c,a);let _=g.getModuleSource(i,"wgsl");l+=_;let x=g.injections[i];for(let v in x){let b=/^(v|f)s:#([\w-]+)$/.exec(v);if(b){let C=b[2]==="decl"?h:d;C[v]=C[v]||[],C[v].push(x[v])}else f[v]=f[v]||[],f[v].push(x[v])}}return l+=dm,l=In(l,i,h),l+=hf(u[i],f),l+=c,l=In(l,i,d),l}function hm(t,e){let{id:r,source:i,stage:s,language:n="glsl",modules:o,defines:a={},hookFunctions:c=[],inject:l={},prologue:u=!0,log:f}=e;Kt(typeof i=="string","shader source must be a string");let h=n==="glsl"?fm(i).version:-1,d=t.shaderLanguageVersion,p=h===100?"#version 100":"#version 300 es",_=i.split(` +`).slice(1).join(` +`),x={};o.forEach(F=>{Object.assign(x,F.getDefines())}),Object.assign(x,a);let v="";switch(n){case"wgsl":break;case"glsl":v=u?`${p} + +// ----- PROLOGUE ------------------------- +${n1({id:r,source:i,stage:s})} +${`#define SHADER_TYPE_${s.toUpperCase()}`} +${am(t)} +${s==="fragment"?s1:""} + +// ----- APPLICATION DEFINES ------------------------- + +${o1(x)} + +`:`${p} +`;break}let b=df(c),A={},C={},M={};for(let F in l){let N=typeof l[F]=="string"?{injection:l[F],order:0}:l[F],D=/^(v|f)s:(#)?([\w-]+)$/.exec(F);if(D){let L=D[2],Y=D[3];L?Y==="decl"?C[F]=[N]:M[F]=[N]:A[F]=[N]}else M[F]=[N]}for(let F of o){f&&F.checkDeprecations(_,f);let N=F.getModuleSource(s);v+=N;let D=F.injections[s];for(let L in D){let Y=/^(v|f)s:#([\w-]+)$/.exec(L);if(Y){let $=Y[2]==="decl"?C:M;$[L]=$[L]||[],$[L].push(D[L])}else A[L]=A[L]||[],A[L].push(D[L])}}return v+="// ----- MAIN SHADER SOURCE -------------------------",v+=dm,v=In(v,s,C),v+=hf(b[s],A),v+=_,v=In(v,s,M),n==="glsl"&&h!==d&&(v=lm(v,s)),v.trim()}function gf(t){return function(r){let i={};for(let s of t){let n=s.getUniforms(r,i);Object.assign(i,n)}return i}}function n1(t){let{id:e,source:r,stage:i}=t;return e&&r.indexOf("SHADER_NAME")===-1?` +#define SHADER_NAME ${e}_${i} + +`:""}function o1(t={}){let e="";for(let r in t){let i=t[r];(i||Number.isFinite(i))&&(e+=`#define ${r.toUpperCase()} ${t[r]} +`)}return e}var xi=class t{static defaultShaderAssembler;_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return t.defaultShaderAssembler=t.defaultShaderAssembler||new t,t.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(r=>r.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let r=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==r)}addShaderHook(e,r){r&&(e=Object.assign(r,{hook:e})),this._hookFunctions.push(e)}assembleShader(e){let r=this._getModuleList(e.modules),i=this._hookFunctions,s=uf(e);return{...pm({platformInfo:e.platformInfo,...s,modules:r,hookFunctions:i}),modules:r}}assembleShaderPair(e){let r=uf(e),i=this._getModuleList(e.modules),s=this._hookFunctions,{platformInfo:n}=e;return{...e.platformInfo.shaderLanguage==="wgsl"?gm({platformInfo:n,...r,modules:i,hookFunctions:s}):mm({platformInfo:n,...r,modules:i,hookFunctions:s}),modules:i}}_getModuleList(e=[]){let r=new Array(this._defaultModules.length+e.length),i={},s=0;for(let n=0,o=this._defaultModules.length;nt.startsWith(e))}function ac(t){let e=m1.exec(t);if(e){let[,r,i,s,n,o]=e;if(r){let a=`${s}${i}`,c=oc(a);return{format:r,components:r.length,srgb:n==="-srgb",unsized:o==="-unsized",webgl:o==="-webgl",...c}}}return y1(t)}var _1={"rgba4unorm-webgl":{format:"rgba",bpp:2},"rgb565unorm-webgl":{format:"rgb",bpp:2},"rgb5a1unorm-webgl":{format:"rgba",bbp:2},rgb9e5ufloat:{format:"rgb",bbp:4},rg11b10ufloat:{format:"rgb",bbp:4},rgb10a2unorm:{format:"rgba",bbp:4},"rgb10a2uint-webgl":{format:"rgba",bbp:4},stencil8:{components:1,bpp:1,a:"stencil"},depth16unorm:{components:1,bpp:2,a:"depth"},depth24plus:{components:1,bpp:3,a:"depth"},depth32float:{components:1,bpp:4,a:"depth"},"depth24plus-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth24unorm-stencil8":{components:2,bpp:4,a:"depth-stencil"},"depth32float-stencil8":{components:2,bpp:4,a:"depth-stencil"}};function y1(t){let e=_1[t];if(!e)throw new Error(`Unknown format ${t}`);return{format:e.format||"",components:e.components||e.format?.length||1,byteLength:e.bpp||1,srgb:!1,unsized:!1}}var Nn=class{},Fn=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures[e]&&this.features.has(e)}},hr=class t{static defaultProps={id:null,canvas:null,container:null,manageState:!0,width:800,height:600,requestMaxLimits:!0,debug:!!O.get("debug"),spector:!!(O.get("spector")||O.get("spectorjs")),break:[],initalizeFeatures:!0,disabledFeatures:{"compilation-status-async-webgl":!0},gl:null,onError:e=>O.error(e.message)};get[Symbol.toStringTag](){return"Device"}static VERSION=ym;constructor(e){this.props={...t.defaultProps,...e},this.id=this.props.id||Fe(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=ls;_lumaData={};isTextureFormatCompressed(e){return Tm(e)}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||typeof e=="string")&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};return(e.usage||0)&ie.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":O.warn("indices buffer content must be of integer type")()),r}};function ee(t,e){if(!t)throw new Error(e||"luma.gl: assertion failed.")}var Dn=new Map,dr=class t{static defaultProps={...hr.defaultProps,type:"best-available",devices:void 0};static stats=ls;static log=O;static registerDevices(e){for(let r of e)ee(r.type&&r.isSupported&&r.create),Dn.set(r.type,r)}static getAvailableDevices(){return Array.from(Dn).map(e=>e.type)}static getSupportedDevices(){return Array.from(Dn).filter(e=>e.isSupported()).map(e=>e.type)}static setDefaultDeviceProps(e){Object.assign(hr.defaultProps,e)}static async attachDevice(e){let r=vm(e.devices)||Dn;if(e.handle instanceof WebGL2RenderingContext){let i=r.get("webgl");if(i)return await i.attach(e.handle)}if(e.handle===null){let i=r.get("unknown");if(i)return await i.attach(null)}throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static async createDevice(e={}){e={...t.defaultProps,...e},e.gl&&(e.type="webgl");let r=vm(e.devices)||Dn;switch(e.type){case"webgpu":let i=r.get("webgpu");if(i)return await i.create(e);break;case"webgl":let s=r.get("webgl");if(s)return await s.create(e);break;case"unknown":let n=r.get("unknown");if(n)return await n.create(e);break;case"best-available":if(i=r.get("webgpu"),i?.isSupported?.())return await i.create(e);if(s=r.get("webgl"),s?.isSupported?.())return await s.create(e);break}throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static enforceWebGL2(e=!0){let r=HTMLCanvasElement.prototype;if(!e&&r.originalGetContext){r.getContext=r.originalGetContext,r.originalGetContext=void 0;return}r.originalGetContext=r.getContext,r.getContext=function(i,s){return i==="webgl"||i==="experimental-webgl"?this.originalGetContext("webgl2",s):this.originalGetContext(i,s)}}};function vm(t){if(!t||t?.length===0)return null;let e=new Map;for(let r of t)e.set(r.type,r);return e}var x1=ke()&&typeof document<"u",cc=()=>x1&&document.readyState==="complete",T1={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"},Ti=class{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return cc()}static pageLoaded=v1();constructor(e){if(this.props={...T1,...e},e=this.props,!ke()){this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,this.canvas=null;return}if(e.canvas)typeof e.canvas=="string"?this.canvas=S1(e.canvas):this.canvas=e.canvas;else{let r=A1(e),i=b1(e?.container||null);i.insertBefore(r,i.firstChild),this.canvas=r,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(r=>{for(let i of r)i.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){return typeof OffscreenCanvas<"u"&&this.canvas instanceof OffscreenCanvas||(e=e===void 0?this.props.useDevicePixels:e,!e||e<=0)?1:e===!0?typeof window<"u"&&window.devicePixelRatio||1:e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":let e=this.getDevicePixelRatio(),r=this.canvas;return r.parentElement?[r.clientWidth*e,r.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){let[e,r]=this.getPixelSize();return e/r}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),{clientWidth:r}=this._canvasSizeInfo;return r?e/r:1}catch{return 1}}cssToDevicePixels(e,r=!0){let i=this.cssToDeviceRatio(),[s,n]=this.getDrawingBufferSize();return E1(e,i,s,n,r)}setDevicePixelRatio(e,r={}){if(!this.htmlCanvas)return;let i="width"in r?r.width:this.htmlCanvas.clientWidth,s="height"in r?r.height:this.htmlCanvas.clientHeight;(!i||!s)&&(O.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,i=this.htmlCanvas.width||1,s=this.htmlCanvas.height||1);let n=this._canvasSizeInfo;if(n.clientWidth!==i||n.clientHeight!==s||n.devicePixelRatio!==e){let o=e,a=Math.floor(i*o),c=Math.floor(s*o);this.htmlCanvas.width=a,this.htmlCanvas.height=c;let[l,u]=this.getDrawingBufferSize();(l!==a||u!==c)&&(o=Math.min(l/i,u/s),this.htmlCanvas.width=Math.floor(i*o),this.htmlCanvas.height=Math.floor(s*o),O.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=i,this._canvasSizeInfo.clientHeight=s,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){let e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}};function v1(){return cc()||typeof window>"u"?Promise.resolve():new Promise(t=>{window.addEventListener("load",()=>t())})}function b1(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e&&!cc())throw new Error(`Accessing '${t}' before page was loaded`);if(!e)throw new Error(`${t} is not an HTML element`);return e}else if(t)return t;return document.body}function S1(t){let e=document.getElementById(t);if(!e&&!cc())throw new Error(`Accessing '${t}' before page was loaded`);if(!(e instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return e}function A1(t){let{width:e,height:r}=t,i=document.createElement("canvas");return i.id="lumagl-auto-created-canvas",i.width=e||1,i.height=r||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(r)?`${r}px`:"100%",i}function E1(t,e,r,i,s){let n=t,o=bm(n[0],e,r),a=Sm(n[1],e,i,s),c=bm(n[0]+1,e,r),l=c===r-1?c:c-1;c=Sm(n[1]+1,e,i,s);let u;return s?(c=c===0?c:c+1,u=a,a=c):u=c===i-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function bm(t,e,r){return Math.min(Math.round(t*e),r-1)}function Sm(t,e,r,i){return i?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var Ae=class t extends Q{static defaultProps={...Q.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0,sampler:{},view:void 0};static COPY_SRC=1;static COPY_DST=2;static TEXTURE_BINDING=4;static STORAGE_BINDING=8;static RENDER_ATTACHMENT=16;get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(e,r,i=t.defaultProps){super(e,r,i),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.updateTimestamp=e.incrementTimestamp()}};var vi=class t extends Q{static defaultProps={...Q.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0};get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,t.defaultProps)}};function Em(t,e,r){let i="",s=e.split(/\r?\n/),n=t.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(r?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=s.length;a++)for(i+=wm(s[a-1],a,r);n.length>o&&n[o].lineNum===a;){let c=n[o++];i+=Am(c,s,c.lineNum,{...r,inlineSource:!1})}return i;case"issues":case"no":for(let a of t)i+=Am(a,s,a.lineNum,{inlineSource:r?.showSourceCode!=="no"});return i}}function Am(t,e,r,i){if(i?.inlineSource){let s=w1(e,r),n=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^ +`:"";return` +${s}${n}${t.type.toUpperCase()}: ${t.message} + +`}return i?.html?`
${t.type.toUpperCase()}: ${t.message}
`:`${t.type.toUpperCase()}: ${t.message}`}function w1(t,e,r){let i="";for(let s=e-2;s<=e;s++){let n=t[s-1];n!==void 0&&(i+=wm(n,e,r))}return i}function wm(t,e,r){let i=r?.html?R1(t):t;return`${P1(String(e),4)}: ${i}${r?.html?"
":` +`}`}function P1(t,e){let r="";for(let i=t.length;i",">").replaceAll('"',""").replaceAll("'","'")}function yf(t,e){return{name:C1(t,e),language:"glsl",version:M1(t)}}function C1(t,e="unnamed"){let i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t);return i?i[1]:e}function M1(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let i=parseInt(r[1],10);Number.isFinite(i)&&(e=i)}return e}var bi=class t extends Q{static defaultProps={...Q.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"};get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,r){super(e,{id:I1(r),...r},t.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let r=await this.getCompilationInfo();this.props.debug==="warnings"&&r?.length===0||this._displayShaderLog(r)}_displayShaderLog(e){if(typeof document>"u"||!document?.createElement)return;let r=yf(this.source).name,i=`${this.stage} ${r}`,s=Em(e,this.source,{showSourceCode:"all",html:!0}),n=this.getTranslatedSource();n&&(s+=`

Translated Source



${n}
`);let o=document.createElement("Button");o.innerHTML=` +

Shader Compilation Error in ${i}



+
+${s}
+
`,o.style.top="10px",o.style.left="10px",o.style.position="absolute",o.style.zIndex="9999",o.style.width="100%",o.style.textAlign="left",document.body.appendChild(o);let a=document.getElementsByClassName("luma-compiler-log-error");a[0]?.scrollIntoView&&a[0].scrollIntoView(),o.onclick=()=>{let c=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(c)}}};function I1(t){return yf(t.source).name||t.id||Fe(`unnamed ${t.stage}-shader`)}var Si=class t extends Q{static defaultProps={...Q.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){super(e,r,t.defaultProps)}};var Ai=class t extends Q{static defaultProps={...Q.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null};get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,r={}){super(e,r,t.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let r=!e;if(e){let[i,s]=Array.isArray(e)?e:[e.width,e.height];r=r||s!==this.height||i!==this.width,this.width=i,this.height=s}r&&(O.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map(r=>{if(typeof r=="string"){let i=this.createColorTexture(r);return this.attachResource(i),i.view}return r instanceof Ae?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof Ae?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:Ae.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:Ae.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){for(let i=0;i":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},F1={f32:4,f16:2,i32:4,u32:4};function xf(t){let e;t.endsWith("-webgl")&&(t.replace("-webgl",""),e=!0);let[r,i]=t.split("x"),s=r,n=i?parseInt(i):1,o=oc(s),a={type:s,components:n,byteLength:o.byteLength*n,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function lc(t,e){let r={};for(let i of t.attributes)r[i.name]=D1(t,e,i.name);return r}function Rm(t,e,r=16){let i=lc(t,e),s=new Array(r).fill(null);for(let n of Object.values(i))s[n.location]=n;return s}function D1(t,e,r){let i=L1(t,r),s=k1(e,r);if(!i)return null;let n=Pm(i.type),o=s?.vertexFormat||n.defaultVertexFormat,a=xf(o);return{attributeName:s?.attributeName||i.name,bufferName:s?.bufferName||i.name,location:i.location,shaderType:i.type,shaderDataType:n.dataType,shaderComponents:n.components,vertexFormat:o,bufferDataType:a.type,bufferComponents:a.components,normalized:a.normalized,integer:n.integer,stepMode:s?.stepMode||i.stepMode,byteOffset:s?.byteOffset||0,byteStride:s?.byteStride||0}}function L1(t,e){let r=t.attributes.find(i=>i.name===e);return r||O.warn(`shader layout attribute "${e}" not present in shader`),r||null}function k1(t,e){B1(t);let r=U1(t,e);return r||(r=z1(t,e),r)?r:(O.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function B1(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&O.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function U1(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function z1(t,e){for(let r of t){let i=r.byteStride;if(typeof r.byteStride!="number")for(let n of r.attributes||[]){let o=xf(n.format);i+=o.byteLength}let s=r.attributes?.find(n=>n.attribute===e);if(s)return{attributeName:s.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:i}}return null}function Tf(t,e){let r={...t,attributes:t.attributes.map(i=>({...i}))};for(let i of e?.attributes||[]){let s=r.attributes.find(n=>n.name===i.name);s?(s.type=i.type||s.type,s.stepMode=i.stepMode||s.stepMode):O.warn(`shader layout attribute ${i.name} not present in shader`)}return r}var Un=class t extends Q{static defaultProps={...Q.defaultProps,renderPipeline:null};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,t.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=Rm(r.renderPipeline.shaderLayout,r.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){throw new Error("constant attributes not supported")}};var zn=class t extends Q{static defaultProps={...Q.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,t.defaultProps)}};var Vn=class t extends Q{static defaultProps={...Q.defaultProps,type:void 0,count:void 0};get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,t.defaultProps)}};var V1={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16}};function Cm(t){let e=V1[t];return ee(t),e}function Mm(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}var uc;function fc(t){return(!uc||uc.byteLengths.type==="uniform"&&s.name===e?.name);if(!r)throw new Error(e?.name);let i=r;for(let s of i.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(let[r,i]of Object.entries(e))this._setUniform(r,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,r){Om(this.uniforms[e],r)||(this.uniforms[e]=Nm(r),this.modifiedUniforms[e]=!0,this.modified=!0)}};var Wn=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[r,i]of Object.entries(e)){let s=r,n=new hc(i.uniformTypes||{});this.uniformBufferLayouts.set(s,n);let o=new dc({name:r});o.setUniforms(i.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[r,i]of Object.entries(e))this.uniformBlocks.get(r).setUniforms(i);this.updateUniformBuffers()}getUniformBufferByteLength(e){return this.uniformBufferLayouts.get(e).byteLength}getUniformBufferData(e){let r=this.uniformBlocks.get(e).getAllUniforms();return this.uniformBufferLayouts.get(e).getData(r)}createUniformBuffer(e,r,i){i&&this.setUniforms(i);let s=this.getUniformBufferByteLength(r),n=e.createBuffer({usage:ie.UNIFORM|ie.COPY_DST,byteLength:s}),o=this.getUniformBufferData(r);return n.write(o),n}getManagedUniformBuffer(e,r){if(!this.uniformBuffers.get(r)){let i=this.getUniformBufferByteLength(r),s=e.createBuffer({usage:ie.UNIFORM|ie.COPY_DST,byteLength:i});this.uniformBuffers.set(r,s)}return this.uniformBuffers.get(r)}updateUniformBuffers(){let e=!1;for(let r of this.uniformBlocks.keys()){let i=this.updateUniformBuffer(r);e||=i}return e&&O.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let r=this.uniformBlocks.get(e),i=this.uniformBuffers.get(e),s=!1;if(i&&r.needsRedraw){s||=r.needsRedraw;let n=this.getUniformBufferData(e);this.uniformBuffers.get(e).write(n);let a=this.uniformBlocks.get(e).getAllUniforms();O.log(4,`Writing to uniform buffer ${String(e)}`,n,a)()}return s}};function pc(t){let e=ArrayBuffer.isView(t)?t.constructor:t;switch(e){case Float32Array:return"float32";case Uint16Array:return"uint16";case Uint32Array:return"uint32";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int8Array:return"sint8";case Int16Array:return"sint16";case Int32Array:return"sint32";default:throw new Error(e.constructor.name)}}function Hn(t){switch(t){case"float32":return Float32Array;case"uint32":return Uint32Array;case"sint32":return Int32Array;case"uint16":case"unorm16":return Uint16Array;case"sint16":case"snorm16":return Int16Array;case"uint8":case"unorm8":return Uint8Array;case"sint8":case"snorm8":return Int8Array;default:throw new Error(t)}}function Sf(t,e,r){if(!e||e>4)throw new Error(`size ${e}`);let i=e,s=pc(t);if(s==="uint8"||s==="sint8"){if(i===1||i===3)throw new Error(`size: ${e}`);return r&&(s=s.replace("int","norm")),`${s}x${i}`}if(s==="uint16"||s==="sint16"){if(i===1||i===3)throw new Error(`size: ${e}`);return r&&(s=s.replace("int","norm")),`${s}x${i}`}return i===1?s:`${s}x${i}`}function Fm(t){return kr(t)!==null||typeof t=="number"||typeof t=="boolean"}function jn(t){let e={bindings:{},uniforms:{}};return Object.keys(t).forEach(r=>{let i=t[r];Fm(i)?e.uniforms[r]=i:e.bindings[r]=i}),e}function Af(t,e,r){let{removedProps:i={},deprecatedProps:s={},replacedProps:n={}}=r;for(let a in i)if(a in e){let l=i[a]?`${t}.${i[a]}`:"N/A";O.removed(`${t}.${a}`,l)()}for(let a in s)if(a in e){let c=s[a];O.deprecated(`${t}.${a}`,`${t}.${c}`)()}let o=null;for(let[a,c]of Object.entries(n))a in e&&(O.deprecated(`${t}.${a}`,`${t}.${c}`)(),o=o||Object.assign({},e),o[c]=e[a],delete o[a]);return o||e}var W1="";async function Ef(t,e){return await new Promise((r,i)=>{try{let s=new Image;s.onload=()=>r(s),s.onerror=()=>i(new Error(`Could not load image ${t}.`)),s.crossOrigin=e?.crossOrigin||"anonymous",s.src=t.startsWith("http")?t:W1+t}catch(s){i(s)}})}async function Xn(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",t),e&&(i.id=e),new Promise((s,n)=>{i.onload=s,i.onerror=o=>n(new Error(`Unable to load script '${t}': ${o}`)),r.appendChild(i)})}function $n(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i":return this.left.evaluate(e)>this.right.evaluate(e)?1:0;case"<=":return this.left.evaluate(e)<=this.right.evaluate(e)?1:0;case">=":return this.left.evaluate(e)>=this.right.evaluate(e)?1:0;case"&&":return this.left.evaluate(e)&&this.right.evaluate(e)?1:0;case"||":return this.left.evaluate(e)||this.right.evaluate(e)?1:0;default:throw new Error(`Unknown operator ${this.operator}`)}}},Pc=class extends gr{constructor(){super()}},Gf=class extends Pc{constructor(e,r){super(),this.selector=e,this.body=r}get astNodeType(){return"case"}},Zf=class extends Pc{constructor(e){super(),this.body=e}get astNodeType(){return"default"}},Jf=class extends gr{constructor(e,r,i){super(),this.name=e,this.type=r,this.attributes=i}get astNodeType(){return"argument"}},Qf=class extends gr{constructor(e,r){super(),this.condition=e,this.body=r}get astNodeType(){return"elseif"}},eh=class extends gr{constructor(e,r,i){super(),this.name=e,this.type=r,this.attributes=i}get astNodeType(){return"member"}},Rc=class extends gr{constructor(e,r){super(),this.name=e,this.value=r}get astNodeType(){return"attribute"}},I,w;(function(t){t[t.token=0]="token",t[t.keyword=1]="keyword",t[t.reserved=2]="reserved"})(w||(w={}));var E=class{constructor(e,r,i){this.name=e,this.type=r,this.rule=i}toString(){return this.name}},T=class{};I=T;T.none=new E("",w.reserved,"");T.eof=new E("EOF",w.token,"");T.reserved={asm:new E("asm",w.reserved,"asm"),bf16:new E("bf16",w.reserved,"bf16"),do:new E("do",w.reserved,"do"),enum:new E("enum",w.reserved,"enum"),f16:new E("f16",w.reserved,"f16"),f64:new E("f64",w.reserved,"f64"),handle:new E("handle",w.reserved,"handle"),i8:new E("i8",w.reserved,"i8"),i16:new E("i16",w.reserved,"i16"),i64:new E("i64",w.reserved,"i64"),mat:new E("mat",w.reserved,"mat"),premerge:new E("premerge",w.reserved,"premerge"),regardless:new E("regardless",w.reserved,"regardless"),typedef:new E("typedef",w.reserved,"typedef"),u8:new E("u8",w.reserved,"u8"),u16:new E("u16",w.reserved,"u16"),u64:new E("u64",w.reserved,"u64"),unless:new E("unless",w.reserved,"unless"),using:new E("using",w.reserved,"using"),vec:new E("vec",w.reserved,"vec"),void:new E("void",w.reserved,"void")};T.keywords={array:new E("array",w.keyword,"array"),atomic:new E("atomic",w.keyword,"atomic"),bool:new E("bool",w.keyword,"bool"),f32:new E("f32",w.keyword,"f32"),i32:new E("i32",w.keyword,"i32"),mat2x2:new E("mat2x2",w.keyword,"mat2x2"),mat2x3:new E("mat2x3",w.keyword,"mat2x3"),mat2x4:new E("mat2x4",w.keyword,"mat2x4"),mat3x2:new E("mat3x2",w.keyword,"mat3x2"),mat3x3:new E("mat3x3",w.keyword,"mat3x3"),mat3x4:new E("mat3x4",w.keyword,"mat3x4"),mat4x2:new E("mat4x2",w.keyword,"mat4x2"),mat4x3:new E("mat4x3",w.keyword,"mat4x3"),mat4x4:new E("mat4x4",w.keyword,"mat4x4"),ptr:new E("ptr",w.keyword,"ptr"),sampler:new E("sampler",w.keyword,"sampler"),sampler_comparison:new E("sampler_comparison",w.keyword,"sampler_comparison"),struct:new E("struct",w.keyword,"struct"),texture_1d:new E("texture_1d",w.keyword,"texture_1d"),texture_2d:new E("texture_2d",w.keyword,"texture_2d"),texture_2d_array:new E("texture_2d_array",w.keyword,"texture_2d_array"),texture_3d:new E("texture_3d",w.keyword,"texture_3d"),texture_cube:new E("texture_cube",w.keyword,"texture_cube"),texture_cube_array:new E("texture_cube_array",w.keyword,"texture_cube_array"),texture_multisampled_2d:new E("texture_multisampled_2d",w.keyword,"texture_multisampled_2d"),texture_storage_1d:new E("texture_storage_1d",w.keyword,"texture_storage_1d"),texture_storage_2d:new E("texture_storage_2d",w.keyword,"texture_storage_2d"),texture_storage_2d_array:new E("texture_storage_2d_array",w.keyword,"texture_storage_2d_array"),texture_storage_3d:new E("texture_storage_3d",w.keyword,"texture_storage_3d"),texture_depth_2d:new E("texture_depth_2d",w.keyword,"texture_depth_2d"),texture_depth_2d_array:new E("texture_depth_2d_array",w.keyword,"texture_depth_2d_array"),texture_depth_cube:new E("texture_depth_cube",w.keyword,"texture_depth_cube"),texture_depth_cube_array:new E("texture_depth_cube_array",w.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new E("texture_depth_multisampled_2d",w.keyword,"texture_depth_multisampled_2d"),texture_external:new E("texture_external",w.keyword,"texture_external"),u32:new E("u32",w.keyword,"u32"),vec2:new E("vec2",w.keyword,"vec2"),vec3:new E("vec3",w.keyword,"vec3"),vec4:new E("vec4",w.keyword,"vec4"),bitcast:new E("bitcast",w.keyword,"bitcast"),block:new E("block",w.keyword,"block"),break:new E("break",w.keyword,"break"),case:new E("case",w.keyword,"case"),continue:new E("continue",w.keyword,"continue"),continuing:new E("continuing",w.keyword,"continuing"),default:new E("default",w.keyword,"default"),discard:new E("discard",w.keyword,"discard"),else:new E("else",w.keyword,"else"),enable:new E("enable",w.keyword,"enable"),fallthrough:new E("fallthrough",w.keyword,"fallthrough"),false:new E("false",w.keyword,"false"),fn:new E("fn",w.keyword,"fn"),for:new E("for",w.keyword,"for"),function:new E("function",w.keyword,"function"),if:new E("if",w.keyword,"if"),let:new E("let",w.keyword,"let"),const:new E("const",w.keyword,"const"),loop:new E("loop",w.keyword,"loop"),while:new E("while",w.keyword,"while"),private:new E("private",w.keyword,"private"),read:new E("read",w.keyword,"read"),read_write:new E("read_write",w.keyword,"read_write"),return:new E("return",w.keyword,"return"),storage:new E("storage",w.keyword,"storage"),switch:new E("switch",w.keyword,"switch"),true:new E("true",w.keyword,"true"),alias:new E("alias",w.keyword,"alias"),type:new E("type",w.keyword,"type"),uniform:new E("uniform",w.keyword,"uniform"),var:new E("var",w.keyword,"var"),override:new E("override",w.keyword,"override"),workgroup:new E("workgroup",w.keyword,"workgroup"),write:new E("write",w.keyword,"write"),r8unorm:new E("r8unorm",w.keyword,"r8unorm"),r8snorm:new E("r8snorm",w.keyword,"r8snorm"),r8uint:new E("r8uint",w.keyword,"r8uint"),r8sint:new E("r8sint",w.keyword,"r8sint"),r16uint:new E("r16uint",w.keyword,"r16uint"),r16sint:new E("r16sint",w.keyword,"r16sint"),r16float:new E("r16float",w.keyword,"r16float"),rg8unorm:new E("rg8unorm",w.keyword,"rg8unorm"),rg8snorm:new E("rg8snorm",w.keyword,"rg8snorm"),rg8uint:new E("rg8uint",w.keyword,"rg8uint"),rg8sint:new E("rg8sint",w.keyword,"rg8sint"),r32uint:new E("r32uint",w.keyword,"r32uint"),r32sint:new E("r32sint",w.keyword,"r32sint"),r32float:new E("r32float",w.keyword,"r32float"),rg16uint:new E("rg16uint",w.keyword,"rg16uint"),rg16sint:new E("rg16sint",w.keyword,"rg16sint"),rg16float:new E("rg16float",w.keyword,"rg16float"),rgba8unorm:new E("rgba8unorm",w.keyword,"rgba8unorm"),rgba8unorm_srgb:new E("rgba8unorm_srgb",w.keyword,"rgba8unorm_srgb"),rgba8snorm:new E("rgba8snorm",w.keyword,"rgba8snorm"),rgba8uint:new E("rgba8uint",w.keyword,"rgba8uint"),rgba8sint:new E("rgba8sint",w.keyword,"rgba8sint"),bgra8unorm:new E("bgra8unorm",w.keyword,"bgra8unorm"),bgra8unorm_srgb:new E("bgra8unorm_srgb",w.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new E("rgb10a2unorm",w.keyword,"rgb10a2unorm"),rg11b10float:new E("rg11b10float",w.keyword,"rg11b10float"),rg32uint:new E("rg32uint",w.keyword,"rg32uint"),rg32sint:new E("rg32sint",w.keyword,"rg32sint"),rg32float:new E("rg32float",w.keyword,"rg32float"),rgba16uint:new E("rgba16uint",w.keyword,"rgba16uint"),rgba16sint:new E("rgba16sint",w.keyword,"rgba16sint"),rgba16float:new E("rgba16float",w.keyword,"rgba16float"),rgba32uint:new E("rgba32uint",w.keyword,"rgba32uint"),rgba32sint:new E("rgba32sint",w.keyword,"rgba32sint"),rgba32float:new E("rgba32float",w.keyword,"rgba32float"),static_assert:new E("static_assert",w.keyword,"static_assert")};T.tokens={decimal_float_literal:new E("decimal_float_literal",w.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),hex_float_literal:new E("hex_float_literal",w.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+f?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+f?))/),int_literal:new E("int_literal",w.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new E("uint_literal",w.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new E("ident",w.token,/[a-zA-Z][0-9a-zA-Z_]*/),and:new E("and",w.token,"&"),and_and:new E("and_and",w.token,"&&"),arrow:new E("arrow ",w.token,"->"),attr:new E("attr",w.token,"@"),attr_left:new E("attr_left",w.token,"[["),attr_right:new E("attr_right",w.token,"]]"),forward_slash:new E("forward_slash",w.token,"/"),bang:new E("bang",w.token,"!"),bracket_left:new E("bracket_left",w.token,"["),bracket_right:new E("bracket_right",w.token,"]"),brace_left:new E("brace_left",w.token,"{"),brace_right:new E("brace_right",w.token,"}"),colon:new E("colon",w.token,":"),comma:new E("comma",w.token,","),equal:new E("equal",w.token,"="),equal_equal:new E("equal_equal",w.token,"=="),not_equal:new E("not_equal",w.token,"!="),greater_than:new E("greater_than",w.token,">"),greater_than_equal:new E("greater_than_equal",w.token,">="),shift_right:new E("shift_right",w.token,">>"),less_than:new E("less_than",w.token,"<"),less_than_equal:new E("less_than_equal",w.token,"<="),shift_left:new E("shift_left",w.token,"<<"),modulo:new E("modulo",w.token,"%"),minus:new E("minus",w.token,"-"),minus_minus:new E("minus_minus",w.token,"--"),period:new E("period",w.token,"."),plus:new E("plus",w.token,"+"),plus_plus:new E("plus_plus",w.token,"++"),or:new E("or",w.token,"|"),or_or:new E("or_or",w.token,"||"),paren_left:new E("paren_left",w.token,"("),paren_right:new E("paren_right",w.token,")"),semicolon:new E("semicolon",w.token,";"),star:new E("star",w.token,"*"),tilde:new E("tilde",w.token,"~"),underscore:new E("underscore",w.token,"_"),xor:new E("xor",w.token,"^"),plus_equal:new E("plus_equal",w.token,"+="),minus_equal:new E("minus_equal",w.token,"-="),times_equal:new E("times_equal",w.token,"*="),division_equal:new E("division_equal",w.token,"/="),modulo_equal:new E("modulo_equal",w.token,"%="),and_equal:new E("and_equal",w.token,"&="),or_equal:new E("or_equal",w.token,"|="),xor_equal:new E("xor_equal",w.token,"^="),shift_right_equal:new E("shift_right_equal",w.token,">>="),shift_left_equal:new E("shift_left_equal",w.token,"<<=")};T.storage_class=[I.keywords.function,I.keywords.private,I.keywords.workgroup,I.keywords.uniform,I.keywords.storage];T.access_mode=[I.keywords.read,I.keywords.write,I.keywords.read_write];T.sampler_type=[I.keywords.sampler,I.keywords.sampler_comparison];T.sampled_texture_type=[I.keywords.texture_1d,I.keywords.texture_2d,I.keywords.texture_2d_array,I.keywords.texture_3d,I.keywords.texture_cube,I.keywords.texture_cube_array];T.multisampled_texture_type=[I.keywords.texture_multisampled_2d];T.storage_texture_type=[I.keywords.texture_storage_1d,I.keywords.texture_storage_2d,I.keywords.texture_storage_2d_array,I.keywords.texture_storage_3d];T.depth_texture_type=[I.keywords.texture_depth_2d,I.keywords.texture_depth_2d_array,I.keywords.texture_depth_cube,I.keywords.texture_depth_cube_array,I.keywords.texture_depth_multisampled_2d];T.texture_external_type=[I.keywords.texture_external];T.any_texture_type=[...I.sampled_texture_type,...I.multisampled_texture_type,...I.storage_texture_type,...I.depth_texture_type,...I.texture_external_type];T.texel_format=[I.keywords.r8unorm,I.keywords.r8snorm,I.keywords.r8uint,I.keywords.r8sint,I.keywords.r16uint,I.keywords.r16sint,I.keywords.r16float,I.keywords.rg8unorm,I.keywords.rg8snorm,I.keywords.rg8uint,I.keywords.rg8sint,I.keywords.r32uint,I.keywords.r32sint,I.keywords.r32float,I.keywords.rg16uint,I.keywords.rg16sint,I.keywords.rg16float,I.keywords.rgba8unorm,I.keywords.rgba8unorm_srgb,I.keywords.rgba8snorm,I.keywords.rgba8uint,I.keywords.rgba8sint,I.keywords.bgra8unorm,I.keywords.bgra8unorm_srgb,I.keywords.rgb10a2unorm,I.keywords.rg11b10float,I.keywords.rg32uint,I.keywords.rg32sint,I.keywords.rg32float,I.keywords.rgba16uint,I.keywords.rgba16sint,I.keywords.rgba16float,I.keywords.rgba32uint,I.keywords.rgba32sint,I.keywords.rgba32float];T.const_literal=[I.tokens.int_literal,I.tokens.uint_literal,I.tokens.decimal_float_literal,I.tokens.hex_float_literal,I.keywords.true,I.keywords.false];T.literal_or_ident=[I.tokens.ident,I.tokens.int_literal,I.tokens.uint_literal,I.tokens.decimal_float_literal,I.tokens.hex_float_literal];T.element_count_expression=[I.tokens.int_literal,I.tokens.uint_literal,I.tokens.ident];T.template_types=[I.keywords.vec2,I.keywords.vec3,I.keywords.vec4,I.keywords.mat2x2,I.keywords.mat2x3,I.keywords.mat2x4,I.keywords.mat3x2,I.keywords.mat3x3,I.keywords.mat3x4,I.keywords.mat4x2,I.keywords.mat4x3,I.keywords.mat4x4,I.keywords.atomic,I.keywords.bitcast,...I.any_texture_type];T.attribute_name=[I.tokens.ident,I.keywords.block];T.assignment_operators=[I.tokens.equal,I.tokens.plus_equal,I.tokens.minus_equal,I.tokens.times_equal,I.tokens.division_equal,I.tokens.modulo_equal,I.tokens.and_equal,I.tokens.or_equal,I.tokens.xor_equal,I.tokens.shift_right_equal,I.tokens.shift_left_equal];T.increment_operators=[I.tokens.plus_plus,I.tokens.minus_minus];var Cc=class{constructor(e,r,i){this.type=e,this.lexeme=r,this.line=i}toString(){return this.lexeme}isTemplateType(){return T.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==T.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}},th=class{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=e??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new Cc(T.eof,"",this._line)),this._tokens}scanToken(){let e=this._advance();if(e==` +`)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=` +`;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}else if(this._peekAhead()=="*"){this._advance();let i=1;for(;i>0;){if(this._isAtEnd())return!0;if(e=this._advance(),e==` +`)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),i--,i==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),i++)}return!0}}let r=T.none;for(;;){let i=this._findType(e),s=this._peekAhead();if(e==">"&&(s==">"||s=="=")){let n=!1,o=this._tokens.length-1;for(let a=0;a<5&&o>=0;++a,--o)if(this._tokens[o].type===T.tokens.less_than){o>0&&this._tokens[o-1].isArrayOrTemplateType()&&(n=!0);break}if(n)return this._addToken(i),!0}if(i===T.none){let n=e,o=0,a=2;for(let c=0;c=this._source.length}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let r=this._source[this._current];return e=e||0,e++,this._current+=e,r}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let r=this._source.substring(this._start,this._current);this._tokens.push(new Cc(e,r,this._line))}},rh=class{constructor(){this._tokens=[],this._current=0,this._context=new Rf}parse(e){this._initialize(e);let r=[];for(;!this._isAtEnd();){let i=this._global_decl_or_directive();if(!i)break;r.push(i)}return r}_initialize(e){if(e)if(typeof e=="string"){let r=new th(e);this._tokens=r.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_error(e,r){return console.error(e,r),{token:e,message:r,toString:function(){return`${r}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==T.eof}_match(e){if(e instanceof E)return this._check(e)?(this._advance(),!0):!1;for(let r=0,i=e.length;r'.");let s=this._paren_expression();return new Yf(i,s)}let e=this._type_decl(),r=this._argument_expression_list();return new Kf(e,r)}_argument_expression_list(){if(!this._match(T.tokens.paren_left))return null;let e=[];do{if(this._check(T.tokens.paren_right))break;let r=this._short_circuit_or_expression();e.push(r)}while(this._match(T.tokens.comma));return this._consume(T.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(T.tokens.paren_left);let e=this._short_circuit_or_expression();return this._match(T.tokens.paren_right),new Ec([e])}_paren_expression(){this._consume(T.tokens.paren_left,"Expected '('.");let e=this._short_circuit_or_expression();return this._consume(T.tokens.paren_right,"Expected ')'."),new Ec([e])}_struct_decl(){if(!this._match(T.keywords.struct))return null;let e=this._consume(T.tokens.ident,"Expected name for struct.").toString();this._consume(T.tokens.brace_left,"Expected '{' for struct body.");let r=[];for(;!this._check(T.tokens.brace_right);){let s=this._attribute(),n=this._consume(T.tokens.ident,"Expected variable name.").toString();this._consume(T.tokens.colon,"Expected ':' for struct member type.");let o=this._attribute(),a=this._type_decl();a!=null&&(a.attributes=o),this._check(T.tokens.brace_right)?this._match(T.tokens.comma):this._consume(T.tokens.comma,"Expected ',' for struct member."),r.push(new eh(n,a,s))}this._consume(T.tokens.brace_right,"Expected '}' after struct body.");let i=new pr(e,r);return this._context.structs.set(e,i),i}_global_variable_decl(){let e=this._variable_decl();return e&&this._match(T.tokens.equal)&&(e.value=this._const_expression()),e}_override_variable_decl(){let e=this._override_decl();return e&&this._match(T.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){if(!this._match(T.keywords.const))return null;let e=this._consume(T.tokens.ident,"Expected variable name"),r=null;if(this._match(T.tokens.colon)){let n=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=n)}let i=null;if(this._match(T.tokens.equal)){let n=this._short_circuit_or_expression();if(n instanceof wi)i=n;else if(n instanceof Sc&&n.initializer instanceof wi)i=n.initializer;else try{let o=n.evaluate(this._context);i=new Ac(o)}catch{i=n}}let s=new yc(e.toString(),r,"","",i);return this._context.constants.set(s.name,s),s}_global_let_decl(){if(!this._match(T.keywords.let))return null;let e=this._consume(T.tokens.ident,"Expected variable name"),r=null;if(this._match(T.tokens.colon)){let s=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=s)}let i=null;return this._match(T.tokens.equal)&&(i=this._const_expression()),new _c(e.toString(),r,"","",i)}_const_expression(){if(this._match(T.const_literal))return new bc(this._previous().toString());let e=this._type_decl();this._consume(T.tokens.paren_left,"Expected '('.");let r=[];for(;!this._check(T.tokens.paren_right)&&(r.push(this._const_expression()),!!this._check(T.tokens.comma));)this._advance();return this._consume(T.tokens.paren_right,"Expected ')'."),new wi(e,r)}_variable_decl(){if(!this._match(T.keywords.var))return null;let e="",r="";this._match(T.tokens.less_than)&&(e=this._consume(T.storage_class,"Expected storage_class.").toString(),this._match(T.tokens.comma)&&(r=this._consume(T.access_mode,"Expected access_mode.").toString()),this._consume(T.tokens.greater_than,"Expected '>'."));let i=this._consume(T.tokens.ident,"Expected variable name"),s=null;if(this._match(T.tokens.colon)){let n=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=n)}return new zr(i.toString(),s,e,r,null)}_override_decl(){if(!this._match(T.keywords.override))return null;let e=this._consume(T.tokens.ident,"Expected variable name"),r=null;if(this._match(T.tokens.colon)){let i=this._attribute();r=this._type_decl(),r!=null&&(r.attributes=i)}return new mc(e.toString(),r,null)}_enable_directive(){let e=this._consume(T.tokens.ident,"identity expected.");return new zf(e.toString())}_type_alias(){let e=this._consume(T.tokens.ident,"identity expected.");this._consume(T.tokens.equal,"Expected '=' for type alias.");let r=this._type_decl();if(r===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(r.name)&&(r=this._context.aliases.get(r.name).type);let i=new xc(e.toString(),r);return this._context.aliases.set(i.name,i),i}_type_decl(){if(this._check([T.tokens.ident,...T.texel_format,T.keywords.bool,T.keywords.f32,T.keywords.i32,T.keywords.u32])){let i=this._advance(),s=i.toString();return this._context.structs.has(s)?this._context.structs.get(s):this._context.aliases.has(s)?this._context.aliases.get(s).type:new mr(i.toString())}let e=this._texture_sampler_types();if(e)return e;if(this._check(T.template_types)){let i=this._advance().toString(),s=null,n=null;return this._match(T.tokens.less_than)&&(s=this._type_decl(),n=null,this._match(T.tokens.comma)&&(n=this._consume(T.access_mode,"Expected access_mode for pointer").toString()),this._consume(T.tokens.greater_than,"Expected '>' for type.")),new Tc(i,s,n)}if(this._match(T.keywords.ptr)){let i=this._previous().toString();this._consume(T.tokens.less_than,"Expected '<' for pointer.");let s=this._consume(T.storage_class,"Expected storage_class for pointer");this._consume(T.tokens.comma,"Expected ',' for pointer.");let n=this._type_decl(),o=null;return this._match(T.tokens.comma)&&(o=this._consume(T.access_mode,"Expected access_mode for pointer").toString()),this._consume(T.tokens.greater_than,"Expected '>' for pointer."),new jf(i,s.toString(),n,o)}let r=this._attribute();if(this._match(T.keywords.array)){let i=null,s=-1,n=this._previous();if(this._match(T.tokens.less_than)){i=this._type_decl(),this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);let o="";this._match(T.tokens.comma)&&(o=this._shift_expression().evaluate(this._context).toString()),this._consume(T.tokens.greater_than,"Expected '>' for array."),s=o?parseInt(o):0}return new vc(n.toString(),r,i,s)}return null}_texture_sampler_types(){if(this._match(T.sampler_type))return new Ei(this._previous().toString(),null,null);if(this._match(T.depth_texture_type))return new Ei(this._previous().toString(),null,null);if(this._match(T.sampled_texture_type)||this._match(T.multisampled_texture_type)){let e=this._previous();this._consume(T.tokens.less_than,"Expected '<' for sampler type.");let r=this._type_decl();return this._consume(T.tokens.greater_than,"Expected '>' for sampler type."),new Ei(e.toString(),r,null)}if(this._match(T.storage_texture_type)){let e=this._previous();this._consume(T.tokens.less_than,"Expected '<' for sampler type.");let r=this._consume(T.texel_format,"Invalid texel format.").toString();this._consume(T.tokens.comma,"Expected ',' after texel format.");let i=this._consume(T.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(T.tokens.greater_than,"Expected '>' for sampler type."),new Ei(e.toString(),r,i)}return null}_attribute(){let e=[];for(;this._match(T.tokens.attr);){let r=this._consume(T.attribute_name,"Expected attribute name"),i=new Rc(r.toString(),null);if(this._match(T.tokens.paren_left)){if(i.value=this._consume(T.literal_or_ident,"Expected attribute value").toString(),this._check(T.tokens.comma)){this._advance();do{let s=this._consume(T.literal_or_ident,"Expected attribute value").toString();i.value instanceof Array||(i.value=[i.value]),i.value.push(s)}while(this._match(T.tokens.comma))}this._consume(T.tokens.paren_right,"Expected ')'")}e.push(i)}for(;this._match(T.tokens.attr_left);){if(!this._check(T.tokens.attr_right))do{let r=this._consume(T.attribute_name,"Expected attribute name"),i=new Rc(r.toString(),null);if(this._match(T.tokens.paren_left)){if(i.value=[this._consume(T.literal_or_ident,"Expected attribute value").toString()],this._check(T.tokens.comma)){this._advance();do{let s=this._consume(T.literal_or_ident,"Expected attribute value").toString();i.value.push(s)}while(this._match(T.tokens.comma))}this._consume(T.tokens.paren_right,"Expected ')'")}e.push(i)}while(this._match(T.tokens.comma));this._consume(T.tokens.attr_right,"Expected ']]' after attribute declarations")}return e.length==0?null:e}},Vr=class{constructor(e,r){this.name=e,this.attributes=r,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}},Mc=class{constructor(e,r,i){this.name=e,this.type=r,this.attributes=i,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},fs=class extends Vr{constructor(e,r){super(e,r),this.members=[],this.align=0}get isStruct(){return!0}},Yn=class extends Vr{constructor(e,r){super(e,r),this.count=0,this.stride=0}get isArray(){return!0}},Ic=class extends Vr{constructor(e,r,i,s){super(e,i),this.format=r,this.access=s}get isTemplate(){return!0}},Ur;(function(t){t[t.Uniform=0]="Uniform",t[t.Storage=1]="Storage",t[t.Texture=2]="Texture",t[t.Sampler=3]="Sampler",t[t.StorageTexture=4]="StorageTexture"})(Ur||(Ur={}));var hs=class{constructor(e,r,i,s,n,o,a){this.name=e,this.type=r,this.group=i,this.binding=s,this.attributes=n,this.resourceType=o,this.access=a}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},ih=class{constructor(e,r){this.name=e,this.type=r}},ds=class{constructor(e,r){this.align=e,this.size=r}},sh=class{constructor(e,r,i,s){this.name=e,this.type=r,this.locationType=i,this.location=s,this.interpolation=null}},Oc=class{constructor(e,r,i,s){this.name=e,this.type=r,this.locationType=i,this.location=s}},nh=class{constructor(e,r=null){this.stage=null,this.inputs=[],this.outputs=[],this.name=e,this.stage=r}},oh=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},ah=class{constructor(e,r,i,s){this.name=e,this.type=r,this.attributes=i,this.id=s}},Pi=class t{constructor(e){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new oh,this._types=new Map,e&&this.update(e)}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}update(e){let i=new rh().parse(e);for(let s of i){if(s instanceof pr){let n=this._getTypeInfo(s,null);n instanceof fs&&this.structs.push(n);continue}if(s instanceof xc){this.aliases.push(this._getAliasInfo(s));continue}if(s instanceof mc){let n=s,o=this._getAttributeNum(n.attributes,"id",0),a=n.type!=null?this._getTypeInfo(n.type,n.attributes):null;this.overrides.push(new ah(n.name,a,n.attributes,o));continue}if(this._isUniformVar(s)){let n=s,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=new hs(n.name,c,o,a,n.attributes,Ur.Uniform,n.access);this.uniforms.push(l);continue}if(this._isStorageVar(s)){let n=s,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=this._isStorageTexture(c),u=new hs(n.name,c,o,a,n.attributes,l?Ur.StorageTexture:Ur.Storage,n.access);this.storage.push(u);continue}if(this._isTextureVar(s)){let n=s,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=this._isStorageTexture(c),u=new hs(n.name,c,o,a,n.attributes,l?Ur.StorageTexture:Ur.Texture,n.access);l?this.storage.push(u):this.textures.push(u);continue}if(this._isSamplerVar(s)){let n=s,o=this._getAttributeNum(n.attributes,"group",0),a=this._getAttributeNum(n.attributes,"binding",0),c=this._getTypeInfo(n.type,n.attributes),l=new hs(n.name,c,o,a,n.attributes,Ur.Sampler,n.access);this.samplers.push(l);continue}if(s instanceof gc){let n=this._getAttribute(s,"vertex"),o=this._getAttribute(s,"fragment"),a=this._getAttribute(s,"compute"),c=n||o||a;if(c){let l=new nh(s.name,c.name);l.inputs=this._getInputs(s.args),l.outputs=this._getOutputs(s.returnType),this.entry[c.name].push(l)}continue}}}getBindGroups(){let e=[];function r(i,s){i>=e.length&&(e.length=i+1),e[i]===void 0&&(e[i]=[]),s>=e[i].length&&(e[i].length=s+1)}for(let i of this.uniforms){r(i.group,i.binding);let s=e[i.group];s[i.binding]=i}for(let i of this.storage){r(i.group,i.binding);let s=e[i.group];s[i.binding]=i}for(let i of this.textures){r(i.group,i.binding);let s=e[i.group];s[i.binding]=i}for(let i of this.samplers){r(i.group,i.binding);let s=e[i.group];s[i.binding]=i}return e}_getOutputs(e,r=void 0){if(r===void 0&&(r=[]),e instanceof pr)this._getStructOutputs(e,r);else{let i=this._getOutputInfo(e);i!==null&&r.push(i)}return r}_getStructOutputs(e,r){for(let i of e.members)if(i.type instanceof pr)this._getStructOutputs(i.type,r);else{let s=this._getAttribute(i,"location")||this._getAttribute(i,"builtin");if(s!==null){let n=this._getTypeInfo(i.type,i.type.attributes),o=this._parseInt(s.value),a=new Oc(i.name,n,s.name,o);r.push(a)}}}_getOutputInfo(e){let r=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(r!==null){let i=this._getTypeInfo(e,e.attributes),s=this._parseInt(r.value);return new Oc("",i,r.name,s)}return null}_getInputs(e,r=void 0){r===void 0&&(r=[]);for(let i of e)if(i.type instanceof pr)this._getStructInputs(i.type,r);else{let s=this._getInputInfo(i);s!==null&&r.push(s)}return r}_getStructInputs(e,r){for(let i of e.members)if(i.type instanceof pr)this._getStructInputs(i.type,r);else{let s=this._getInputInfo(i);s!==null&&r.push(s)}}_getInputInfo(e){let r=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(r!==null){let i=this._getAttribute(e,"interpolation"),s=this._getTypeInfo(e.type,e.attributes),n=this._parseInt(r.value),o=new sh(e.name,s,r.name,n);return i!==null&&(o.interpolation=this._parseString(i.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);let r=parseInt(e);return isNaN(r)?e:r}_getAlias(e){for(let r of this.aliases)if(r.name==e)return r.type;return null}_getAliasInfo(e){return new ih(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,r){if(this._types.has(e))return this._types.get(e);if(e instanceof vc){let s=e,n=this._getTypeInfo(s.format,s.attributes),o=new Yn(s.name,r);return o.format=n,o.count=s.count,this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof pr){let s=e,n=new fs(s.name,r);for(let o of s.members){let a=this._getTypeInfo(o.type,o.attributes);n.members.push(new Mc(o.name,a,o.attributes))}return this._types.set(e,n),this._updateTypeInfo(n),n}if(e instanceof Ei){let s=e,n=s.format instanceof mr,o=s.format?n?this._getTypeInfo(s.format,null):new Vr(s.format,null):null,a=new Ic(s.name,o,r,s.access);return this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof Tc){let s=e,n=s.format?this._getTypeInfo(s.format,null):null,o=new Ic(s.name,n,r,s.access);return this._types.set(e,o),this._updateTypeInfo(o),o}let i=new Vr(e.name,r);return this._types.set(e,i),this._updateTypeInfo(i),i}_updateTypeInfo(e){var r,i;let s=this._getTypeSize(e);if(e.size=(r=s?.size)!==null&&r!==void 0?r:0,e instanceof Yn){let n=this._getTypeSize(e.format);e.stride=(i=n?.size)!==null&&i!==void 0?i:0,this._updateTypeInfo(e.format)}e instanceof fs&&this._updateStructInfo(e)}_updateStructInfo(e){var r;let i=0,s=0,n=0,o=0;for(let a=0,c=e.members.length;at.name);Pi._samplerTypes=T.sampler_type.map(t=>t.name);function ch(t){let e={attributes:[],bindings:[]},r;try{r=H1(t)}catch(n){return O.error(n.message)(),e}for(let n of r.uniforms){let o=[];for(let a of n.type.members)o.push({name:a.name,type:Dm(a.type)});e.bindings.push({type:"uniform",name:n.name,location:n.binding,group:n.group,members:o})}let i=r.entry.vertex[0],s=i?.inputs.length||0;for(let n=0;n`:t.name}function H1(t){try{return new Pi(t)}catch(e){if(e instanceof Error)throw e;let r="WGSL parse error";throw typeof e=="object"&&e?.message&&(r+=`: ${e.message} `),typeof e=="object"&&e?.token&&(r+=e.token.line||""),new Error(r,{cause:e})}}var j1=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND +const float TWO_PI = 6.2831854820251465; +const float PI_2 = 1.5707963705062866; +const float PI_16 = 0.1963495463132858; +const float SIN_TABLE_0 = 0.19509032368659973; +const float SIN_TABLE_1 = 0.3826834261417389; +const float SIN_TABLE_2 = 0.5555702447891235; +const float SIN_TABLE_3 = 0.7071067690849304; +const float COS_TABLE_0 = 0.9807852506637573; +const float COS_TABLE_1 = 0.9238795042037964; +const float COS_TABLE_2 = 0.8314695954322815; +const float COS_TABLE_3 = 0.7071067690849304; +const float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; +const float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; +const float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; +const float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; +float sin_taylor_fp32(float a) { +float r, s, t, x; +if (a == 0.0) { +return 0.0; +} +x = -a * a; +s = a; +r = a; +r = r * x; +t = r * INVERSE_FACTORIAL_3; +s = s + t; +r = r * x; +t = r * INVERSE_FACTORIAL_5; +s = s + t; +r = r * x; +t = r * INVERSE_FACTORIAL_7; +s = s + t; +r = r * x; +t = r * INVERSE_FACTORIAL_9; +s = s + t; +return s; +} +void sincos_taylor_fp32(float a, out float sin_t, out float cos_t) { +if (a == 0.0) { +sin_t = 0.0; +cos_t = 1.0; +} +sin_t = sin_taylor_fp32(a); +cos_t = sqrt(1.0 - sin_t * sin_t); +} +float tan_taylor_fp32(float a) { +float sin_a; +float cos_a; +if (a == 0.0) { +return 0.0; +} +float z = floor(a / TWO_PI); +float r = a - TWO_PI * z; +float t; +float q = floor(r / PI_2 + 0.5); +int j = int(q); +if (j < -2 || j > 2) { +return 1.0 / 0.0; +} +t = r - PI_2 * q; +q = floor(t / PI_16 + 0.5); +int k = int(q); +int abs_k = int(abs(float(k))); +if (abs_k > 4) { +return 1.0 / 0.0; +} else { +t = t - PI_16 * q; +} +float u = 0.0; +float v = 0.0; +float sin_t, cos_t; +float s, c; +sincos_taylor_fp32(t, sin_t, cos_t); +if (k == 0) { +s = sin_t; +c = cos_t; +} else { +if (abs(float(abs_k) - 1.0) < 0.5) { +u = COS_TABLE_0; +v = SIN_TABLE_0; +} else if (abs(float(abs_k) - 2.0) < 0.5) { +u = COS_TABLE_1; +v = SIN_TABLE_1; +} else if (abs(float(abs_k) - 3.0) < 0.5) { +u = COS_TABLE_2; +v = SIN_TABLE_2; +} else if (abs(float(abs_k) - 4.0) < 0.5) { +u = COS_TABLE_3; +v = SIN_TABLE_3; +} +if (k > 0) { +s = u * sin_t + v * cos_t; +c = u * cos_t - v * sin_t; +} else { +s = u * sin_t - v * cos_t; +c = u * cos_t + v * sin_t; +} +} +if (j == 0) { +sin_a = s; +cos_a = c; +} else if (j == 1) { +sin_a = c; +cos_a = -s; +} else if (j == -1) { +sin_a = -c; +cos_a = s; +} else { +sin_a = -s; +cos_a = -c; +} +return sin_a / cos_a; +} +#endif +float tan_fp32(float a) { +#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND +return tan_taylor_fp32(a); +#else +return tan(a); +#endif +} +`,lh={name:"fp32",vs:j1};var X1=new Float32Array([0,1,1,1]),$1=`uniform pickingUniforms { +float isActive; +float isAttribute; +float isHighlightActive; +float useFloatColors; +vec3 highlightedObjectColor; +vec4 highlightColor; +} picking; +out vec4 picking_vRGBcolor_Avalid; +vec3 picking_normalizeColor(vec3 color) { +return picking.useFloatColors > 0.5 ? color : color / 255.0; +} +vec4 picking_normalizeColor(vec4 color) { +return picking.useFloatColors > 0.5 ? color : color / 255.0; +} +bool picking_isColorZero(vec3 color) { +return dot(color, vec3(1.0)) < 0.00001; +} +bool picking_isColorValid(vec3 color) { +return dot(color, vec3(1.0)) > 0.00001; +} +bool isVertexHighlighted(vec3 vertexColor) { +vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); +return +bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor)); +} +void picking_setPickingColor(vec3 pickingColor) { +pickingColor = picking_normalizeColor(pickingColor); +if (bool(picking.isActive)) { +picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor)); +if (!bool(picking.isAttribute)) { +picking_vRGBcolor_Avalid.rgb = pickingColor; +} +} else { +picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor)); +} +} +void picking_setPickingAttribute(float value) { +if (bool(picking.isAttribute)) { +picking_vRGBcolor_Avalid.r = value; +} +} +void picking_setPickingAttribute(vec2 value) { +if (bool(picking.isAttribute)) { +picking_vRGBcolor_Avalid.rg = value; +} +} +void picking_setPickingAttribute(vec3 value) { +if (bool(picking.isAttribute)) { +picking_vRGBcolor_Avalid.rgb = value; +} +} +`,Y1=`uniform pickingUniforms { +float isActive; +float isAttribute; +float isHighlightActive; +float useFloatColors; +vec3 highlightedObjectColor; +vec4 highlightColor; +} picking; +in vec4 picking_vRGBcolor_Avalid; +vec4 picking_filterHighlightColor(vec4 color) { +if (picking.isActive > 0.5) { +return color; +} +bool selected = bool(picking_vRGBcolor_Avalid.a); +if (selected) { +float highLightAlpha = picking.highlightColor.a; +float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha); +float highLightRatio = highLightAlpha / blendedAlpha; +vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio); +return vec4(blendedRGB, blendedAlpha); +} else { +return color; +} +} +vec4 picking_filterPickingColor(vec4 color) { +if (bool(picking.isActive)) { +if (picking_vRGBcolor_Avalid.a == 0.0) { +discard; +} +return picking_vRGBcolor_Avalid; +} +return color; +} +vec4 picking_filterColor(vec4 color) { +vec4 highlightColor = picking_filterHighlightColor(color); +return picking_filterPickingColor(highlightColor); +} +`,Nc={name:"picking",vs:$1,fs:Y1,uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:new Float32Array([0,0,0]),highlightColor:X1},getUniforms:K1};function K1(t={},e){let r={};if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let i=t.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=i}if(t.highlightColor){let i=Array.from(t.highlightColor,s=>s/255);Number.isFinite(i[3])||(i[3]=1),r.highlightColor=i}return t.isActive!==void 0&&(r.isActive=!!t.isActive,r.isAttribute=!!t.isAttribute),t.useFloatColors!==void 0&&(r.useFloatColors=!!t.useFloatColors),r}function uh(t,e=[],r=0){let i=Math.fround(t),s=t-i;return e[r]=i,e[r+1]=s,e}function Lm(t){return t-Math.fround(t)}function km(t){let e=new Float32Array(32);for(let r=0;r<4;++r)for(let i=0;i<4;++i){let s=r*4+i;uh(t[i*4+r],e,s*2)}return e}var Bm=`uniform float ONE; +vec2 split(float a) { +const float SPLIT = 4097.0; +float t = a * SPLIT; +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) +float a_hi = t * ONE - (t - a); +float a_lo = a * ONE - a_hi; +#else +float a_hi = t - (t - a); +float a_lo = a - a_hi; +#endif +return vec2(a_hi, a_lo); +} +vec2 split2(vec2 a) { +vec2 b = split(a.x); +b.y += a.y; +return b; +} +vec2 quickTwoSum(float a, float b) { +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) +float sum = (a + b) * ONE; +float err = b - (sum - a) * ONE; +#else +float sum = a + b; +float err = b - (sum - a); +#endif +return vec2(sum, err); +} +vec2 twoSum(float a, float b) { +float s = (a + b); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) +float v = (s * ONE - a) * ONE; +float err = (a - (s - v) * ONE) * ONE * ONE * ONE + (b - v); +#else +float v = s - a; +float err = (a - (s - v)) + (b - v); +#endif +return vec2(s, err); +} +vec2 twoSub(float a, float b) { +float s = (a - b); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) +float v = (s * ONE - a) * ONE; +float err = (a - (s - v) * ONE) * ONE * ONE * ONE - (b + v); +#else +float v = s - a; +float err = (a - (s - v)) - (b + v); +#endif +return vec2(s, err); +} +vec2 twoSqr(float a) { +float prod = a * a; +vec2 a_fp64 = split(a); +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) +float err = ((a_fp64.x * a_fp64.x - prod) * ONE + 2.0 * a_fp64.x * +a_fp64.y * ONE * ONE) + a_fp64.y * a_fp64.y * ONE * ONE * ONE; +#else +float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y; +#endif +return vec2(prod, err); +} +vec2 twoProd(float a, float b) { +float prod = a * b; +vec2 a_fp64 = split(a); +vec2 b_fp64 = split(b); +float err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y + +a_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y; +return vec2(prod, err); +} +vec2 sum_fp64(vec2 a, vec2 b) { +vec2 s, t; +s = twoSum(a.x, b.x); +t = twoSum(a.y, b.y); +s.y += t.x; +s = quickTwoSum(s.x, s.y); +s.y += t.y; +s = quickTwoSum(s.x, s.y); +return s; +} +vec2 sub_fp64(vec2 a, vec2 b) { +vec2 s, t; +s = twoSub(a.x, b.x); +t = twoSub(a.y, b.y); +s.y += t.x; +s = quickTwoSum(s.x, s.y); +s.y += t.y; +s = quickTwoSum(s.x, s.y); +return s; +} +vec2 mul_fp64(vec2 a, vec2 b) { +vec2 prod = twoProd(a.x, b.x); +prod.y += a.x * b.y; +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) +prod = split2(prod); +#endif +prod = quickTwoSum(prod.x, prod.y); +prod.y += a.y * b.x; +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) +prod = split2(prod); +#endif +prod = quickTwoSum(prod.x, prod.y); +return prod; +} +vec2 div_fp64(vec2 a, vec2 b) { +float xn = 1.0 / b.x; +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) +vec2 yn = mul_fp64(a, vec2(xn, 0)); +#else +vec2 yn = a * xn; +#endif +float diff = (sub_fp64(a, mul_fp64(b, yn))).x; +vec2 prod = twoProd(xn, diff); +return sum_fp64(yn, prod); +} +vec2 sqrt_fp64(vec2 a) { +if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0); +if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0); +float x = 1.0 / sqrt(a.x); +float yn = a.x * x; +#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) +vec2 yn_sqr = twoSqr(yn) * ONE; +#else +vec2 yn_sqr = twoSqr(yn); +#endif +float diff = sub_fp64(a, yn_sqr).x; +vec2 prod = twoProd(x * 0.5, diff); +#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) +return sum_fp64(split(yn), prod); +#else +return sum_fp64(vec2(yn, 0.0), prod); +#endif +} +`;var q1={ONE:1};function G1(){return q1}var Wr={name:"fp64-arithmetic",vs:Bm,getUniforms:G1,fp64ify:uh,fp64LowPart:Lm,fp64ifyMatrix4:km};var UU=1/Math.PI*180,zU=1/180*Math.PI,Z1={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Z1}};var Me=globalThis.mathgl.config;function fh(t,{precision:e=Me.precision}={}){return t=J1(t),`${parseFloat(t.toPrecision(e))}`}function _r(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function yt(t,e,r){return eA(t,i=>Math.max(e,Math.min(r,i)))}function Ct(t,e,r){return _r(t)?t.map((i,s)=>Ct(i,e[s],r)):r*e+(1-r)*t}function yr(t,e,r){let i=Me.EPSILON;r&&(Me.EPSILON=r);try{if(t===e)return!0;if(_r(t)&&_r(e)){if(t.length!==e.length)return!1;for(let s=0;s0?", ":"")+fh(this[i],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r=0&&e=0&&eoA,angle:()=>EA,ceil:()=>aA,clone:()=>rA,copy:()=>sA,create:()=>Um,cross:()=>yA,dist:()=>FA,distance:()=>Hm,div:()=>NA,divide:()=>Wm,dot:()=>_A,equals:()=>CA,exactEquals:()=>RA,floor:()=>cA,forEach:()=>kA,fromValues:()=>iA,inverse:()=>gA,len:()=>MA,length:()=>Xm,lerp:()=>xA,max:()=>uA,min:()=>lA,mul:()=>OA,multiply:()=>Vm,negate:()=>pA,normalize:()=>mA,random:()=>TA,rotate:()=>AA,round:()=>fA,scale:()=>hA,scaleAndAdd:()=>dA,set:()=>nA,sqrDist:()=>DA,sqrLen:()=>LA,squaredDistance:()=>jm,squaredLength:()=>$m,str:()=>PA,sub:()=>IA,subtract:()=>zm,transformMat2:()=>vA,transformMat2d:()=>bA,transformMat3:()=>SA,transformMat4:()=>dh,zero:()=>wA});var Te=typeof Float32Array<"u"?Float32Array:Array,Gt=Math.random;function xt(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var ZU=Math.PI/180;function Um(){let t=new Te(2);return Te!=Float32Array&&(t[0]=0,t[1]=0),t}function rA(t){let e=new Te(2);return e[0]=t[0],e[1]=t[1],e}function iA(t,e){let r=new Te(2);return r[0]=t,r[1]=e,r}function sA(t,e){return t[0]=e[0],t[1]=e[1],t}function nA(t,e,r){return t[0]=e,t[1]=r,t}function oA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function zm(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function Vm(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function Wm(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function aA(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function cA(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function lA(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function uA(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function fA(t,e){return t[0]=xt(e[0]),t[1]=xt(e[1]),t}function hA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function dA(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t}function Hm(t,e){let r=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(r*r+i*i)}function jm(t,e){let r=e[0]-t[0],i=e[1]-t[1];return r*r+i*i}function Xm(t){let e=t[0],r=t[1];return Math.sqrt(e*e+r*r)}function $m(t){let e=t[0],r=t[1];return e*e+r*r}function pA(t,e){return t[0]=-e[0],t[1]=-e[1],t}function gA(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function mA(t,e){let r=e[0],i=e[1],s=r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t}function _A(t,e){return t[0]*e[0]+t[1]*e[1]}function yA(t,e,r){let i=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=i,t}function xA(t,e,r,i){let s=e[0],n=e[1];return t[0]=s+i*(r[0]-s),t[1]=n+i*(r[1]-n),t}function TA(t,e){e=e===void 0?1:e;let r=Gt()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function vA(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[2]*s,t[1]=r[1]*i+r[3]*s,t}function bA(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[2]*s+r[4],t[1]=r[1]*i+r[3]*s+r[5],t}function SA(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[3]*s+r[6],t[1]=r[1]*i+r[4]*s+r[7],t}function dh(t,e,r){let i=e[0],s=e[1];return t[0]=r[0]*i+r[4]*s+r[12],t[1]=r[1]*i+r[5]*s+r[13],t}function AA(t,e,r,i){let s=e[0]-r[0],n=e[1]-r[1],o=Math.sin(i),a=Math.cos(i);return t[0]=s*a-n*o+r[0],t[1]=s*o+n*a+r[1],t}function EA(t,e){let r=t[0],i=t[1],s=e[0],n=e[1],o=Math.sqrt((r*r+i*i)*(s*s+n*n)),a=o&&(r*s+i*n)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function wA(t){return t[0]=0,t[1]=0,t}function PA(t){return`vec2(${t[0]}, ${t[1]})`}function RA(t,e){return t[0]===e[0]&&t[1]===e[1]}function CA(t,e){let r=t[0],i=t[1],s=e[0],n=e[1];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-n)<=1e-6*Math.max(1,Math.abs(i),Math.abs(n))}var MA=Xm,IA=zm,OA=Vm,NA=Wm,FA=Hm,DA=jm,LA=$m,kA=function(){let t=Um();return function(e,r,i,s,n,o){let a,c;for(r||(r=2),i||(i=0),s?c=Math.min(s*r+i,e.length):c=e.length,a=i;aWA,angle:()=>vh,bezier:()=>rE,ceil:()=>HA,clone:()=>BA,copy:()=>zA,create:()=>qm,cross:()=>gh,dist:()=>fE,distance:()=>e_,div:()=>uE,divide:()=>Qm,dot:()=>ph,equals:()=>aE,exactEquals:()=>oE,floor:()=>jA,forEach:()=>gE,fromValues:()=>UA,hermite:()=>tE,inverse:()=>ZA,len:()=>dE,length:()=>Gm,lerp:()=>QA,max:()=>$A,min:()=>XA,mul:()=>lE,multiply:()=>Jm,negate:()=>GA,normalize:()=>JA,random:()=>iE,rotateX:()=>yh,rotateY:()=>xh,rotateZ:()=>Th,round:()=>YA,scale:()=>KA,scaleAndAdd:()=>qA,set:()=>VA,slerp:()=>eE,sqrDist:()=>hE,sqrLen:()=>pE,squaredDistance:()=>t_,squaredLength:()=>r_,str:()=>nE,sub:()=>cE,subtract:()=>Zm,transformMat3:()=>mh,transformMat4:()=>qn,transformQuat:()=>_h,zero:()=>sE});function qm(){let t=new Te(3);return Te!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function BA(t){let e=new Te(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Gm(t){let e=t[0],r=t[1],i=t[2];return Math.sqrt(e*e+r*r+i*i)}function UA(t,e,r){let i=new Te(3);return i[0]=t,i[1]=e,i[2]=r,i}function zA(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function VA(t,e,r,i){return t[0]=e,t[1]=r,t[2]=i,t}function WA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function Zm(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function Jm(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function Qm(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function HA(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function jA(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function XA(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function $A(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function YA(t,e){return t[0]=xt(e[0]),t[1]=xt(e[1]),t[2]=xt(e[2]),t}function KA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function qA(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t}function e_(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2];return Math.sqrt(r*r+i*i+s*s)}function t_(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2];return r*r+i*i+s*s}function r_(t){let e=t[0],r=t[1],i=t[2];return e*e+r*r+i*i}function GA(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function ZA(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function JA(t,e){let r=e[0],i=e[1],s=e[2],n=r*r+i*i+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function ph(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function gh(t,e,r){let i=e[0],s=e[1],n=e[2],o=r[0],a=r[1],c=r[2];return t[0]=s*c-n*a,t[1]=n*o-i*c,t[2]=i*a-s*o,t}function QA(t,e,r,i){let s=e[0],n=e[1],o=e[2];return t[0]=s+i*(r[0]-s),t[1]=n+i*(r[1]-n),t[2]=o+i*(r[2]-o),t}function eE(t,e,r,i){let s=Math.acos(Math.min(Math.max(ph(e,r),-1),1)),n=Math.sin(s),o=Math.sin((1-i)*s)/n,a=Math.sin(i*s)/n;return t[0]=o*e[0]+a*r[0],t[1]=o*e[1]+a*r[1],t[2]=o*e[2]+a*r[2],t}function tE(t,e,r,i,s,n){let o=n*n,a=o*(2*n-3)+1,c=o*(n-2)+n,l=o*(n-1),u=o*(3-2*n);return t[0]=e[0]*a+r[0]*c+i[0]*l+s[0]*u,t[1]=e[1]*a+r[1]*c+i[1]*l+s[1]*u,t[2]=e[2]*a+r[2]*c+i[2]*l+s[2]*u,t}function rE(t,e,r,i,s,n){let o=1-n,a=o*o,c=n*n,l=a*o,u=3*n*a,f=3*c*o,h=c*n;return t[0]=e[0]*l+r[0]*u+i[0]*f+s[0]*h,t[1]=e[1]*l+r[1]*u+i[1]*f+s[1]*h,t[2]=e[2]*l+r[2]*u+i[2]*f+s[2]*h,t}function iE(t,e){e=e===void 0?1:e;let r=Gt()*2*Math.PI,i=Gt()*2-1,s=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*s,t[1]=Math.sin(r)*s,t[2]=i*e,t}function qn(t,e,r){let i=e[0],s=e[1],n=e[2],o=r[3]*i+r[7]*s+r[11]*n+r[15];return o=o||1,t[0]=(r[0]*i+r[4]*s+r[8]*n+r[12])/o,t[1]=(r[1]*i+r[5]*s+r[9]*n+r[13])/o,t[2]=(r[2]*i+r[6]*s+r[10]*n+r[14])/o,t}function mh(t,e,r){let i=e[0],s=e[1],n=e[2];return t[0]=i*r[0]+s*r[3]+n*r[6],t[1]=i*r[1]+s*r[4]+n*r[7],t[2]=i*r[2]+s*r[5]+n*r[8],t}function _h(t,e,r){let i=r[0],s=r[1],n=r[2],o=r[3],a=e[0],c=e[1],l=e[2],u=s*l-n*c,f=n*a-i*l,h=i*c-s*a,d=s*h-n*f,p=n*u-i*h,g=i*f-s*u,_=o*2;return u*=_,f*=_,h*=_,d*=2,p*=2,g*=2,t[0]=a+u+d,t[1]=c+f+p,t[2]=l+h+g,t}function yh(t,e,r,i){let s=[],n=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],n[0]=s[0],n[1]=s[1]*Math.cos(i)-s[2]*Math.sin(i),n[2]=s[1]*Math.sin(i)+s[2]*Math.cos(i),t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function xh(t,e,r,i){let s=[],n=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],n[0]=s[2]*Math.sin(i)+s[0]*Math.cos(i),n[1]=s[1],n[2]=s[2]*Math.cos(i)-s[0]*Math.sin(i),t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function Th(t,e,r,i){let s=[],n=[];return s[0]=e[0]-r[0],s[1]=e[1]-r[1],s[2]=e[2]-r[2],n[0]=s[0]*Math.cos(i)-s[1]*Math.sin(i),n[1]=s[0]*Math.sin(i)+s[1]*Math.cos(i),n[2]=s[2],t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function vh(t,e){let r=t[0],i=t[1],s=t[2],n=e[0],o=e[1],a=e[2],c=Math.sqrt((r*r+i*i+s*s)*(n*n+o*o+a*a)),l=c&&ph(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function sE(t){return t[0]=0,t[1]=0,t[2]=0,t}function nE(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function oE(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function aE(t,e){let r=t[0],i=t[1],s=t[2],n=e[0],o=e[1],a=e[2];return Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(i-o)<=1e-6*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}var cE=Zm,lE=Jm,uE=Qm,fE=e_,hE=t_,dE=Gm,pE=r_,gE=function(){let t=qm();return function(e,r,i,s,n,o){let a,c;for(r||(r=3),i||(i=0),s?c=Math.min(s*r+i,e.length):c=e.length,a=i;azE,adjoint:()=>vE,clone:()=>_E,copy:()=>yE,create:()=>mE,decompose:()=>IE,determinant:()=>Eh,equals:()=>jE,exactEquals:()=>HE,frob:()=>UE,fromQuat:()=>Oh,fromQuat2:()=>RE,fromRotation:()=>AE,fromRotationTranslation:()=>s_,fromRotationTranslationScale:()=>OE,fromRotationTranslationScaleOrigin:()=>NE,fromScaling:()=>SE,fromTranslation:()=>bE,fromValues:()=>xE,fromXRotation:()=>EE,fromYRotation:()=>wE,fromZRotation:()=>PE,frustum:()=>Nh,getRotation:()=>ME,getScaling:()=>n_,getTranslation:()=>CE,identity:()=>i_,invert:()=>Ah,lookAt:()=>Lh,mul:()=>XE,multiply:()=>Gn,multiplyScalar:()=>VE,multiplyScalarAndAdd:()=>WE,ortho:()=>Dh,orthoNO:()=>a_,orthoZO:()=>LE,perspective:()=>Fh,perspectiveFromFieldOfView:()=>DE,perspectiveNO:()=>o_,perspectiveZO:()=>FE,rotate:()=>Rh,rotateX:()=>Ch,rotateY:()=>Mh,rotateZ:()=>Ih,scale:()=>Ph,set:()=>TE,str:()=>BE,sub:()=>$E,subtract:()=>c_,targetTo:()=>kE,translate:()=>wh,transpose:()=>Sh});function mE(){let t=new Te(16);return Te!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function _E(t){let e=new Te(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function yE(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function xE(t,e,r,i,s,n,o,a,c,l,u,f,h,d,p,g){let _=new Te(16);return _[0]=t,_[1]=e,_[2]=r,_[3]=i,_[4]=s,_[5]=n,_[6]=o,_[7]=a,_[8]=c,_[9]=l,_[10]=u,_[11]=f,_[12]=h,_[13]=d,_[14]=p,_[15]=g,_}function TE(t,e,r,i,s,n,o,a,c,l,u,f,h,d,p,g,_){return t[0]=e,t[1]=r,t[2]=i,t[3]=s,t[4]=n,t[5]=o,t[6]=a,t[7]=c,t[8]=l,t[9]=u,t[10]=f,t[11]=h,t[12]=d,t[13]=p,t[14]=g,t[15]=_,t}function i_(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Sh(t,e){if(t===e){let r=e[1],i=e[2],s=e[3],n=e[6],o=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=n,t[11]=e[14],t[12]=s,t[13]=o,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Ah(t,e){let r=e[0],i=e[1],s=e[2],n=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],g=e[13],_=e[14],x=e[15],v=r*a-i*o,b=r*c-s*o,A=r*l-n*o,C=i*c-s*a,M=i*l-n*a,F=s*l-n*c,N=u*g-f*p,D=u*_-h*p,L=u*x-d*p,Y=f*_-h*g,X=f*x-d*g,$=h*x-d*_,Z=v*$-b*X+A*Y+C*L-M*D+F*N;return Z?(Z=1/Z,t[0]=(a*$-c*X+l*Y)*Z,t[1]=(s*X-i*$-n*Y)*Z,t[2]=(g*F-_*M+x*C)*Z,t[3]=(h*M-f*F-d*C)*Z,t[4]=(c*L-o*$-l*D)*Z,t[5]=(r*$-s*L+n*D)*Z,t[6]=(_*A-p*F-x*b)*Z,t[7]=(u*F-h*A+d*b)*Z,t[8]=(o*X-a*L+l*N)*Z,t[9]=(i*L-r*X-n*N)*Z,t[10]=(p*M-g*A+x*v)*Z,t[11]=(f*A-u*M-d*v)*Z,t[12]=(a*D-o*Y-c*N)*Z,t[13]=(r*Y-i*D+s*N)*Z,t[14]=(g*b-p*C-_*v)*Z,t[15]=(u*C-f*b+h*v)*Z,t):null}function vE(t,e){let r=e[0],i=e[1],s=e[2],n=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],g=e[13],_=e[14],x=e[15],v=r*a-i*o,b=r*c-s*o,A=r*l-n*o,C=i*c-s*a,M=i*l-n*a,F=s*l-n*c,N=u*g-f*p,D=u*_-h*p,L=u*x-d*p,Y=f*_-h*g,X=f*x-d*g,$=h*x-d*_;return t[0]=a*$-c*X+l*Y,t[1]=s*X-i*$-n*Y,t[2]=g*F-_*M+x*C,t[3]=h*M-f*F-d*C,t[4]=c*L-o*$-l*D,t[5]=r*$-s*L+n*D,t[6]=_*A-p*F-x*b,t[7]=u*F-h*A+d*b,t[8]=o*X-a*L+l*N,t[9]=i*L-r*X-n*N,t[10]=p*M-g*A+x*v,t[11]=f*A-u*M-d*v,t[12]=a*D-o*Y-c*N,t[13]=r*Y-i*D+s*N,t[14]=g*b-p*C-_*v,t[15]=u*C-f*b+h*v,t}function Eh(t){let e=t[0],r=t[1],i=t[2],s=t[3],n=t[4],o=t[5],a=t[6],c=t[7],l=t[8],u=t[9],f=t[10],h=t[11],d=t[12],p=t[13],g=t[14],_=t[15],x=e*o-r*n,v=e*a-i*n,b=r*a-i*o,A=l*p-u*d,C=l*g-f*d,M=u*g-f*p,F=e*M-r*C+i*A,N=n*M-o*C+a*A,D=l*b-u*v+f*x,L=d*b-p*v+g*x;return c*F-s*N+_*D-h*L}function Gn(t,e,r){let i=e[0],s=e[1],n=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=e[9],d=e[10],p=e[11],g=e[12],_=e[13],x=e[14],v=e[15],b=r[0],A=r[1],C=r[2],M=r[3];return t[0]=b*i+A*a+C*f+M*g,t[1]=b*s+A*c+C*h+M*_,t[2]=b*n+A*l+C*d+M*x,t[3]=b*o+A*u+C*p+M*v,b=r[4],A=r[5],C=r[6],M=r[7],t[4]=b*i+A*a+C*f+M*g,t[5]=b*s+A*c+C*h+M*_,t[6]=b*n+A*l+C*d+M*x,t[7]=b*o+A*u+C*p+M*v,b=r[8],A=r[9],C=r[10],M=r[11],t[8]=b*i+A*a+C*f+M*g,t[9]=b*s+A*c+C*h+M*_,t[10]=b*n+A*l+C*d+M*x,t[11]=b*o+A*u+C*p+M*v,b=r[12],A=r[13],C=r[14],M=r[15],t[12]=b*i+A*a+C*f+M*g,t[13]=b*s+A*c+C*h+M*_,t[14]=b*n+A*l+C*d+M*x,t[15]=b*o+A*u+C*p+M*v,t}function wh(t,e,r){let i=r[0],s=r[1],n=r[2],o,a,c,l,u,f,h,d,p,g,_,x;return e===t?(t[12]=e[0]*i+e[4]*s+e[8]*n+e[12],t[13]=e[1]*i+e[5]*s+e[9]*n+e[13],t[14]=e[2]*i+e[6]*s+e[10]*n+e[14],t[15]=e[3]*i+e[7]*s+e[11]*n+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],h=e[6],d=e[7],p=e[8],g=e[9],_=e[10],x=e[11],t[0]=o,t[1]=a,t[2]=c,t[3]=l,t[4]=u,t[5]=f,t[6]=h,t[7]=d,t[8]=p,t[9]=g,t[10]=_,t[11]=x,t[12]=o*i+u*s+p*n+e[12],t[13]=a*i+f*s+g*n+e[13],t[14]=c*i+h*s+_*n+e[14],t[15]=l*i+d*s+x*n+e[15]),t}function Ph(t,e,r){let i=r[0],s=r[1],n=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Rh(t,e,r,i){let s=i[0],n=i[1],o=i[2],a=Math.sqrt(s*s+n*n+o*o),c,l,u,f,h,d,p,g,_,x,v,b,A,C,M,F,N,D,L,Y,X,$,Z,ge;return a<1e-6?null:(a=1/a,s*=a,n*=a,o*=a,l=Math.sin(r),c=Math.cos(r),u=1-c,f=e[0],h=e[1],d=e[2],p=e[3],g=e[4],_=e[5],x=e[6],v=e[7],b=e[8],A=e[9],C=e[10],M=e[11],F=s*s*u+c,N=n*s*u+o*l,D=o*s*u-n*l,L=s*n*u-o*l,Y=n*n*u+c,X=o*n*u+s*l,$=s*o*u+n*l,Z=n*o*u-s*l,ge=o*o*u+c,t[0]=f*F+g*N+b*D,t[1]=h*F+_*N+A*D,t[2]=d*F+x*N+C*D,t[3]=p*F+v*N+M*D,t[4]=f*L+g*Y+b*X,t[5]=h*L+_*Y+A*X,t[6]=d*L+x*Y+C*X,t[7]=p*L+v*Y+M*X,t[8]=f*$+g*Z+b*ge,t[9]=h*$+_*Z+A*ge,t[10]=d*$+x*Z+C*ge,t[11]=p*$+v*Z+M*ge,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Ch(t,e,r){let i=Math.sin(r),s=Math.cos(r),n=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=n*s+l*i,t[5]=o*s+u*i,t[6]=a*s+f*i,t[7]=c*s+h*i,t[8]=l*s-n*i,t[9]=u*s-o*i,t[10]=f*s-a*i,t[11]=h*s-c*i,t}function Mh(t,e,r){let i=Math.sin(r),s=Math.cos(r),n=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],h=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*s-l*i,t[1]=o*s-u*i,t[2]=a*s-f*i,t[3]=c*s-h*i,t[8]=n*i+l*s,t[9]=o*i+u*s,t[10]=a*i+f*s,t[11]=c*i+h*s,t}function Ih(t,e,r){let i=Math.sin(r),s=Math.cos(r),n=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],h=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*s+l*i,t[1]=o*s+u*i,t[2]=a*s+f*i,t[3]=c*s+h*i,t[4]=l*s-n*i,t[5]=u*s-o*i,t[6]=f*s-a*i,t[7]=h*s-c*i,t}function bE(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function SE(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function AE(t,e,r){let i=r[0],s=r[1],n=r[2],o=Math.sqrt(i*i+s*s+n*n),a,c,l;return o<1e-6?null:(o=1/o,i*=o,s*=o,n*=o,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=i*i*l+a,t[1]=s*i*l+n*c,t[2]=n*i*l-s*c,t[3]=0,t[4]=i*s*l-n*c,t[5]=s*s*l+a,t[6]=n*s*l+i*c,t[7]=0,t[8]=i*n*l+s*c,t[9]=s*n*l-i*c,t[10]=n*n*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function EE(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function wE(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function PE(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function s_(t,e,r){let i=e[0],s=e[1],n=e[2],o=e[3],a=i+i,c=s+s,l=n+n,u=i*a,f=i*c,h=i*l,d=s*c,p=s*l,g=n*l,_=o*a,x=o*c,v=o*l;return t[0]=1-(d+g),t[1]=f+v,t[2]=h-x,t[3]=0,t[4]=f-v,t[5]=1-(u+g),t[6]=p+_,t[7]=0,t[8]=h+x,t[9]=p-_,t[10]=1-(u+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function RE(t,e){let r=new Te(3),i=-e[0],s=-e[1],n=-e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=i*i+s*s+n*n+o*o;return f>0?(r[0]=(a*o+u*i+c*n-l*s)*2/f,r[1]=(c*o+u*s+l*i-a*n)*2/f,r[2]=(l*o+u*n+a*s-c*i)*2/f):(r[0]=(a*o+u*i+c*n-l*s)*2,r[1]=(c*o+u*s+l*i-a*n)*2,r[2]=(l*o+u*n+a*s-c*i)*2),s_(t,e,r),t}function CE(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function n_(t,e){let r=e[0],i=e[1],s=e[2],n=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return t[0]=Math.sqrt(r*r+i*i+s*s),t[1]=Math.sqrt(n*n+o*o+a*a),t[2]=Math.sqrt(c*c+l*l+u*u),t}function ME(t,e){let r=new Te(3);n_(r,e);let i=1/r[0],s=1/r[1],n=1/r[2],o=e[0]*i,a=e[1]*s,c=e[2]*n,l=e[4]*i,u=e[5]*s,f=e[6]*n,h=e[8]*i,d=e[9]*s,p=e[10]*n,g=o+u+p,_=0;return g>0?(_=Math.sqrt(g+1)*2,t[3]=.25*_,t[0]=(f-d)/_,t[1]=(h-c)/_,t[2]=(a-l)/_):o>u&&o>p?(_=Math.sqrt(1+o-u-p)*2,t[3]=(f-d)/_,t[0]=.25*_,t[1]=(a+l)/_,t[2]=(h+c)/_):u>p?(_=Math.sqrt(1+u-o-p)*2,t[3]=(h-c)/_,t[0]=(a+l)/_,t[1]=.25*_,t[2]=(f+d)/_):(_=Math.sqrt(1+p-o-u)*2,t[3]=(a-l)/_,t[0]=(h+c)/_,t[1]=(f+d)/_,t[2]=.25*_),t}function IE(t,e,r,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let s=i[0],n=i[1],o=i[2],a=i[4],c=i[5],l=i[6],u=i[8],f=i[9],h=i[10];r[0]=Math.sqrt(s*s+n*n+o*o),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(u*u+f*f+h*h);let d=1/r[0],p=1/r[1],g=1/r[2],_=s*d,x=n*p,v=o*g,b=a*d,A=c*p,C=l*g,M=u*d,F=f*p,N=h*g,D=_+A+N,L=0;return D>0?(L=Math.sqrt(D+1)*2,t[3]=.25*L,t[0]=(C-F)/L,t[1]=(M-v)/L,t[2]=(x-b)/L):_>A&&_>N?(L=Math.sqrt(1+_-A-N)*2,t[3]=(C-F)/L,t[0]=.25*L,t[1]=(x+b)/L,t[2]=(M+v)/L):A>N?(L=Math.sqrt(1+A-_-N)*2,t[3]=(M-v)/L,t[0]=(x+b)/L,t[1]=.25*L,t[2]=(C+F)/L):(L=Math.sqrt(1+N-_-A)*2,t[3]=(x-b)/L,t[0]=(M+v)/L,t[1]=(C+F)/L,t[2]=.25*L),t}function OE(t,e,r,i){let s=e[0],n=e[1],o=e[2],a=e[3],c=s+s,l=n+n,u=o+o,f=s*c,h=s*l,d=s*u,p=n*l,g=n*u,_=o*u,x=a*c,v=a*l,b=a*u,A=i[0],C=i[1],M=i[2];return t[0]=(1-(p+_))*A,t[1]=(h+b)*A,t[2]=(d-v)*A,t[3]=0,t[4]=(h-b)*C,t[5]=(1-(f+_))*C,t[6]=(g+x)*C,t[7]=0,t[8]=(d+v)*M,t[9]=(g-x)*M,t[10]=(1-(f+p))*M,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function NE(t,e,r,i,s){let n=e[0],o=e[1],a=e[2],c=e[3],l=n+n,u=o+o,f=a+a,h=n*l,d=n*u,p=n*f,g=o*u,_=o*f,x=a*f,v=c*l,b=c*u,A=c*f,C=i[0],M=i[1],F=i[2],N=s[0],D=s[1],L=s[2],Y=(1-(g+x))*C,X=(d+A)*C,$=(p-b)*C,Z=(d-A)*M,ge=(1-(h+x))*M,rt=(_+v)*M,ot=(p+b)*F,Pt=(_-v)*F,Vt=(1-(h+g))*F;return t[0]=Y,t[1]=X,t[2]=$,t[3]=0,t[4]=Z,t[5]=ge,t[6]=rt,t[7]=0,t[8]=ot,t[9]=Pt,t[10]=Vt,t[11]=0,t[12]=r[0]+N-(Y*N+Z*D+ot*L),t[13]=r[1]+D-(X*N+ge*D+Pt*L),t[14]=r[2]+L-($*N+rt*D+Vt*L),t[15]=1,t}function Oh(t,e){let r=e[0],i=e[1],s=e[2],n=e[3],o=r+r,a=i+i,c=s+s,l=r*o,u=i*o,f=i*a,h=s*o,d=s*a,p=s*c,g=n*o,_=n*a,x=n*c;return t[0]=1-f-p,t[1]=u+x,t[2]=h-_,t[3]=0,t[4]=u-x,t[5]=1-l-p,t[6]=d+g,t[7]=0,t[8]=h+_,t[9]=d-g,t[10]=1-l-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Nh(t,e,r,i,s,n,o){let a=1/(r-e),c=1/(s-i),l=1/(n-o);return t[0]=n*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(s+i)*c,t[10]=(o+n)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*n*2*l,t[15]=0,t}function o_(t,e,r,i,s){let n=1/Math.tan(e/2);if(t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0){let o=1/(i-s);t[10]=(s+i)*o,t[14]=2*s*i*o}else t[10]=-1,t[14]=-2*i;return t}var Fh=o_;function FE(t,e,r,i,s){let n=1/Math.tan(e/2);if(t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0){let o=1/(i-s);t[10]=s*o,t[14]=s*i*o}else t[10]=-1,t[14]=-i;return t}function DE(t,e,r,i){let s=Math.tan(e.upDegrees*Math.PI/180),n=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(s+n);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((o-a)*c*.5),t[9]=(s-n)*l*.5,t[10]=i/(r-i),t[11]=-1,t[12]=0,t[13]=0,t[14]=i*r/(r-i),t[15]=0,t}function a_(t,e,r,i,s,n,o){let a=1/(e-r),c=1/(i-s),l=1/(n-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(s+i)*c,t[14]=(o+n)*l,t[15]=1,t}var Dh=a_;function LE(t,e,r,i,s,n,o){let a=1/(e-r),c=1/(i-s),l=1/(n-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(s+i)*c,t[14]=n*l,t[15]=1,t}function Lh(t,e,r,i){let s,n,o,a,c,l,u,f,h,d,p=e[0],g=e[1],_=e[2],x=i[0],v=i[1],b=i[2],A=r[0],C=r[1],M=r[2];return Math.abs(p-A)<1e-6&&Math.abs(g-C)<1e-6&&Math.abs(_-M)<1e-6?i_(t):(f=p-A,h=g-C,d=_-M,s=1/Math.sqrt(f*f+h*h+d*d),f*=s,h*=s,d*=s,n=v*d-b*h,o=b*f-x*d,a=x*h-v*f,s=Math.sqrt(n*n+o*o+a*a),s?(s=1/s,n*=s,o*=s,a*=s):(n=0,o=0,a=0),c=h*a-d*o,l=d*n-f*a,u=f*o-h*n,s=Math.sqrt(c*c+l*l+u*u),s?(s=1/s,c*=s,l*=s,u*=s):(c=0,l=0,u=0),t[0]=n,t[1]=c,t[2]=f,t[3]=0,t[4]=o,t[5]=l,t[6]=h,t[7]=0,t[8]=a,t[9]=u,t[10]=d,t[11]=0,t[12]=-(n*p+o*g+a*_),t[13]=-(c*p+l*g+u*_),t[14]=-(f*p+h*g+d*_),t[15]=1,t)}function kE(t,e,r,i){let s=e[0],n=e[1],o=e[2],a=i[0],c=i[1],l=i[2],u=s-r[0],f=n-r[1],h=o-r[2],d=u*u+f*f+h*h;d>0&&(d=1/Math.sqrt(d),u*=d,f*=d,h*=d);let p=c*h-l*f,g=l*u-a*h,_=a*f-c*u;return d=p*p+g*g+_*_,d>0&&(d=1/Math.sqrt(d),p*=d,g*=d,_*=d),t[0]=p,t[1]=g,t[2]=_,t[3]=0,t[4]=f*_-h*g,t[5]=h*p-u*_,t[6]=u*g-f*p,t[7]=0,t[8]=u,t[9]=f,t[10]=h,t[11]=0,t[12]=s,t[13]=n,t[14]=o,t[15]=1,t}function BE(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function UE(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function zE(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function c_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function VE(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function WE(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t[6]=e[6]+r[6]*i,t[7]=e[7]+r[7]*i,t[8]=e[8]+r[8]*i,t[9]=e[9]+r[9]*i,t[10]=e[10]+r[10]*i,t[11]=e[11]+r[11]*i,t[12]=e[12]+r[12]*i,t[13]=e[13]+r[13]*i,t[14]=e[14]+r[14]*i,t[15]=e[15]+r[15]*i,t}function HE(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function jE(t,e){let r=t[0],i=t[1],s=t[2],n=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],f=t[9],h=t[10],d=t[11],p=t[12],g=t[13],_=t[14],x=t[15],v=e[0],b=e[1],A=e[2],C=e[3],M=e[4],F=e[5],N=e[6],D=e[7],L=e[8],Y=e[9],X=e[10],$=e[11],Z=e[12],ge=e[13],rt=e[14],ot=e[15];return Math.abs(r-v)<=1e-6*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(i-b)<=1e-6*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(s-A)<=1e-6*Math.max(1,Math.abs(s),Math.abs(A))&&Math.abs(n-C)<=1e-6*Math.max(1,Math.abs(n),Math.abs(C))&&Math.abs(o-M)<=1e-6*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(a-F)<=1e-6*Math.max(1,Math.abs(a),Math.abs(F))&&Math.abs(c-N)<=1e-6*Math.max(1,Math.abs(c),Math.abs(N))&&Math.abs(l-D)<=1e-6*Math.max(1,Math.abs(l),Math.abs(D))&&Math.abs(u-L)<=1e-6*Math.max(1,Math.abs(u),Math.abs(L))&&Math.abs(f-Y)<=1e-6*Math.max(1,Math.abs(f),Math.abs(Y))&&Math.abs(h-X)<=1e-6*Math.max(1,Math.abs(h),Math.abs(X))&&Math.abs(d-$)<=1e-6*Math.max(1,Math.abs(d),Math.abs($))&&Math.abs(p-Z)<=1e-6*Math.max(1,Math.abs(p),Math.abs(Z))&&Math.abs(g-ge)<=1e-6*Math.max(1,Math.abs(g),Math.abs(ge))&&Math.abs(_-rt)<=1e-6*Math.max(1,Math.abs(_),Math.abs(rt))&&Math.abs(x-ot)<=1e-6*Math.max(1,Math.abs(x),Math.abs(ot))}var XE=Gn,$E=c_;var Jt={};ui(Jt,{add:()=>ZE,ceil:()=>JE,clone:()=>YE,copy:()=>qE,create:()=>l_,cross:()=>lw,dist:()=>Tw,distance:()=>d_,div:()=>xw,divide:()=>h_,dot:()=>cw,equals:()=>mw,exactEquals:()=>gw,floor:()=>QE,forEach:()=>Aw,fromValues:()=>KE,inverse:()=>ow,len:()=>bw,length:()=>g_,lerp:()=>uw,max:()=>tw,min:()=>ew,mul:()=>yw,multiply:()=>f_,negate:()=>nw,normalize:()=>aw,random:()=>fw,round:()=>rw,scale:()=>iw,scaleAndAdd:()=>sw,set:()=>GE,sqrDist:()=>vw,sqrLen:()=>Sw,squaredDistance:()=>p_,squaredLength:()=>m_,str:()=>pw,sub:()=>_w,subtract:()=>u_,transformMat4:()=>kh,transformQuat:()=>hw,zero:()=>dw});function l_(){let t=new Te(4);return Te!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function YE(t){let e=new Te(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function KE(t,e,r,i){let s=new Te(4);return s[0]=t,s[1]=e,s[2]=r,s[3]=i,s}function qE(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function GE(t,e,r,i,s){return t[0]=e,t[1]=r,t[2]=i,t[3]=s,t}function ZE(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function u_(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function f_(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function h_(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function JE(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function QE(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function ew(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function tw(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function rw(t,e){return t[0]=xt(e[0]),t[1]=xt(e[1]),t[2]=xt(e[2]),t[3]=xt(e[3]),t}function iw(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function sw(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t}function d_(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2],n=e[3]-t[3];return Math.sqrt(r*r+i*i+s*s+n*n)}function p_(t,e){let r=e[0]-t[0],i=e[1]-t[1],s=e[2]-t[2],n=e[3]-t[3];return r*r+i*i+s*s+n*n}function g_(t){let e=t[0],r=t[1],i=t[2],s=t[3];return Math.sqrt(e*e+r*r+i*i+s*s)}function m_(t){let e=t[0],r=t[1],i=t[2],s=t[3];return e*e+r*r+i*i+s*s}function nw(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function ow(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function aw(t,e){let r=e[0],i=e[1],s=e[2],n=e[3],o=r*r+i*i+s*s+n*n;return o>0&&(o=1/Math.sqrt(o)),t[0]=r*o,t[1]=i*o,t[2]=s*o,t[3]=n*o,t}function cw(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function lw(t,e,r,i){let s=r[0]*i[1]-r[1]*i[0],n=r[0]*i[2]-r[2]*i[0],o=r[0]*i[3]-r[3]*i[0],a=r[1]*i[2]-r[2]*i[1],c=r[1]*i[3]-r[3]*i[1],l=r[2]*i[3]-r[3]*i[2],u=e[0],f=e[1],h=e[2],d=e[3];return t[0]=f*l-h*c+d*a,t[1]=-(u*l)+h*o-d*n,t[2]=u*c-f*o+d*s,t[3]=-(u*a)+f*n-h*s,t}function uw(t,e,r,i){let s=e[0],n=e[1],o=e[2],a=e[3];return t[0]=s+i*(r[0]-s),t[1]=n+i*(r[1]-n),t[2]=o+i*(r[2]-o),t[3]=a+i*(r[3]-a),t}function fw(t,e){e=e===void 0?1:e;let r,i,s,n,o,a;do r=Gt()*2-1,i=Gt()*2-1,o=r*r+i*i;while(o>=1);do s=Gt()*2-1,n=Gt()*2-1,a=s*s+n*n;while(a>=1);let c=Math.sqrt((1-o)/a);return t[0]=e*r,t[1]=e*i,t[2]=e*s*c,t[3]=e*n*c,t}function kh(t,e,r){let i=e[0],s=e[1],n=e[2],o=e[3];return t[0]=r[0]*i+r[4]*s+r[8]*n+r[12]*o,t[1]=r[1]*i+r[5]*s+r[9]*n+r[13]*o,t[2]=r[2]*i+r[6]*s+r[10]*n+r[14]*o,t[3]=r[3]*i+r[7]*s+r[11]*n+r[15]*o,t}function hw(t,e,r){let i=e[0],s=e[1],n=e[2],o=r[0],a=r[1],c=r[2],l=r[3],u=l*i+a*n-c*s,f=l*s+c*i-o*n,h=l*n+o*s-a*i,d=-o*i-a*s-c*n;return t[0]=u*l+d*-o+f*-c-h*-a,t[1]=f*l+d*-a+h*-o-u*-c,t[2]=h*l+d*-c+u*-a-f*-o,t[3]=e[3],t}function dw(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function pw(t){return`vec4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}function gw(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function mw(t,e){let r=t[0],i=t[1],s=t[2],n=t[3],o=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(n-l)<=1e-6*Math.max(1,Math.abs(n),Math.abs(l))}var _w=u_,yw=f_,xw=h_,Tw=d_,vw=p_,bw=g_,Sw=m_,Aw=function(){let t=l_();return function(e,r,i,s,n,o){let a,c;for(r||(r=4),i||(i=0),s?c=Math.min(s*r+i,e.length):c=e.length,a=i;aMath.PI*2)throw Error("expected radians")}function Mw(t,e,r,i,s,n){let o=2*n/(r-e),a=2*n/(s-i),c=(r+e)/(r-e),l=(s+i)/(s-i),u=-1,f=-1,h=-2*n;return t[0]=o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=u,t[11]=f,t[12]=0,t[13]=0,t[14]=h,t[15]=0,t}var Vh=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) +struct AmbientLight { +vec3 color; +}; +struct PointLight { +vec3 color; +vec3 position; +vec3 attenuation; +}; +struct DirectionalLight { +vec3 color; +vec3 direction; +}; +uniform AmbientLight lighting_uAmbientLight; +uniform PointLight lighting_uPointLight[MAX_LIGHTS]; +uniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS]; +uniform int lighting_uPointLightCount; +uniform int lighting_uDirectionalLightCount; +uniform bool lighting_uEnabled; +float getPointLightAttenuation(PointLight pointLight, float distance) { +return pointLight.attenuation.x ++ pointLight.attenuation.y * distance ++ pointLight.attenuation.z * distance * distance; +} +#endif +`;var Iw={lightSources:{}};function Wh(t={}){let{color:e=[0,0,0],intensity:r=1}=t;return e.map(i=>i*r/255)}function Ow({ambientLight:t,pointLights:e=[],directionalLights:r=[]}){let i={};return t?i["lighting_uAmbientLight.color"]=Wh(t):i["lighting_uAmbientLight.color"]=[0,0,0],e.forEach((s,n)=>{i[`lighting_uPointLight[${n}].color`]=Wh(s),i[`lighting_uPointLight[${n}].position`]=s.position,i[`lighting_uPointLight[${n}].attenuation`]=s.attenuation||[1,0,0]}),i.lighting_uPointLightCount=e.length,r.forEach((s,n)=>{i[`lighting_uDirectionalLight[${n}].color`]=Wh(s),i[`lighting_uDirectionalLight[${n}].direction`]=s.direction}),i.lighting_uDirectionalLightCount=r.length,i}function y_(t=Iw){if("lightSources"in t){let{ambientLight:e,pointLights:r,directionalLights:i}=t.lightSources||{};return e||r&&r.length>0||i&&i.length>0?Object.assign({},Ow({ambientLight:e,pointLights:r,directionalLights:i}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){let e={pointLights:[],directionalLights:[]};for(let r of t.lights||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;default:}return y_({lightSources:e})}return{}}var Hh={name:"lights",vs:Vh,fs:Vh,getUniforms:y_,defines:{MAX_LIGHTS:3}};var jh=`uniform float lighting_uAmbient; +uniform float lighting_uDiffuse; +uniform float lighting_uShininess; +uniform vec3 lighting_uSpecularColor; +vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) { +vec3 halfway_direction = normalize(light_direction + view_direction); +float lambertian = dot(light_direction, normal_worldspace); +float specular = 0.0; +if (lambertian > 0.0) { +float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); +specular = pow(specular_angle, lighting_uShininess); +} +lambertian = max(lambertian, 0.0); +return (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color; +} +vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) { +vec3 lightColor = surfaceColor; +if (lighting_uEnabled) { +vec3 view_direction = normalize(cameraPosition - position_worldspace); +lightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color; +for (int i = 0; i < MAX_LIGHTS; i++) { +if (i >= lighting_uPointLightCount) { +break; +} +PointLight pointLight = lighting_uPointLight[i]; +vec3 light_position_worldspace = pointLight.position; +vec3 light_direction = normalize(light_position_worldspace - position_worldspace); +lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color); +} +for (int i = 0; i < MAX_LIGHTS; i++) { +if (i >= lighting_uDirectionalLightCount) { +break; +} +DirectionalLight directionalLight = lighting_uDirectionalLight[i]; +lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); +} +} +return lightColor; +} +vec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) { +vec3 lightColor = vec3(0, 0, 0); +vec3 surfaceColor = vec3(0, 0, 0); +if (lighting_uEnabled) { +vec3 view_direction = normalize(cameraPosition - position_worldspace); +for (int i = 0; i < MAX_LIGHTS; i++) { +if (i >= lighting_uPointLightCount) { +break; +} +PointLight pointLight = lighting_uPointLight[i]; +vec3 light_position_worldspace = pointLight.position; +vec3 light_direction = normalize(light_position_worldspace - position_worldspace); +lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color); +} +for (int i = 0; i < MAX_LIGHTS; i++) { +if (i >= lighting_uDirectionalLightCount) { +break; +} +DirectionalLight directionalLight = lighting_uDirectionalLight[i]; +lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); +} +} +return lightColor; +} +`;var Nw={};function Fw(t){let{ambient:e=.35,diffuse:r=.6,shininess:i=32,specularColor:s=[30,30,30]}=t;return{lighting_uAmbient:e,lighting_uDiffuse:r,lighting_uShininess:i,lighting_uSpecularColor:s.map(n=>n/255)}}function x_(t=Nw){if(!("material"in t))return{};let{material:e}=t;return e?Fw(e):{lighting_uEnabled:!1}}var Mt={name:"gouraud-lighting",dependencies:[Hh],vs:jh,defines:{LIGHTING_VERTEX:1},getUniforms:x_},Zn={name:"phong-lighting",dependencies:[Hh],fs:jh,defines:{LIGHTING_FRAGMENT:1},getUniforms:x_};var T_="#define SMOOTH_EDGE_RADIUS 0.5",Dw=` +${T_} + +struct VertexGeometry { + vec4 position; + vec3 worldPosition; + vec3 worldPositionAlt; + vec3 normal; + vec2 uv; + vec3 pickingColor; +} geometry = VertexGeometry( + vec4(0.0, 0.0, 1.0, 0.0), + vec3(0.0), + vec3(0.0), + vec3(0.0), + vec2(0.0), + vec3(0.0) +); +`,Lw=` +${T_} + +struct FragmentGeometry { + vec2 uv; +} geometry; + +float smoothedge(float edge, float x) { + return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); +} +`,v_={name:"geometry",vs:Dw,fs:Lw};var q={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(q,"IDENTITY",{get:()=>(U.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});var Ge={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},pe={common:0,meters:1,pixels:2},Jn={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}};var kw=Object.keys(q).map(t=>`const int COORDINATE_SYSTEM_${t} = ${q[t]};`).join(""),Bw=Object.keys(Ge).map(t=>`const int PROJECTION_MODE_${t} = ${Ge[t]};`).join(""),Uw=Object.keys(pe).map(t=>`const int UNIT_${t.toUpperCase()} = ${pe[t]};`).join(""),b_=`${kw} +${Bw} +${Uw} +uniform int project_uCoordinateSystem; +uniform int project_uProjectionMode; +uniform float project_uScale; +uniform bool project_uWrapLongitude; +uniform vec3 project_uCommonUnitsPerMeter; +uniform vec3 project_uCommonUnitsPerWorldUnit; +uniform vec3 project_uCommonUnitsPerWorldUnit2; +uniform vec4 project_uCenter; +uniform mat4 project_uModelMatrix; +uniform mat4 project_uViewProjectionMatrix; +uniform vec2 project_uViewportSize; +uniform float project_uDevicePixelRatio; +uniform float project_uFocalDistance; +uniform vec3 project_uCameraPosition; +uniform vec3 project_uCoordinateOrigin; +uniform vec3 project_uCommonOrigin; +uniform bool project_uPseudoMeters; +const float TILE_SIZE = 512.0; +const float PI = 3.1415926536; +const float WORLD_SCALE = TILE_SIZE / (PI * 2.0); +const vec3 ZERO_64_LOW = vec3(0.0); +const float EARTH_RADIUS = 6370972.0; +const float GLOBE_RADIUS = 256.0; +float project_size_at_latitude(float lat) { +float y = clamp(lat, -89.9, 89.9); +return 1.0 / cos(radians(y)); +} +float project_size() { +if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR && +project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT && +project_uPseudoMeters == false) { +if (geometry.position.w == 0.0) { +return project_size_at_latitude(geometry.worldPosition.y); +} +float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0; +float y2 = y * y; +float y4 = y2 * y2; +float y6 = y4 * y2; +return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6; +} +return 1.0; +} +float project_size_at_latitude(float meters, float lat) { +return meters * project_uCommonUnitsPerMeter.z * project_size_at_latitude(lat); +} +float project_size(float meters) { +return meters * project_uCommonUnitsPerMeter.z * project_size(); +} +vec2 project_size(vec2 meters) { +return meters * project_uCommonUnitsPerMeter.xy * project_size(); +} +vec3 project_size(vec3 meters) { +return meters * project_uCommonUnitsPerMeter * project_size(); +} +vec4 project_size(vec4 meters) { +return vec4(meters.xyz * project_uCommonUnitsPerMeter, meters.w); +} +mat3 project_get_orientation_matrix(vec3 up) { +vec3 uz = normalize(up); +vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0)); +vec3 uy = cross(uz, ux); +return mat3(ux, uy, uz); +} +bool project_needs_rotation(vec3 commonPosition, out mat3 transform) { +if (project_uProjectionMode == PROJECTION_MODE_GLOBE) { +transform = project_get_orientation_matrix(commonPosition); +return true; +} +return false; +} +vec3 project_normal(vec3 vector) { +vec4 normal_modelspace = project_uModelMatrix * vec4(vector, 0.0); +vec3 n = normalize(normal_modelspace.xyz * project_uCommonUnitsPerMeter); +mat3 rotation; +if (project_needs_rotation(geometry.position.xyz, rotation)) { +n = rotation * n; +} +return n; +} +vec4 project_offset_(vec4 offset) { +float dy = offset.y; +vec3 commonUnitsPerWorldUnit = project_uCommonUnitsPerWorldUnit + project_uCommonUnitsPerWorldUnit2 * dy; +return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w); +} +vec2 project_mercator_(vec2 lnglat) { +float x = lnglat.x; +if (project_uWrapLongitude) { +x = mod(x + 180., 360.0) - 180.; +} +float y = clamp(lnglat.y, -89.9, 89.9); +return vec2( +radians(x) + PI, +PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5)) +) * WORLD_SCALE; +} +vec3 project_globe_(vec3 lnglatz) { +float lambda = radians(lnglatz.x); +float phi = radians(lnglatz.y); +float cosPhi = cos(phi); +float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS; +return vec3( +sin(lambda) * cosPhi, +-cos(lambda) * cosPhi, +sin(phi) +) * D; +} +vec4 project_position(vec4 position, vec3 position64Low) { +vec4 position_world = project_uModelMatrix * position; +if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR) { +if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +return vec4( +project_mercator_(position_world.xy), +project_size_at_latitude(position_world.z, position_world.y), +position_world.w +); +} +if (project_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN) { +position_world.xyz += project_uCoordinateOrigin; +} +} +if (project_uProjectionMode == PROJECTION_MODE_GLOBE) { +if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +return vec4( +project_globe_(position_world.xyz), +position_world.w +); +} +} +if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { +if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +if (abs(position_world.y - project_uCoordinateOrigin.y) > 0.25) { +return vec4( +project_mercator_(position_world.xy) - project_uCommonOrigin.xy, +project_size(position_world.z), +position_world.w +); +} +} +} +if (project_uProjectionMode == PROJECTION_MODE_IDENTITY || +(project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET && +(project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT || +project_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) { +position_world.xyz -= project_uCoordinateOrigin; +} +return project_offset_(position_world) + project_offset_(project_uModelMatrix * vec4(position64Low, 0.0)); +} +vec4 project_position(vec4 position) { +return project_position(position, ZERO_64_LOW); +} +vec3 project_position(vec3 position, vec3 position64Low) { +vec4 projected_position = project_position(vec4(position, 1.0), position64Low); +return projected_position.xyz; +} +vec3 project_position(vec3 position) { +vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW); +return projected_position.xyz; +} +vec2 project_position(vec2 position) { +vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW); +return projected_position.xy; +} +vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) { +return viewProjectionMatrix * position + center; +} +vec4 project_common_position_to_clipspace(vec4 position) { +return project_common_position_to_clipspace(position, project_uViewProjectionMatrix, project_uCenter); +} +vec2 project_pixel_size_to_clipspace(vec2 pixels) { +vec2 offset = pixels / project_uViewportSize * project_uDevicePixelRatio * 2.0; +return offset * project_uFocalDistance; +} +float project_size_to_pixel(float meters) { +return project_size(meters) * project_uScale; +} +float project_size_to_pixel(float size, int unit) { +if (unit == UNIT_METERS) return project_size_to_pixel(size); +if (unit == UNIT_COMMON) return size * project_uScale; +return size; +} +float project_pixel_size(float pixels) { +return pixels / project_uScale; +} +vec2 project_pixel_size(vec2 pixels) { +return pixels / project_uScale; +} +`;function zw(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let i=0;i{for(let s in i)if(!zw(i[s],e[s])){r=t(i),e=i;break}return r}}var S_=[0,0,0,0],Vw=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],A_=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Ww=[0,0,0],E_=[0,0,0],Hw=Qt(Xw);function Xh(t,e,r=E_){r.length<3&&(r=[r[0],r[1],0]);let i=r,s,n=!0;switch(e===q.LNGLAT_OFFSETS||e===q.METER_OFFSETS?s=r:s=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case Ge.WEB_MERCATOR:(e===q.LNGLAT||e===q.CARTESIAN)&&(s=[0,0,0],n=!1);break;case Ge.WEB_MERCATOR_AUTO_OFFSET:e===q.LNGLAT?i=s:e===q.CARTESIAN&&(i=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],s=t.unprojectPosition(i),i[0]-=r[0],i[1]-=r[1],i[2]-=r[2]);break;case Ge.IDENTITY:i=t.position.map(Math.fround),i[2]=i[2]||0;break;case Ge.GLOBE:n=!1,s=null;break;default:n=!1}return{geospatialOrigin:s,shaderCoordinateOrigin:i,offsetMode:n}}function jw(t,e,r){let{viewMatrixUncentered:i,projectionMatrix:s}=t,{viewMatrix:n,viewProjectionMatrix:o}=t,a=S_,c=S_,l=t.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:f,offsetMode:h}=Xh(t,e,r);return h&&(c=t.projectPosition(u||f),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=Jt.transformMat4([],c,o),n=i||n,o=Pe.multiply([],s,n),o=Pe.multiply([],o,Vw)),{viewMatrix:n,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:f,geospatialOrigin:u}}function w_({viewport:t,devicePixelRatio:e=1,modelMatrix:r=null,coordinateSystem:i=q.DEFAULT,coordinateOrigin:s=E_,autoWrapLongitude:n=!1}){i===q.DEFAULT&&(i=t.isGeospatial?q.LNGLAT:q.CARTESIAN);let o=Hw({viewport:t,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:s});return o.project_uWrapLongitude=n,o.project_uModelMatrix=r||A_,o}function Xw({viewport:t,devicePixelRatio:e,coordinateSystem:r,coordinateOrigin:i}){let{projectionCenter:s,viewProjectionMatrix:n,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=jw(t,r,i),u=t.getDistanceScales(),f=[t.width*e,t.height*e],h=Jt.transformMat4([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,d={project_uCoordinateSystem:r,project_uProjectionMode:t.projectionMode,project_uCoordinateOrigin:c,project_uCommonOrigin:o.slice(0,3),project_uCenter:s,project_uPseudoMeters:!!t._pseudoMeters,project_uViewportSize:f,project_uDevicePixelRatio:e,project_uFocalDistance:h,project_uCommonUnitsPerMeter:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:Ww,project_uScale:t.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:n,project_uModelMatrix:A_,project_uCameraPosition:a};if(l){let p=t.getDistanceScales(l);switch(r){case q.METER_OFFSETS:d.project_uCommonUnitsPerWorldUnit=p.unitsPerMeter,d.project_uCommonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case q.LNGLAT:case q.LNGLAT_OFFSETS:t._pseudoMeters||(d.project_uCommonUnitsPerMeter=p.unitsPerMeter),d.project_uCommonUnitsPerWorldUnit=p.unitsPerDegree,d.project_uCommonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case q.CARTESIAN:d.project_uCommonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],d.project_uCommonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}return d}var $w={};function Yw(t=$w){return"viewport"in t?w_(t):{}}var Ri={name:"project",dependencies:[lh,v_],vs:b_,getUniforms:Yw};var Kw=` +vec4 project_position_to_clipspace( + vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition +) { + vec3 projectedPosition = project_position(position, position64Low); + mat3 rotation; + if (project_needs_rotation(projectedPosition, rotation)) { + // offset is specified as ENU + // when in globe projection, rotate offset so that the ground alighs with the surface of the globe + offset = rotation * offset; + } + commonPosition = vec4(projectedPosition + offset, 1.0); + return project_common_position_to_clipspace(commonPosition); +} + +vec4 project_position_to_clipspace( + vec3 position, vec3 position64Low, vec3 offset +) { + vec4 commonPosition; + return project_position_to_clipspace(position, position64Low, offset, commonPosition); +} +`,ae={name:"project32",dependencies:[Ri],vs:Kw};function $h(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Hr(t,e){let r=Jt.transformMat4([],e,t);return Jt.scale(r,r,1/r[3]),r}function Yh(t,e){let r=t%e;return r<0?e+r:r}function Qn(t,e,r){return tr?r:t}function qw(t){return Math.log(t)*Math.LOG2E}var _s=Math.log2||qw;function It(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var Ot=Math.PI,P_=Ot/4,Tt=Ot/180,Kh=180/Ot,ys=512,Wc=4003e4,xs=85.051129,R_=1.5;function qh(t){return _s(t)}function Ze(t){let[e,r]=t;It(Number.isFinite(e)),It(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let i=e*Tt,s=r*Tt,n=ys*(i+Ot)/(2*Ot),o=ys*(Ot+Math.log(Math.tan(P_+s*.5)))/(2*Ot);return[n,o]}function it(t){let[e,r]=t,i=e/ys*(2*Ot)-Ot,s=2*(Math.atan(Math.exp(r/ys*(2*Ot)-Ot))-P_);return[i*Kh,s*Kh]}function Gh(t){let{latitude:e}=t;It(Number.isFinite(e));let r=Math.cos(e*Tt);return qh(Wc*r)-9}function Mi(t){let e=Math.cos(t*Tt);return ys/Wc/e}function Ts(t){let{latitude:e,longitude:r,highPrecision:i=!1}=t;It(Number.isFinite(e)&&Number.isFinite(r));let s=ys,n=Math.cos(e*Tt),o=s/360,a=o/n,c=s/Wc/n,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(i){let u=Tt*Math.tan(e*Tt)/n,f=o*u/2,h=s/Wc*u,d=h/a*c;l.unitsPerDegree2=[0,f,h],l.unitsPerMeter2=[d,0,d]}return l}function eo(t,e){let[r,i,s]=t,[n,o,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=Ts({longitude:r,latitude:i,highPrecision:!0}),u=Ze(t);u[0]+=n*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let f=it(u),h=(s||0)+(a||0);return Number.isFinite(s)||Number.isFinite(a)?[f[0],f[1],h]:f}function Hc(t){let{height:e,pitch:r,bearing:i,altitude:s,scale:n,center:o}=t,a=$h();Pe.translate(a,a,[0,0,-s]),Pe.rotateX(a,a,-r*Tt),Pe.rotateZ(a,a,i*Tt);let c=n/e;return Pe.scale(a,a,[c,c,c]),o&&Pe.translate(a,a,ms.negate([],o)),a}function Zh(t){let{width:e,height:r,altitude:i,pitch:s=0,offset:n,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=t,{fovy:u=Ci(R_)}=t;i!==void 0&&(u=Ci(i));let f=u*Tt,h=s*Tt,d=to(u),p=d;o&&(p+=o[2]*a/Math.cos(h)/r);let g=f*(.5+(n?n[1]:0)/r),_=Math.sin(g)*p/Math.sin(Qn(Math.PI/2-h-g,.01,Math.PI-.01)),x=Math.sin(h)*_+p,v=p*10,b=Math.min(x*l,v);return{fov:f,aspect:e/r,focalDistance:d,near:c,far:b}}function Ci(t){return 2*Math.atan(.5/t)*Kh}function to(t){return .5/Math.tan(.5*t*Tt)}function vs(t,e){let[r,i,s=0]=t;return It(Number.isFinite(r)&&Number.isFinite(i)&&Number.isFinite(s)),Hr(e,[r,i,s,1])}function jr(t,e,r=0){let[i,s,n]=t;if(It(Number.isFinite(i)&&Number.isFinite(s),"invalid pixel coordinate"),Number.isFinite(n))return Hr(e,[i,s,n,1]);let o=Hr(e,[i,s,0,1]),a=Hr(e,[i,s,1,1]),c=o[2],l=a[2],u=c===l?0:((r||0)-c)/(l-c);return Zt.lerp([],o,a,u)}function jc(t){let{width:e,height:r,bounds:i,minExtent:s=0,maxZoom:n=24,offset:o=[0,0]}=t,[[a,c],[l,u]]=i,f=Gw(t.padding),h=Ze([a,Qn(u,-xs,xs)]),d=Ze([l,Qn(c,-xs,xs)]),p=[Math.max(Math.abs(d[0]-h[0]),s),Math.max(Math.abs(d[1]-h[1]),s)],g=[e-f.left-f.right-Math.abs(o[0])*2,r-f.top-f.bottom-Math.abs(o[1])*2];It(g[0]>0&&g[1]>0);let _=g[0]/p[0],x=g[1]/p[1],v=(f.right-f.left)/2/_,b=(f.top-f.bottom)/2/x,A=[(d[0]+h[0])/2+v,(d[1]+h[1])/2+b],C=it(A),M=Math.min(n,_s(Math.abs(Math.min(_,x))));return It(Number.isFinite(M)),{longitude:C[0],latitude:C[1],zoom:M}}function Gw(t=0){return typeof t=="number"?{top:t,bottom:t,left:t,right:t}:(It(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t)}var C_=Math.PI/180;function Xc(t,e=0){let{width:r,height:i,unproject:s}=t,n={targetZ:e},o=s([0,i],n),a=s([r,i],n),c,l,u=t.fovy?.5*t.fovy*C_:Math.atan(.5/t.altitude),f=(90-t.pitch)*C_;return u>f-.01?(c=M_(t,0,e),l=M_(t,r,e)):(c=s([0,0],n),l=s([r,0],n)),[o,a,l,c]}function M_(t,e,r){let{pixelUnprojectionMatrix:i}=t,s=Hr(i,[e,0,1,1]),n=Hr(i,[e,t.height,1,1]),a=(r*t.distanceScales.unitsPerMeter[2]-s[2])/(n[2]-s[2]),c=Zt.lerp([],s,n,a),l=it(c);return l.push(r),l}var O_=512;function Jh(t){let{width:e,height:r,pitch:i=0}=t,{longitude:s,latitude:n,zoom:o,bearing:a=0}=t;(s<-180||s>180)&&(s=Yh(s+180,360)-180),(a<-180||a>180)&&(a=Yh(a+180,360)-180);let c=_s(r/O_);if(o<=c)o=c,n=0;else{let l=r/2/Math.pow(2,o),u=it([0,l])[1];if(nf&&(n=f)}}return{width:e,height:r,longitude:s,latitude:n,zoom:o,pitch:i,bearing:a}}var Qw=` +const int max_lights = 2; +uniform mat4 shadow_uViewProjectionMatrices[max_lights]; +uniform vec4 shadow_uProjectCenters[max_lights]; +uniform bool shadow_uDrawShadowMap; +uniform bool shadow_uUseShadowMap; +uniform int shadow_uLightId; +uniform float shadow_uLightCount; + +out vec3 shadow_vPosition[max_lights]; + +vec4 shadow_setVertexPosition(vec4 position_commonspace) { + if (shadow_uDrawShadowMap) { + return project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[shadow_uLightId], shadow_uProjectCenters[shadow_uLightId]); + } + if (shadow_uUseShadowMap) { + for (int i = 0; i < max_lights; i++) { + if(i < int(shadow_uLightCount)) { + vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[i], shadow_uProjectCenters[i]); + shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0; + } + } + } + return gl_Position; +} +`,eP=` +const int max_lights = 2; +uniform bool shadow_uDrawShadowMap; +uniform bool shadow_uUseShadowMap; +uniform sampler2D shadow_uShadowMap0; +uniform sampler2D shadow_uShadowMap1; +uniform vec4 shadow_uColor; +uniform float shadow_uLightCount; + +in vec3 shadow_vPosition[max_lights]; + +const vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0); +const vec4 bitUnpackShift = 1.0 / bitPackShift; +const vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0); + +float shadow_getShadowWeight(vec3 position, sampler2D shadowMap) { + vec4 rgbaDepth = texture(shadowMap, position.xy); + + float z = dot(rgbaDepth, bitUnpackShift); + return smoothstep(0.001, 0.01, position.z - z); +} + +vec4 shadow_filterShadowColor(vec4 color) { + if (shadow_uDrawShadowMap) { + vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift); + rgbaDepth -= rgbaDepth.gbaa * bitMask; + return rgbaDepth; + } + if (shadow_uUseShadowMap) { + float shadowAlpha = 0.0; + shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0); + if(shadow_uLightCount > 1.0) { + shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1); + } + shadowAlpha *= shadow_uColor.a / shadow_uLightCount; + float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha); + + return vec4( + mix(color.rgb, shadow_uColor.rgb, shadowAlpha / blendedAlpha), + blendedAlpha + ); + } + return color; +} +`,tP=Qt(oP),rP=Qt(aP),iP=[0,0,0,1],sP=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function nP(t,e){let[r,i,s]=t,n=jr([r,i,s],e);return Number.isFinite(s)?n:[n[0],n[1],0]}function oP({viewport:t,center:e}){return new De(t.viewProjectionMatrix).invert().transform(e)}function aP({viewport:t,shadowMatrices:e}){let r=[],i=t.pixelUnprojectionMatrix,s=t.isGeospatial?void 0:1,n=[[0,0,s],[t.width,0,s],[0,t.height,s],[t.width,t.height,s],[0,0,-1],[t.width,0,-1],[0,t.height,-1],[t.width,t.height,-1]].map(o=>nP(o,i));for(let o of e){let a=o.clone().translate(new Ue(t.center).negate()),c=n.map(u=>a.transform(u)),l=new De().ortho({left:Math.min(...c.map(u=>u[0])),right:Math.max(...c.map(u=>u[0])),bottom:Math.min(...c.map(u=>u[1])),top:Math.max(...c.map(u=>u[1])),near:Math.min(...c.map(u=>-u[2])),far:Math.max(...c.map(u=>-u[2]))});r.push(l.multiplyRight(o))}return r}function cP(t,e){let{shadowEnabled:r=!0}=t;if(!r||!t.shadowMatrices||!t.shadowMatrices.length)return{shadow_uDrawShadowMap:!1,shadow_uUseShadowMap:!1,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};let i={shadow_uDrawShadowMap:!!t.drawToShadowMap,shadow_uUseShadowMap:t.shadowMaps?t.shadowMaps.length>0:!1,shadow_uColor:t.shadowColor||iP,shadow_uLightId:t.shadowLightId||0,shadow_uLightCount:t.shadowMatrices.length},s=tP({viewport:t.viewport,center:e.project_uCenter}),n=[],o=rP({shadowMatrices:t.shadowMatrices,viewport:t.viewport}).slice();for(let a=0;a"viewport"in t&&(t.drawToShadowMap||t.shadowMaps&&t.shadowMaps.length>0)?cP(t,e):{}};var ue={...Nc,defaultUniforms:{...Nc.defaultUniforms,useFloatColors:!1},inject:{"vs:DECKGL_FILTER_GL_POSITION":` + // for picking depth values + picking_setPickingAttribute(position.z / position.w); + `,"vs:DECKGL_FILTER_COLOR":` + picking_setPickingColor(geometry.pickingColor); + `,"fs:DECKGL_FILTER_COLOR":{order:99,injection:` + // use highlight color if this fragment belongs to the selected object. + color = picking_filterHighlightColor(color); + + // use picking color if rendering to picking FBO. + color = picking_filterPickingColor(color); + `}}};var lP=[Ri],uP=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"];function ro(){let t=xi.getDefaultShaderAssembler();for(let e of lP)t.addDefaultModule(e);for(let e of uP)t.addShaderHook(e);return t}var fP=[255,255,255],hP=1,dP=0,Yc=class{constructor(e={}){this.type="ambient";let{color:r=fP}=e,{intensity:i=hP}=e;this.id=e.id||`ambient-${dP++}`,this.color=r,this.intensity=i}};var pP=[255,255,255],gP=1,mP=[0,0,-1],_P=0,io=class{constructor(e={}){this.type="directional";let{color:r=pP}=e,{intensity:i=gP}=e,{direction:s=mP}=e,{_shadow:n=!1}=e;this.id=e.id||`directional-${_P++}`,this.color=r,this.intensity=i,this.type="directional",this.direction=new Ue(s).normalize().toArray(),this.shadow=n}getProjectedLight(e){return this}};var so=class{constructor(e,r={id:"pass"}){let{id:i}=r;this.id=i,this.device=e,this.props={...r}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var xr=class extends so{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){let[r,i]=this.device.canvasContext.getDrawingBufferSize(),s=e.clearCanvas??!0,n=e.clearColor??(s?[0,0,0,0]:!1),o=s?1:!1,a=s?0:!1,c=e.colorMask??15,l={viewport:[0,0,r,i]};e.colorMask&&(l.colorMask=c),e.scissorRect&&(l.scissorRect=e.scissorRect);let u=this.device.beginRenderPass({framebuffer:e.target,parameters:l,clearColor:n,clearDepth:o,clearStencil:a});try{return this._drawLayers(u,e)}finally{u.end()}}_drawLayers(e,r){let{target:i,moduleParameters:s,viewports:n,views:o,onViewportActive:a,clearStack:c=!0}=r;r.pass=r.pass||"unknown",c&&(this._lastRenderIndex=-1);let l=[];for(let u of n){let f=o&&o[u.id];a?.(u);let h=this._getDrawLayerParams(u,r),d=u.subViewports||[u];for(let p of d){let g=this._drawLayersInViewport(e,{target:i,moduleParameters:s,viewport:p,view:f,pass:r.pass,layers:r.layers},h);l.push(g)}}return l}_getDrawLayerParams(e,{layers:r,pass:i,isPicking:s=!1,layerFilter:n,cullRect:o,effects:a,moduleParameters:c},l=!1){let u=[],f=N_(this._lastRenderIndex+1),h={layer:r[0],viewport:e,isPicking:s,renderPass:i,cullRect:o},d={};for(let p=0;pthis.device.clearWebGL(f))}let u={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let f=0;f{let o=s.props._offset,a=s.id,c=s.parent&&s.parent.id,l;if(c&&!(c in e)&&i(s.parent,!1),c in r){let u=r[c]=r[c]||N_(e[c],e);l=u(s,n),r[a]=u}else Number.isFinite(o)?(l=o+(e[c]||0),r[a]=null):l=t;return n&&l>=t&&(t=l+1),e[a]=l,l};return i}function yP(t,{moduleParameters:e,target:r,viewport:i}){let s=e&&e.devicePixelRatio||t.canvasContext.cssToDeviceRatio(),[,n]=t.canvasContext.getDrawingBufferSize(),o=r?r.height:n,a=i;return[a.x*s,o-(a.y+a.height)*s,a.width*s,a.height*s]}var no=class extends xr{constructor(e,r){super(e,r),this.shadowMap=e.createTexture({width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.depthBuffer=e.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1,dataFormat:6402,type:5125}),this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[this.shadowMap],depthStencilAttachment:this.depthBuffer})}render(e){let r=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),s=e.viewports[0],n=s.width*i,o=s.height*i,a=[1,1,1,1];(n!==r.width||o!==r.height)&&r.resize({width:n,height:o}),super.render({...e,clearColor:a,target:r,pass:"shadow"})}getLayerParameters(e,r,i){return{...e.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getModuleParameters(){return{drawToShadowMap:!0}}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.shadowMap&&(this.shadowMap.destroy(),this.shadowMap=null),this.depthBuffer&&(this.depthBuffer.destroy(),this.depthBuffer=null)}};var xP={color:[255,255,255],intensity:1},F_=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],TP=[0,0,0,200/255],bs=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=TP,this.shadow=!1,this.ambientLight=null,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.shadowMaps=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:r,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),i._addDefaultShaderModule($c),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(let r in e){let i=e[r];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:r,viewports:i,onViewportActive:s,views:n}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;oi.getProjectedLight({layer:e})),pointLights:this.pointLights.map(i=>i.getProjectedLight({layer:e}))},r}cleanup(e){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule($c))}_calculateMatrices(){let e=[];for(let r of this.directionalLights){let i=new De().lookAt({eye:new Ue(r.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let r=0;rs&&(n=s);let o=this._pool,a=e.BYTES_PER_ELEMENT*n,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(o.splice(c,1)[0],0,n);return i&&l.fill(0),l}return new e(n)}_release(e){if(!ArrayBuffer.isView(e))return;let r=this._pool,{buffer:i}=e,{byteLength:s}=i,n=r.findIndex(o=>o.byteLength>=s);n<0?r.push(i):(n>0||r.lengththis.opts.poolSize&&r.shift()}},Nt=new Qh;function As(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function L_(t){return[t[12],t[13],t[14]]}function k_(t){return{left:Ss(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:Ss(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:Ss(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:Ss(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:Ss(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:Ss(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}var D_=new Ue;function Ss(t,e,r,i){D_.set(t,e,r);let s=D_.len();return{distance:i/s,normal:new Ue(-t/s,-e/s,-r/s)}}function Ii(t){return t-Math.fround(t)}var oo;function Kc(t,e){let{size:r=1,startIndex:i=0}=e,s=e.endIndex!==void 0?e.endIndex:t.length,n=(s-i)/r;oo=Nt.allocate(oo,n,{type:Float32Array,size:r*2});let o=i,a=0;for(;o=r.delay+r.duration*r.repeat}getTime(e){if(e===void 0)return this.time;let r=this.channels.get(e);return r===void 0?-1:r.time}setTime(e){this.time=Math.max(0,e);let r=this.channels.values();for(let s of r)this._setChannelTime(s,this.time);let i=this.animations.values();for(let s of i){let{animation:n,channel:o}=s;n.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,r){let i=PP++;return this.animations.set(i,{animation:e,channel:r}),e.setTime(this.getTime(r)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,r){let i=r-e.delay,s=e.duration*e.repeat;i>=s?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}};var RP=0,CP={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:t=>console.error(t),stats:dr.stats.get(`animation-loop-${RP++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1},ao=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;constructor(e){if(this.props={...CP,...e},e=this.props,!e.device)throw new Error("No device provided");let{useDevicePixels:r=!0}=this.props;this.stats=e.stats||new dt({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:r}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let r=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(r),r}}stop(){return this._running&&(this.animationProps&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost?this:(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=wf(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(Pf(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){if(!this.device)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:this.device?.canvasContext?.canvas,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:r,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=r,this.animationProps.aspect=i,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(r);let i=this.props.onAddHTML(r);i&&(r.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,r]=this.device?.canvasContext?.getPixelSize()||[1,1],i=1,s=this.device?.canvasContext?.canvas;return s&&s.clientHeight?i=s.clientWidth/s.clientHeight:e>0&&r>0&&(i=e/r),{width:e,height:r,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}};var qc=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){this.id=e.id||Fe("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&ee(this.indices.usage===ie.INDEX)}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}};function W_(t,e){if(e instanceof qc)return e;let r=MP(t,e),{attributes:i,bufferLayout:s}=IP(t,e);return new qc({topology:e.topology||"triangle-list",bufferLayout:s,vertexCount:e.vertexCount,indices:r,attributes:i})}function MP(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:ie.INDEX,data:r})}function IP(t,e){let r=[],i={};for(let[n,o]of Object.entries(e.attributes)){let a=n;switch(n){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}i[a]=t.createBuffer({data:o.value,id:`${n}-buffer`});let{value:c,size:l,normalized:u}=o;r.push({name:a,format:Sf(c,l,u)})}let s=e._calculateVertexCount(e.attributes,e.indices);return{attributes:i,bufferLayout:r,vertexCount:s}}var Gc=class{modules;moduleUniforms;moduleBindings;moduleUniformsChanged;constructor(e){let r=yi(Object.values(e).filter(i=>i.dependencies));for(let i of r)e[i.name]=i;O.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[i,s]of Object.entries(e)){let n=i;this.moduleUniforms[n]=s.defaultUniforms||{},this.moduleBindings[n]={}}}destroy(){}setProps(e){for(let r of Object.keys(e)){let i=r,s=e[i],n=this.modules[i];if(!n){O.warn(`Module ${r} not found`)();continue}let o=this.moduleUniforms[i],a=n.getUniforms?.(s,this.moduleUniforms[i])||s;this.moduleUniforms[i]={...o,...a}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){let e={};for(let r of Object.values(this.moduleBindings))Object.assign(e,r);return e}getDebugTable(){let e={};for(let[r,i]of Object.entries(this.moduleUniforms))for(let[s,n]of Object.entries(i))e[`${r}.${s}`]={type:this.modules[r].uniformTypes?.[s],value:String(n)};return e}};var Zc=class t{static defaultProps={...qt.defaultProps};device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new t(e),e._lumaData.defaultPipelineFactory}constructor(e){this.device=e}createRenderPipeline(e){let r={...qt.defaultProps,...e},i=this._hashRenderPipeline(r);if(!this._renderPipelineCache[i]){let s=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:void 0});s.hash=i,this._renderPipelineCache[i]={pipeline:s,useCount:0}}return this._renderPipelineCache[i].useCount++,this._renderPipelineCache[i].pipeline}createComputePipeline(e){let r={...us.defaultProps,...e},i=this._hashComputePipeline(r);if(!this._computePipelineCache[i]){let s=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0});s.hash=i,this._computePipelineCache[i]={pipeline:s,useCount:0}}return this._computePipelineCache[i].useCount++,this._computePipelineCache[i].pipeline}release(e){let r=e.hash,i=e instanceof us?this._computePipelineCache:this._renderPipelineCache;i[r].useCount--,i[r].useCount===0&&(i[r].pipeline.destroy(),delete i[r])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){let r=this._getHash(e.vs.source),i=e.fs?this._getHash(e.fs.source):0,s="-",n=this._getHash(JSON.stringify(e.bufferLayout));switch(this.device.type){case"webgl":return`${r}/${i}V${s}BL${n}`;default:let o=this._getHash(JSON.stringify(e.parameters));return`${r}/${i}V${s}T${e.topology}P${o}BL${n}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};var Jc=class t{static defaultProps={...bi.defaultProps};device;_cache={};static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new t(e),e._lumaData.defaultShaderFactory}constructor(e){this.device=e}createShader(e){let r=this._hashShader(e),i=this._cache[r];if(!i){let s=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[r]=i={shader:s,useCount:0}}return i.useCount++,i.shader}release(e){let r=this._hashShader(e),i=this._cache[r];i&&(i.useCount--,i.useCount===0&&(delete this._cache[r],i.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}};function H_(t,e){let r={},i="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let s of t.attributes)if(s){let n=`${s.location} ${s.name}: ${s.type}`;r[`in ${n}`]={[i]:s.stepMode||"vertex"}}for(let s of t.varyings||[]){let n=`${s.location} ${s.name}`;r[`out ${n}`]={[i]:JSON.stringify(s.accessor)}}return r}var Ie=null,rd=null;function j_(t,{id:e,minimap:r,opaque:i,top:s="0",left:n="0",rgbaScale:o=1}){Ie||(Ie=document.createElement("canvas"),Ie.id=e,Ie.title=e,Ie.style.zIndex="100",Ie.style.position="absolute",Ie.style.top=s,Ie.style.left=n,Ie.style.border="blue 1px solid",Ie.style.transform="scaleY(-1)",document.body.appendChild(Ie),rd=Ie.getContext("2d")),(Ie.width!==t.width||Ie.height!==t.height)&&(Ie.width=t.width/2,Ie.height=t.height/2,Ie.style.width="400px",Ie.style.height="400px");let a=t.device.readPixelsToArrayWebGL(t),c=rd.createImageData(t.width,t.height),l=0;for(let u=0;u[a.name,a])||[]);this.setShaderInputs(r.shaderInputs||new Gc(i));let s=NP(e),n=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){this.props.shaderLayout||=ch(this.props.source);let{source:a,getUniforms:c}=this.props.shaderAssembler.assembleShader({platformInfo:s,...this.props,modules:n});this.source=a,this._getModuleUniforms=c}else{let{vs:a,fs:c,getUniforms:l}=this.props.shaderAssembler.assembleShaderPair({platformInfo:s,...this.props,modules:n});this.vs=a,this.fs=c,this._getModuleUniforms=l}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||Zc.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||Jc.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.uniforms&&this.setUniforms(r.uniforms),r.moduleSettings&&this.updateModuleSettings(r.moduleSettings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){this.predraw();let r;try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings,{disableWarnings:this.props.disableWarnings}),Br(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);let{indexBuffer:i}=this.vertexArray,s=i?i.byteLength/(i.indexType==="uint32"?4:2):void 0;r=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:s,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(e),r?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",r}setGeometry(e){this._gpuGeometry?.destroy();let r=e&&W_(this.device,e);r&&(this.setTopology(r.topology||"triangle-list"),this.bufferLayout=X_(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)),this._gpuGeometry=r}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?X_(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){$n(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Wn(this.shaderInputs.modules);for(let r of Object.keys(this.shaderInputs.modules)){let i=this._uniformStore.getManagedUniformBuffer(this.device,r);this.bindings[`${r}Uniforms`]=i}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,r){e.indices&&O.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(let[i,s]of Object.entries(e)){let n=this.bufferLayout.find(c=>$_(c).includes(i));if(!n){O.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}let o=$_(n),a=!1;for(let c of o){let l=this._attributeInfos[c];l&&(this.vertexArray.setBuffer(l.location,s),a=!0)}!a&&!(r?.disableWarnings??this.props.disableWarnings)&&O.warn(`Model(${this.id}): Ignoring buffer "${s.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,r){for(let[i,s]of Object.entries(e)){let n=this._attributeInfos[i];n?this.vertexArray.setConstantWebGL(n.location,s):(r?.disableWarnings??this.props.disableWarnings)||O.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){Br(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettings(e){let{bindings:r,uniforms:i}=jn(this._getModuleUniforms(e));Object.assign(this.bindings,r),Object.assign(this.uniforms,i),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof vi?e=Math.max(e,r.texture.updateTimestamp):r instanceof ie||r instanceof Ae?e=Math.max(e,r.updateTimestamp):r instanceof Si||(e=Math.max(e,r.buffer.updateTimestamp));return e}_setGeometryAttributes(e){let r={...e.attributes};for(let[i]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(s=>s.name===i)&&i!=="positions"&&delete r[i];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,r=null;this.pipeline&&(O.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders}),s=null;this.source?s=i:this.fs&&(s=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:i,fs:s}),this._attributeInfos=lc(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),r&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=O.level>3?0:OP;O.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:O.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=H_(this.pipeline.shaderLayout,this.id);O.table(Es,e)();let r=this.shaderInputs.getDebugTable();for(let[s,n]of Object.entries(this.uniforms))r[s]={value:n};O.table(Es,r)();let i=this._getAttributeDebugTable();O.table(Es,this._attributeInfos)(),O.table(Es,i)(),O.groupEnd(Es)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let r=O.get("framebuffer");if(this._drawCount++,!r||this._drawCount++>3&&this._drawCount%60)return;let i=e.props.framebuffer;i&&j_(i,{id:i.id,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[r,i]of Object.entries(this._attributeInfos))e[i.location]={name:r,type:i.shaderType,values:this._getBufferOrConstantValues(this.vertexArray.attributes[i.location],i.bufferDataType)};if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,i=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);e.indices={name:"indices",type:r.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,r){let i=Hn(r);return(e instanceof ie?new i(e.debugData):e).toString()}};function X_(t,e){let r=[...t];for(let i of e){let s=r.findIndex(n=>n.name===i.name);s<0?r.push(i):r[s]=i}return r}function NP(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}function $_(t){return t.attributes?t.attributes?.map(e=>e.attribute):[t.name]}var Xr=class t{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,r=te.defaultProps){ee(t.isSupported(e),"BufferTransform not yet implemented on WebGPU"),this.device=e,this.model=new te(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||On(),topology:r.topology||"point-list",...r}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){let r=this.device.beginRenderPass(e);this.model.draw(r),r.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let r=this.getBuffer(e);if(r instanceof ie)return r.readAsync();let{buffer:i,byteOffset:s=0,byteLength:n=i.byteLength}=r;return i.readAsync(s,n)}};var FP="transform_output",$r=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,r){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new te(this.device,{id:r.id||"texture-transform-model",fs:r.fs||On({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:FP}),vertexCount:r.vertexCount,...r}),this._initialize(r),Object.seal(this)}destroy(){}delete(){this.destroy()}run(e){let{framebuffer:r}=this.bindings[this.currentIndex],i=this.device.beginRenderPass({framebuffer:r,...e});this.model.draw(i),i.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getData({packed:e=!1}={}){throw new Error("getData() not implemented")}getTargetTexture(){let{targetTexture:e}=this.bindings[this.currentIndex];return e}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(e){this._updateBindings(e)}_updateBindings(e){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e)}_updateBinding(e,{sourceBuffers:r,sourceTextures:i,targetTexture:s}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,i),Object.assign(e.sourceBuffers,r),s){e.targetTexture=s;let{width:n,height:o}=s;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:n,height:o,colorAttachments:[s]}),e.framebuffer.resize({width:n,height:o})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:r}=this.bindings[e];for(let i in r)r[i].sampler=this.sampler}};var fe=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:r={},indices:i=null,vertexCount:s=null}=e;this.id=e.id||Fe("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[n,o]of Object.entries(r)){let a=ArrayBuffer.isView(o)?{value:o}:o;ee(ArrayBuffer.isView(a.value),`${this._print(n)}: must be typed array or object with value as typed array`),(n==="POSITION"||n==="positions")&&!a.size&&(a.size=3),n==="indices"?(ee(!this.indices),this.indices=a):this.attributes[n]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=s||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let i=1/0;for(let s of Object.values(e)){let{value:n,size:o,constant:a}=s;!a&&n&&o>=1&&(i=Math.min(i,n.length/o))}return ee(Number.isFinite(i)),i}};var Fi=class extends fe{constructor(e={}){let{id:r=Fe("cube-geometry"),indices:i=!0}=e;super(i?{...e,id:r,topology:"triangle-list",indices:{size:1,value:DP},attributes:{...WP,...e.attributes}}:{...e,id:r,topology:"triangle-list",indices:void 0,attributes:{...HP,...e.attributes}})}},DP=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),LP=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),kP=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),BP=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),UP=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),zP=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),VP=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),WP={POSITION:{size:3,value:LP},NORMAL:{size:3,value:kP},TEXCOORD_0:{size:2,value:BP}},HP={POSITION:{size:3,value:UP},TEXCOORD_0:{size:2,value:zP},COLOR_0:{size:3,value:VP}};var jP={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant-alpha",blendAlphaDstFactor:"zero"},Di=class extends xr{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:r,views:i,viewports:s,onViewportActive:n,pickingFBO:o,deviceRect:{x:a,y:c,width:l,height:u},cullRect:f,effects:h,pass:d="picking",pickZ:p,moduleParameters:g}){this.pickZ=p;let _=this._resetColorEncoder(p),x=[a,c,l,u],v=super.render({target:o,layers:e,layerFilter:r,views:i,viewports:s,onViewportActive:n,cullRect:f,effects:h?.filter(A=>A.useInPicking),pass:d,isPicking:!0,moduleParameters:g,clearColor:[0,0,0,0],colorMask:15,scissorRect:x});return this._colorEncoderState=null,{decodePickingColor:_&&$P.bind(null,_),stats:v}}shouldDrawLayer(e){let{pickable:r,operation:i}=e.props;return r&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getModuleParameters(){return{picking:{isActive:1,isAttribute:this.pickZ},lightSources:{}}}getLayerParameters(e,r,i){let s={depthMask:!0,depthTest:!0,depthRange:[0,1],...e.props.parameters},{pickable:n,operation:o}=e.props;return!this._colorEncoderState||o.includes("terrain")?s.blend=!1:n&&o.includes("draw")&&(Object.assign(s,jP),s.blend=!0,s.blendColor=XP(this._colorEncoderState,e,i)),s}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function XP(t,e,r){let{byLayer:i,byAlpha:s}=t,n,o=i.get(e);return o?(o.viewports.push(r),n=o.a):(n=i.size+1,n<=255?(o={a:n,layer:e,viewports:[r]},i.set(e,o),s[n]=o):(U.warn("Too many pickable layers, only picking the first 255")(),n=0)),[0,0,0,n/255]}function $P(t,e){let r=t.byAlpha[e[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(e)}}var Yr={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},ws=Symbol.for("component"),vt=Symbol.for("propTypes"),Qc=Symbol.for("deprecatedProps"),Tr=Symbol.for("asyncPropDefaults"),tr=Symbol.for("asyncPropOriginal"),Ft=Symbol.for("asyncPropResolved");function bt(t,e=()=>!0){return Array.isArray(t)?Y_(t,e,[]):e(t)?[t]:[]}function Y_(t,e,r){let i=-1;for(;++i0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,r){if(e===this._data&&!r)return;this._data=e;let i=++this._loadCount,s=e;typeof e=="string"&&(s=Lr(e)),s instanceof Promise?(this.isLoaded=!1,this._loader=s.then(n=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=n)}).catch(n=>{this._loadCount===i&&(this.isLoaded=!0,this._error=n||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let n of this._subscribers)n.onChange(this.getData())}};var lo=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:r,forceUpdate:i=!1,persistent:s=!0}){let n=this._resources[e];n?n.setData(r,i):(n=new co(e,r,this._context),this._resources[e]=n),n.persistent=s}remove(e){let r=this._resources[e];r&&(r.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let r=this._consumers[e];if(r){for(let i in r){let s=r[i],n=this._resources[s.resourceId];n&&n.unsubscribe(s)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:r,consumerId:i,requestId:s="default"}){let{_resources:n,protocol:o}=this;e.startsWith(o)&&(e=e.replace(o,""),n[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=n[e];if(this._track(i,s,a,r),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,r,i,s){let n=this._consumers,o=n[e]=n[e]||{},a=o[r],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),i&&(a?(a.onChange=s,a.resourceId=i.id):a={onChange:s,resourceId:i.id},o[r]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let r=this._resources[e];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[e])}}};var YP="layerManager.setLayers",KP="layerManager.activateViewport",uo=class{constructor(e,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{xe(KP,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:s,viewport:n,timeline:o}=r||{};this.layers=[],this.resourceManager=new lo({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:ro(),defaultShaderModules:[],renderPass:void 0,stats:s||new dt({id:"deck.gl"}),viewport:n||new Oi({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new Ni,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let s=i.getNeedsRedraw(e);r=r||s}return r}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(r=>e.find(i=>r.id.indexOf(i)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,r){xe(YP,this,r,e),this._lastRenderedLayers=e;let i=bt(e,Boolean);for(let s of i)s.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:r}=this.context;r.find(i=>i.name===e.name)||(r.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:r}=this.context,i=r.findIndex(s=>s.name===e.name);i>=0&&(r.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,r,i){i.raiseError(r,`${e} of ${i}`)}_updateLayers(e,r){let i={};for(let o of e)i[o.id]?U.warn(`Multiple old layers with same id ${o.id}`)():i[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of e)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let s=[];this._updateSublayersRecursively(r,i,s),this._finalizeOldLayers(i);let n=!1;for(let o of s)if(o.hasUniformTransition()){n=`Uniform transition in ${o}`;break}this._needsUpdate=n,this.layers=s}_updateSublayersRecursively(e,r,i){for(let s of e){s.context=this.context;let n=r[s.id];n===null&&U.warn(`Multiple new layers with same id ${s.id}`)(),r[s.id]=null;let o=null;try{this._debug&&n!==s&&s.validateProps(),n?(this._transferLayerState(n,s),this._updateLayer(s)):this._initializeLayer(s),i.push(s),o=s.isComposite?s.getSubLayers():null}catch(a){this._handleError("matching",a,s)}o&&this._updateSublayersRecursively(o,r,i)}}_finalizeOldLayers(e){for(let r in e){let i=e[r];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=Yr.INITIALIZED}catch(r){this._handleError("initialization",r,e)}}_transferLayerState(e,r){r._transferState(e),r.lifecycle=Yr.MATCHED,r!==e&&(e.lifecycle=Yr.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(r){this._handleError("update",r,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Yr.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=Yr.FINALIZED}catch(r){this._handleError("finalization",r,e)}}};function Le(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;ir.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(r=>{e[r.id]=r}),e}getView(e){return this.views.find(r=>r.id===e)}getViewState(e){let r=typeof e=="string"?this.getView(e):e,i=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}unproject(e,r){let i=this.getViewports(),s={x:e[0],y:e[1]};for(let n=i.length-1;n>=0;--n){let o=i[n];if(o.containsPixel(s)){let a=e.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,r)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,r){(e!==this.width||r!==this.height)&&(this.width=e,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(e){e=bt(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!Le(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):U.warn("missing `viewState` or `initialViewState`")()}_createController(e,r){let i=r.type;return new i({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:n=>this.getView(e.id)?.makeViewport({viewState:n,width:this.width,height:this.height})})}_updateController(e,r,i,s){let n=e.controller;if(n&&i){let o={...r,...n,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!s||s.constructor!==n.type)&&(s=this._createController(e,o)),s&&s.setProps(o),s}return null}_rebuildViewports(){let{views:e}=this,r=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let s=e.length;s--;){let n=e[s],o=this.getViewState(n),a=n.makeViewport({viewState:o,width:this.width,height:this.height}),c=r[n.id],l=!!n.controller;l&&!c&&(i=!0),(i||!l)&&c&&(c.finalize(),c=null),this.controllers[n.id]=this._updateController(n,o,a,c),a&&this._viewports.unshift(a)}for(let s in r){let n=r[s];n&&!this.controllers[s]&&n.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,r){return e.length!==r.length?!0:e.some((i,s)=>!e[s].equals(r[s]))}};var qP=/([0-9]+\.?[0-9]*)(%|px)/;function vr(t){switch(typeof t){case"number":return{position:t,relative:!1};case"string":let e=qP.exec(t);if(e&&e.length>=3){let r=e[2]==="%",i=parseFloat(e[1]);return{position:r?i/100:i,relative:r}}default:throw new Error(`Could not parse position string ${t}`)}}function br(t,e){return t.relative?Math.round(t.position*e):t.position}var ho=class{constructor(e){let{id:r,x:i=0,y:s=0,width:n="100%",height:o="100%",padding:a=null}=e;this.id=r||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=vr(i),this._y=vr(s),this._width=vr(n),this._height=vr(o),this._padding=a&&{left:vr(a.left||0),right:vr(a.right||0),top:vr(a.top||0),bottom:vr(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.ViewportType===e.ViewportType&&Le(this.props,e.props,2)}makeViewport({width:e,height:r,viewState:i}){i=this.filterViewState(i);let s=this.getDimensions({width:e,height:r});return!s.height||!s.width?null:new this.ViewportType({...i,...this.props,...s})}getViewStateId(){let{viewState:e}=this.props;return typeof e=="string"?e:e?.id||this.id}filterViewState(e){if(this.props.viewState&&typeof this.props.viewState=="object"){if(!this.props.viewState.id)return this.props.viewState;let r={...e};for(let i in this.props.viewState)i!=="id"&&(r[i]=this.props.viewState[i]);return r}return e}getDimensions({width:e,height:r}){let i={x:br(this._x,e),y:br(this._y,r),width:br(this._width,e),height:br(this._height,r)};return this._padding&&(i.padding={left:br(this._padding.left,e),top:br(this._padding.top,r),right:br(this._padding.right,e),bottom:br(this._padding.bottom,r)}),i}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}};var Dt=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(this._handle===null){let{_timeline:e,settings:r}=this;this._handle=e.addChannel({delay:e.getTime(),duration:r.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}};var K_=()=>{},sd={BREAK:1,SNAP_TO_END:2,IGNORE:3},GP=t=>t,ZP=sd.BREAK,po=class{constructor(e){this._onTransitionUpdate=r=>{let{time:i,settings:{interpolator:s,startProps:n,endProps:o,duration:a,easing:c}}=r,l=c(i/a),u=s.interpolateProps(n,o,l);this.propsInTransition=this.getControllerState({...this.props,...u}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new Dt(e.timeline),this.onViewStateChange=e.onViewStateChange||K_,this.onStateChange=e.onStateChange||K_}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let r=!1,i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let s=i;if(this.transition.inProgress){let{interruption:n,endProps:o}=this.transition.settings;s={...i,...n===sd.SNAP_TO_END?o:this.propsInTransition||i}}this._triggerTransition(s,e),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:r,transitionInterpolator:i}=e;return(r>0||r==="auto")&&!!i}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,r){return this.transition.inProgress?this.transition.settings.interruption===sd.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(e,r):!0}_triggerTransition(e,r){let i=this.getControllerState(e),s=this.getControllerState(r).shortestPathFrom(i),n=r.transitionInterpolator,o=n.getDuration?n.getDuration(e,r):r.transitionDuration;if(o===0)return;let a=n.initializeProps(e,s);this.propsInTransition={};let c={duration:o,easing:r.transitionEasing||GP,interpolator:n,interruption:r.transitionInterruption||ZP,startProps:a.start,endProps:a.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(r)}}};function oe(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}var go=class{constructor(e){let{compare:r,extract:i,required:s}=e;this._propsToCompare=r,this._propsToExtract=i||r,this._requiredProps=s}arePropsEqual(e,r){for(let i of this._propsToCompare)if(!(i in e)||!(i in r)||!yr(e[i],r[i]))return!1;return!0}initializeProps(e,r){let i={},s={};for(let n of this._propsToExtract)(n in e||n in r)&&(i[n]=e[n],s[n]=r[n]);return this._checkRequiredProps(i),this._checkRequiredProps(s),{start:i,end:s}}getDuration(e,r){return r.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(r=>{let i=e[r];oe(Number.isFinite(i)||Array.isArray(i),`${r} is required for transition`)})}};var JP=["longitude","latitude","zoom","bearing","pitch"],QP=["longitude","latitude","zoom"],Li=class extends go{constructor(e={}){let r=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:JP,required:QP},super(i.transitionProps),this.opts=i}initializeProps(e,r){let i=super.initializeProps(e,r),{makeViewport:s,around:n}=this.opts;if(s&&n){let o=s(e),a=s(r),c=o.unproject(n);i.start.around=n,Object.assign(i.end,{around:a.project(c),aroundPosition:c,width:r.width,height:r.height})}return i}interpolateProps(e,r,i){let s={};for(let n of this._propsToExtract)s[n]=Ct(e[n]||0,r[n]||0,i);if(r.aroundPosition&&this.opts.makeViewport){let n=this.opts.makeViewport({...r,...s});Object.assign(s,n.panByPosition(r.aroundPosition,Ct(e.around,r.around,i)))}return s}};var Kr={transitionDuration:0},eR=300,el=t=>1-(1-t)*(1-t),Ps={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],TRIPLE_PAN:["tripanstart","tripanmove","tripanend"],DOUBLE_TAP:["doubletap"],KEYBOARD:["keydown"]},ki={},mo=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new po({...e,getControllerState:r=>new this.ControllerState(r),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let r=this._eventStartBlocked;switch(e.type){case"panstart":return r?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return r?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"tripanstart":return r?!1:this._onTriplePanStart(e);case"tripanmove":return this._onTriplePan(e);case"tripanend":return this._onTriplePanEnd(e);case"doubletap":return this._onDoubleTap(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:r,y:i}=this.props,{offsetCenter:s}=e;return[s.x-r,s.y-i]}isPointInBounds(e,r){let{width:i,height:s}=this.props;if(r&&r.handled)return!1;let n=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=s;return n&&r&&r.stopPropagation(),n}isFunctionKeyPressed(e){let{srcEvent:r}=e;return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=r}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:r}=e;this.inertia=Number.isFinite(r)?r:r===!0?eR:0;let{scrollZoom:i=!0,dragPan:s=!0,dragRotate:n=!0,doubleClickZoom:o=!0,touchZoom:a=!0,touchRotate:c=!1,keyboard:l=!0}=e,u=!!this.onViewStateChange;this.toggleEvents(Ps.WHEEL,u&&i),this.toggleEvents(Ps.PAN,u),this.toggleEvents(Ps.PINCH,u&&(a||c)),this.toggleEvents(Ps.TRIPLE_PAN,u&&c),this.toggleEvents(Ps.DOUBLE_TAP,u&&o),this.toggleEvents(Ps.KEYBOARD,u&&l),this.scrollZoom=i,this.dragPan=s,this.dragRotate=n,this.doubleClickZoom=o,this.touchZoom=a,this.touchRotate=c,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,r){this.eventManager&&e.forEach(i=>{this._events[i]!==r&&(this._events[i]=r,r?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(e,r=null,i={}){let s={...e.getViewportProps(),...r},n=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),n){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:s,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let s=this.controllerState[i?"panStart":"rotateStart"]({pos:r});return this._panMove=i,this.updateViewport(s,Kr,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let r=this.getCenter(e),i=this.controllerState.pan({pos:r});return this.updateViewport(i,Kr,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:r}=this;if(this.dragPan&&r&&e.velocity){let i=this.getCenter(e),s=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],n=this.controllerState.pan({pos:s}).panEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:el},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState.panEnd();this.updateViewport(i,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let r=this.getCenter(e),i=this.controllerState.rotate({pos:r});return this.updateViewport(i,Kr,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:r}=this;if(this.dragRotate&&r&&e.velocity){let i=this.getCenter(e),s=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],n=this.controllerState.rotate({pos:s}).rotateEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:el},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;e.srcEvent.preventDefault();let{speed:i=.01,smooth:s=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:n}=e,o=2/(1+Math.exp(-Math.abs(n*i)));n<0&&o!==0&&(o=1/o);let a=this.controllerState.zoom({pos:r,scale:o});return this.updateViewport(a,{...this._getTransitionProps({around:r}),transitionDuration:s?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.rotateStart({pos:r});return this.updateViewport(i,Kr,{isDragging:!0}),!0}_onTriplePan(e){if(!this.touchRotate||!this.isDragging())return!1;let r=this.getCenter(e);r[0]-=e.deltaX;let i=this.controllerState.rotate({pos:r});return this.updateViewport(i,Kr,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this;if(this.touchRotate&&r&&e.velocityY){let i=this.getCenter(e),s=[i[0],i[1]+=e.velocityY*r/2],n=this.controllerState.rotate({pos:s});this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:el},{isDragging:!1,isRotating:!0}),this.blockEvents(r)}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.zoomStart({pos:r}).rotateStart({pos:r});return ki._startPinchRotation=e.rotation,ki._lastPinchEvent=e,this.updateViewport(i,Kr,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:i}=e,s=this.getCenter(e);r=r.zoom({pos:s,scale:i})}if(this.touchRotate){let{rotation:i}=e;r=r.rotate({deltaAngleX:ki._startPinchRotation-i})}return this.updateViewport(r,Kr,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),ki._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:i}=ki;if(this.touchZoom&&r&&i&&e.scale!==i.scale){let s=this.getCenter(e),n=this.controllerState.rotateEnd(),o=Math.log2(e.scale),a=(o-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),c=Math.pow(2,o+a*r/2);n=n.zoom({pos:s,scale:c}).zoomEnd(),this.updateViewport(n,{...this._getTransitionProps({around:s}),transitionDuration:r,transitionEasing:el},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let s=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(s,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return ki._startPinchRotation=null,ki._lastPinchEvent=null,!0}_onDoubleTap(e){if(!this.doubleClickZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e),s=this.controllerState.zoom({pos:r,scale:i?.5:2});return this.updateViewport(s,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(e),{zoomSpeed:i,moveSpeed:s,rotateSpeedX:n,rotateSpeedY:o}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(e.srcEvent.code){case"Minus":c=r?a.zoomOut(i).zoomOut(i):a.zoomOut(i),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(i).zoomIn(i):a.zoomIn(i),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(n),l.isRotating=!0):(c=a.moveLeft(s),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(n),l.isRotating=!0):(c=a.moveRight(s),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(o),l.isRotating=!0):(c=a.moveUp(s),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(o),l.isRotating=!0):(c=a.moveDown(s),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(e){let{transition:r}=this;return!r||!r.transitionInterpolator?Kr:e?{...r,transitionInterpolator:new Li({...e,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var _o=class{constructor(e,r){this._viewportProps=this.applyConstraints(e),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};var q_=5,tR=1.2,nd=class extends _o{constructor(e){let{width:r,height:i,latitude:s,longitude:n,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:u=[0,0,0],maxZoom:f=20,minZoom:h=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:g,startZoomLngLat:_,startRotatePos:x,startBearing:v,startPitch:b,startZoom:A,normalize:C=!0}=e;oe(Number.isFinite(n)),oe(Number.isFinite(s)),oe(Number.isFinite(o)),super({width:r,height:i,latitude:s,longitude:n,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:f,minZoom:h,maxPitch:d,minPitch:p,normalize:C,position:u},{startPanLngLat:g,startZoomLngLat:_,startRotatePos:x,startBearing:v,startPitch:b,startZoom:A}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:r}){let i=this.getState().startPanLngLat||this._unproject(r);if(!i)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:s,startBearing:n,startPitch:o}=this.getState();if(!s||n===void 0||o===void 0)return this;let a;return e?a=this._getNewRotation(e,s,o,n):a={bearing:n+r,pitch:o+i},this._getUpdatedState(a)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:s,startZoomLngLat:n}=this.getState();if(n||(s=this.getViewportProps().zoom,n=this._unproject(r)||this._unproject(e)),!n)return this;let{maxZoom:o,minZoom:a}=this.getViewportProps(),c=s+Math.log2(i);c=yt(c,a,o);let l=this.makeViewport({...this.getViewportProps(),zoom:c});return this._getUpdatedState({zoom:c,...l.panByPosition(n,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{bearing:s,longitude:n}=i;return Math.abs(s-r.bearing)>180&&(i.bearing=s<0?s+360:s-360),Math.abs(n-r.longitude)>180&&(i.longitude=n<0?n+360:n-360),i}applyConstraints(e){let{maxZoom:r,minZoom:i,zoom:s}=e;e.zoom=yt(s,i,r);let{maxPitch:n,minPitch:o,pitch:a}=e;e.pitch=yt(a,o,n);let{normalize:c=!0}=e;return c&&Object.assign(e,Jh(e)),e}_zoomFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.zoom({pos:[r/2,i/2],scale:e})}_panFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.pan({startPos:[r/2,i/2],pos:[r/2+e[0],i/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let r=this.makeViewport(this.getViewportProps());return e&&r.unproject(e)}_getNewRotation(e,r,i,s){let n=e[0]-r[0],o=e[1]-r[1],a=e[1],c=r[1],{width:l,height:u}=this.getViewportProps(),f=n/l,h=0;o>0?Math.abs(u-c)>q_&&(h=o/(c-u)*tR):o<0&&c>q_&&(h=1-a/c),h=yt(h,-1,1);let{minPitch:d,maxPitch:p}=this.getViewportProps(),g=s+180*f,_=i;return h>0?_=i+h*(p-i):h<0&&(_=i-h*(d-i)),{pitch:_,bearing:g}}},yo=class extends mo{constructor(){super(...arguments),this.ControllerState=nd,this.transition={transitionDuration:300,transitionInterpolator:new Li({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];let r=this.props;super.setProps(e),(!r||r.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}};var qr=class extends ho{static{this.displayName="MapView"}constructor(e={}){super(e)}get ViewportType(){return er}get ControllerType(){return yo}};var rR=new bs;function iR(t,e){let r=t.order??1/0,i=e.order??1/0;return r-i}var xo=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let r=this._defaultEffects;if(!r.find(i=>i.id===e.id)){let i=r.findIndex(s=>iR(s,e)>0);i<0?r.push(e):r.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(Le(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(e){let r={};for(let s of this.effects)r[s.id]=s;let i=[];for(let s of e){let n=r[s.id],o=s;n&&n!==s?n.setProps?(n.setProps(s.props),o=n):n.cleanup(this._context):n||s.setup(this._context),i.push(o),delete r[s.id]}for(let s in r)r[s].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(s=>s instanceof bs)||this._resolvedEffects.push(rR),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var To=class extends xr{shouldDrawLayer(e){let{operation:r}=e.props;return r.includes("draw")||r.includes("terrain")}};var sR="deckRenderer.renderLayers",vo=class{constructor(e){this.device=e,this.gl=e.gl,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new To(e),this.pickLayersPass=new Di(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;let r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};i.effects&&this._preRender(i.effects,i);let s=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let n=r.render({...i,target:s});i.effects&&this._postRender(i.effects,i),this.renderCount++,xe(sR,this,n,e)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:e}=this;for(let r of e)r.delete();e.length=0}_preRender(e,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let i of e)r.preRenderStats[i.id]=i.preRender(r),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,r=this.device.canvasContext.getDrawingBufferSize();e.length===0&&[0,1].map(i=>{let s=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"}});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${i}`,colorAttachments:[s]}))});for(let i of e)i.resize(r)}_postRender(e,r){let{renderBuffers:i}=this,s={...r,inputBuffer:i[0],swapBuffer:i[1]};for(let n of e)if(n.postRender){s.target=n.id===this.lastPostProcessEffect?r.target:void 0;let o=n.postRender(s);s.inputBuffer=o,s.swapBuffer=o===i[0]?i[1]:i[0]}}};var nR={pickedColor:null,pickedObjectIndex:-1};function G_({pickedColors:t,decodePickingColor:e,deviceX:r,deviceY:i,deviceRadius:s,deviceRect:n}){let{x:o,y:a,width:c,height:l}=n,u=s*s,f=-1,h=0;for(let d=0;du)h+=4*c;else for(let _=0;_=0){let v=_+o-r,b=v*v+g;b<=u&&(u=b,f=h)}h+=4}}if(f>=0){let d=t.slice(f,f+4),p=e(d);if(p){let g=Math.floor(f/4/c),_=f/4-g*c;return{...p,pickedColor:d,pickedX:o+_,pickedY:a+g}}U.error("Picked non-existent layer. Is picking buffer corrupt?")()}return nR}function Z_({pickedColors:t,decodePickingColor:e}){let r=new Map;if(t){for(let i=0;i=0){let n=t.slice(i,i+4),o=n.join(",");if(!r.has(o)){let a=e(n);a?r.set(o,{...a,color:n}):U.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function od({pickInfo:t,viewports:e,pixelRatio:r,x:i,y:s,z:n}){let o=e[0];e.length>1&&(o=oR(t?.pickedViewports||e,{x:i,y:s}));let a;if(o){let c=[i-o.x,s-o.y];n!==void 0&&(c[2]=n),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:i,y:s,pixel:[i,s],coordinate:a,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:r}}function J_(t){let{pickInfo:e,lastPickedInfo:r,mode:i,layers:s}=t,{pickedColor:n,pickedLayer:o,pickedObjectIndex:a}=e,c=o?[o]:[];if(i==="hover"){let f=r.index,h=r.layerId,d=o?o.props.id:null;if(d!==h||a!==f){if(d!==h){let p=s.find(g=>g.props.id===h);p&&c.unshift(p)}r.layerId=d,r.index=a,r.info=null}}let l=od(t),u=new Map;return u.set(null,l),c.forEach(f=>{let h={...l};f===o&&(h.color=n,h.index=a,h.picked=!0),h=ad({layer:f,info:h,mode:i});let d=h.layer;f===o&&i==="hover"&&(r.info=h),u.set(d.id,h),i==="hover"&&d.updateAutoHighlight(h)}),u}function ad({layer:t,info:e,mode:r}){for(;t&&e;){let i=e.layer||null;e.sourceLayer=i,e.layer=t,e=t.getPickingInfo({info:e,mode:r,sourceLayer:i}),t=t.parent}return e}function oR(t,e){for(let r=t.length-1;r>=0;r--){let i=t[r];if(i.containsPixel(e))return i}return t[0]}var bo=class{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new Di(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:r,layers:i,viewports:s},n=this.lastPickedInfo.info){let o=n&&n.layer&&n.layer.id,a=n&&n.viewport&&n.viewport.id,c=o?i.find(h=>h.id===o):null,l=a&&s.find(h=>h.id===a)||s[0],u=l&&l.unproject([e-l.x,r-l.y]);return{...n,...{x:e,y:r,viewport:l,coordinate:u,layer:c}}}_resizeBuffer(){if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){let r=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=r}let e=this.device.gl;this.pickingFBO?.resize({width:e.canvas.width,height:e.canvas.height}),this.depthFBO?.resize({width:e.canvas.width,height:e.canvas.height})}_getPickable(e){if(this._pickable===!1)return null;let r=e.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return r.length?r:null}_pickClosestObject({layers:e,views:r,viewports:i,x:s,y:n,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:u,effects:f}){let h=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||i.length===0)return{result:[],emptyInfo:od({viewports:i,x:s,y:n,pixelRatio:h})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([s,n],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],_=Math.round(o*h),{width:x,height:v}=this.pickingFBO,b=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:_,deviceWidth:x,deviceHeight:v}),A={x:s-o,y:n-o,width:o*2+1,height:o*2+1},C,M=[],F=new Set;for(let N=0;N=l);L++){let Y=M[L],X={color:Y.pickedColor,layer:null,index:Y.pickedObjectIndex,picked:!0,x:s,y:n,pixelRatio:d};X=ad({layer:Y.pickedLayer,info:X,mode:c});let $=X.layer.id;F.has($)||F.set($,new Set);let Z=F.get($),ge=X.object??X.index;Z.has(ge)||(Z.add(ge),N.push(X))}return N}_drawAndSample({layers:e,views:r,viewports:i,onViewportActive:s,deviceRect:n,cullRect:o,effects:a,pass:c},l=!1){let u=l?this.depthFBO:this.pickingFBO,f={layers:e,layerFilter:this.layerFilter,views:r,viewports:i,onViewportActive:s,pickingFBO:u,deviceRect:n,cullRect:o,effects:a,pass:c,pickZ:l,preRenderStats:{}};for(let v of a)v.useInPicking&&(f.preRenderStats[v.id]=v.preRender(f));let{decodePickingColor:h}=this.pickLayersPass.render(f),{x:d,y:p,width:g,height:_}=n,x=new(l?Float32Array:Uint8Array)(g*_*4);return this.device.readPixelsToArrayWebGL(u,{sourceX:d,sourceY:p,sourceWidth:g,sourceHeight:_,target:x}),{pickedColors:x,decodePickingColor:h}}_getPickingRect({deviceX:e,deviceY:r,deviceRadius:i,deviceWidth:s,deviceHeight:n}){let o=Math.max(0,e-i),a=Math.max(0,r-i),c=Math.min(s,e+i+1)-o,l=Math.min(n,r+i+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}};var aR={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},cR="top-left",Q_="__root",tl=class{constructor({deck:e,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(e){e.widgets&&!Le(e.widgets,this.widgets,1)&&this._setWidgets(e.widgets)}finalize(){for(let e of this.getWidgets())this._remove(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(r=>r.id===e.id)||(this._add(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}_setWidgets(e){let r={};for(let i of this.resolvedWidgets)r[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)r[i.id]=null,this.resolvedWidgets.push(i);for(let i of e){let s=r[i.id];s?s.viewId!==i.viewId||s.placement!==i.placement?(this._remove(s),this._add(i)):i!==s&&(s.setProps(i.props),i=s):this._add(i),r[i.id]=null,this.resolvedWidgets.push(i)}for(let i in r){let s=r[i];s&&this._remove(s)}this.widgets=e}_add(e){let{viewId:r=null,placement:i=cR}=e,s=e.onAdd({deck:this.deck,viewId:r});s&&this._getContainer(r,i).append(s),e._element=s}_remove(e){e.onRemove(),e._element&&e._element.remove(),e._element=void 0}_getContainer(e,r){let i=e||Q_,s=this.containers[i];s||(s=document.createElement("div"),s.style.pointerEvents="none",s.style.position="absolute",s.style.overflow="hidden",this.parentElement?.append(s),this.containers[i]=s);let n=s.querySelector(`.${r}`);return n||(n=document.createElement("div"),n.className=r,n.style.position="absolute",n.style.zIndex="2",Object.assign(n.style,aR[r]),s.append(n)),n}_updateContainers(){let e=this.deck.width,r=this.deck.height;for(let i in this.containers){let s=this.lastViewports[i]||null,n=i===Q_||s,o=this.containers[i];n?(o.style.display="block",o.style.left=`${s?s.x:0}px`,o.style.top=`${s?s.y:0}px`,o.style.width=`${s?s.width:e}px`,o.style.height=`${s?s.height:r}px`):o.style.display="none"}}onRedraw({viewports:e,layers:r}){let i=e.reduce((n,o)=>(n[o.id]=o,n),{}),{lastViewports:s}=this;for(let n of this.getWidgets()){let{viewId:o}=n;if(o){let a=i[o];a&&(n.onViewportChange&&!a.equals(s[o])&&n.onViewportChange(a),n.onRedraw?.({viewports:[a],layers:r}))}else{if(n.onViewportChange)for(let a of e)a.equals(s[a.id])||n.onViewportChange(a);n.onRedraw?.({viewports:e,layers:r})}}this.lastViewports=i,this._updateContainers()}onHover(e,r){for(let i of this.getWidgets()){let{viewId:s}=i;(!s||s===e.viewport?.id)&&i.onHover?.(e,r)}}onEvent(e,r){let i=Jn[r.type];if(i)for(let s of this.getWidgets()){let{viewId:n}=s;(!n||n===e.viewport?.id)&&s[i.handler]?.(e,r)}}};var lR={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},So=class{constructor(){this.id="default-tooltip",this.placement="fill",this.props={},this.isVisible=!1}onAdd({deck:e}){let r=document.createElement("div");return r.className="deck-tooltip",Object.assign(r.style,lR),this.deck=e,this.element=r,r}onRemove(){this.deck=void 0,this.element=void 0}setProps(){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&e!==this.lastViewport&&this.setTooltip(null)}onHover(e){let{deck:r}=this,i=r&&r.props.getTooltip;if(!i)return;let s=i(e);this.lastViewport=e.viewport,this.setTooltip(s,e.x,e.y)}setTooltip(e,r,i){let s=this.element;if(s){if(typeof e=="string")s.innerText=e;else if(e)e.text&&(s.innerText=e.text),e.html&&(s.innerHTML=e.html),e.className&&(s.className=e.className);else{this.isVisible=!1,s.style.display="none";return}this.isVisible=!0,s.style.display="block",s.style.transform=`translate(${r}px, ${i}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(s.style,e.style)}}};var Gr;(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Gr||(Gr={}));var Eo={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Ee=(t,e,r)=>e?t.enable(r):t.disable(r),ey=(t,e,r)=>t.hint(r,e),st=(t,e,r)=>t.pixelStorei(r,e),ty=(t,e,r)=>{let i=r===36006?36009:36008;return t.bindFramebuffer(i,e)},Ao=(t,e,r)=>{let s={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r];t.bindBuffer(s,e)};function cd(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}var ry={3042:Ee,32773:(t,e)=>t.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(t,e)=>t.clearColor(...e),3107:(t,e)=>t.colorMask(...e),2884:Ee,2885:(t,e)=>t.cullFace(e),2929:Ee,2931:(t,e)=>t.clearDepth(e),2932:(t,e)=>t.depthFunc(e),2928:(t,e)=>t.depthRange(...e),2930:(t,e)=>t.depthMask(e),3024:Ee,35723:ey,35725:(t,e)=>t.useProgram(e),36007:(t,e)=>t.bindRenderbuffer(36161,e),36389:(t,e)=>t.bindTransformFeedback?.(36386,e),34229:(t,e)=>t.bindVertexArray(e),36006:ty,36010:ty,34964:Ao,36662:Ao,36663:Ao,35053:Ao,35055:Ao,2886:(t,e)=>t.frontFace(e),33170:ey,2849:(t,e)=>t.lineWidth(e),32823:Ee,32824:"polygonOffset",10752:"polygonOffset",35977:Ee,32926:Ee,32928:Ee,32938:"sampleCoverage",32939:"sampleCoverage",3089:Ee,3088:(t,e)=>t.scissor(...e),2960:Ee,2961:(t,e)=>t.clearStencil(e),2968:(t,e)=>t.stencilMaskSeparate(1028,e),36005:(t,e)=>t.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(t,e)=>t.viewport(...e),34383:Ee,10754:Ee,12288:Ee,12289:Ee,12290:Ee,12291:Ee,12292:Ee,12293:Ee,12294:Ee,12295:Ee,3333:st,3317:st,37440:st,37441:st,37443:st,3330:st,3332:st,3331:st,3314:st,32878:st,3316:st,3315:st,32877:st,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,r)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(...e),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=cd(e)?e:[e,e];let[r,i]=e;t.stencilMaskSeparate(1028,r),t.stencilMaskSeparate(1029,i)},stencilFunc:(t,e)=>{e=cd(e)&&e.length===3?[...e,...e]:e;let[r,i,s,n,o,a]=e;t.stencilFuncSeparate(1028,r,i,s),t.stencilFuncSeparate(1029,n,o,a)},stencilOp:(t,e)=>{e=cd(e)&&e.length===3?[...e,...e]:e;let[r,i,s,n,o,a]=e;t.stencilOpSeparate(1028,r,i,s),t.stencilOpSeparate(1029,n,o,a)},viewport:(t,e)=>t.viewport(...e)};function ve(t,e,r){return e[t]!==void 0?e[t]:r[t]}var iy={blendEquation:(t,e,r)=>t.blendEquationSeparate(ve(32777,e,r),ve(34877,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(ve(32969,e,r),ve(32968,e,r),ve(32971,e,r),ve(32970,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(ve(32824,e,r),ve(10752,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(ve(32938,e,r),ve(32939,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(1028,ve(2962,e,r),ve(2967,e,r),ve(2963,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(1029,ve(34816,e,r),ve(36003,e,r),ve(36004,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(1028,ve(2964,e,r),ve(2965,e,r),ve(2966,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(1029,ve(34817,e,r),ve(34818,e,r),ve(34819,e,r))},ld={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({35725:e}),bindRenderbuffer:(t,e,r)=>t({36007:r}),bindTransformFeedback:(t,e,r)=>t({36389:r}),bindVertexArray:(t,e)=>t({34229:e}),bindFramebuffer:(t,e,r)=>{switch(e){case 36160:return t({36006:r,36010:r});case 36009:return t({36006:r});case 36008:return t({36010:r});default:return null}},bindBuffer:(t,e,r)=>{let i={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return i?t({[i]:r}):{valueChanged:!0}},blendColor:(t,e,r,i,s)=>t({32773:new Float32Array([e,r,i,s])}),blendEquation:(t,e)=>t({32777:e,34877:e}),blendEquationSeparate:(t,e,r)=>t({32777:e,34877:r}),blendFunc:(t,e,r)=>t({32969:e,32968:r,32971:e,32970:r}),blendFuncSeparate:(t,e,r,i,s)=>t({32969:e,32968:r,32971:i,32970:s}),clearColor:(t,e,r,i,s)=>t({3106:new Float32Array([e,r,i,s])}),clearDepth:(t,e)=>t({2931:e}),clearStencil:(t,e)=>t({2961:e}),colorMask:(t,e,r,i,s)=>t({3107:[e,r,i,s]}),cullFace:(t,e)=>t({2885:e}),depthFunc:(t,e)=>t({2932:e}),depthRange:(t,e,r)=>t({2928:new Float32Array([e,r])}),depthMask:(t,e)=>t({2930:e}),frontFace:(t,e)=>t({2886:e}),lineWidth:(t,e)=>t({2849:e}),polygonOffset:(t,e,r)=>t({32824:e,10752:r}),sampleCoverage:(t,e,r)=>t({32938:e,32939:r}),scissor:(t,e,r,i,s)=>t({3088:new Int32Array([e,r,i,s])}),stencilMask:(t,e)=>t({2968:e,36005:e}),stencilMaskSeparate:(t,e,r)=>t({[e===1028?2968:36005]:r}),stencilFunc:(t,e,r,i)=>t({2962:e,2967:r,2963:i,34816:e,36003:r,36004:i}),stencilFuncSeparate:(t,e,r,i,s)=>t({[e===1028?2962:34816]:r,[e===1028?2967:36003]:i,[e===1028?2963:36004]:s}),stencilOp:(t,e,r,i)=>t({2964:e,2965:r,2966:i,34817:e,34818:r,34819:i}),stencilOpSeparate:(t,e,r,i,s)=>t({[e===1028?2964:34817]:r,[e===1028?2965:34818]:i,[e===1028?2966:34819]:s}),viewport:(t,e,r,i,s)=>t({2978:[e,r,i,s]})},rr=(t,e)=>t.isEnabled(e),ud={3042:rr,2884:rr,2929:rr,3024:rr,32823:rr,32926:rr,32928:rr,3089:rr,2960:rr,35977:rr},sy=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function Lt(t,e){if(uR(e))return;let r={};for(let s in e){let n=Number(s),o=ry[s];o&&(typeof o=="string"?r[o]=!0:o(t,e[s],n))}let i=t.state&&t.state.cache;if(i)for(let s in r){let n=iy[s];n(t,e,i)}}function rl(t,e=Eo){if(typeof e=="number"){let s=e,n=ud[s];return n?n(t,s):t.getParameter(s)}let r=Array.isArray(e)?e:Object.keys(e),i={};for(let s of r){let n=ud[s];i[s]=n?n(t,Number(s)):t.getParameter(Number(s))}return i}function ny(t){Lt(t,Eo)}function uR(t){for(let e in t)return!1;return!0}function oy(t,e){if(t===e)return!0;let r=Array.isArray(t)||ArrayBuffer.isView(t),i=Array.isArray(e)||ArrayBuffer.isView(e);if(r&&i&&t.length===e.length){for(let s=0;s{}}={}){this.gl=e,this.cache=r?rl(e):Object.assign({},Eo),this.log=i,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){ee(this.stateStack.length>0);let e=this.stateStack[this.stateStack.length-1];Lt(this.gl,e),this.stateStack.pop()}_updateCache(e){let r=!1,i,s=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let n in e){ee(n!==void 0);let o=e[n],a=this.cache[n];oy(o,a)||(r=!0,i=a,s&&!(n in s)&&(s[n]=a),this.cache[n]=o)}return{valueChanged:r,oldValue:i}}};function Bi(t){return t.state}function hd(t,e){let{enable:r=!0,copyState:i}=e;if(ee(i!==void 0),!t.state){t.state=new fd(t,{copyState:i}),hR(t);for(let n in ld){let o=ld[n];fR(t,n,o)}ay(t,"getParameter"),ay(t,"isEnabled")}let s=Bi(t);return s.enable=r,t}function Zr(t){let e=Bi(t);e||(hd(t,{copyState:!1}),e=Bi(t)),e.push()}function Sr(t){let e=Bi(t);ee(e),e.pop()}function ay(t,e){let r=t[e].bind(t);t[e]=function(s){if(s===void 0||sy.has(s))return r(s);let n=Bi(t);return s in n.cache||(n.cache[s]=r(s)),n.enable?n.cache[s]:r(s)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function fR(t,e,r){if(!t[e])return;let i=t[e].bind(t);t[e]=function(...n){let o=Bi(t),{valueChanged:a,oldValue:c}=r(o._updateCache,...n);return a&&i(...n),c},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function hR(t){let e=t.useProgram.bind(t);t.useProgram=function(i){let s=Bi(t);s.program!==i&&(e(i),s.program=i)}}var dR={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function cy(t,e){e={...dR,...e};let r=null,i=n=>r=n.statusMessage||r;t.addEventListener("webglcontextcreationerror",i,!1);let s=null;if(s||=t.getContext("webgl2",e),t.removeEventListener("webglcontextcreationerror",i,!1),!s)throw new Error(`Failed to create WebGL context: ${r||"Unknown error"}`);if(e.onContextLost){let{onContextLost:n}=e;t.addEventListener("webglcontextlost",o=>n(o),!1)}if(e.onContextRestored){let{onContextRestored:n}=e;t.addEventListener("webglcontextrestored",o=>n(o),!1)}return s}function St(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}function ly(t,e){let r=t.getParameter(7936),i=t.getParameter(7937);St(t,"WEBGL_debug_renderer_info",e);let s=e.WEBGL_debug_renderer_info,n=t.getParameter(s?s.UNMASKED_VENDOR_WEBGL:7936),o=t.getParameter(s?s.UNMASKED_RENDERER_WEBGL:7937),a=n||r,c=o||i,l=t.getParameter(7938),u=uy(a,c),f=pR(a,c),h=gR(a,c);return{type:"webgl",gpu:u,gpuType:h,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function uy(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function pR(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function gR(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(uy(t,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function il(t){switch(t){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(t))}var ze="texture-compression-bc",ce="texture-compression-astc",ir="texture-compression-etc2",mR="texture-compression-etc1-webgl",sl="texture-compression-pvrtc-webgl",dd="texture-compression-atc-webgl",wo="float32-renderable-webgl",pd="float16-renderable-webgl",_R="rgb9e5ufloat_renderable-webgl",gd="snorm8-renderable-webgl",Po="norm16-renderable-webgl",md="snorm16-renderable-webgl",nl="float32-filterable",fy="float16-filterable-webgl",Ro="WEBGL_compressed_texture_s3tc",Co="WEBGL_compressed_texture_s3tc_srgb",Rs="EXT_texture_compression_rgtc",Cs="EXT_texture_compression_bptc",yR="WEBGL_compressed_texture_etc",xR="WEBGL_compressed_texture_astc",TR="WEBGL_compressed_texture_etc1",vR="WEBGL_compressed_texture_pvrtc",bR="WEBGL_compressed_texture_atc",hy="EXT_texture_norm16",dy="EXT_render_snorm",SR="EXT_color_buffer_float",ol={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[dy],"norm16-renderable-webgl":[hy],"snorm16-renderable-webgl":[hy,dy],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[Ro,Co,Rs,Cs],"texture-compression-bc5-webgl":[Rs],"texture-compression-bc7-webgl":[Cs],"texture-compression-etc2":[yR],"texture-compression-astc":[xR],"texture-compression-etc1-webgl":[TR],"texture-compression-pvrtc-webgl":[vR],"texture-compression-atc-webgl":[bR]};function py(t){return t in ol}function gy(t,e,r){return(ol[e]||[]).every(s=>St(t,s,r))}var al={"rgb8unorm-unsized":{gl:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,rb:!0},r8snorm:{gl:36756,b:1,c:1,render:gd},r8uint:{gl:33330,b:1,c:1,rb:!0},r8sint:{gl:33329,b:1,c:1,rb:!0},rg8unorm:{gl:33323,b:2,c:2,rb:!0},rg8snorm:{gl:36757,b:2,c:2,render:gd},rg8uint:{gl:33336,b:2,c:2,rb:!0},rg8sint:{gl:33335,b:2,c:2,rb:!0},r16uint:{gl:33332,b:2,c:1,rb:!0},r16sint:{gl:33331,b:2,c:1,rb:!0},r16float:{gl:33325,b:2,c:1,render:pd,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:Po,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:md},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,b:4,c:4,bpp:4},rgba8snorm:{gl:36759,b:4,c:4,render:gd},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:pd,filter:fy,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:Po},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:md},r32uint:{gl:33334,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,rb:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:wo,filter:nl},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:_R},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:wo,rb:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:Po},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:Po},rg32uint:{gl:33340,b:8,c:2,rb:!0},rg32sint:{gl:33339,b:8,c:2,rb:!0},rg32float:{gl:33328,b:8,c:2,render:wo,filter:nl,rb:!0},rgba16uint:{gl:36214,b:8,c:4,rb:!0},rgba16sint:{gl:36232,b:8,c:4,rb:!0},rgba16float:{gl:34842,b:8,c:4,render:pd,filter:fy},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:Po,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:md},"rgb32float-webgl":{gl:34837,render:wo,filter:nl,gl2ext:SR,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,rb:!0},rgba32sint:{gl:36226,b:16,c:4,rb:!0},rgba32float:{gl:34836,b:16,c:4,render:wo,filter:nl,rb:!0},stencil8:{gl:36168,b:1,c:1,attachment:36128,rb:!0},depth16unorm:{gl:33189,b:2,c:1,attachment:36096,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096,dataFormat:6402,types:[5125]},depth32float:{gl:36012,b:4,c:1,attachment:36096,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,dataFormat:34041,types:[34042],rb:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Ro,f:ze},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Co,f:ze},"bc1-rgba-unorm":{gl:33777,x:Ro,f:ze},"bc1-rgba-unorm-srgb":{gl:35916,x:Co,f:ze},"bc2-rgba-unorm":{gl:33778,x:Ro,f:ze},"bc2-rgba-unorm-srgb":{gl:35918,x:Co,f:ze},"bc3-rgba-unorm":{gl:33779,x:Ro,f:ze},"bc3-rgba-unorm-srgb":{gl:35919,x:Co,f:ze},"bc4-r-unorm":{gl:36283,x:Rs,f:ze},"bc4-r-snorm":{gl:36284,x:Rs,f:ze},"bc5-rg-unorm":{gl:36285,x:Rs,f:ze},"bc5-rg-snorm":{gl:36286,x:Rs,f:ze},"bc6h-rgb-ufloat":{gl:36495,x:Cs,f:ze},"bc6h-rgb-float":{gl:36494,x:Cs,f:ze},"bc7-rgba-unorm":{gl:36492,x:Cs,f:ze},"bc7-rgba-unorm-srgb":{gl:36493,x:Cs,f:ze},"etc2-rgb8unorm":{gl:37492,f:ir},"etc2-rgb8unorm-srgb":{gl:37494,f:ir},"etc2-rgb8a1unorm":{gl:37496,f:ir},"etc2-rgb8a1unorm-srgb":{gl:37497,f:ir},"etc2-rgba8unorm":{gl:37493,f:ir},"etc2-rgba8unorm-srgb":{gl:37495,f:ir},"eac-r11unorm":{gl:37488,f:ir},"eac-r11snorm":{gl:37489,f:ir},"eac-rg11unorm":{gl:37490,f:ir},"eac-rg11snorm":{gl:37491,f:ir},"astc-4x4-unorm":{gl:37808,f:ce},"astc-4x4-unorm-srgb":{gl:37840,f:ce},"astc-5x4-unorm":{gl:37809,f:ce},"astc-5x4-unorm-srgb":{gl:37841,f:ce},"astc-5x5-unorm":{gl:37810,f:ce},"astc-5x5-unorm-srgb":{gl:37842,f:ce},"astc-6x5-unorm":{gl:37811,f:ce},"astc-6x5-unorm-srgb":{gl:37843,f:ce},"astc-6x6-unorm":{gl:37812,f:ce},"astc-6x6-unorm-srgb":{gl:37844,f:ce},"astc-8x5-unorm":{gl:37813,f:ce},"astc-8x5-unorm-srgb":{gl:37845,f:ce},"astc-8x6-unorm":{gl:37814,f:ce},"astc-8x6-unorm-srgb":{gl:37846,f:ce},"astc-8x8-unorm":{gl:37815,f:ce},"astc-8x8-unorm-srgb":{gl:37847,f:ce},"astc-10x5-unorm":{gl:37819,f:ce},"astc-10x5-unorm-srgb":{gl:37851,f:ce},"astc-10x6-unorm":{gl:37817,f:ce},"astc-10x6-unorm-srgb":{gl:37849,f:ce},"astc-10x8-unorm":{gl:37818,f:ce},"astc-10x8-unorm-srgb":{gl:37850,f:ce},"astc-10x10-unorm":{gl:37819,f:ce},"astc-10x10-unorm-srgb":{gl:37851,f:ce},"astc-12x10-unorm":{gl:37820,f:ce},"astc-12x10-unorm-srgb":{gl:37852,f:ce},"astc-12x12-unorm":{gl:37821,f:ce},"astc-12x12-unorm-srgb":{gl:37853,f:ce},"pvrtc-rgb4unorm-webgl":{gl:35840,f:sl},"pvrtc-rgba4unorm-webgl":{gl:35842,f:sl},"pvrtc-rbg2unorm-webgl":{gl:35841,f:sl},"pvrtc-rgba2unorm-webgl":{gl:35843,f:sl},"etc1-rbg-unorm-webgl":{gl:36196,f:mR},"atc-rgb-unorm-webgl":{gl:35986,f:dd},"atc-rgba-unorm-webgl":{gl:35986,f:dd},"atc-rgbai-unorm-webgl":{gl:34798,f:dd}},AR={6403:1,36244:1,33319:2,33320:2,6407:3,36248:3,6408:4,36249:4,6402:1,34041:1,6406:1,6409:1,6410:2},ER={5126:4,5125:4,5124:4,5123:2,5122:2,5131:2,5120:1,5121:1};function cl(t,e,r){let i=al[e];if(!i||i.gl===void 0)return!1;let s=i.x||i.gl2ext;return s?!!St(t,s,r):!0}function _d(t){let r=al[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}function my(t,e,r){if(!cl(t,e,r)||e.startsWith("depth")||e.startsWith("stencil"))return!1;try{if(ac(e).signed)return!1}catch{return!1}return e.endsWith("32float")?!!St(t,"OES_texture_float_linear, extensions",r):e.endsWith("16float")?!!St(t,"OES_texture_half_float_linear, extensions",r):!0}function _y(t,e,r){return!(!cl(t,e,r)||typeof e=="number")}function Ms(t){let e=al[t],r=_d(t),i=ac(t);return{format:r,dataFormat:e?.dataFormat||wR(i.format,i.integer,i.normalized,r),type:i.dataType?il(i.dataType):e?.types?.[0]||5121,compressed:i.compressed}}function yy(t){let e=al[t];if(!e?.attachment)throw new Error(`${t} is not a depth stencil format`);return e.attachment}function yd(t){let e=Ms(t),r=AR[e.dataFormat]||4,i=ER[e.type]||1;return r*i}function wR(t,e,r,i){if(i===6408||i===6407)return i;switch(t){case"r":return e&&!r?36244:6403;case"rg":return e&&!r?33320:33319;case"rgb":return e&&!r?36248:6407;case"rgba":return e&&!r?36249:6408;default:return 6408}}var xy={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},ll=class extends Fn{gl;extensions;testedFeatures=new Set;constructor(e,r,i){super([],i),this.gl=e,this.extensions=r,St(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let e=this.getFeatures();for(let r of e)this.has(r)&&(yield r);return[]}has(e){return this.disabledFeatures[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),py(e)&&gy(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of e)this.has(r)}getFeatures(){return[...Object.keys(xy),...Object.keys(ol)]}getWebGLFeature(e){let r=xy[e];return typeof r=="string"?!!St(this.gl,r,this.extensions):!!r}};var ul=class extends Nn{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]}};function At(t,e,r){if(PR(e))return r(t);let{nocatch:i=!0}=e;Zr(t),Lt(t,e);let s;if(i)s=r(t),Sr(t);else try{s=r(t)}finally{Sr(t)}return s}function PR(t){for(let e in t)return!1;return!0}function vy(t,e,r,i){if(Br(e))return i(t);let s=t;Zr(s.gl);try{return RR(t,e),Lt(s.gl,r),i(t)}finally{Sr(s.gl)}}function RR(t,e){let r=t,{gl:i}=r;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(Ui("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){let n=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=Ui("provokingVertex",e.provokingVertex,{first:36429,last:36430});n?.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){let n=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=Ui("polygonMode",e.polygonMode,{fill:6914,line:6913});n?.polygonModeWEBGL(1028,o),n?.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&i.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(MR("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(hl("depthCompare",e.depthCompare))),e.stencilWriteMask){let s=e.stencilWriteMask;i.stencilMaskSeparate(1028,s),i.stencilMaskSeparate(1029,s)}if(e.stencilReadMask&&O.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let s=e.stencilReadMask||4294967295,n=hl("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,n,0,s),i.stencilFuncSeparate(1029,n,0,s)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let s=xd("stencilPassOperation",e.stencilPassOperation),n=xd("stencilFailOperation",e.stencilFailOperation),o=xd("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,n,o,s),i.stencilOpSeparate(1029,n,o,s)}if(e.blendColorOperation||e.blendAlphaOperation){i.enable(3042);let s=Ty("blendColorOperation",e.blendColorOperation||"add"),n=Ty("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(s,n);let o=fl("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=fl("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=fl("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=fl("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(o,a,c,l)}}function hl(t,e){return Ui(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function xd(t,e){return Ui(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function Ty(t,e){return Ui(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function fl(t,e){return Ui(t,e,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function CR(t,e){return`Illegal parameter ${e} for ${t}`}function Ui(t,e,r){if(!(e in r))throw new Error(CR(t,e));return r[e]}function MR(t,e){return e}function dl(t){let e={};return t.addressModeU&&(e[10242]=Td(t.addressModeU)),t.addressModeV&&(e[10243]=Td(t.addressModeV)),t.addressModeW&&(e[32882]=Td(t.addressModeW)),t.magFilter&&(e[10240]=by(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=IR(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=hl("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function Td(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function by(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function IR(t,e){if(!e)return by(t);switch(t){case"nearest":return e==="nearest"?9984:9986;case"linear":return e==="nearest"?9985:9987}}var Xe=class extends ie{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength;bytesUsed;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let i=typeof r=="object"?r.handle:void 0;this.handle=i||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=OR(this.props.usage),this.glUsage=NR(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(e,r=0,i=e.byteLength+r){let s=this.glTarget;this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,i,this.glUsage),this.gl.bufferSubData(s,r,e),this.gl.bindBuffer(s,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,r,i),this.trackAllocatedMemory(i)}_initWithByteLength(e){ee(e>=0);let r=e;e===0&&(r=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,r,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,r=0){this.gl.bindBuffer(36663,this.handle),this.gl.bufferSubData(36663,r,e),this.gl.bindBuffer(36663,null),this._setDebugData(e,r,e.byteLength)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let i=new Uint8Array(r),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,s,r),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,r),i}};function OR(t){return t&ie.INDEX?34963:t&ie.VERTEX?34962:t&ie.UNIFORM?35345:34962}function NR(t){return t&ie.INDEX||t&ie.VERTEX?35044:t&ie.UNIFORM?35048:35044}var zi=class extends Si{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=dl(r),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(let[r,i]of Object.entries(e)){let s=Number(r);switch(s){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,s,i);break;default:this.device.gl.samplerParameteri(this.handle,s,i);break}}}};var kt=class extends vi{device;gl;handle;texture;constructor(e,r){super(e,{...Ae.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}};var FR={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},Je=class t extends Ae{static FACES=[34069,34070,34071,34072,34073,34074];MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,r){super(e,{...FR,format:"rgba8unorm",...r}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=DR(this.props),this.loaded=!1,typeof this.props?.data=="string"&&Object.assign(this.props,{data:Ef(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(e){return new kt(this.device,{...e,texture:this})}initialize(e={}){if(this.props.dimension==="cube")return this.initializeCube(e);let r=e.data;if(r instanceof Promise)return r.then(_=>this.initialize(Object.assign({},e,{pixels:_,data:_}))),this;let i=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(i&&r.readyStatethis.initialize(e)),this;let{parameters:s={}}=e,{pixels:n=null,pixelStore:o={},textureUnit:a=void 0,mipmaps:c=!0}=e;r||(r=n);let{width:l,height:u,dataFormat:f,type:h,compressed:d=!1}=e,{depth:p=0}=e,g=_d(e.format);return{width:l,height:u,compressed:d,dataFormat:f,type:h}=this._deduceParameters({format:e.format,type:h,dataFormat:f,compressed:d,data:r,width:l,height:u}),this.width=l,this.height=u,this.glFormat=g,this.type=h,this.dataFormat=f,this.textureUnit=a,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=c,this.setImageData({data:r,width:l,height:u,depth:p,format:g,type:h,dataFormat:f,parameters:o,compressed:d}),this.setSampler(e.sampler),this._setSamplerParameters(s),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),c&&this.device.isTextureFormatFilterable(e.format)&&this.generateMipmap(),i&&(this._video={video:r,parameters:s,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(e){let{mipmaps:r=!0,parameters:i={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,r&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(i)}),this}setSampler(e={}){let r;e instanceof zi?(this.sampler=e,r=e.props):(this.sampler=new zi(this.device,e),r=e);let i=dl(r);return this._setSamplerParameters(i),this}resize(e){let{height:r,width:i,mipmaps:s=!1}=e;return i!==this.width||r!==this.height?this.initialize({width:i,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:s}):this}update(){if(this._video){let{video:e,parameters:r,lastTime:i}=this._video;if(i===e.currentTime||e.readyState{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");let{target:r=this.target,pixels:i=null,level:s=0,glFormat:n=this.glFormat,offset:o=0,parameters:a={}}=e,{data:c=null,type:l=this.type,width:u=this.width,height:f=this.height,dataFormat:h=this.dataFormat,compressed:d=!1}=e;c||(c=i),{type:l,dataFormat:h,compressed:d,width:u,height:f}=this._deduceParameters({format:this.props.format,type:l,dataFormat:h,compressed:d,data:c,width:u,height:f});let{gl:p}=this;p.bindTexture(this.target,this.handle);let g=null;if({data:c,dataType:g}=this._getDataType({data:c,compressed:d}),At(this.gl,a,()=>{switch(g){case"null":p.texImage2D(r,s,n,u,f,0,h,l,c);break;case"typed-array":p.texImage2D(r,s,n,u,f,0,h,l,c,o);break;case"buffer":this.device.gl.bindBuffer(35052,c.handle||c),this.device.gl.texImage2D(r,s,n,u,f,0,h,l,o),this.device.gl.bindBuffer(35052,null);break;case"browser-object":p.texImage2D(r,s,n,u,f,0,h,l,c);break;case"compressed":for(let[_,x]of c.entries())p.compressedTexImage2D(r,_,x.format,x.width,x.height,0,x.data);break;default:ee(!1,"Unknown image data type")}}),c&&c.byteLength)this.trackAllocatedMemory(c.byteLength,"Texture");else{let _=yd(this.props.format);this.trackAllocatedMemory(this.width*this.height*_,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:r=null,data:i=null,x:s=0,y:n=0,width:o=this.width,height:a=this.height,level:c=0,glFormat:l=this.glFormat,type:u=this.type,dataFormat:f=this.dataFormat,compressed:h=!1,offset:d=0,parameters:p={}}){if({type:u,dataFormat:f,compressed:h,width:o,height:a}=this._deduceParameters({format:this.props.format,type:u,dataFormat:f,compressed:h,data:i,width:o,height:a}),ee(this.depth===1,"texSubImage not supported for 3D textures"),i||(i=r),i&&i.data){let g=i;i=g.data,o=g.shape[0],a=g.shape[1]}i instanceof Xe&&(i=i.handle),this.gl.bindTexture(this.target,this.handle),At(this.gl,p,()=>{h?this.gl.compressedTexSubImage2D(e,c,s,n,o,a,l,i):i===null?this.gl.texSubImage2D(e,c,s,n,o,a,f,u,null):ArrayBuffer.isView(i)?this.gl.texSubImage2D(e,c,s,n,o,a,f,u,i,d):typeof WebGLBuffer<"u"&&i instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,i),this.device.gl.texSubImage2D(e,c,s,n,o,a,f,u,d),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(e,c,s,n,o,a,f,u,i)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return O.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){let{gl:r}=this;return e!==void 0&&(this.textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.target,null),e}_getDataType({data:e,compressed:r=!1}){return r?{data:e,dataType:"compressed"}:e===null?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof Xe?{data:e.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){let{format:r,data:i}=e,{width:s,height:n,dataFormat:o,type:a,compressed:c}=e,l=Ms(r);return o=o||l.dataFormat,a=a||l.type,c=c||l.compressed,{width:s,height:n}=this._deduceImageSize(i,s,n),{dataFormat:o,type:a,compressed:c,width:s,height:n,format:r,data:i}}_deduceImageSize(e,r,i){let s;return typeof ImageData<"u"&&e instanceof ImageData?s={width:e.width,height:e.height}:typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement?s={width:e.naturalWidth,height:e.naturalHeight}:typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement?s={width:e.width,height:e.height}:typeof ImageBitmap<"u"&&e instanceof ImageBitmap?s={width:e.width,height:e.height}:typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?s={width:e.videoWidth,height:e.videoHeight}:e?s={width:r,height:i}:s={width:r>=0?r:1,height:i>=0?i:1},ee(s,"Could not deduced texture size"),ee(r===void 0||s.width===r,"Deduced texture width does not match supplied width"),ee(i===void 0||s.height===i,"Deduced texture height does not match supplied height"),s}async setCubeMapImageData(e){let{gl:r}=this,{width:i,height:s,pixels:n,data:o,format:a=6408,type:c=5121}=e,l=n||o,u=await Promise.all(t.FACES.map(f=>{let h=l[f];return Promise.all(Array.isArray(h)?h:[h])}));this.bind(),t.FACES.forEach((f,h)=>{u[h].length>1&&this.props.mipmaps!==!1&&O.warn(`${this.id} has mipmap and multiple LODs.`)(),u[h].forEach((d,p)=>{i&&s?r.texImage2D(f,p,a,i,s,0,a,c,d):r.texImage2D(f,p,a,a,c,d)})}),this.unbind()}setImageDataForFace(e){let{face:r,width:i,height:s,pixels:n,data:o,format:a=6408,type:c=5121}=e,{gl:l}=this,u=n||o;return this.bind(),u instanceof Promise?u.then(f=>this.setImageDataForFace(Object.assign({},e,{face:r,data:f,pixels:f}))):this.width||this.height?l.texImage2D(r,0,a,i,s,0,a,c,u):l.texImage2D(r,0,a,a,c,u),this}setImageData3D(e){let{level:r=0,dataFormat:i,format:s,type:n,width:o,height:a,depth:c=1,offset:l=0,data:u,parameters:f={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let h=Ms(s);if(At(this.gl,f,()=>{ArrayBuffer.isView(u)&&this.gl.texImage3D(this.target,r,h.format,o,a,c,0,h.dataFormat,h.type,u),u instanceof Xe&&(this.gl.bindBuffer(35052,u.handle),this.gl.texImage3D(this.target,r,i,o,a,c,0,s,n,l))}),u&&u.byteLength)this.trackAllocatedMemory(u.byteLength,"Texture");else{let d=yd(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*d,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!Br(e)){LR(e),this.gl.bindTexture(this.target,this.handle);for(let[r,i]of Object.entries(e)){let s=Number(r),n=i;switch(s){case 33082:case 33083:this.gl.texParameterf(this.target,s,n);break;default:this.gl.texParameteri(this.target,s,n);break}}this.gl.bindTexture(this.target,null)}}};function DR(t){switch(t.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;case"1d":case"cube-array":default:throw new Error(t.dimension)}}function LR(t){O.log(1,"texture sampler parameters",t)()}var sr=class extends Ai{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,r){super(e,r);let i=r.handle===null;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),!i){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();let s=this.gl.bindFramebuffer(36160,this.handle);for(let n=0;nO.info("Spector capture started:",e)()),Qe?.onCapture.add(e=>{O.info("Spector capture complete:",e)(),Qe?.getResultUI(),Qe?.resultView.display(),Qe?.resultView.addCapture(e)})),t?.canvas){if(typeof t.spector=="string"&&t.spector!==t.canvas.id)return Qe;Qe?.startCapture(t?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{O.info("Spector capture stopped after 2 seconds")(),Qe?.stopCapture()})}return Qe}var WR="https://unpkg.com/webgl-debug@2.0.1/index.js";function wy(t){return t.luma=t.luma||{},t.luma}async function Py(){ke()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Xn(WR))}function Ry(t,e={}){return t?e.debug?jR(t,e):HR(t):null}function HR(t){let e=wy(t);return e.realContext?e.realContext:t}function jR(t,e){if(!globalThis.WebGLDebugUtils)return O.warn("webgl-debug not loaded")(),t;let r=wy(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...Gr,...t});let i=globalThis.WebGLDebugUtils.makeDebugContext(t,XR.bind(null,e),$R.bind(null,e));for(let o in Gr)!(o in i)&&typeof Gr[o]=="number"&&(i[o]=Gr[o]);class s{}Object.setPrototypeOf(i,Object.getPrototypeOf(t)),Object.setPrototypeOf(s,i);let n=Object.create(s);return r.realContext=t,r.debugContext=n,n.debug=!0,n}function vd(t,e){e=Array.from(e).map(i=>i===void 0?"undefined":i);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function XR(t,e,r,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);let s=globalThis.WebGLDebugUtils.glEnumToString(e),n=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,i),o=`${s} in gl.${r}(${n})`;O.error(o)();debugger;if(t.throwOnError)throw new Error(o)}function $R(t,e,r){let i="";if(O.level>=1&&(i=vd(e,r),O.log(1,i)()),t.break&&t.break.length>0&&(i=i||vd(e,r),t.break.every(n=>i.indexOf(n)!==-1)))debugger;for(let s of r)if(s===void 0){if(i=i||vd(e,r),t.throwOnError)throw new Error(`Undefined argument: ${i}`);O.error(`Undefined argument: ${i}`)();debugger}}function My(t){let e=t.split(/\r?\n/),r=[];for(let i of e){if(i.length<=1)continue;let s=i.split(":");if(s.length===2){let[f,h]=s;r.push({message:h.trim(),type:Cy(f),lineNum:0,linePos:0});continue}let[n,o,a,...c]=s,l=parseInt(a,10);isNaN(l)&&(l=0);let u=parseInt(o,10);isNaN(u)&&(u=0),r.push({message:c.join(":").trim(),type:Cy(n),lineNum:l,linePos:u})}return r}function Cy(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var gl=class extends bi{device;handle;constructor(e,r){switch(super(e,r),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);return My(e)}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)}async _compile(e){e=(s=>s.startsWith("#version ")?s:`#version 100 +${s}`)(e);let{gl:i}=this.device;if(i.shaderSource(this.handle,e),i.compileShader(this.handle),O.level===0){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}O.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),O.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async s=>await new Promise(n=>setTimeout(n,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}};var YR=256,KR=1024,qR=16384,bd=6144,GR=[1,2,4,8],ml=class extends Ln{device;glParameters;constructor(e,r){super(e,r),this.device=e,Zr(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){Sr(this.device.gl)}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let r={...this.glParameters};this.props.framebuffer&&(r.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),e.scissorRect&&(r.scissorTest=!0,r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[2967]=e.stencilReference),e.colorMask&&(r.colorMask=GR.map(i=>!!(i&e.colorMask))),this.glParameters=r,Lt(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColor!==!1&&(r|=qR,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=YR,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=KR,e.clearStencil=this.props.clearStencil),r!==0&&At(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){At(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl.clearBufferiv(bd,e,r);break;case Uint32Array:this.device.gl.clearBufferuiv(bd,e,r);break;case Float32Array:default:this.device.gl.clearBufferfv(bd,e,r);break}})}};var ZR="Failed to deduce GL constant from typed array";function Iy(t){switch(ArrayBuffer.isView(t)?t.constructor:t){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:return 5121;case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error(ZR)}}function Mo(t,e){let{clamped:r=!0}=e||{};switch(t){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return r?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var JR={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},QR={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},_l=class t{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return Mo(e.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(e){return ee(e.size),Mo(e.type||5126).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new t(JR,...e)}constructor(...e){e.forEach(r=>this._assign(r)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return t.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return t.getBytesPerVertex(this)}_assign(e={}){return e=Af("Accessor",e,QR),e.type!==void 0&&(this.type=e.type,(e.type===5124||e.type===5125)&&(this.integer=!0)),e.size!==void 0&&(this.size=e.size),e.offset!==void 0&&(this.offset=e.offset),e.stride!==void 0&&(this.stride=e.stride),e.normalize!==void 0&&(this.normalized=e.normalize),e.normalized!==void 0&&(this.normalized=e.normalized),e.integer!==void 0&&(this.integer=e.integer),e.divisor!==void 0&&(this.divisor=e.divisor),e.buffer!==void 0&&(this.buffer=e.buffer),e.index!==void 0&&(typeof e.index=="boolean"?this.index=e.index?1:0:this.index=e.index),e.instanced!==void 0&&(this.divisor=e.instanced?1:0),e.isInstanced!==void 0&&(this.divisor=e.isInstanced?1:0),this.offset===void 0&&delete this.offset,this.stride===void 0&&delete this.stride,this.type===void 0&&delete this.type,this.size===void 0&&delete this.size,this.divisor===void 0&&delete this.divisor,this.normalized===void 0&&delete this.normalized,this.integer===void 0&&delete this.integer,this.buffer===void 0&&delete this.buffer,this.index===void 0&&delete this.index,this}};function Oy(t){return eC.includes(t)}var eC=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],Ny={5126:[5126,1,"float","f32","float32"],35664:[5126,2,"vec2","vec2","float32x2"],35665:[5126,3,"vec3","vec3","float32x3"],35666:[5126,4,"vec4","vec4","float32x4"],5124:[5124,1,"int","i32","sint32"],35667:[5124,2,"ivec2","vec2","sint32x2"],35668:[5124,3,"ivec3","vec3","sint32x3"],35669:[5124,4,"ivec4","vec4","sint32x4"],5125:[5125,1,"uint","u32","uint32"],36294:[5125,2,"uvec2","vec2","uint32x2"],36295:[5125,3,"uvec3","vec3","uint32x3"],36296:[5125,4,"uvec4","vec4","uint32x4"],35670:[5126,1,"bool","f32","float32"],35671:[5126,2,"bvec2","vec2","float32x2"],35672:[5126,3,"bvec3","vec3","float32x3"],35673:[5126,4,"bvec4","vec4","float32x4"],35674:[5126,8,"mat2","mat2x2"],35685:[5126,8,"mat2x3","mat2x3"],35686:[5126,8,"mat2x4","mat2x4"],35687:[5126,12,"mat3x2","mat3x2"],35675:[5126,12,"mat3","mat3x3"],35688:[5126,12,"mat3x4","mat3x4"],35689:[5126,16,"mat4x2","mat4x2"],35690:[5126,16,"mat4x3","mat4x3"],35676:[5126,16,"mat4","mat4x4"]};function Sd(t){let e=Ny[t];if(!e)throw new Error("uniform");let[r,i,,s]=e;return{format:s,components:i,glType:r}}function Fy(t){let e=Ny[t];if(!e)throw new Error("attribute");let[,r,,i,s]=e;return{attributeType:i,vertexFormat:s,components:r}}function Dy(t,e){let r={attributes:[],bindings:[]};r.attributes=tC(t,e);let i=sC(t,e);for(let a of i){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.bindings.push({type:"uniform",name:a.name,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}let s=iC(t,e),n=0;for(let a of s)if(Oy(a.type)){let{viewDimension:c,sampleType:l}=oC(a.type);r.bindings.push({type:"texture",name:a.name,location:n,viewDimension:c,sampleType:l}),a.textureUnit=n,n+=1}s.length&&(r.uniforms=s);let o=rC(t,e);return o?.length&&(r.varyings=o),r}function tC(t,e){let r=[],i=t.getProgramParameter(e,35721);for(let s=0;s=0){let{attributeType:l}=Fy(a),u=/instance/i.test(o)?"instance":"vertex";r.push({name:o,location:c,stepMode:u,type:l})}}return r.sort((s,n)=>s.location-n.location),r}function rC(t,e){let r=[],i=t.getProgramParameter(e,35971);for(let s=0;ss.location-n.location),r}function iC(t,e){let r=[],i=t.getProgramParameter(e,35718);for(let s=0;s1)for(let d=0;dt.getActiveUniformBlockParameter(e,n,o),i=[],s=t.getProgramParameter(e,35382);for(let n=0;nn.location-o.location),i}var nC={35678:["2d","float"],35680:["cube","float"],35679:["3d","float"],35682:["3d","depth"],36289:["2d-array","float"],36292:["2d-array","depth"],36293:["cube","float"],36298:["2d","sint"],36299:["3d","sint"],36300:["cube","sint"],36303:["2d-array","uint"],36306:["2d","uint"],36307:["3d","uint"],36308:["cube","uint"],36311:["2d-array","uint"]};function oC(t){let e=nC[t];if(!e)throw new Error("sampler");let[r,i]=e;return{viewDimension:r,sampleType:i}}function aC(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${t}`);return{name:r[1],length:r[2]?1:0,isArray:!!r[2]}}function Ly(t,e,r,i){let s=t,n=i;n===!0&&(n=1),n===!1&&(n=0);let o=typeof n=="number"?[n]:n;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,i);case 5126:return t.uniform1fv(e,o);case 35664:return t.uniform2fv(e,o);case 35665:return t.uniform3fv(e,o);case 35666:return t.uniform4fv(e,o);case 5124:return t.uniform1iv(e,o);case 35667:return t.uniform2iv(e,o);case 35668:return t.uniform3iv(e,o);case 35669:return t.uniform4iv(e,o);case 35670:return t.uniform1iv(e,o);case 35671:return t.uniform2iv(e,o);case 35672:return t.uniform3iv(e,o);case 35673:return t.uniform4iv(e,o);case 5125:return s.uniform1uiv(e,o,1);case 36294:return s.uniform2uiv(e,o,2);case 36295:return s.uniform3uiv(e,o,3);case 36296:return s.uniform4uiv(e,o,4);case 35674:return t.uniformMatrix2fv(e,!1,o);case 35675:return t.uniformMatrix3fv(e,!1,o);case 35676:return t.uniformMatrix4fv(e,!1,o);case 35685:return s.uniformMatrix2x3fv(e,!1,o);case 35686:return s.uniformMatrix2x4fv(e,!1,o);case 35687:return s.uniformMatrix3x2fv(e,!1,o);case 35688:return s.uniformMatrix3x4fv(e,!1,o);case 35689:return s.uniformMatrix4x2fv(e,!1,o);case 35690:return s.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}function ky(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"line-loop-webgl":return 2;case"triangle-list":return 4;case"triangle-strip":return 5;case"triangle-fan-webgl":return 6;default:throw new Error(t)}}function By(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"line-loop-webgl":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;case"triangle-fan-webgl":return 4;default:throw new Error(t)}}var Uy=4,yl=class extends qt{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,r){super(e,r),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=r.vs,this.fs=r.fs;let{varyings:i,bufferMode:s=35981}=r;switch(i&&i.length>0&&(this.varyings=i,this.device.gl.transformFeedbackVaryings(this.handle,i,s)),this._linkShaders(),O.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Dy(this.device.gl,this.handle),O.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=Tf(this.introspectedLayout,r.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":O.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`);break;default:}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e,r){for(let[i,s]of Object.entries(e)){let n=this.shaderLayout.bindings.find(o=>o.name===i)||this.shaderLayout.bindings.find(o=>o.name===`${i}Uniforms`);if(!n){let o=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");r?.disableWarnings||O.warn(`Unknown binding "${i}" in render pipeline "${this.id}", expected one of ${o}`)();continue}switch(s||O.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),n.type){case"uniform":if(!(s instanceof Xe)&&!(s.buffer instanceof Xe))throw new Error("buffer value");break;case"texture":if(!(s instanceof kt||s instanceof Je||s instanceof sr))throw new Error("texture value");break;case"sampler":O.warn(`Ignoring sampler ${i}`)();break;default:throw new Error(n.type)}this.bindings[i]=s}}draw(e){let{renderPass:r,parameters:i=this.props.parameters,topology:s=this.props.topology,vertexArray:n,vertexCount:o,instanceCount:a,isInstanced:c=!1,firstVertex:l=0,transformFeedback:u}=e,f=ky(s),h=!!n.indexBuffer,d=n.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return O.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||o===0)return O.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(o===0)return O.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),n.bindBeforeRender(r),u&&u.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let p=r;return vy(this.device,i,p.glParameters,()=>{h&&c?this.device.gl.drawElementsInstanced(f,o||0,d,l,a||0):h?this.device.gl.drawElements(f,o||0,d,l):c?this.device.gl.drawArraysInstanced(f,l,o||0,a||0):this.device.gl.drawArrays(f,l,o||0),u&&u.end()}),n.unbindAfterRender(r),!0}setUniformsWebGL(e){let{bindings:r}=jn(e);Object.keys(r).forEach(i=>{O.warn(`Unsupported value "${JSON.stringify(r[i])}" used in setUniforms() for key ${i}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),O.time(Uy,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),O.timeEnd(Uy,`linkProgram for ${this.id}`)(),O.level,!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}O.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),O.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}_reportLinkStatus(e){switch(e){case"success":return;default:throw this.vs.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`)):this.fs?.compilationStatus==="error"?(this.fs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`)):new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let e=async s=>await new Promise(n=>setTimeout(n,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let[,r]of Object.entries(this.bindings))r instanceof Je&&(r.update(),e=e&&r.loaded);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);let r=0,i=0;for(let s of this.shaderLayout.bindings){let n=this.bindings[s.name]||this.bindings[s.name.replace(/Uniforms$/,"")];if(!n)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":let{name:o}=s,a=e.getUniformBlockIndex(this.handle,o);if(a===4294967295)throw new Error(`Invalid uniform block name ${o}`);e.uniformBlockBinding(this.handle,i,a),n instanceof Xe?e.bindBufferBase(35345,i,n.handle):e.bindBufferRange(35345,i,n.buffer.handle,n.offset||0,n.size||n.buffer.byteLength-n.offset),i+=1;break;case"texture":if(!(n instanceof kt||n instanceof Je||n instanceof sr))throw new Error("texture");let c;if(n instanceof kt)c=n.texture;else if(n instanceof Je)c=n;else if(n instanceof sr&&n.colorAttachments[0]instanceof kt)O.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),c=n.colorAttachments[0].texture;else throw new Error("No texture");e.activeTexture(33984+r),e.bindTexture(c.target,c.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(){for(let e of this.shaderLayout.uniforms||[]){let{name:r,location:i,type:s,textureUnit:n}=e,o=this.uniforms[r]??n;o!==void 0&&Ly(this.device.gl,i,s,o)}}};var xl=class extends Bn{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":cC(this.device,r.options);break;case"copy-buffer-to-texture":lC(this.device,r.options);break;case"copy-texture-to-buffer":uC(this.device,r.options);break;case"copy-texture-to-texture":fC(this.device,r.options);break}}};function cC(t,e){let r=e.source,i=e.destination;t.gl.bindBuffer(36662,r.handle),t.gl.bindBuffer(36663,i.handle),t.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(36662,null),t.gl.bindBuffer(36663,null)}function lC(t,e){throw new Error("Not implemented")}function uC(t,e){let{source:r,mipLevel:i=0,aspect:s="all",width:n=e.source.width,height:o=e.source.height,depthOrArrayLayers:a=0,origin:c=[0,0],destination:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:h}=e;if(s!=="all")throw new Error("not supported");if(i!==0||a!==0||f||h)throw new Error("not implemented");let{framebuffer:d,destroyFramebuffer:p}=zy(r),g;try{let _=l,x=n||d.width,v=o||d.height,b=Ms(d.texture.props.format),A=b.dataFormat,C=b.type;t.gl.bindBuffer(35051,_.handle),g=t.gl.bindFramebuffer(36160,d.handle),t.gl.readPixels(c[0],c[1],x,v,A,C,u)}finally{t.gl.bindBuffer(35051,null),g!==void 0&&t.gl.bindFramebuffer(36160,g),p&&d.destroy()}}function fC(t,e){let{source:r,destinationMipLevel:i=0,origin:s=[0,0],destinationOrigin:n=[0,0],destination:o}=e,{width:a=e.destination.width,height:c=e.destination.height}=e,{framebuffer:l,destroyFramebuffer:u}=zy(r),[f,h]=s,[d,p,g]=n,_=t.gl.bindFramebuffer(36160,l.handle),x=null,v;if(o instanceof Je)x=o,a=Number.isFinite(a)?a:x.width,c=Number.isFinite(c)?c:x.height,x.bind(0),v=x.target;else throw new Error("invalid destination");switch(v){case 3553:case 34067:t.gl.copyTexSubImage2D(v,i,d,p,f,h,a,c);break;case 35866:case 32879:t.gl.copyTexSubImage3D(v,i,d,p,g,f,h,a,c);break;default:}x&&x.unbind(),t.gl.bindFramebuffer(36160,_),u&&l.destroy()}function zy(t){if(t instanceof Ae){let{width:e,height:r,id:i}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var Tl=class extends kn{device;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new xl(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,r,i){}};var vl=class t extends Un{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return Pu()==="Chrome"}constructor(e,r){super(e,r),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){let r=e;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(e,r){let i=r;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:s,type:n,stride:o,offset:a,normalized:c,integer:l,divisor:u}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,s,n,o,a):this.device.gl.vertexAttribPointer(e,s,n,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,u||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{for(let r in e)this.setBuffer(r,e[r])})}setBuffer(e,r){let i=this._getVaryingIndex(e),{buffer:s,byteLength:n,byteOffset:o}=this._getBufferRange(r);if(i<0){this.unusedBuffers[e]=s,O.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:s,byteLength:n,byteOffset:o},this.bindOnUse||this._bindBuffer(i,s,o,n)}getBuffer(e){if(Vy(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return r>=0?this.buffers[r]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof Xe)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:i=0,byteLength:s=e.buffer.byteLength}=e;return{buffer:r,byteOffset:i,byteLength:s}}_getVaryingIndex(e){if(Vy(e))return Number(e);for(let r of this.layout.varyings)if(e===r.name)return r.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:r,byteLength:i,byteOffset:s}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),r,s,i)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,r,i=0,s){let n=r&&r.handle;!n||s===void 0?this.gl.bindBufferBase(35982,e,n):this.gl.bindBufferRange(35982,e,n,i,s)}};function Vy(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var Sl=class extends Vn{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,r){if(super(e,r),this.device=e,r.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;let e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let r=0;return this._pollingPromise=new Promise((i,s)=>{let n=()=>{this.isResultAvailable()?(i(this.getResult()),this._pollingPromise=null):r++>e?(s("Timed out"),this._pollingPromise=null):requestAnimationFrame(n)};requestAnimationFrame(n)}),this._pollingPromise}};function Ad(t){switch(t){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return ee(!1),0}}function Wy(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return ee(!1),0}}function Hy(t,e){let{sourceX:r=0,sourceY:i=0,sourceFormat:s=6408,sourceAttachment:n=36064}=e||{},{target:o=null,sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=Xy(t);ee(u);let{gl:h,handle:d}=u;a=a||u.width,c=c||u.height;let p=n-36064;l=l||u.colorAttachments[p]?.texture?.type||5121,o=gC(o,l,s,a,c),l=l||Iy(o);let g=h.bindFramebuffer(36160,d);return h.readPixels(r,i,a,c,s,l,o),h.bindFramebuffer(36160,g||null),f&&u.destroy(),o}function jy(t,e){let{target:r,sourceX:i=0,sourceY:s=0,sourceFormat:n=6408,targetByteOffset:o=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=Xy(t);ee(u),a=a||u.width,c=c||u.height;let h=u;l=l||5121;let d=r;if(!d){let g=Ad(n),_=Wy(l),x=o+a*c*g*_;d=h.device.createBuffer({byteLength:x})}let p=t.device.createCommandEncoder();return p.copyTextureToBuffer({source:t,width:a,height:c,origin:[i,s],destination:d,byteOffset:o}),p.destroy(),f&&u.destroy(),d}function Xy(t){return t instanceof Ai?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:pC(t),deleteFramebuffer:!0}}function pC(t,e){let{device:r,width:i,height:s,id:n}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${n}`,width:i,height:s,colorAttachments:[t]})}function gC(t,e,r,i,s){if(t)return t;e=e||5121;let n=Mo(e,{clamped:!1}),o=Ad(r);return new n(i*s*o)}var mC=256,_C=1024,yC=16384;var xC="clear: bad arguments";function $y(t,e){let{framebuffer:r=null,color:i=null,depth:s=null,stencil:n=null}=e||{},o={};r&&(o.framebuffer=r);let a=0;i&&(a|=yC,i!==!0&&(o.clearColor=i)),s&&(a|=mC,s!==!0&&(o.clearDepth=s)),n&&(a|=_C,s!==!0&&(o.clearStencil=s)),ee(a!==0,xC);let c=t.gl;At(c,o,()=>{c.clear(a)})}var Io=1,Vi=class t extends hr{static type="webgl";type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return typeof WebGL2RenderingContext<"u"}static attach(e){if(e instanceof t)return e;if(e?.device instanceof hr)return e.device;if(!TC(e))throw new Error("Invalid WebGL2RenderingContext");return new t({gl:e})}static async create(e={}){O.groupCollapsed(Io,"WebGLDevice created")();let r=[];e.debug&&r.push(Py()),e.spector&&r.push(Ay()),typeof e.canvas=="string"&&r.push(Ti.pageLoaded);let i=await Promise.allSettled(r);for(let o of i)o.status==="rejected"&&O.error(`Failed to initialize debug libraries ${o.reason}`)();if(O.probe(Io+1,"DOM is loaded")(),e.gl?.device)return O.warn("reattaching existing device")(),t.attach(e.gl);let s=new t(e),n=`Created ${s.type}${s.debug?" debug":""} context: ${s.info.vendor}, ${s.info.renderer} for canvas: ${s.canvasContext.id}`;return O.probe(Io,n)(),O.table(Io,s.info)(),O.groupEnd(Io)(),s}constructor(e){super({...e,id:e.id||Fe("webgl-device")});let r=e.gl?.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);let i=e.gl?.canvas||e.canvas;this.canvasContext=new pl(this,{...e,canvas:i}),this.lost=new Promise(a=>{this._resolveContextLost=a});let s=e.gl||null;if(s||=cy(this.canvasContext.canvas,{...e,onContextLost:a=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!s)throw new Error("WebGL context creation failed");this.handle=s,this.gl=s,this.gl.device=this,this.gl._version=2,e.spector&&(this.spectorJS=Ey({...this.props,canvas:this.handle.canvas})),this.info=ly(this.gl,this._extensions),this.limits=new ul(this.gl),this.features=new ll(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),this.canvasContext.resize();let{enable:n=!0,copyState:o=!1}=e;hd(this.gl,{enable:n,copyState:o,log:(...a)=>O.log(1,...a)()}),e.debug&&(this.gl=Ry(this.gl,{...e,throwOnError:!0}),this.debug=!0,O.level=Math.max(O.level,1),O.warn("WebGL debug mode activated. Performance reduced.")())}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return cl(this.gl,e,this._extensions)}isTextureFormatFilterable(e){return my(this.gl,e,this._extensions)}isTextureFormatRenderable(e){return _y(this.gl,e,this._extensions)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let r=this._getBufferProps(e);return new Xe(this,r)}_createTexture(e){return new Je(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new zi(this,e)}createShader(e){return new gl(this,e)}createFramebuffer(e){return new sr(this,e)}createVertexArray(e){return new vl(this,e)}createTransformFeedback(e){return new bl(this,e)}createQuerySet(e){return new Sl(this,e)}createRenderPipeline(e){return new yl(this,e)}beginRenderPass(e){return new ml(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e){return new Tl(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,r){return Hy(e,r)}readPixelsToBufferWebGL(e,r){return jy(e,r)}setParametersWebGL(e){Lt(this.gl,e)}getParametersWebGL(e){return rl(this.gl,e)}withParametersWebGL(e,r){return At(this.gl,e,r)}clearWebGL(e){$y(this,e)}resetWebGL(){O.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),ny(this.gl)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){Zr(this.gl)}popState(){Sr(this.gl)}setSpectorMetadata(e,r){e.__SPECTOR_Metadata=r}getGLKey(e,r){r=r||this.gl2||this.gl;let i=Number(e);for(let s in r)if(r[s]===i)return`GL.${s}`;return String(e)}_constants;setConstantAttributeWebGL(e,r){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let s=this._constants[e];switch(s&&AC(s,r)&&O.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:vC(this,e,r);break;case Int32Array:bC(this,e,r);break;case Uint32Array:SC(this,e,r);break;default:ee(!1)}}getExtension(e){return St(this.gl,e,this._extensions),this._extensions}};function TC(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:!!(t&&Number.isFinite(t._version))}function vC(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:ee(!1)}}function bC(t,e,r){t.gl.vertexAttribI4iv(e,r)}function SC(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function AC(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r0&&i.type==="pointerdown"&&(wC(s,n=>n.pointerId===i.pointerId)||s.push(i)),e.call(this,i)}}function qy(t){t.prototype.handler=function(r){let i=EC[r.type];i&1&&r.button>=0&&(this.pressed=!0),i&2&&r.buttons===0&&(i=4),this.pressed&&(i&4&&(this.pressed=!1),this.callback(this.manager,i,{pointers:[r],changedPointers:[r],pointerType:"mouse",srcEvent:r}))}}Ky(Wi.PointerEventInput);qy(Wi.MouseInput);var Gy=Wi.Manager,Bt=Wi;var Ut=class{constructor(e,r,i){this.element=e,this.callback=r,this.options={enable:!0,...i}}};var Zy=Bt?[[Bt.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[Bt.Rotate,{enable:!1}],[Bt.Pinch,{enable:!1}],[Bt.Swipe,{enable:!1}],[Bt.Pan,{threshold:0,enable:!1}],[Bt.Press,{enable:!1}],[Bt.Tap,{event:"doubletap",taps:2,enable:!1}],[Bt.Tap,{event:"anytap",enable:!1}],[Bt.Tap,{enable:!1}]]:null,Ed={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},Jy={doubletap:["tap"]},Qy={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},Is={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},ex={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},wd={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"};var tx=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",Hi=typeof window<"u"?window:global;var El=!1;try{let t={get passive(){return El=!0,!0}};Hi.addEventListener("test",null,t),Hi.removeEventListener("test",null)}catch{El=!1}var PC=tx.indexOf("firefox")!==-1,{WHEEL_EVENTS:RC}=Is,rx="wheel",ix=4.000244140625,CC=40,MC=.25,Oo=class extends Ut{constructor(e,r,i){super(e,r,i),this.handleEvent=s=>{if(!this.options.enable)return;let n=s.deltaY;Hi.WheelEvent&&(PC&&s.deltaMode===Hi.WheelEvent.DOM_DELTA_PIXEL&&(n/=Hi.devicePixelRatio),s.deltaMode===Hi.WheelEvent.DOM_DELTA_LINE&&(n*=CC)),n!==0&&n%ix===0&&(n=Math.floor(n/ix)),s.shiftKey&&n&&(n=n*MC),this.callback({type:rx,center:{x:s.clientX,y:s.clientY},delta:-n,srcEvent:s,pointerType:"mouse",target:s.target})},this.events=(this.options.events||[]).concat(RC),this.events.forEach(s=>e.addEventListener(s,this.handleEvent,El?{passive:!1}:!1))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e===rx&&(this.options.enable=r)}};var{MOUSE_EVENTS:IC}=Is,sx="pointermove",nx="pointerover",ox="pointerout",ax="pointerenter",cx="pointerleave",No=class extends Ut{constructor(e,r,i){super(e,r,i),this.handleEvent=n=>{this.handleOverEvent(n),this.handleOutEvent(n),this.handleEnterEvent(n),this.handleLeaveEvent(n),this.handleMoveEvent(n)},this.pressed=!1;let{enable:s}=this.options;this.enableMoveEvent=s,this.enableLeaveEvent=s,this.enableEnterEvent=s,this.enableOutEvent=s,this.enableOverEvent=s,this.events=(this.options.events||[]).concat(IC),this.events.forEach(n=>e.addEventListener(n,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e===sx&&(this.enableMoveEvent=r),e===nx&&(this.enableOverEvent=r),e===ox&&(this.enableOutEvent=r),e===ax&&(this.enableEnterEvent=r),e===cx&&(this.enableLeaveEvent=r)}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit(nx,e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit(ox,e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit(ax,e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit(cx,e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit(sx,e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,r){this.callback({type:e,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var{KEY_EVENTS:OC}=Is,lx="keydown",ux="keyup",Fo=class extends Ut{constructor(e,r,i){super(e,r,i),this.handleEvent=s=>{let n=s.target||s.srcElement;n.tagName==="INPUT"&&n.type==="text"||n.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:lx,srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:ux,srcEvent:s,key:s.key,target:s.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=(this.options.events||[]).concat(OC),e.tabIndex=this.options.tabIndex||0,e.style.outline="none",this.events.forEach(s=>e.addEventListener(s,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e===lx&&(this.enableDownEvent=r),e===ux&&(this.enableUpEvent=r)}};var fx="contextmenu",Do=class extends Ut{constructor(e,r,i){super(e,r,i),this.handleEvent=s=>{this.options.enable&&this.callback({type:fx,center:{x:s.clientX,y:s.clientY},srcEvent:s,pointerType:"mouse",target:s.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,r){e===fx&&(this.options.enable=r)}};var NC={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},FC=0,DC=1,LC=2,kC=1,BC=2,UC=4;function hx(t){let e=NC[t.srcEvent.type];if(!e)return null;let{buttons:r,button:i}=t.srcEvent,s=!1,n=!1,o=!1;return e===2?(s=!!(r&kC),n=!!(r&UC),o=!!(r&BC)):(s=i===FC,n=i===DC,o=i===LC),{leftButton:s,middleButton:n,rightButton:o}}function dx(t,e){let r=t.center;if(!r)return null;let i=e.getBoundingClientRect(),s=i.width/e.offsetWidth||1,n=i.height/e.offsetHeight||1,o={x:(r.x-i.left-e.clientLeft)/s,y:(r.y-i.top-e.clientTop)/n};return{center:r,offsetCenter:o}}var Pd={srcElement:"root",priority:0},Lo=class{constructor(e){this.handleEvent=r=>{if(this.isEmpty())return;let i=this._normalizeEvent(r),s=r.srcEvent.target;for(;s&&s!==i.rootElement;){if(this._emit(i,s),i.handled)return;s=s.parentNode}this._emit(i,"root")},this.eventManager=e,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,r,i,s=!1,n=!1){let{handlers:o,handlersByElement:a}=this,c=Pd;typeof i=="string"||i&&i.addEventListener?c={...Pd,srcElement:i}:i&&(c={...Pd,...i});let l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let u={type:e,handler:r,srcElement:c.srcElement,priority:c.priority};s&&(u.once=!0),n&&(u.passive=!0),o.push(u),this._active=this._active||!u.passive;let f=l.length-1;for(;f>=0&&!(l[f].priority>=u.priority);)f--;l.splice(f+1,0,u)}remove(e,r){let{handlers:i,handlersByElement:s}=this;for(let n=i.length-1;n>=0;n--){let o=i[n];if(o.type===e&&o.handler===r){i.splice(n,1);let a=s.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&s.delete(o.srcElement)}}this._active=i.some(n=>!n.passive)}_emit(e,r){let i=this.handlersByElement.get(r);if(i){let s=!1,n=()=>{e.handled=!0},o=()=>{e.handled=!0,s=!0},a=[];for(let c=0;c{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};var zC={events:null,recognizers:null,recognizerOptions:{},Manager:Gy,touchAction:"none",tabIndex:0},Os=class{constructor(e=null,r){this._onBasicInput=s=>{let{srcEvent:n}=s,o=Qy[n.type];o&&this.manager.emit(o,s)},this._onOtherEvent=s=>{this.manager.emit(s.type,s)},this.options={...zC,...r},this.events=new Map,this.setElement(e);let{events:i}=this.options;i&&this.on(i)}getElement(){return this.element}setElement(e){if(this.element&&this.destroy(),this.element=e,!e)return;let{options:r}=this,i=r.Manager;this.manager=new i(e,{touchAction:r.touchAction,recognizers:r.recognizers||Zy}).on("hammer.input",this._onBasicInput),r.recognizers||Object.keys(Ed).forEach(s=>{let n=this.manager.get(s);n&&Ed[s].forEach(o=>{n.recognizeWith(o)})});for(let s in r.recognizerOptions){let n=this.manager.get(s);if(n){let o=r.recognizerOptions[s];delete o.enable,n.set(o)}}this.wheelInput=new Oo(e,this._onOtherEvent,{enable:!1}),this.moveInput=new No(e,this._onOtherEvent,{enable:!1}),this.keyInput=new Fo(e,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new Do(e,this._onOtherEvent,{enable:!1});for(let[s,n]of this.events)n.isEmpty()||(this._toggleRecognizer(n.recognizerName,!0),this.manager.on(s,n.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(e,r,i){this._addEventHandler(e,r,i,!1)}once(e,r,i){this._addEventHandler(e,r,i,!0)}watch(e,r,i){this._addEventHandler(e,r,i,!1,!0)}off(e,r){this._removeEventHandler(e,r)}_toggleRecognizer(e,r){let{manager:i}=this;if(!i)return;let s=i.get(e);if(s&&s.options.enable!==r){s.set({enable:r});let n=Jy[e];n&&!this.options.recognizers&&n.forEach(o=>{let a=i.get(o);r?(a.requireFailure(e),s.dropRequireFailure(o)):a.dropRequireFailure(e)})}this.wheelInput.enableEventType(e,r),this.moveInput.enableEventType(e,r),this.keyInput.enableEventType(e,r),this.contextmenuInput.enableEventType(e,r)}_addEventHandler(e,r,i,s,n){if(typeof e!="string"){i=r;for(let u in e)this._addEventHandler(u,e[u],i,s,n);return}let{manager:o,events:a}=this,c=wd[e]||e,l=a.get(c);l||(l=new Lo(this),a.set(c,l),l.recognizerName=ex[c]||c,o&&o.on(c,l.handleEvent)),l.add(e,r,i,s,n),l.isEmpty()||this._toggleRecognizer(l.recognizerName,!0)}_removeEventHandler(e,r){if(typeof e!="string"){for(let o in e)this._removeEventHandler(o,e[o]);return}let{events:i}=this,s=wd[e]||e,n=i.get(s);if(n&&(n.remove(e,r),n.isEmpty())){let{recognizerName:o}=n,a=!1;for(let c of i.values())if(c.recognizerName===o&&!c.isEmpty()){a=!0;break}a||this._toggleRecognizer(o,!1)}}};function Jr(){}var VC=({isDragging:t})=>t?"grabbing":"grab",px={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{type:"webgl"},gl:null,glOptions:{},canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:Jr,onWebGLInitialized:Jr,onResize:Jr,onViewStateChange:Jr,onInteractionStateChange:Jr,onBeforeRender:Jr,onAfterRender:Jr,onLoad:Jr,onError:t=>U.error(t.message,t.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:VC,getTooltip:null,debug:!1,drawPickingColors:!1},Ar=class{static{this.defaultProps=px}static{this.VERSION=Gg}constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new dt({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null},this._lastPointerDownInfo=null,this._onPointerMove=i=>{let{_pickRequest:s}=this;if(i.type==="pointerleave")s.x=-1,s.y=-1,s.radius=0;else{if(i.leftButton||i.rightButton)return;{let n=i.offsetCenter;if(!n)return;s.x=n.x,s.y=n.y,s.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:s.x,y:s.y}),s.event=i},this._onEvent=i=>{let s=Jn[i.type],n=i.offsetCenter;if(!s||!n||!this.layerManager)return;let o=this.layerManager.getLayers(),a=this.deckPicker.getLastPickedObject({x:n.x,y:n.y,layers:o,viewports:this.getViewports(n)},this._lastPointerDownInfo),{layer:c}=a,l=c&&(c[s.handler]||c.props[s.handler]),u=this.props[s.handler],f=!1;l&&(f=l.call(c,a,i)),f||(u?.(a,i),this.widgetManager.onEvent(a,i))},this._onPointerDown=i=>{let s=i.offsetCenter,n=this._pick("pickObject","pickObject Time",{x:s.x,y:s.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=n.result[0]||n.emptyInfo},this.props={...px,...e},e=this.props,e.viewState&&e.initialViewState&&U.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device?this.device=e.device:e.gl&&(e.gl instanceof WebGLRenderingContext&&U.error("WebGL1 context not supported.")(),this.device=Vi.attach(e.gl));let r=this.device;r||(dr.registerDevices([Vi]),r=dr.createDevice({...e.deviceProps,canvas:this._createCanvas(e)})),this.animationLoop=this._createAnimationLoop(r,e),this.setProps(e),e._typedArrayManagerProps&&Nt.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._lastPointerDownInfo=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&U.removed("onLayerHover","onHover")(),"onLayerClick"in e&&U.removed("onLayerClick","onClick")(),e.initialViewState&&!Le(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._setCanvasSize(this.props);let r=Object.create(this.props);Object.assign(r,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),this.animationLoop?.setProps(r),this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(e),s=this.layerManager.needsRedraw(e),n=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return r=r||i||s||n||o,r}redraw(e){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=e||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return oe(this.viewManager),this.viewManager.views}getViewports(e){return oe(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}pickObject(e){let r=this._pick("pickObject","pickObject Time",e).result;return r.length?r[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_addResources(e,r=!1){for(let i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:r})}_removeResources(e){for(let r of e)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_pick(e,r,i){oe(this.deckPicker);let{stats:s}=this;s.get("Pick Count").incrementCount(),s.get(r).timeStart();let n=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return s.get(r).timeEnd(),n}_createCanvas(e){let r=e.canvas;return typeof r=="string"&&(r=document.getElementById(r),oe(r)),r||(r=document.createElement("canvas"),r.id=e.id||"deckgl-overlay",(e.parent||document.body).appendChild(r)),Object.assign(r.style,e.style),r}_setCanvasSize(e){if(!this.canvas)return;let{width:r,height:i}=e;if(r||r===0){let s=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=s}if(i||i===0){let s=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=s}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let r=e.clientWidth??e.width,i=e.clientHeight??e.height;(r!==this.width||i!==this.height)&&(this.width=r,this.height=i,this.viewManager?.setProps({width:r,height:i}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:r,height:i}))}_createAnimationLoop(e,r){let{gl:i,onError:s,useDevicePixels:n}=r;return new ao({device:e,useDevicePixels:n,autoResizeDrawingBuffer:!i,autoResizeViewport:!1,onInitialize:o=>this._setDevice(o.device),onRender:this._onRenderFrame.bind(this),onError:s})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,r=Array.isArray(e)?e:e?[e]:[new qr({id:"default-view"})];return r.length&&this.props.controller&&(r[0].props.controller=this.props.controller),r}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let{result:r,emptyInfo:i}=this._pick("pickObject","pickObject Time",e);this.cursorState.isHovering=r.length>0;let s=i,n=!1;for(let o of r)s=o,n=o.layer?.onHover(o,e.event)||n;n||(this.props.onHover?.(s,e.event),this.widgetManager.onHover(s,e.event)),e.event=null}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas),this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device instanceof Vi&&this.props.onWebGLInitialized(this.device.gl);let r=new Ni;r.play(),this.animationLoop.attachTimeline(r),this.eventManager=new Os(this.props.parent||this.canvas,{touchAction:this.props.touchAction,recognizerOptions:this.props.eventRecognizerOptions,events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let s in Jn)this.eventManager.on(s,this._onEvent);this.viewManager=new fo({timeline:r,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let i=this.viewManager.getViewports()[0];this.layerManager=new uo(this.device,{deck:this,stats:this.stats,viewport:i,timeline:r}),this.effectManager=new xo({deck:this,device:this.device}),this.deckRenderer=new vo(this.device),this.deckPicker=new bo(this.device),this.widgetManager=new tl({deck:this,parentElement:this.canvas?.parentElement}),this.widgetManager.addDefault(new So),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,r){let{device:i,gl:s}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:s});let n={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...r};this.deckRenderer?.renderLayers(n),n.pass==="screen"&&this.widgetManager.onRedraw({viewports:n.viewports,layers:n.layers}),this.props.onAfterRender({device:i,gl:s})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),U.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let r=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:r},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let r=this.animationLoop.stats;e.get("GPU Time").addTime(r.get("GPU Time").lastTiming),e.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:r}=this;e.fps=r.get("frameRate").getHz(),e.setPropsTime=r.get("setProps Time").time,e.updateAttributesTime=r.get("Update Attributes").time,e.framesRedrawn=r.get("Redraw Count").count,e.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,e.pickCount=r.get("Pick Count").count,e.gpuTime=r.get("GPU Time").time,e.cpuTime=r.get("CPU Time").time,e.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let i=dr.stats.get("Memory Usage");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}};function gx(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Hn(t)}}var mx=pc;function ko(t,e){return{attribute:t,format:e.size>1?`${e.type}x${e.size}`:e.type,byteOffset:e.offset||0}}function Qr(t){return t.stride||t.size*t.bytesPerElement}function _x(t,e){return t.type===e.type&&t.size===e.size&&Qr(t)===Qr(e)&&(t.offset||0)===(e.offset||0)}function Rd(t,e){e.offset&&U.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=Qr(t),i=e.vertexOffset!==void 0?e.vertexOffset:t.vertexOffset||0,s=e.elementOffset||0,n=i*r+s*t.bytesPerElement+(t.offset||0);return{...e,offset:n,stride:r}}function WC(t,e){let r=Rd(t,e);return{high:r,low:{...r,offset:r.offset+t.size*4}}}var Bo=class{constructor(e,r,i){this._buffer=null,this.device=e,this.id=r.id||"",this.size=r.size||1;let s=r.logicalType||r.type,n=s==="float64",{defaultValue:o}=r;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;n?a="float32":!s&&r.isIndexed?a="uint32":a=s||"float32";let c=gx(s||a);this.doublePrecision=n,n&&r.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...r,defaultType:c,defaultValue:o,logicalType:s,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*Qr(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Nt.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,r=null){let i={};if(this.state.constant){let s=this.value;if(r){let n=Rd(this.getAccessor(),r),o=n.offset/s.BYTES_PER_ELEMENT,a=n.size||this.size;i[e]=s.subarray(o,o+a)}else i[e]=s}else i[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,r=null){let i=this.getAccessor(),s=[],n={name:this.id,byteStride:Qr(i),attributes:s};if(this.doublePrecision){let o=WC(i,r||{});s.push(ko(e,{...i,...o.high}),ko(`${e}64Low`,{...i,...o.low}))}else if(r){let o=Rd(i,r);s.push(ko(e,{...i,...o}))}else s.push(ko(e,i));return n}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let r=Array.from(this.value);e=[r,r]}else{let{value:r,numInstances:i,size:s}=this,n=i*s;if(r&&n&&r.length>=n){let o=new Array(s).fill(1/0),a=new Array(s).fill(-1/0);for(let c=0;ca[l]&&(a[l]=u)}e=[o,a]}}return this.state.bounds=e,e}setData(e){let{state:r}=this,i;ArrayBuffer.isView(e)?i={value:e}:e instanceof ie?i={buffer:e}:i=e;let s={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)s.type="float32";else{let o=mx(i.value);s.type=s.normalized?o.replace("int","norm"):o}s.bytesPerElement=i.value.BYTES_PER_ELEMENT,s.stride=Qr(s)}if(r.bounds=null,i.constant){let n=i.value;if(n=this._normalizeValue(n,[],0),this.settings.normalized&&(n=this.normalizeConstant(n)),!(!r.constant||!this._areValuesEqual(n,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(n)?n:new Float32Array(n)}else if(i.buffer){let n=i.buffer;r.externalBuffer=n,r.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let n=i.value;r.externalBuffer=null,r.constant=!1,this.value=n;let{buffer:o}=this,a=Qr(s),c=(s.vertexOffset||0)*a;if(this.doublePrecision&&n instanceof Float64Array&&(n=Kc(n,s)),this.settings.isIndexed){let u=this.settings.defaultType;n.constructor!==u&&(n=new u(n))}let l=n.byteLength+c+a*2;(!o||o.byteLength(r+128)/255*2-1);case"snorm16":return new Float32Array(e).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(r=>r/255);case"unorm16":return new Float32Array(e).map(r=>r/65535);default:return e}}_normalizeValue(e,r,i){let{defaultValue:s,size:n}=this.settings;if(Number.isFinite(e))return r[i]=e,r;if(!e){let o=n;for(;--o>=0;)r[i+o]=s[o];return r}switch(n){case 4:r[i+3]=Number.isFinite(e[3])?e[3]:s[3];case 3:r[i+2]=Number.isFinite(e[2])?e[2]:s[2];case 2:r[i+1]=Number.isFinite(e[1])?e[1]:s[1];case 1:r[i+0]=Number.isFinite(e[0])?e[0]:s[0];break;default:let o=n;for(;--o>=0;)r[i+o]=Number.isFinite(e[o])?e[o]:s[o]}return r}_areValuesEqual(e,r){if(!e||!r)return!1;let{size:i}=this;for(let s=0;s0&&(xx.length=t.length,i=xx):i=yx,(e>0||Number.isFinite(r))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,r),s.index=e-1),{iterable:i,objectInfo:s}}function wl(t){return t&&t[Symbol.asyncIterator]}function Pl(t,e){let{size:r,stride:i,offset:s,startIndices:n,nested:o}=e,a=t.BYTES_PER_ELEMENT,c=i?i/a:r,l=s?s/a:0,u=Math.floor((t.length-l)/c);return(f,{index:h,target:d})=>{if(!n){let x=h*c+l;for(let v=0;v=e[1]))return t;let r=[],i=t.length,s=0;for(let n=0;ne[1]?r.push(o):e=[Math.min(o[0],e[0]),Math.max(o[1],e[1])]}return r.splice(s,0,e),r}var jC={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function Rl(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});let r=t.type||"interpolation";return{...jC[r],...e,...t,type:r}}var ji=class extends Bo{constructor(e,r){super(e,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:Uo}),this.constant=!1,this.settings.update=r.update||(r.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let r=this.state.needsRedraw;return this.state.needsRedraw=r&&!e,r}layoutChanged(){return this.state.layoutChanged}setAccessor(e){this.state.layoutChanged||=!_x(e,this.getAccessor()),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:r}=this.settings,i=this.settings.transition,s=Array.isArray(r)?e[r.find(n=>e[n])]:e[r];return Rl(s,i)}setNeedsUpdate(e=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),r){let{startRow:i=0,endRow:s=1/0}=r;this.state.updateRanges=vx(this.state.updateRanges,[i,s])}else this.state.updateRanges=Uo}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=Tx}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:r,settings:i}=this;return i.noAlloc?!1:i.update?(super.allocate(e,r.updateRanges!==Uo),!0):!1}updateBuffer({numInstances:e,data:r,props:i,context:s}){if(!this.needsUpdate())return!1;let{state:{updateRanges:n},settings:{update:o,noAlloc:a}}=this,c=!0;if(o){for(let[l,u]of n)o.call(s,this,{data:r,startRow:l,endRow:u,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthu?l.set(b,g):(e._normalizeValue(b,x.target,0),id({target:l,source:x.target,start:g,count:A}));g+=A*u}else e._normalizeValue(b,l,g),g+=u}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,r=Math.min(4,this.size);if(e&&e.length>=r){let i=!0;switch(r){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function Cd(t){let{source:e,target:r,start:i=0,size:s,getData:n}=t,o=t.end||r.length,a=e.length,c=o-i;if(a>c){r.set(e.subarray(0,c),i);return}if(r.set(e,i),!n)return;let l=a;for(;li(u+a,f)),l=Math.min(s.length,n.length);for(let u=1;ua}){let a=r.doublePrecision&&r.value instanceof Float64Array?2:1,c=r.size*a,l=r.byteOffset,u=r.settings.bytesPerElement<4?l/r.settings.bytesPerElement*4:l,f=r.startIndices,h=n&&f,d=r.isConstant;if(!h&&e&&i>=s)return e;let p=r.value instanceof Float64Array?Float32Array:r.value.constructor,g=d?r.value:new p(r.getBuffer().readSyncWebGL(l,s*p.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!d){let b=o;o=(A,C)=>r.normalizeConstant(b(A,C))}let _=d?(b,A)=>o(g,A):(b,A)=>o(g.subarray(b+l,b+l+c),A),x=e?new Float32Array(e.readSyncWebGL(u,i*4).buffer):new Float32Array(0),v=new Float32Array(s);return bx({source:x,target:v,sourceStartIndices:n,targetStartIndices:f,size:c,getData:_}),(!e||e.byteLength0||s.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},KC=`#version 300 es +#define SHADER_NAME spring-transition-vertex-shader + +#define EPSILON 0.00001 + +uniform float stiffness; +uniform float damping; +in ATTRIBUTE_TYPE aPrev; +in ATTRIBUTE_TYPE aCur; +in ATTRIBUTE_TYPE aTo; +out ATTRIBUTE_TYPE vNext; +out float vIsTransitioningFlag; + +ATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) { + ATTRIBUTE_TYPE velocity = cur - prev; + ATTRIBUTE_TYPE delta = dest - cur; + ATTRIBUTE_TYPE spring = delta * stiffness; + ATTRIBUTE_TYPE damper = velocity * -1.0 * damping; + return spring + damper + velocity + cur; +} + +void main(void) { + bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON; + vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0; + + vNext = getNextValue(aCur, aPrev, aTo); + gl_Position = vec4(0, 0, 0, 1); + gl_PointSize = 100.0; +} +`,qC=`#version 300 es +#define SHADER_NAME spring-transition-is-transitioning-fragment-shader + +in float vIsTransitioningFlag; + +out vec4 fragColor; + +void main(void) { + if (vIsTransitioningFlag == 0.0) { + discard; + } + fragColor = vec4(1.0); +}`;function GC(t,e){let r=Cl(e.size),i=Ml(e.size);return new Xr(t,{vs:KC,fs:qC,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function ZC(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",mipmaps:!1,width:1,height:1})}function JC(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var QC={interpolation:zo,spring:Vo},Wo=class{constructor(e,{id:r,timeline:i}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:r,numInstances:i}){this.numInstances=i||1;for(let s in e){let n=e[s],o=n.getTransitionSetting(r);o&&this._updateAttribute(s,n,o)}for(let s in this.transitions){let n=e[s];(!n||!n.getTransitionSetting(r))&&this._removeTransition(s)}}hasAttribute(e){let r=this.transitions[e];return r&&r.inProgress}getAttributes(){let e={};for(let r in this.transitions){let i=this.transitions[r];i.inProgress&&(e[r]=i.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,r,i){let s=this.transitions[e],n=!s||s.type!==i.type;if(n){s&&this._removeTransition(e);let o=QC[i.type];o?this.transitions[e]=new o({attribute:r,timeline:this.timeline,device:this.device}):(U.error(`unsupported transition type '${i.type}'`)(),n=!1)}(n||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}};var wx="attributeManager.invalidate",eM="attributeManager.updateStart",tM="attributeManager.updateEnd",rM="attribute.updateStart",iM="attribute.allocate",sM="attribute.updateEnd",nr=class{constructor(e,{id:r="attribute-manager",stats:i,timeline:s}={}){this.mergeBoundsMemoized=Qt(B_),this.id=r,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new Wo(e,{id:`${r}-transitions`,timeline:s}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let r of e)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(e,r){let i=this._invalidateTrigger(e,r);xe(wx,this,e,i)}invalidateAll(e){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,e);xe(wx,this,"all")}update({data:e,numInstances:r,startIndices:i=null,transitions:s,props:n={},buffers:o={},context:a={}}){let c=!1;xe(eM,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let u=this.attributes[l],f=u.settings.accessor;u.startIndices=i,u.numInstances=r,n[l]&&U.removed(`props.${l}`,`data.attributes.${l}`)(),u.setExternalBuffer(o[l])||u.setBinaryValue(typeof f=="string"?o[f]:void 0,e.startIndices)||typeof f=="string"&&!o[f]&&u.setConstantValue(n[f])||u.needsUpdate()&&(c=!0,this._updateAttribute({attribute:u,numInstances:r,data:e,props:n,context:a})),this.needsRedraw=this.needsRedraw||u.needsRedraw()}c&&xe(tM,this,r),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:s})}updateTransition(){let{attributeTransitionManager:e}=this,r=e.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let r=e.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:i}=this,s={...i.getAttributes()};for(let n in r){let o=r[n];o.needsRedraw(e)&&!i.hasAttribute(n)&&(s[n]=o)}return s}getBufferLayouts(e){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(e))}_add(e,r){for(let i in e){let s=e[i],n={...s,id:i,size:s.isIndexed&&1||s.size||1,...r};this.attributes[i]=new ji(this.device,n)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(s=>{e[s]||(e[s]=[]),e[s].push(r)});this.updateTriggers=e}_invalidateTrigger(e,r){let{attributes:i,updateTriggers:s}=this,n=s[e];return n&&n.forEach(o=>{let a=i[o];a&&a.setNeedsUpdate(a.id,r)}),n}_updateAttribute(e){let{attribute:r,numInstances:i}=e;if(xe(rM,r),r.constant){r.setConstantValue(r.value);return}r.allocate(i)&&xe(iM,r,i),r.updateBuffer(e)&&(this.needsRedraw=!0,xe(sM,r,i))}};var Ho=class extends Dt{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:r,toValue:i,duration:s,easing:n}}=this,o=n(e/s);this._value=Ct(r,i,o)}};var Px=1e-5;function Rx(t,e,r,i,s){let n=e-t,a=(r-e)*s,c=-n*i;return a+c+n+e}function nM(t,e,r,i,s){if(Array.isArray(r)){let n=[];for(let o=0;o0}add(e,r,i,s){let{transitions:n}=this;if(n.has(e)){let c=n.get(e),{value:l=c.settings.fromValue}=c;r=l,this.remove(e)}if(s=Rl(s),!s)return;let o=oM[s.type];if(!o){U.error(`unsupported transition type '${s.type}'`)();return}let a=new o(this.timeline);a.start({...s,fromValue:r,toValue:i}),n.set(e,a)}remove(e){let{transitions:r}=this;r.has(e)&&(r.get(e).cancel(),r.delete(e))}update(){let e={};for(let[r,i]of this.transitions)i.update(),e[r]=i.value,i.inProgress||this.remove(r);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function Ix(t){let e=t[vt];for(let r in e){let i=e[r],{validate:s}=i;if(s&&!s(t[r],i))throw new Error(`Invalid prop ${r}: ${t[r]}`)}}function Ox(t,e){let r=$o({newProps:t,oldProps:e,propTypes:t[vt],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=cM(t,e),s=!1;return i||(s=lM(t,e)),{dataChanged:i,propsChanged:r,updateTriggersChanged:s,extensionsChanged:uM(t,e),transitionsChanged:aM(t,e)}}function aM(t,e){if(!t.transitions)return!1;let r={},i=t[vt],s=!1;for(let n in t.transitions){let o=i[n],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&Md(t[n],e[n],o)&&(r[n]=!0,s=!0)}return s?r:!1}function $o({newProps:t,oldProps:e,ignoreProps:r={},propTypes:i={},triggerName:s="props"}){if(e===t)return!1;if(typeof t!="object"||t===null)return`${s} changed shallowly`;if(typeof e!="object"||e===null)return`${s} changed shallowly`;for(let n of Object.keys(t))if(!(n in r)){if(!(n in e))return`${s}.${n} added`;let o=Md(t[n],e[n],i[n]);if(o)return`${s}.${n} ${o}`}for(let n of Object.keys(e))if(!(n in r)){if(!(n in t))return`${s}.${n} dropped`;if(!Object.hasOwnProperty.call(t,n)){let o=Md(t[n],e[n],i[n]);if(o)return`${s}.${n} ${o}`}}return!1}function Md(t,e,r){let i=r&&r.equal;return i&&!i(t,e,r)||!i&&(i=t&&e&&t.equals,i&&!i.call(t,e))?"changed deeply":!i&&e!==t?"changed shallowly":null}function cM(t,e){if(e===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:i,_dataDiff:s}=t;return i?i(t.data,e.data)||(r="Data comparator detected a change"):t.data!==e.data&&(r="A new data container was supplied"),r&&s&&(r=s(t.data,e.data)||r),r}function lM(t,e){if(e===null)return{all:!0};if("all"in t.updateTriggers&&Mx(t,e,"all"))return{all:!0};let r={},i=!1;for(let s in t.updateTriggers)s!=="all"&&Mx(t,e,s)&&(r[s]=!0,i=!0);return i?r:!1}function uM(t,e){if(e===null)return!0;let r=e.extensions,{extensions:i}=t;if(i===r)return!1;if(!r||!i||i.length!==r.length)return!0;for(let s=0;si.name==="project64"))){let i=r.modules.findIndex(s=>s.name==="project32");i>=0&&r.modules.splice(i,1)}if("inject"in e)if(!t.inject)r.inject=e.inject;else{let i={...t.inject};for(let s in e.inject)i[s]=(i[s]||"")+e.inject[s];r.inject=i}return r}var gM={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Id={};function Fx(t,e,r,i){if(r instanceof Ae)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let s=null;r.compressed&&(s={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let n=e.createTexture({...r,sampler:{...gM,...s,...i}});return Id[n.id]=t,n}function Dx(t,e){!e||!(e instanceof Ae)||Id[e.id]===t&&(e.delete(),delete Id[e.id])}var mM={boolean:{validate(t,e){return!0},equal(t,e,r){return!!t==!!e}},number:{validate(t,e){return Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)}},color:{validate(t,e){return e.optional&&!t||Od(t)&&(t.length===3||t.length===4)},equal(t,e,r){return Le(t,e,1)}},accessor:{validate(t,e){let r=Fl(t);return r==="function"||r===Fl(e.value)},equal(t,e,r){return typeof e=="function"?!0:Le(t,e,1)}},array:{validate(t,e){return e.optional&&!t||Od(t)},equal(t,e,r){let{compare:i}=r,s=Number.isInteger(i)?i:i?1:0;return i?Le(t,e,s):t===e}},object:{equal(t,e,r){if(r.ignore)return!0;let{compare:i}=r,s=Number.isInteger(i)?i:i?1:0;return i?Le(t,e,s):t===e}},function:{validate(t,e){return e.optional&&!t||typeof t=="function"},equal(t,e,r){return!r.compare&&r.ignore!==!1||t===e}},data:{transform:(t,e,r)=>{if(!t)return t;let{dataTransform:i}=r.props;return i?i(t):typeof t.shape=="string"&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(t,e,r)=>{let i=r.context;return!i||!i.device?null:Fx(r.id,i.device,t,{...e.parameters,...r.props.textureParameters})},release:(t,e,r)=>{Dx(r.id,t)}}};function Lx(t){let e={},r={},i={};for(let[s,n]of Object.entries(t)){let o=n?.deprecatedFor;if(o)i[s]=Array.isArray(o)?o:[o];else{let a=_M(s,n);e[s]=a,r[s]=a.value}}return{propTypes:e,defaultProps:r,deprecatedProps:i}}function _M(t,e){switch(Fl(e)){case"object":return Yo(t,e);case"array":return Yo(t,{type:"array",value:e,compare:!1});case"boolean":return Yo(t,{type:"boolean",value:e});case"number":return Yo(t,{type:"number",value:e});case"function":return Yo(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function Yo(t,e){return"type"in e?{name:t,...mM[e.type],...e}:"value"in e?{name:t,type:Fl(e.value),...e}:{name:t,type:"object",value:e}}function Od(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function Fl(t){return Od(t)?"array":t===null?"null":typeof t}function kx(t,e){let r;for(let n=e.length-1;n>=0;n--){let o=e[n];"extensions"in o&&(r=o.extensions)}let i=Nd(t.constructor,r),s=Object.create(i);s[ws]=t,s[tr]={},s[Ft]={};for(let n=0;n{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let r=this.asyncProps[e];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||wM}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let r=this.asyncProps[e];return r&&r.resolvedValue}isAsyncPropLoading(e){if(e){let r=this.asyncProps[e];return!!(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(e,r){this._watchPromise(e,Promise.resolve(r))}setAsyncProps(e){this.component=e[ws]||this.component;let r=e[Ft]||{},i=e[tr]||e,s=e[Tr]||{};for(let n in r){let o=r[n];this._createAsyncPropData(n,s[n]),this._updateAsyncProp(n,o),r[n]=this.getAsyncProp(n)}for(let n in i){let o=i[n];this._createAsyncPropData(n,s[n]),this._updateAsyncProp(n,o)}}_fetch(e,r){return null}_onResolve(e,r){}_onError(e,r){}_updateAsyncProp(e,r){if(this._didAsyncInputValueChange(e,r)){if(typeof r=="string"&&(r=this._fetch(e,r)),r instanceof Promise){this._watchPromise(e,r);return}if(wl(r)){this._resolveAsyncIterable(e,r);return}this._setPropValue(e,r)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,r){let i=this.asyncProps[e];return r===i.resolvedValue||r===i.lastValue?!1:(i.lastValue=r,!0)}_setPropValue(e,r){this._freezeAsyncOldProps();let i=this.asyncProps[e];i&&(r=this._postProcessValue(i,r),i.resolvedValue=r,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,r,i){let s=this.asyncProps[e];s&&i>=s.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),s.resolvedValue=r,s.resolvedLoadCount=i,this.onAsyncPropUpdated(e,r))}_watchPromise(e,r){let i=this.asyncProps[e];if(i){i.pendingLoadCount++;let s=i.pendingLoadCount;r.then(n=>{this.component&&(n=this._postProcessValue(i,n),this._setAsyncPropValue(e,n,s),this._onResolve(e,n))}).catch(n=>{this._onError(e,n)})}}async _resolveAsyncIterable(e,r){if(e!=="data"){this._setPropValue(e,r);return}let i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;let s=i.pendingLoadCount,n=[],o=0;for await(let a of r){if(!this.component)return;let{dataTransform:c}=this.component.props;c?n=c(a,n):n=n.concat(a),Object.defineProperty(n,"__diff",{enumerable:!1,value:[{startRow:o,endRow:n.length}]}),o=n.length,this._setAsyncPropValue(e,n,s)}this._onResolve(e,n)}_postProcessValue(e,r){let i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(r,i,this.component):r}_createAsyncPropData(e,r){if(!this.asyncProps[e]){let s=this.component&&this.component.props[vt];this.asyncProps[e]={type:s&&s[e],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var Go=class extends qo{constructor({attributeManager:e,layer:r}){super(r),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,r){let i=this.layer,s=i?.props.fetch;return s?s(r,{propName:e,layer:i}):super._fetch(e,r)}_onResolve(e,r){let i=this.layer;if(i){let s=i.props.onDataLoad;e==="data"&&s&&s(r,{propName:e,layer:i})}}_onError(e,r){let i=this.layer;i&&i.raiseError(r,`loading ${e} of ${this.layer}`)}};var PM="layer.changeFlag",RM="layer.initialize",CM="layer.update",MM="layer.finalize",IM="layer.matched",Ux=2**24-1,OM=Object.freeze([]),NM=Qt(({oldViewport:t,viewport:e})=>t.equals(e)),or=new Uint8ClampedArray(0),FM={data:{type:"data",value:OM,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(t,{propName:e,layer:r,loaders:i,loadOptions:s,signal:n})=>{let{resourceManager:o}=r.context;s=s||r.getLoadOptions(),i=i||r.props.loaders,n&&(s={...s,fetch:{...s?.fetch,signal:n}});let a=o.contains(t);return!a&&!s&&(o.add({resourceId:t,data:Lr(t,i),persistent:!1}),a=!0),a?o.subscribe({resourceId:t,onChange:c=>r.internalState?.reloadAsyncProp(e,c),consumerId:r.id,requestId:e}):Lr(t,i,s)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:q.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,-t*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},ne=class extends Ko{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Yr.NO_STATE,this.parent=null}static{this.defaultProps=FM}static{this.layerName="Layer"}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){oe(this.internalState);let r=this.internalState.viewport||this.context.viewport,i=td(e,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[s,n,o]=vs(i,r.pixelProjectionMatrix);return e.length===2?[s,n]:[s,n,o]}unproject(e){return oe(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,r){oe(this.internalState);let i=this.internalState.viewport||this.context.viewport;return V_(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}get isComposite(){return!1}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setModuleParameters(e){for(let r of this.getModels())r.updateModuleSettings(e)}setShaderModuleProps(...e){for(let r of this.getModels())r.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e===q.DEFAULT||e===q.LNGLAT||e===q.CARTESIAN}onHover(e,r){return this.props.onHover&&this.props.onHover(e,r)||!1}onClick(e,r){return this.props.onClick&&this.props.onClick(e,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,r=[]){return r[0]=e+1&255,r[1]=e+1>>8&255,r[2]=e+1>>8>>8&255,r}decodePickingColor(e){oe(e instanceof Uint8Array);let[r,i,s]=e;return r+i*256+s*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:Nx(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=Fs(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)e=Fs(e,r.getShaders.call(this,r));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let r=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&r)if(Array.isArray(i))for(let s of i)r.invalidateAll(s);else r.invalidateAll();if(r){let{props:s}=e,n=this.internalState.hasPickingBuffer,o=Number.isInteger(s.highlightedObjectIndex)||s.pickable||s.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(n!==o){this.internalState.hasPickingBuffer=o;let{pickingColors:a,instancePickingColors:c}=r.attributes,l=a||c;l&&(o&&l.constant&&(l.constant=!1,r.invalidate(l.id)),!l.value&&!o&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(e){for(let i of this.getModels())i.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let r of this.getModels())r.draw(e)}getPickingInfo({info:e,mode:r,sourceLayer:i}){let{index:s}=e;return s>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[s]),e}raiseError(e,r){r&&(e=new Error(`${r}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let r=this.internalState.viewport;this.internalState.viewport=e,(!r||!NM({oldViewport:r,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let r=this.getAttributeManager();r&&(e==="all"?r.invalidateAll():r.invalidate(e))}updateAttributes(e){let r=!1;for(let i in e)e[i].layoutChanged()&&(r=!0);for(let i of this.getModels())this._setModelAttributes(i,e,r)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let r=this.props,i=this.getNumInstances(),s=this.getStartIndices();e.update({data:r.data,numInstances:i,startIndices:s,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let n=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(n)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let r=e.update(),i=Object.create(this.props);for(let s in r)Object.defineProperty(i,s,{value:r[s]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:r}){if(e.constant)return;let i=Math.floor(or.length/4);if(this.internalState.usesPickingColorCache=!0,iUx&&U.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),or=Nt.allocate(or,r,{size:4,copy:!0,maxCount:Math.max(r,Ux)});let s=Math.floor(or.length/4),n=[];for(let o=i;o(U.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new Xo(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){xe(IM,this,this===e);let{state:r,internalState:i}=e;this!==e&&(this.internalState=i,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(xe(CM,this,e),!e)return;let r=this.props,i=this.context,s=this.internalState,n=i.viewport,o=this._updateUniformTransition();s.propsInTransition=o,i.viewport=s.viewport||n,this.props=o;try{let a=this._getUpdateParams(),c=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let u of this.props.extensions)u.updateState.call(this,a,u);let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{i.viewport=n,this.props=r,this._clearChangeFlags(),s.needsUpdate=!1,s.resetOldProps()}}_finalize(){xe(MM,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,moduleParameters:r=null,uniforms:i={},parameters:s={}}){this._updateAttributeTransition();let n=this.props,o=this.context;this.props=this.internalState.propsInTransition||n;let a=this.props.opacity;i.opacity=Math.pow(a,1/2.2);try{if(r){let{isActive:u,isAttribute:f}=r.picking;this.setModuleParameters(r),this.setShaderModuleProps({picking:{isActive:u,isAttribute:f}})}let{getPolygonOffset:c}=this.props,l=c&&c(i)||[0,0];o.device.setParametersWebGL({polygonOffset:l});for(let u of this.getModels())u.setParameters(s);o.device.withParametersWebGL(s,()=>{let u={renderPass:e,moduleParameters:r,uniforms:i,parameters:s,context:o};for(let f of this.props.extensions)f.draw.call(this,u,f);this.draw(u)})}finally{this.props=n}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let s in e)if(e[s]){let n=!1;switch(s){case"dataChanged":let o=e[s],a=r[s];o&&Array.isArray(a)&&(r.dataChanged=Array.isArray(o)?a.concat(o):o,n=!0);default:r[s]||(r[s]=e[s],n=!0)}n&&xe(PM,this,s,e)}let i=!!(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=i,r.somethingChanged=i||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,r){let i=Ox(e,r);if(i.updateTriggersChanged)for(let s in i.updateTriggersChanged)i.updateTriggersChanged[s]&&this.invalidateAttribute(s);if(i.transitionsChanged)for(let s in i.transitionsChanged)this.internalState.uniformTransitions.add(s,r[s],e[s],e.transitions?.[s]);return this.setChangeFlags(i)}validateProps(){Ix(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let r={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&typeof i=="function"&&(r.highlightColor=i(e)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new nr(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,r){let{props:i,oldProps:s}=e;this.setNeedsRedraw(),this._updateAttributes();let n=this.state.model;n?.isInstanced&&n.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=i;if(r||s.autoHighlight!==o||s.highlightedObjectIndex!==a||s.highlightColor!==c){let l={};o||(l.highlightedObjectColor=null),Array.isArray(c)&&(l.highlightColor=c),(r||a!==s.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let r=!1;r=r||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),s=i?i.getNeedsRedraw(e):!1;if(r=r||s,r)for(let n of this.props.extensions)n.onNeedsRedraw.call(this,n);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};var DM="compositeLayer.renderLayers",et=class extends ne{static{this.layerName="CompositeLayer"}get isComposite(){return!0}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:r}=e;return r&&r.__source&&r.__source.parent&&r.__source.parent.id===this.id&&(e.object=r.__source.object,e.index=r.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,r){return r&&r.length}getSubLayerClass(e,r){let{_subLayerProps:i}=this.props;return i&&i[e]&&i[e].type||r}getSubLayerRow(e,r,i){return e.__source={parent:this,object:r,index:i},e}getSubLayerAccessor(e){if(typeof e=="function"){let r={index:-1,data:this.props.data,target:[]};return(i,s)=>i&&i.__source?(r.index=i.__source.index,e(i.__source.object,r)):e(i,s)}return e}getSubLayerProps(e={}){let{opacity:r,pickable:i,visible:s,parameters:n,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:f,wrapLongitude:h,positionFormat:d,modelMatrix:p,extensions:g,fetch:_,operation:x,_subLayerProps:v}=this.props,b={id:"",updateTriggers:{},opacity:r,pickable:i,visible:s,parameters:n,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:f,wrapLongitude:h,positionFormat:d,modelMatrix:p,extensions:g,fetch:_,operation:x},A=v&&e.id&&v[e.id],C=A&&A.updateTriggers,M=e.id||"sublayer";if(A){let F=this.props[vt],N=e.type?e.type._propTypes:{};for(let D in A){let L=N[D]||F[D];L&&L.type==="accessor"&&(A[D]=this.getSubLayerAccessor(A[D]))}}Object.assign(b,e,A),b.id=`${this.props.id}-${M}`,b.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...C};for(let F of g){let N=F.getSubLayerProps.call(this,F);N&&Object.assign(b,N,{updateTriggers:Object.assign(b.updateTriggers,N.updateTriggers)})}return b}_updateAutoHighlight(e){for(let r of this.getSubLayers())r.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,r){let i=this.internalState.subLayers,s=!i||this.needsUpdate();if(s){let n=this.renderLayers();i=bt(n,Boolean),this.internalState.subLayers=i}xe(DM,this,s,i);for(let n of i)n.parent=this}};var ei=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=e;this.typedArrayManager=Nt,this.attributes={},this._attributeDefs=r,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:r,buffers:i={},getGeometry:s,geometryBuffer:n,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=r,this.getGeometry=s,this.positionSize=n&&n.size||(o==="XY"?2:3),this.buffers=i,this.normalize=c,n&&(oe(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(n),c||(i.vertexPositions=n)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:r}){this._rebuildGeometry({startRow:e,endRow:r})}getGeometryFromBuffer(e){let r=e.value||e;return ArrayBuffer.isView(r)?Pl(r,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,r){let{attributes:i,buffers:s,_attributeDefs:n,typedArrayManager:o}=this;for(let a in n)if(a in s)o.release(i[a]),i[a]=null;else{let c=n[a];c.copy=r,i[a]=o.allocate(i[a],e,c)}}_forEachGeometry(e,r,i){let{data:s,getGeometry:n}=this,{iterable:o,objectInfo:a}=$e(s,r,i);for(let c of o){a.index++;let l=n?n(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:r,vertexStarts:i,instanceCount:s}=this,{data:n,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(r=[0],i=[0]),this.normalize||!o)this._forEachGeometry((f,h)=>{let d=f&&this.normalizeGeometry(f);l[h]=d,i[h+1]=i[h]+(d?this.getGeometrySize(d):0)},a,c),s=i[i.length-1];else if(i=n.startIndices,s=i[n.length]||0,ArrayBuffer.isView(o))s=s||o.length/this.positionSize;else if(o instanceof ie){let f=this.positionSize*4;s=s||o.byteLength/f}else if(o.buffer){let f=o.stride||this.positionSize*4;s=s||o.buffer.byteLength/f}else if(o.value){let f=o.value,h=o.stride/f.BYTES_PER_ELEMENT||this.positionSize;s=s||f.length/h}this._allocate(s,!!e),this.indexStarts=r,this.vertexStarts=i,this.instanceCount=s;let u={};this._forEachGeometry((f,h)=>{let d=l[h]||f;u.vertexStart=i[h],u.indexStart=r[h];let p=h{t.triggerRepaint(),i?.("")}}),o;return(!r||r.props.gl===e)&&(Object.assign(n,{gl:e,width:null,height:null,touchAction:"unset",viewState:Ds(t)}),r?.isInitialized?zx(r,t):n.onLoad=()=>{s?.(),zx(o,t)}),r?(o=r,r.setProps(n),r.userData.isExternal=!0):(o=new Ar(n),t.on("remove",()=>{Ld(t)})),o.userData.mapboxLayers=new Set,t.__deck=o,t.on("render",()=>{o.isInitialized&&BM(o,t)}),o}function zx(t,e){let r=()=>{t.isInitialized?UM(t,e):e.off("move",r)};e.on("move",r)}function Ld(t){t.__deck?.finalize(),t.__deck=null}function kd(t){return{...t,parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774,...t.parameters},views:t.views||[new qr({id:"mapbox"})]}}function Vx(t,e){t.userData.mapboxLayers.add(e),Bd(t)}function Wx(t,e){t.userData.mapboxLayers.delete(e),Bd(t)}function Hx(t,e){Bd(t)}function jx(t,e,r){let{currentViewport:i}=t.userData,s=!1;i||(i=Xx(t,e,!0),t.userData.currentViewport=i,s=!0),t.isInitialized&&t._drawLayers("mapbox-repaint",{viewports:[i],layerFilter:({layer:n})=>r.id===n.id||n.props.operation.includes("terrain"),clearStack:s,clearCanvas:!1})}function Ds(t){let{lng:e,lat:r}=t.getCenter(),i={longitude:(e+540)%360-180,latitude:r,zoom:t.getZoom(),bearing:t.getBearing(),pitch:t.getPitch(),padding:t.getPadding(),repeat:t.getRenderWorldCopies()};return t.getTerrain?.()&&kM(t,i),i}function kM(t,e){if(t.getFreeCameraOptions){let{position:r}=t.getFreeCameraOptions();if(!r||r.z===void 0)return;let i=t.transform.height,{longitude:s,latitude:n,pitch:o}=e,a=r.x*Dd,c=(1-r.y)*Dd,l=r.z*Dd,u=Ze([s,n]),f=a-u[0],h=c-u[1],d=Math.sqrt(f*f+h*h),p=o*LM,g=1.5*i,_=p<.001?g*Math.cos(p)/l:g*Math.sin(p)/d;e.zoom=Math.log2(_);let x=g*Math.cos(p)/_,v=l-x;e.position=[0,0,v/Mi(n)]}else typeof t.transform.elevation=="number"&&(e.position=[0,0,t.transform.elevation])}function Xx(t,e,r=!0){return new er({id:"mapbox",x:0,y:0,width:t.width,height:t.height,...Ds(e),nearZMultiplier:r?.02:.1,nearZ:e.transform._nearZ/e.transform.height,farZ:e.transform._farZ/e.transform.height})}function BM(t,e){let{mapboxLayers:r,isExternal:i}=t.userData;if(i){let s=Array.from(r,u=>u.id),o=bt(t.props.layers,Boolean).some(u=>u&&!s.includes(u.id)),a=t.getViewports(),c=a.findIndex(u=>u.id==="mapbox"),l=a.length>1||c<0;(o||l)&&(c>=0&&(a=a.slice(),a[c]=Xx(t,e,!1)),t._drawLayers("mapbox-repaint",{viewports:a,layerFilter:u=>(!t.props.layerFilter||t.props.layerFilter(u))&&(u.viewport.id!=="mapbox"||!s.includes(u.layer.id)),clearCanvas:!1}))}t.userData.currentViewport=null}function UM(t,e){t.setProps({viewState:Ds(e)}),t.needsRedraw({clearRedrawFlags:!0})}function Bd(t){if(t.userData.isExternal)return;let e=[];t.userData.mapboxLayers.forEach(r=>{let i=r.props.type,s=new i(r.props);e.push(s)}),t.setProps({layers:e})}var Zo=class{constructor(e){if(!e.id)throw new Error("Layer must have an unique id");this.id=e.id,this.type="custom",this.renderingMode=e.renderingMode||"3d",this.map=null,this.deck=null,this.props=e}onAdd(e,r){this.map=e,this.deck=Dl({map:e,gl:r,deck:this.props.deck}),Vx(this.deck,this)}onRemove(){this.deck&&Wx(this.deck,this)}setProps(e){Object.assign(this.props,e,{id:this.id}),this.deck&&Hx(this.deck,this)}render(){jx(this.deck,this.map,this)}};var Ud="__UNDEFINED__";function Jo(t,e,r,i){if(!t||!e||!t.style||!t.style._loaded)return;let s=bt(i,Boolean);if(r!==i){let a=bt(r,Boolean),c=new Set(a.map(l=>l.id));for(let l of s)c.delete(l.id);for(let l of c)t.getLayer(l)&&t.removeLayer(l)}for(let a of s){let c=t.getLayer(a.id);c?c.implementation.setProps(a.props):t.addLayer(new Zo({id:a.id,deck:e}),a.props.beforeId)}let n=t.style._order,o={};for(let a of s){let{beforeId:c}=a.props;(!c||!n.includes(c))&&(c=Ud),o[c]=o[c]||[],o[c].push(a.id)}for(let a in o){let c=o[a],l=a===Ud?n.length:n.indexOf(a),u=a===Ud?void 0:a;for(let f=c.length-1;f>=0;f--){let h=c[f],d=n.indexOf(h);d!==l-1&&(t.moveLayer(h,u),d>l&&l++),l--,u=h}}}var Ls=class{constructor(e){this._handleStyleChange=()=>{Jo(this._map,this._deck,this._props.layers,this._props.layers)},this._updateContainerSize=()=>{if(this._map&&this._container){let{clientWidth:s,clientHeight:n}=this._map.getContainer();Object.assign(this._container.style,{width:`${s}px`,height:`${n}px`})}},this._updateViewState=()=>{let s=this._deck;s&&(s.setProps({viewState:Ds(this._map)}),s.isInitialized&&s.redraw())},this._handleMouseEvent=s=>{let n=this._deck;if(!n||!n.isInitialized)return;let o={type:s.type,offsetCenter:s.point,srcEvent:s},a=this._lastMouseDownPoint;switch(!s.point&&a&&(o.deltaX=s.originalEvent.clientX-a.clientX,o.deltaY=s.originalEvent.clientY-a.clientY,o.offsetCenter={x:a.x+o.deltaX,y:a.y+o.deltaY}),o.type){case"mousedown":n._onPointerDown(o),this._lastMouseDownPoint={...s.point,clientX:s.originalEvent.clientX,clientY:s.originalEvent.clientY};break;case"dragstart":o.type="panstart",n._onEvent(o);break;case"drag":o.type="panmove",n._onEvent(o);break;case"dragend":o.type="panend",n._onEvent(o);break;case"click":o.tapCount=1,n._onEvent(o);break;case"dblclick":o.type="click",o.tapCount=2,n._onEvent(o);break;case"mousemove":o.type="pointermove",n._onPointerMove(o);break;case"mouseout":o.type="pointerleave",n._onPointerMove(o);break;default:return}};let{interleaved:r=!1,...i}=e;this._interleaved=r,this._props=i}setProps(e){this._interleaved&&e.layers&&Jo(this._map,this._deck,this._props.layers,e.layers),Object.assign(this._props,e),this._deck&&this._deck.setProps(this._interleaved?kd(this._props):this._props)}onAdd(e){return this._map=e,this._interleaved?this._onAddInterleaved(e):this._onAddOverlaid(e)}_onAddOverlaid(e){let r=document.createElement("div");return Object.assign(r.style,{position:"absolute",left:0,top:0,textAlign:"initial",pointerEvents:"none"}),this._container=r,this._deck=new Ar({...this._props,parent:r,viewState:Ds(e)}),e.on("resize",this._updateContainerSize),e.on("render",this._updateViewState),e.on("mousedown",this._handleMouseEvent),e.on("dragstart",this._handleMouseEvent),e.on("drag",this._handleMouseEvent),e.on("dragend",this._handleMouseEvent),e.on("mousemove",this._handleMouseEvent),e.on("mouseout",this._handleMouseEvent),e.on("click",this._handleMouseEvent),e.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),r}_onAddInterleaved(e){let r=e.painter.context.gl;return r instanceof WebGLRenderingContext&&U.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=Dl({map:e,gl:r,deck:new Ar({...this._props,gl:r})}),e.on("styledata",this._handleStyleChange),Jo(e,this._deck,[],this._props.layers),document.createElement("div")}onRemove(){let e=this._map;e&&(this._interleaved?this._onRemoveInterleaved(e):this._onRemoveOverlaid(e)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(e){e.off("resize",this._updateContainerSize),e.off("render",this._updateViewState),e.off("mousedown",this._handleMouseEvent),e.off("dragstart",this._handleMouseEvent),e.off("drag",this._handleMouseEvent),e.off("dragend",this._handleMouseEvent),e.off("mousemove",this._handleMouseEvent),e.off("mouseout",this._handleMouseEvent),e.off("click",this._handleMouseEvent),e.off("dblclick",this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(e){e.off("styledata",this._handleStyleChange),Jo(e,this._deck,this._props.layers,[]),Ld(e)}getDefaultPosition(){return"top-left"}pickObject(e){return oe(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return oe(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return oe(this._deck),this._deck.pickObjects(e)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}};function ks(t,e=""){if(!t)throw new Error(`JSON conversion error ${e}`)}function Yx(t,e){let r=VM(e),i=t;for(let s of r)i=zM(i)?i[s]:void 0;return i}function zM(t){return t!==null&&typeof t=="object"}var $x={};function VM(t){if(typeof t=="string"){let e=$x[t];return e||(e=t.split("."),$x[t]=e),e}return Array.isArray(t)?t:[t]}var Vd={};ui(Vd,{addBinaryOp:()=>$M,addUnaryOp:()=>XM,compile:()=>HM,compileAsync:()=>jM,eval:()=>Oe,evalAsync:()=>ea,parse:()=>Jx.default});var Bs=ja(zd()),Jx=ja(zd()),ea=function t(e,r){try{var i,s=e;switch(s.type){case"ArrayExpression":return Promise.resolve(qx(s.elements,r));case"BinaryExpression":return Promise.resolve(Promise.all([t(s.left,r),t(s.right,r)])).then(function(d){return Us[s.operator](d[0],d[1])});case"CallExpression":var n,o,a,c=function(){if(typeof o=="function"){var d=o,p=d.apply,g=n;return Promise.resolve(qx(s.arguments,r)).then(function(_){return Promise.resolve(p.call(d,g,_))})}},l=s.callee.type==="MemberExpression"?Promise.resolve(Kx(s.callee,r)).then(function(d){n=(a=d)[0],o=a[1]}):Promise.resolve(t(s.callee,r)).then(function(d){o=d});return Promise.resolve(l&&l.then?l.then(c):c());case"ConditionalExpression":return Promise.resolve(t(s.test,r)).then(function(d){return Promise.resolve(t(d?s.consequent:s.alternate,r))});case"Identifier":return Promise.resolve(r[s.name]);case"Literal":return Promise.resolve(s.value);case"LogicalExpression":var u=function(d){return i?d:Promise.resolve(Promise.all([t(s.left,r),t(s.right,r)])).then(function(p){return Us[s.operator](p[0],p[1])})},f=s.operator==="||"?(i=1,Promise.resolve(t(s.left,r)).then(function(d){return d||Promise.resolve(t(s.right,r))})):function(){if(s.operator==="&&")return i=1,Promise.resolve(t(s.left,r)).then(function(d){return d&&Promise.resolve(t(s.right,r))})}();return Promise.resolve(f&&f.then?f.then(u):u(f));case"MemberExpression":return Promise.resolve(Kx(s,r)).then(function(d){return d[1]});case"ThisExpression":return Promise.resolve(r);case"UnaryExpression":var h=kl[s.operator];return Promise.resolve(t(s.argument,r)).then(function(d){return h.call(kl,d)});default:return Promise.resolve(void 0)}}catch(d){return Promise.reject(d)}},Kx=function(t,e){try{return Promise.resolve(ea(t.object,e)).then(function(r){function i(){if(/^__proto__|prototype|constructor$/.test(s))throw Error('Access to member "'+s+'" disallowed.');return[r,r[s]]}var s,n=function(){if(t.computed)return Promise.resolve(ea(t.property,e)).then(function(o){s=o});s=t.property.name}();return n&&n.then?n.then(i):i()})}catch(r){return Promise.reject(r)}},qx=function(t,e){try{return Promise.resolve(Promise.all(t.map(function(r){return ea(r,e)})))}catch(r){return Promise.reject(r)}},WM={"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},Us={"||":function(t,e){return t||e},"&&":function(t,e){return t&&e},"|":function(t,e){return t|e},"^":function(t,e){return t^e},"&":function(t,e){return t&e},"==":function(t,e){return t==e},"!=":function(t,e){return t!=e},"===":function(t,e){return t===e},"!==":function(t,e){return t!==e},"<":function(t,e){return t":function(t,e){return t>e},"<=":function(t,e){return t<=e},">=":function(t,e){return t>=e},"<<":function(t,e){return t<>":function(t,e){return t>>e},">>>":function(t,e){return t>>>e},"+":function(t,e){return t+e},"-":function(t,e){return t-e},"*":function(t,e){return t*e},"/":function(t,e){return t/e},"%":function(t,e){return t%e}},kl={"-":function(t){return-t},"+":function(t){return+t},"~":function(t){return~t},"!":function(t){return!t}};function Gx(t,e){return t.map(function(r){return Oe(r,e)})}function Zx(t,e){var r,i=Oe(t.object,e);if(r=t.computed?Oe(t.property,e):t.property.name,/^__proto__|prototype|constructor$/.test(r))throw Error('Access to member "'+r+'" disallowed.');return[i,i[r]]}function Oe(t,e){var r=t;switch(r.type){case"ArrayExpression":return Gx(r.elements,e);case"BinaryExpression":return Us[r.operator](Oe(r.left,e),Oe(r.right,e));case"CallExpression":var i,s,n;return r.callee.type==="MemberExpression"?(i=(n=Zx(r.callee,e))[0],s=n[1]):s=Oe(r.callee,e),typeof s!="function"?void 0:s.apply(i,Gx(r.arguments,e));case"ConditionalExpression":return Oe(r.test,e)?Oe(r.consequent,e):Oe(r.alternate,e);case"Identifier":return e[r.name];case"Literal":return r.value;case"LogicalExpression":return r.operator==="||"?Oe(r.left,e)||Oe(r.right,e):r.operator==="&&"?Oe(r.left,e)&&Oe(r.right,e):Us[r.operator](Oe(r.left,e),Oe(r.right,e));case"MemberExpression":return Zx(r,e)[1];case"ThisExpression":return e;case"UnaryExpression":return kl[r.operator](Oe(r.argument,e));default:return}}function HM(t){return Oe.bind(null,(0,Bs.default)(t))}function jM(t){return ea.bind(null,(0,Bs.default)(t))}function XM(t,e){Bs.default.addUnaryOp(t),kl[t]=e}function $M(t,e,r){r?(Bs.default.addBinaryOp(t,e),Us[t]=r):(Bs.default.addBinaryOp(t,WM[t]||1),Us[t]=e)}var{parse:YM,eval:KM}=Vd,Wd={"-":t=>t};function ta(t,e){if(t in Wd)return Wd[t];let r,i=YM(t);return i.type==="Identifier"?r=s=>Yx(s,t):(Hd(i,s=>{if(s.type==="CallExpression")throw new Error("Function calls not allowed in JSON expressions")}),r=s=>KM(i,s)),Wd[t]=r,r}function Hd(t,e){if(Array.isArray(t))t.forEach(r=>Hd(r,e));else if(t&&typeof t=="object"){t.type&&e(t);for(let r in t)Hd(t[r],e)}}var zs="@@=",jd="@@#",Qx="@@type",Bl="@@function";var e0=t=>t&&typeof t=="object",ar=class{constructor(...e){this.typeKey=Qx,this.functionKey=Bl,this.log=console,this.classes={},this.reactComponents={},this.enumerations={},this.constants={},this.functions={},this.React=null,this.convertFunction=ta,this.preProcessClassProps=(r,i)=>i,this.postProcessConvertedJson=r=>r;for(let r of e)this.merge(r)}merge(e){for(let r in e)switch(r){case"layers":case"views":Object.assign(this.classes,e[r]);break;default:if(r in this){let i=e[r];this[r]=e0(this[r])?Object.assign(this[r],i):i}}}validate(e){return ks(!this.typeKey||typeof this.typeKey=="string"),ks(e0(this.classes)),!0}};function qM(t){return typeof t=="string"&&t.startsWith(zs)}function GM(t){return t.replace(zs,"")}function Ul(t,e){let r={};for(let i in t){let s=t[i];qM(s)&&(s=GM(s),s=ta(s,e)),r[i]=s}return r}function t0(t,e,r){let i=r.classes[t],s=r.reactComponents[t];if(!i&&!s){let{log:n}=r;if(n){let o=JSON.stringify(e,null,0).slice(0,40);n.warn(`JSON converter: No registered class of type ${t}(${o}...) `)}return null}return i?ZM(i,e,r):JM(s,e,r)}function ZM(t,e,r){return r.preProcessClassProps&&(e=r.preProcessClassProps(t,e,r)),e=Ul(e,r),new t(e)}function JM(t,e,r){let{React:i}=r,{children:s=[]}=e;return delete e.children,r.preProcessClassProps&&(e=r.preProcessClassProps(t,e,r)),e=Ul(e,r),i.createElement(t,e,s)}function r0(t,e,r){let i=r.functions[t];if(!i){let{log:s}=r;if(s){let n=JSON.stringify(e,null,0).slice(0,40);s.warn(`JSON converter: No registered function ${t}(${n}...) `)}return null}return i(e)}function Xd(t){return typeof t=="string"?JSON.parse(t):t}var $d=t=>t&&typeof t=="object",Vs=class{constructor(e){this.log=console,this.onJSONChange=()=>{},this.json=null,this.convertedJson=null,this.setProps(e)}finalize(){}setProps(e){"configuration"in e&&(this.configuration=e.configuration instanceof ar?e.configuration:new ar(e.configuration)),"onJSONChange"in e&&(this.onJSONChange=e.onJSONChange)}mergeConfiguration(e){this.configuration.merge(e)}convert(e){if(!e||e===this.json)return this.convertedJson;this.json=e;let r=Xd(e),i=QM(r,this.configuration);return i=this.configuration.postProcessConvertedJson(i),this.convertedJson=i,i}convertJson(e){return this.convert(e)}};function QM(t,e){return e=new ar(e),Yd(t,"",e)}function Yd(t,e,r){return Array.isArray(t)?t.map((i,s)=>Yd(i,String(s),r)):e3(t,r)?t3(t,r):$d(t)?Bl in t?r3(t,r):Kd(t,r):typeof t=="string"?i3(t,e,r):t}function e3(t,e){let{typeKey:r}=e;return $d(t)&&!!t[r]}function t3(t,e){let{typeKey:r}=e,i=t[r],s={...t};return delete s[r],s=Kd(s,e),t0(i,s,e)}function r3(t,e){let{functionKey:r}=e,i=t[r],s={...t};return delete s[r],s=Kd(s,e),r0(i,s,e)}function Kd(t,e){ks($d(t));let r={};for(let i in t){let s=t[i];r[i]=Yd(s,i,e)}return r}function i3(t,e,r){if(t.startsWith(zs)&&r.convertFunction)return t=t.replace(zs,""),r.convertFunction(t,r);if(t.startsWith(jd)){if(t=t.replace(jd,""),r.constants[t])return r.constants[t];let[i,s]=t.split(".");return r.enumerations[i][s]}return t}var vp={};ui(vp,{AGGREGATION_OPERATION:()=>le,ArcLayer:()=>ra,BitmapLayer:()=>ia,CPUGridLayer:()=>ni,ColumnLayer:()=>wr,ContourLayer:()=>Ra,GPUGridLayer:()=>oi,GeoJsonLayer:()=>Sa,GridCellLayer:()=>Ki,GridLayer:()=>Ma,HeatmapLayer:()=>Oa,HexagonLayer:()=>wa,IconLayer:()=>Er,LineLayer:()=>Xi,PathLayer:()=>Pr,PointCloudLayer:()=>oa,PolygonLayer:()=>ya,ScatterplotLayer:()=>$i,ScreenGridLayer:()=>Ea,SolidPolygonLayer:()=>zt,TextLayer:()=>Qi,_AggregationLayer:()=>nt,_BinSorter:()=>Rr,_CPUAggregator:()=>Mr,_GPUGridAggregator:()=>Re,_MultiIconLayer:()=>Gi,_TextBackgroundLayer:()=>Ji});var i0=`#version 300 es +#define SHADER_NAME arc-layer-vertex-shader +in vec3 positions; +in vec4 instanceSourceColors; +in vec4 instanceTargetColors; +in vec3 instanceSourcePositions; +in vec3 instanceSourcePositions64Low; +in vec3 instanceTargetPositions; +in vec3 instanceTargetPositions64Low; +in vec3 instancePickingColors; +in float instanceWidths; +in float instanceHeights; +in float instanceTilts; +uniform bool greatCircle; +uniform bool useShortestPath; +uniform float numSegments; +uniform float opacity; +uniform float widthScale; +uniform float widthMinPixels; +uniform float widthMaxPixels; +uniform int widthUnits; +out vec4 vColor; +out vec2 uv; +out float isValid; +float paraboloid(float distance, float sourceZ, float targetZ, float ratio) { +float deltaZ = targetZ - sourceZ; +float dh = distance * instanceHeights; +if (dh == 0.0) { +return sourceZ + deltaZ * ratio; +} +float unitZ = deltaZ / dh; +float p2 = unitZ * unitZ + 1.0; +float dir = step(deltaZ, 0.0); +float z0 = mix(sourceZ, targetZ, dir); +float r = mix(ratio, 1.0 - ratio, dir); +return sqrt(r * (p2 - r)) * dh + z0; +} +vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) { +vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize); +dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x); +return dir_screenspace * offset_direction * width / 2.0; +} +float getSegmentRatio(float index) { +return smoothstep(0.0, 1.0, index / (numSegments - 1.0)); +} +vec3 interpolateFlat(vec3 source, vec3 target, float segmentRatio) { +float distance = length(source.xy - target.xy); +float z = paraboloid(distance, source.z, target.z, segmentRatio); +float tiltAngle = radians(instanceTilts); +vec2 tiltDirection = normalize(target.xy - source.xy); +vec2 tilt = vec2(-tiltDirection.y, tiltDirection.x) * z * sin(tiltAngle); +return vec3( +mix(source.xy, target.xy, segmentRatio) + tilt, +z * cos(tiltAngle) +); +} +float getAngularDist (vec2 source, vec2 target) { +vec2 sourceRadians = radians(source); +vec2 targetRadians = radians(target); +vec2 sin_half_delta = sin((sourceRadians - targetRadians) / 2.0); +vec2 shd_sq = sin_half_delta * sin_half_delta; +float a = shd_sq.y + cos(sourceRadians.y) * cos(targetRadians.y) * shd_sq.x; +return 2.0 * asin(sqrt(a)); +} +vec3 interpolateGreatCircle(vec3 source, vec3 target, vec3 source3D, vec3 target3D, float angularDist, float t) { +vec2 lngLat; +if(abs(angularDist - PI) < 0.001) { +lngLat = (1.0 - t) * source.xy + t * target.xy; +} else { +float a = sin((1.0 - t) * angularDist); +float b = sin(t * angularDist); +vec3 p = source3D.yxz * a + target3D.yxz * b; +lngLat = degrees(vec2(atan(p.y, -p.x), atan(p.z, length(p.xy)))); +} +float z = paraboloid(angularDist * EARTH_RADIUS, source.z, target.z, t); +return vec3(lngLat, z); +} +void main(void) { +geometry.worldPosition = instanceSourcePositions; +geometry.worldPositionAlt = instanceTargetPositions; +float segmentIndex = positions.x; +float segmentRatio = getSegmentRatio(segmentIndex); +float prevSegmentRatio = getSegmentRatio(max(0.0, segmentIndex - 1.0)); +float nextSegmentRatio = getSegmentRatio(min(numSegments - 1.0, segmentIndex + 1.0)); +float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0)); +isValid = 1.0; +uv = vec2(segmentRatio, positions.y); +geometry.uv = uv; +geometry.pickingColor = instancePickingColors; +vec4 curr; +vec4 next; +vec3 source; +vec3 target; +if ((greatCircle || project_uProjectionMode == PROJECTION_MODE_GLOBE) && project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) { +source = project_globe_(vec3(instanceSourcePositions.xy, 0.0)); +target = project_globe_(vec3(instanceTargetPositions.xy, 0.0)); +float angularDist = getAngularDist(instanceSourcePositions.xy, instanceTargetPositions.xy); +vec3 prevPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, prevSegmentRatio); +vec3 currPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, segmentRatio); +vec3 nextPos = interpolateGreatCircle(instanceSourcePositions, instanceTargetPositions, source, target, angularDist, nextSegmentRatio); +if (abs(currPos.x - prevPos.x) > 180.0) { +indexDir = -1.0; +isValid = 0.0; +} else if (abs(currPos.x - nextPos.x) > 180.0) { +indexDir = 1.0; +isValid = 0.0; +} +nextPos = indexDir < 0.0 ? prevPos : nextPos; +nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio; +if (isValid == 0.0) { +nextPos.x += nextPos.x > 0.0 ? -360.0 : 360.0; +float t = ((currPos.x > 0.0 ? 180.0 : -180.0) - currPos.x) / (nextPos.x - currPos.x); +currPos = mix(currPos, nextPos, t); +segmentRatio = mix(segmentRatio, nextSegmentRatio, t); +} +vec3 currPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, segmentRatio); +vec3 nextPos64Low = mix(instanceSourcePositions64Low, instanceTargetPositions64Low, nextSegmentRatio); +curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0), geometry.position); +next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0)); +} else { +vec3 source_world = instanceSourcePositions; +vec3 target_world = instanceTargetPositions; +if (useShortestPath) { +source_world.x = mod(source_world.x + 180., 360.0) - 180.; +target_world.x = mod(target_world.x + 180., 360.0) - 180.; +float deltaLng = target_world.x - source_world.x; +if (deltaLng > 180.) target_world.x -= 360.; +if (deltaLng < -180.) source_world.x -= 360.; +} +source = project_position(source_world, instanceSourcePositions64Low); +target = project_position(target_world, instanceTargetPositions64Low); +float antiMeridianX = 0.0; +if (useShortestPath) { +if (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { +antiMeridianX = -(project_uCoordinateOrigin.x + 180.) / 360. * TILE_SIZE; +} +float thresholdRatio = (antiMeridianX - source.x) / (target.x - source.x); +if (prevSegmentRatio <= thresholdRatio && nextSegmentRatio > thresholdRatio) { +isValid = 0.0; +indexDir = sign(segmentRatio - thresholdRatio); +segmentRatio = thresholdRatio; +} +} +nextSegmentRatio = indexDir < 0.0 ? prevSegmentRatio : nextSegmentRatio; +vec3 currPos = interpolateFlat(source, target, segmentRatio); +vec3 nextPos = interpolateFlat(source, target, nextSegmentRatio); +if (useShortestPath) { +if (nextPos.x < antiMeridianX) { +currPos.x += TILE_SIZE; +nextPos.x += TILE_SIZE; +} +} +curr = project_common_position_to_clipspace(vec4(currPos, 1.0)); +next = project_common_position_to_clipspace(vec4(nextPos, 1.0)); +geometry.position = vec4(currPos, 1.0); +} +float widthPixels = clamp( +project_size_to_pixel(instanceWidths * widthScale, widthUnits), +widthMinPixels, widthMaxPixels +); +vec3 offset = vec3( +getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y, widthPixels), +0.0); +DECKGL_FILTER_SIZE(offset, geometry); +DECKGL_FILTER_GL_POSITION(curr, geometry); +gl_Position = curr + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0); +vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio); +vColor = vec4(color.rgb, color.a * opacity); +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var s0=`#version 300 es +#define SHADER_NAME arc-layer-fragment-shader +precision highp float; +in vec4 vColor; +in vec2 uv; +in float isValid; +out vec4 fragColor; +void main(void) { +if (isValid == 0.0) { +discard; +} +fragColor = vColor; +geometry.uv = uv; +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var zl=[0,0,0,255],s3={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getSourceColor:{type:"accessor",value:zl},getTargetColor:{type:"accessor",value:zl},getWidth:{type:"accessor",value:1},getHeight:{type:"accessor",value:1},getTilt:{type:"accessor",value:0},greatCircle:!1,numSegments:{type:"number",value:50,min:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},ra=class extends ne{static{this.layerName="ArcLayer"}static{this.defaultProps=s3}getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:i0,fs:s0,modules:[ae,ue]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceSourceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getSourceColor",defaultValue:zl},instanceTargetColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getTargetColor",defaultValue:zl},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1},instanceHeights:{size:1,transition:!0,accessor:"getHeight",defaultValue:1},instanceTilts:{size:1,transition:!0,accessor:"getTilt",defaultValue:0}})}updateState(e){super.updateState(e);let{props:r,oldProps:i,changeFlags:s}=e;(s.extensionsChanged||r.numSegments!==i.numSegments)&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{widthUnits:r,widthScale:i,widthMinPixels:s,widthMaxPixels:n,greatCircle:o,wrapLongitude:a}=this.props,c=this.state.model;c.setUniforms(e),c.setUniforms({greatCircle:o,widthUnits:pe[r],widthScale:i,widthMinPixels:s,widthMaxPixels:n,useShortestPath:a}),c.draw(this.context.renderPass)}_getModel(){let{numSegments:e}=this.props,r=[];for(let s=0;s0&&p>0&&(a[f++]=u-n,a[f++]=u-n-1,a[f++]=u-1,a[f++]=u-n,a[f++]=u-1,a[f++]=u),u++}}return{vertexCount:o,positions:l,indices:a,texCoords:c}}function a3(t){let e=new Float64Array(12);for(let r=0;r 0.5) { + vTexPos = geometry.worldPosition.xy; + } + + vec4 color = vec4(0.0); + DECKGL_FILTER_COLOR(color, geometry); +} +`;var l3=` +vec3 packUVsIntoRGB(vec2 uv) { + // Extract the top 8 bits. We want values to be truncated down so we can add a fraction + vec2 uv8bit = floor(uv * 256.); + + // Calculate the normalized remainders of u and v parts that do not fit into 8 bits + // Scale and clamp to 0-1 range + vec2 uvFraction = fract(uv * 256.); + vec2 uvFraction4bit = floor(uvFraction * 16.); + + // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates + float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.; + + return vec3(uv8bit, fractions) / 255.; +} +`,o0=`#version 300 es +#define SHADER_NAME bitmap-layer-fragment-shader + +#ifdef GL_ES +precision highp float; +#endif + +uniform sampler2D bitmapTexture; + +in vec2 vTexCoord; +in vec2 vTexPos; + +out vec4 fragColor; + +uniform float desaturate; +uniform vec4 transparentColor; +uniform vec3 tintColor; +uniform float opacity; + +uniform float coordinateConversion; +uniform vec4 bounds; + +/* projection utils */ +const float TILE_SIZE = 512.0; +const float PI = 3.1415926536; +const float WORLD_SCALE = TILE_SIZE / PI / 2.0; + +// from degrees to Web Mercator +vec2 lnglat_to_mercator(vec2 lnglat) { + float x = lnglat.x; + float y = clamp(lnglat.y, -89.9, 89.9); + return vec2( + radians(x) + PI, + PI + log(tan(PI * 0.25 + radians(y) * 0.5)) + ) * WORLD_SCALE; +} + +// from Web Mercator to degrees +vec2 mercator_to_lnglat(vec2 xy) { + xy /= WORLD_SCALE; + return degrees(vec2( + xy.x - PI, + atan(exp(xy.y - PI)) * 2.0 - PI * 0.5 + )); +} +/* End projection utils */ + +// apply desaturation +vec3 color_desaturate(vec3 color) { + float luminance = (color.r + color.g + color.b) * 0.333333333; + return mix(color, vec3(luminance), desaturate); +} + +// apply tint +vec3 color_tint(vec3 color) { + return color * tintColor; +} + +// blend with background color +vec4 apply_opacity(vec3 color, float alpha) { + if (transparentColor.a == 0.0) { + return vec4(color, alpha); + } + float blendedAlpha = alpha + transparentColor.a * (1.0 - alpha); + float highLightRatio = alpha / blendedAlpha; + vec3 blendedRGB = mix(transparentColor.rgb, color, highLightRatio); + return vec4(blendedRGB, blendedAlpha); +} + +vec2 getUV(vec2 pos) { + return vec2( + (pos.x - bounds[0]) / (bounds[2] - bounds[0]), + (pos.y - bounds[3]) / (bounds[1] - bounds[3]) + ); +} + +${l3} + +void main(void) { + vec2 uv = vTexCoord; + if (coordinateConversion < -0.5) { + vec2 lnglat = mercator_to_lnglat(vTexPos); + uv = getUV(lnglat); + } else if (coordinateConversion > 0.5) { + vec2 commonPos = lnglat_to_mercator(vTexPos); + uv = getUV(commonPos); + } + vec4 bitmapColor = texture(bitmapTexture, uv); + + fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * opacity); + + geometry.uv = uv; + DECKGL_FILTER_COLOR(fragColor, geometry); + + if (bool(picking.isActive) && !bool(picking.isAttribute)) { + // Since instance information is not used, we can use picking color for pixel index + fragColor.rgb = packUVsIntoRGB(uv); + } +} +`;var u3={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:q.DEFAULT,desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}},ia=class extends ne{static{this.layerName="BitmapLayer"}static{this.defaultProps=u3}getShaders(){return super.getShaders({vs:n0,fs:o0,modules:[ae,ue]})}initializeState(){let e=this.getAttributeManager();e.remove(["instancePickingColors"]);let r=!0;e.add({indices:{size:1,isIndexed:!0,update:i=>i.value=this.state.mesh.indices,noAlloc:r},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:i=>i.value=this.state.mesh.positions,noAlloc:r},texCoords:{size:2,update:i=>i.value=this.state.mesh.texCoords,noAlloc:r}})}updateState({props:e,oldProps:r,changeFlags:i}){let s=this.getAttributeManager();if(i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll()),e.bounds!==r.bounds){let n=this.state.mesh,o=this._createMesh();this.state.model.setVertexCount(o.vertexCount);for(let a in o)n&&n[a]!==o[a]&&s.invalidate(a);this.setState({mesh:o,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==r._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){let{image:r}=this.props,i=e.info;if(!i.color||!r)return i.bitmap=null,i;let{width:s,height:n}=r;i.index=0;let o=f3(i.color);return i.bitmap={size:{width:s,height:n},uv:o,pixel:[Math.floor(o[0]*s),Math.floor(o[1]*n)]},i}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){let{bounds:e}=this.props,r=e;return a0(e)&&(r=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),qd(r,this.context.viewport.resolution)}_getModel(){return new te(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-list",isInstanced:!1})}draw(e){let{uniforms:r,moduleParameters:i}=e,{model:s,coordinateConversion:n,bounds:o,disablePicking:a}=this.state,{image:c,desaturate:l,transparentColor:u,tintColor:f}=this.props;i.picking.isActive&&a||c&&s&&(s.setUniforms(r),s.setBindings({bitmapTexture:c}),s.setUniforms({desaturate:l,transparentColor:u.map(h=>h/255),tintColor:f.slice(0,3).map(h=>h/255),coordinateConversion:n,bounds:o}),s.draw(this.context.renderPass))}_getCoordinateUniforms(){let{LNGLAT:e,CARTESIAN:r,DEFAULT:i}=q,{_imageCoordinateSystem:s}=this.props;if(s!==i){let{bounds:n}=this.props;if(!a0(n))throw new Error("_imageCoordinateSystem only supports rectangular bounds");let o=this.context.viewport.resolution?e:r;if(s=s===e?e:r,s===e&&o===r)return{coordinateConversion:-1,bounds:n};if(s===r&&o===e){let a=Ze([n[0],n[1]]),c=Ze([n[2],n[3]]);return{coordinateConversion:1,bounds:[a[0],a[1],c[0],c[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}};function f3(t){let[e,r,i]=t,s=(i&240)/256,n=(i&15)/16;return[(e+n)/256,(r+s)/256]}function a0(t){return Number.isFinite(t[0])}var c0=`#version 300 es +#define SHADER_NAME icon-layer-vertex-shader +in vec2 positions; +in vec3 instancePositions; +in vec3 instancePositions64Low; +in float instanceSizes; +in float instanceAngles; +in vec4 instanceColors; +in vec3 instancePickingColors; +in vec4 instanceIconFrames; +in float instanceColorModes; +in vec2 instanceOffsets; +in vec2 instancePixelOffset; +uniform float sizeScale; +uniform vec2 iconsTextureDim; +uniform float sizeMinPixels; +uniform float sizeMaxPixels; +uniform bool billboard; +uniform int sizeUnits; +out float vColorMode; +out vec4 vColor; +out vec2 vTextureCoords; +out vec2 uv; +vec2 rotate_by_angle(vec2 vertex, float angle) { +float angle_radian = angle * PI / 180.0; +float cos_angle = cos(angle_radian); +float sin_angle = sin(angle_radian); +mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle); +return rotationMatrix * vertex; +} +void main(void) { +geometry.worldPosition = instancePositions; +geometry.uv = positions; +geometry.pickingColor = instancePickingColors; +uv = positions; +vec2 iconSize = instanceIconFrames.zw; +float sizePixels = clamp( +project_size_to_pixel(instanceSizes * sizeScale, sizeUnits), +sizeMinPixels, sizeMaxPixels +); +float instanceScale = iconSize.y == 0.0 ? 0.0 : sizePixels / iconSize.y; +vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets; +pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale; +pixelOffset += instancePixelOffset; +pixelOffset.y *= -1.0; +if (billboard) { +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +vec3 offset = vec3(pixelOffset, 0.0); +DECKGL_FILTER_SIZE(offset, geometry); +gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); +} else { +vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0); +DECKGL_FILTER_SIZE(offset_common, geometry); +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +} +vTextureCoords = mix( +instanceIconFrames.xy, +instanceIconFrames.xy + iconSize, +(positions.xy + 1.0) / 2.0 +) / iconsTextureDim; +vColor = instanceColors; +DECKGL_FILTER_COLOR(vColor, geometry); +vColorMode = instanceColorModes; +} +`;var l0=`#version 300 es +#define SHADER_NAME icon-layer-fragment-shader +precision highp float; +uniform float opacity; +uniform sampler2D iconsTexture; +uniform float alphaCutoff; +in float vColorMode; +in vec4 vColor; +in vec2 vTextureCoords; +in vec2 uv; +out vec4 fragColor; +void main(void) { +geometry.uv = uv; +vec4 texColor = texture(iconsTexture, vTextureCoords); +vec3 color = mix(texColor.rgb, vColor.rgb, vColorMode); +float a = texColor.a * opacity * vColor.a; +if (a < alphaCutoff) { +discard; +} +fragColor = vec4(color, a); +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var h3=1024,d3=4,u0=()=>{},f0={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},p3={x:0,y:0,width:0,height:0};function g3(t){return Math.pow(2,Math.ceil(Math.log2(t)))}function m3(t,e,r,i){let s=Math.min(r/e.width,i/e.height),n=Math.floor(e.width*s),o=Math.floor(e.height*s);return s===1?{data:e,width:n,height:o}:(t.canvas.height=o,t.canvas.width=n,t.clearRect(0,0,n,o),t.drawImage(e,0,0,e.width,e.height,0,0,n,o),{data:t.canvas,width:n,height:o})}function sa(t){return t&&(t.id||t.url)}function _3(t,e,r,i){let{width:s,height:n,device:o}=t,a=o.createTexture({format:"rgba8unorm",width:e,height:r,sampler:i}),c=o.createCommandEncoder();return c.copyTextureToTexture({source:t,destination:a,width:s,height:n}),c.finish(),t.destroy(),a}function h0(t,e,r){for(let i=0;io&&(h0(r,a,s),i=0,s=n+s+e,n=0,a=[]),a.push({icon:l,xOffset:i}),i=i+h+e,n=Math.max(n,f)}}return a.length>0&&h0(r,a,s),{mapping:r,rowHeight:n,xOffset:i,yOffset:s,canvasWidth:o,canvasHeight:g3(n+s+e)}}function x3(t,e,r){if(!t||!e)return null;r=r||{};let i={},{iterable:s,objectInfo:n}=$e(t);for(let o of s){n.index++;let a=e(o,n),c=sa(a);if(!a)throw new Error("Icon is missing.");if(!a.url)throw new Error("Icon url is missing.");!i[c]&&(!r[c]||a.url!==r[c].url)&&(i[c]={...a,source:o,sourceIndex:n.index})}return i}var na=class{constructor(e,{onUpdate:r=u0,onError:i=u0}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._textureParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=d3,this._canvasWidth=h3,this._canvasHeight=0,this._canvas=null,this.device=e,this.onUpdate=r,this.onError=i}finalize(){this._texture?.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){let r=this._autoPacking?sa(e):e;return this._mapping[r]||p3}setProps({loadOptions:e,autoPacking:r,iconAtlas:i,iconMapping:s,textureParameters:n}){e&&(this._loadOptions=e),r!==void 0&&(this._autoPacking=r),s&&(this._mapping=s),i&&(this._texture?.delete(),this._texture=null,this._externalTexture=i),n&&(this._textureParameters=n)}get isLoaded(){return this._pendingCount===0}packIcons(e,r){if(!this._autoPacking||typeof document>"u")return;let i=Object.values(x3(e,r,this._mapping)||{});if(i.length>0){let{mapping:s,xOffset:n,yOffset:o,rowHeight:a,canvasHeight:c}=y3({icons:i,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=a,this._mapping=s,this._xOffset=n,this._yOffset=o,this._canvasHeight=c,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",width:this._canvasWidth,height:this._canvasHeight,sampler:this._textureParameters||f0})),this._texture.height!==this._canvasHeight&&(this._texture=_3(this._texture,this._canvasWidth,this._canvasHeight,this._textureParameters||f0)),this.onUpdate(),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(i)}}_loadIcons(e){let r=this._canvas.getContext("2d",{willReadFrequently:!0});for(let i of e)this._pendingCount++,Lr(i.url,this._loadOptions).then(s=>{let n=sa(i),o=this._mapping[n],{x:a,y:c,width:l,height:u}=o,{data:f,width:h,height:d}=m3(r,s,l,u);this._texture.setSubImageData({data:f,x:a+(l-h)/2,y:c+(u-d)/2,width:h,height:d}),o.width=h,o.height=d,this._texture.generateMipmap(),this.onUpdate()}).catch(s=>{this.onError({url:i.url,source:i.source,sourceIndex:i.sourceIndex,loadOptions:this._loadOptions,error:s})}).finally(()=>{this._pendingCount--})}};var d0=[0,0,0,255],T3={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:t=>t.position},getIcon:{type:"accessor",value:t=>t.icon},getColor:{type:"accessor",value:d0},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},onIconError:{type:"function",value:null,optional:!0},textureParameters:{type:"object",ignore:!0,value:null}},Er=class extends ne{static{this.defaultProps=T3}static{this.layerName="IconLayer"}getShaders(){return super.getShaders({vs:c0,fs:l0,modules:[ae,ue]})}initializeState(){this.state={iconManager:new na(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})},this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceOffsets:{size:2,accessor:"getIcon",transform:this.getInstanceOffset},instanceIconFrames:{size:4,accessor:"getIcon",transform:this.getInstanceIconFrame},instanceColorModes:{size:1,type:"uint8",accessor:"getIcon",transform:this.getInstanceColorMode},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:d0},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e);let{props:r,oldProps:i,changeFlags:s}=e,n=this.getAttributeManager(),{iconAtlas:o,iconMapping:a,data:c,getIcon:l,textureParameters:u}=r,{iconManager:f}=this.state;if(typeof o=="string")return;let h=o||this.internalState.isAsyncPropLoading("iconAtlas");f.setProps({loadOptions:r.loadOptions,autoPacking:!h,iconAtlas:o,iconMapping:h?a:null,textureParameters:u}),h?i.iconMapping!==r.iconMapping&&n.invalidate("getIcon"):(s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged.getIcon))&&f.packIcons(c,l),s.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){let{sizeScale:r,sizeMinPixels:i,sizeMaxPixels:s,sizeUnits:n,billboard:o,alphaCutoff:a}=this.props,{iconManager:c}=this.state,l=c.getTexture();if(l){let u=this.state.model;u.setBindings({iconsTexture:l}),u.setUniforms(e),u.setUniforms({iconsTextureDim:[l.width,l.height],sizeUnits:pe[n],sizeScale:r,sizeMinPixels:i,sizeMaxPixels:s,billboard:o,alphaCutoff:a}),u.draw(this.context.renderPass)}}_getModel(){let e=[-1,-1,1,-1,-1,1,1,1];return new te(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new fe({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}_onUpdate(){this.setNeedsRedraw()}_onError(e){let r=this.getCurrentLayer()?.props.onIconError;r?r(e):U.error(e.error.message)()}getInstanceOffset(e){let{width:r,height:i,anchorX:s=r/2,anchorY:n=i/2}=this.state.iconManager.getIconMapping(e);return[r/2-s,i/2-n]}getInstanceColorMode(e){return this.state.iconManager.getIconMapping(e).mask?1:0}getInstanceIconFrame(e){let{x:r,y:i,width:s,height:n}=this.state.iconManager.getIconMapping(e);return[r,i,s,n]}};var p0=`#version 300 es +#define SHADER_NAME line-layer-vertex-shader +in vec3 positions; +in vec3 instanceSourcePositions; +in vec3 instanceTargetPositions; +in vec3 instanceSourcePositions64Low; +in vec3 instanceTargetPositions64Low; +in vec4 instanceColors; +in vec3 instancePickingColors; +in float instanceWidths; +uniform float opacity; +uniform float widthScale; +uniform float widthMinPixels; +uniform float widthMaxPixels; +uniform float useShortestPath; +uniform int widthUnits; +out vec4 vColor; +out vec2 uv; +vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) { +vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize); +dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x); +return dir_screenspace * offset_direction * width / 2.0; +} +vec3 splitLine(vec3 a, vec3 b, float x) { +float t = (x - a.x) / (b.x - a.x); +return vec3(x, mix(a.yz, b.yz, t)); +} +void main(void) { +geometry.worldPosition = instanceSourcePositions; +geometry.worldPositionAlt = instanceTargetPositions; +vec3 source_world = instanceSourcePositions; +vec3 target_world = instanceTargetPositions; +vec3 source_world_64low = instanceSourcePositions64Low; +vec3 target_world_64low = instanceTargetPositions64Low; +if (useShortestPath > 0.5 || useShortestPath < -0.5) { +source_world.x = mod(source_world.x + 180., 360.0) - 180.; +target_world.x = mod(target_world.x + 180., 360.0) - 180.; +float deltaLng = target_world.x - source_world.x; +if (deltaLng * useShortestPath > 180.) { +source_world.x += 360. * useShortestPath; +source_world = splitLine(source_world, target_world, 180. * useShortestPath); +source_world_64low = vec3(0.0); +} else if (deltaLng * useShortestPath < -180.) { +target_world.x += 360. * useShortestPath; +target_world = splitLine(source_world, target_world, 180. * useShortestPath); +target_world_64low = vec3(0.0); +} else if (useShortestPath < 0.) { +gl_Position = vec4(0.); +return; +} +} +vec4 source_commonspace; +vec4 target_commonspace; +vec4 source = project_position_to_clipspace(source_world, source_world_64low, vec3(0.), source_commonspace); +vec4 target = project_position_to_clipspace(target_world, target_world_64low, vec3(0.), target_commonspace); +float segmentIndex = positions.x; +vec4 p = mix(source, target, segmentIndex); +geometry.position = mix(source_commonspace, target_commonspace, segmentIndex); +uv = positions.xy; +geometry.uv = uv; +geometry.pickingColor = instancePickingColors; +float widthPixels = clamp( +project_size_to_pixel(instanceWidths * widthScale, widthUnits), +widthMinPixels, widthMaxPixels +); +vec3 offset = vec3( +getExtrusionOffset(target.xy - source.xy, positions.y, widthPixels), +0.0); +DECKGL_FILTER_SIZE(offset, geometry); +DECKGL_FILTER_GL_POSITION(p, geometry); +gl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0); +vColor = vec4(instanceColors.rgb, instanceColors.a * opacity); +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var g0=`#version 300 es +#define SHADER_NAME line-layer-fragment-shader +precision highp float; +in vec4 vColor; +in vec2 uv; +out vec4 fragColor; +void main(void) { +geometry.uv = uv; +fragColor = vColor; +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var v3=[0,0,0,255],b3={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getColor:{type:"accessor",value:v3},getWidth:{type:"accessor",value:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}},Xi=class extends ne{static{this.layerName="LineLayer"}static{this.defaultProps=b3}getBounds(){return this.getAttributeManager()?.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:p0,fs:g0,modules:[ae,ue]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{widthUnits:r,widthScale:i,widthMinPixels:s,widthMaxPixels:n,wrapLongitude:o}=this.props,a=this.state.model;a.setUniforms(e),a.setUniforms({widthUnits:pe[r],widthScale:i,widthMinPixels:s,widthMaxPixels:n,useShortestPath:o?1:0}),a.draw(this.context.renderPass),o&&(a.setUniforms({useShortestPath:-1}),a.draw(this.context.renderPass))}_getModel(){let e=[0,-1,0,0,1,0,1,-1,0,1,1,0];return new te(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new fe({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};var m0=`#version 300 es +#define SHADER_NAME point-cloud-layer-vertex-shader +in vec3 positions; +in vec3 instanceNormals; +in vec4 instanceColors; +in vec3 instancePositions; +in vec3 instancePositions64Low; +in vec3 instancePickingColors; +uniform float opacity; +uniform float radiusPixels; +uniform int sizeUnits; +out vec4 vColor; +out vec2 unitPosition; +void main(void) { +geometry.worldPosition = instancePositions; +geometry.normal = project_normal(instanceNormals); +unitPosition = positions.xy; +geometry.uv = unitPosition; +geometry.pickingColor = instancePickingColors; +vec3 offset = vec3(positions.xy * project_size_to_pixel(radiusPixels, sizeUnits), 0.0); +DECKGL_FILTER_SIZE(offset, geometry); +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); +vec3 lightColor = lighting_getLightColor(instanceColors.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal); +vColor = vec4(lightColor, instanceColors.a * opacity); +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var _0=`#version 300 es +#define SHADER_NAME point-cloud-layer-fragment-shader +precision highp float; +in vec4 vColor; +in vec2 unitPosition; +out vec4 fragColor; +void main(void) { +geometry.uv = unitPosition; +float distToCenter = length(unitPosition); +if (distToCenter > 1.0) { +discard; +} +fragColor = vColor; +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var y0=[0,0,0,255],x0=[0,0,1],S3={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:t=>t.position},getNormal:{type:"accessor",value:x0},getColor:{type:"accessor",value:y0},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};function A3(t){let{header:e,attributes:r}=t;if(!(!e||!r)&&(t.length=e.vertexCount,r.POSITION&&(r.instancePositions=r.POSITION),r.NORMAL&&(r.instanceNormals=r.NORMAL),r.COLOR_0)){let{size:i,value:s}=r.COLOR_0;r.instanceColors={size:i,type:"unorm8",value:s}}}var oa=class extends ne{static{this.layerName="PointCloudLayer"}static{this.defaultProps=S3}getShaders(){return super.getShaders({vs:m0,fs:_0,modules:[ae,Mt,ue]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:x0},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:y0}})}updateState(e){let{changeFlags:r,props:i}=e;super.updateState(e),r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),r.dataChanged&&A3(i.data)}draw({uniforms:e}){let{pointSize:r,sizeUnits:i}=this.props,s=this.state.model;s.setUniforms(e),s.setUniforms({sizeUnits:pe[i],radiusPixels:r}),s.draw(this.context.renderPass)}_getModel(){let e=[];for(let r=0;r<3;r++){let i=r/3*Math.PI*2;e.push(Math.cos(i)*2,Math.sin(i)*2,0)}return new te(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new fe({topology:"triangle-list",attributes:{positions:new Float32Array(e)}}),isInstanced:!0})}};var T0=`#version 300 es +#define SHADER_NAME scatterplot-layer-vertex-shader +in vec3 positions; +in vec3 instancePositions; +in vec3 instancePositions64Low; +in float instanceRadius; +in float instanceLineWidths; +in vec4 instanceFillColors; +in vec4 instanceLineColors; +in vec3 instancePickingColors; +uniform float opacity; +uniform float radiusScale; +uniform float radiusMinPixels; +uniform float radiusMaxPixels; +uniform float lineWidthScale; +uniform float lineWidthMinPixels; +uniform float lineWidthMaxPixels; +uniform float stroked; +uniform bool filled; +uniform bool antialiasing; +uniform bool billboard; +uniform int radiusUnits; +uniform int lineWidthUnits; +out vec4 vFillColor; +out vec4 vLineColor; +out vec2 unitPosition; +out float innerUnitRadius; +out float outerRadiusPixels; +void main(void) { +geometry.worldPosition = instancePositions; +outerRadiusPixels = clamp( +project_size_to_pixel(radiusScale * instanceRadius, radiusUnits), +radiusMinPixels, radiusMaxPixels +); +float lineWidthPixels = clamp( +project_size_to_pixel(lineWidthScale * instanceLineWidths, lineWidthUnits), +lineWidthMinPixels, lineWidthMaxPixels +); +outerRadiusPixels += stroked * lineWidthPixels / 2.0; +float edgePadding = antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0; +unitPosition = edgePadding * positions.xy; +geometry.uv = unitPosition; +geometry.pickingColor = instancePickingColors; +innerUnitRadius = 1.0 - stroked * lineWidthPixels / outerRadiusPixels; +if (billboard) { +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +vec3 offset = edgePadding * positions * outerRadiusPixels; +DECKGL_FILTER_SIZE(offset, geometry); +gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); +} else { +vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels); +DECKGL_FILTER_SIZE(offset, geometry); +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +} +vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * opacity); +DECKGL_FILTER_COLOR(vFillColor, geometry); +vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity); +DECKGL_FILTER_COLOR(vLineColor, geometry); +} +`;var v0=`#version 300 es +#define SHADER_NAME scatterplot-layer-fragment-shader +precision highp float; +uniform bool filled; +uniform float stroked; +uniform bool antialiasing; +in vec4 vFillColor; +in vec4 vLineColor; +in vec2 unitPosition; +in float innerUnitRadius; +in float outerRadiusPixels; +out vec4 fragColor; +void main(void) { +geometry.uv = unitPosition; +float distToCenter = length(unitPosition) * outerRadiusPixels; +float inCircle = antialiasing ? +smoothedge(distToCenter, outerRadiusPixels) : +step(distToCenter, outerRadiusPixels); +if (inCircle == 0.0) { +discard; +} +if (stroked > 0.5) { +float isLine = antialiasing ? +smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) : +step(innerUnitRadius * outerRadiusPixels, distToCenter); +if (filled) { +fragColor = mix(vFillColor, vLineColor, isLine); +} else { +if (isLine == 0.0) { +discard; +} +fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine); +} +} else if (!filled) { +discard; +} else { +fragColor = vFillColor; +} +fragColor.a *= inCircle; +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var b0=[0,0,0,255],E3={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:t=>t.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:b0},getLineColor:{type:"accessor",value:b0},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},$i=class extends ne{static{this.defaultProps=E3}static{this.layerName="ScatterplotLayer"}getShaders(){return super.getShaders({vs:T0,fs:v0,modules:[ae,ue]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{radiusUnits:r,radiusScale:i,radiusMinPixels:s,radiusMaxPixels:n,stroked:o,filled:a,billboard:c,antialiasing:l,lineWidthUnits:u,lineWidthScale:f,lineWidthMinPixels:h,lineWidthMaxPixels:d}=this.props,p=this.state.model;p.setUniforms(e),p.setUniforms({stroked:o?1:0,filled:a,billboard:c,antialiasing:l,radiusUnits:pe[r],radiusScale:i,radiusMinPixels:s,radiusMaxPixels:n,lineWidthUnits:pe[u],lineWidthScale:f,lineWidthMinPixels:h,lineWidthMaxPixels:d}),p.draw(this.context.renderPass)}_getModel(){let e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new te(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new fe({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};var Ws={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function Yi(t,e,r={}){return S0(t,r)!==e?(w3(t,r),!0):!1}function S0(t,e={}){return Math.sign(Vl(t,e))}var Gd={x:0,y:1,z:2};function Vl(t,e={}){let{start:r=0,end:i=t.length,plane:s="xy"}=e,n=e.size||2,o=0,a=Gd[s[0]],c=Gd[s[1]];for(let l=r,u=i-n;l0){let s=!0;for(let n=0;ne[2]&&(r|=2),t[1]e[3]&&(r|=8),r}function la(t,e){let{size:r=2,broken:i=!1,gridResolution:s=10,gridOffset:n=[0,0],startIndex:o=0,endIndex:a=t.length}=e||{},c=(a-o)/r,l=[],u=[l],f=ti(t,0,r,o),h,d,p=w0(f,s,n,[]),g=[];tt(l,f);for(let _=1;_r&&(l=[],u.push(l),tt(l,f)),d=ca(h,p)}tt(l,h),aa(f,h)}return i?u:u[0]}var A0=0,R3=1;function ua(t,e=null,r){if(!t.length)return[];let{size:i=2,gridResolution:s=10,gridOffset:n=[0,0],edgeTypes:o=!1}=r||{},a=[],c=[{pos:t,types:o?new Array(t.length/i).fill(R3):null,holes:e||[]}],l=[[],[]],u=[];for(;c.length;){let{pos:f,types:h,holes:d}=c.shift();M3(f,i,d[0]||f.length,l),u=w0(l[0],s,n,u);let p=ca(l[1],u);if(p){let g=E0(f,h,i,0,d[0]||f.length,u,p),_={pos:g[0].pos,types:g[0].types,holes:[]},x={pos:g[1].pos,types:g[1].types,holes:[]};c.push(_,x);for(let v=0;v=0?(tt(l,d)&&f.push(g),A+=p):f.length&&(f[f.length-1]=A0),aa(_,d),x=p,v=g;return[b?{pos:c,types:e&&u}:null,A?{pos:l,types:e&&f}:null]}function w0(t,e,r,i){let s=Math.floor((t[0]-r[0])/e)*e+r[0],n=Math.floor((t[1]-r[1])/e)*e+r[1];return i[0]=s,i[1]=n,i[2]=s+e,i[3]=n+e,i}function C3(t,e,r){r&8?(t[1]+=e,t[3]+=e):r&4?(t[1]-=e,t[3]-=e):r&2?(t[0]+=e,t[2]+=e):r&1&&(t[0]-=e,t[2]-=e)}function M3(t,e,r,i){let s=1/0,n=-1/0,o=1/0,a=-1/0;for(let c=0;cn?l:n,o=ua?u:a}return i[0][0]=s,i[0][1]=o,i[1][0]=n,i[1][1]=a,i}function Hl(t,e){for(let r=0;rs&&(s=a,n=o-1)}return n}function N3(t,e,r,i,s=I3){let n=t[r],o=t[i-e];if(Math.abs(n-o)>180){let a=ti(t,0,e,r);a[0]+=Math.round((o-n)/360)*360,tt(t,a),a[1]=Math.sign(a[1])*s,tt(t,a),a[0]=n,tt(t,a)}}function P0(t,e,r,i){let s=t[0],n;for(let o=r;o180||a<-180)&&(n-=Math.round(a/360)*360),t[o]=s=n}}function R0(t,e){let r,i=t.length/e;for(let n=0;n=i),s=s.flatMap(d=>[d[0],d[1]]),Yi(s,Ws.COUNTER_CLOCKWISE));let n=r>0,o=i+1,a=n?o*3+1:i,c=Math.PI*2/i,l=new Uint16Array(n?i*3*2:0),u=new Float32Array(a*3),f=new Float32Array(a*3),h=0;if(n){for(let d=0;d 0.0 && instanceElevations >= 0.0); +float dotRadius = radius * coverage * shouldRender; +geometry.pickingColor = instancePickingColors; +vec3 centroidPosition = vec3(instancePositions.xy, instancePositions.z + elevation); +vec3 centroidPosition64Low = instancePositions64Low; +vec2 offset = (rotationMatrix * positions.xy * strokeOffsetRatio + offset) * dotRadius; +if (radiusUnits == UNIT_METERS) { +offset = project_size(offset); +} +vec3 pos = vec3(offset, 0.); +DECKGL_FILTER_SIZE(pos, geometry); +gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position); +geometry.normal = project_normal(vec3(rotationMatrix * normals.xy, normals.z)); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +if (extruded && !isStroke) { +#ifdef FLAT_SHADING +position_commonspace = geometry.position; +vColor = vec4(color.rgb, color.a * opacity); +#else +vec3 lightColor = lighting_getLightColor(color.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal); +vColor = vec4(lightColor, color.a * opacity); +#endif +} else { +vColor = vec4(color.rgb, color.a * opacity); +} +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var M0=`#version 300 es +#define SHADER_NAME column-layer-fragment-shader +precision highp float; +uniform vec3 project_uCameraPosition; +uniform bool extruded; +uniform bool isStroke; +out vec4 fragColor; +in vec4 vColor; +#ifdef FLAT_SHADING +in vec4 position_commonspace; +#endif +void main(void) { +fragColor = vColor; +geometry.uv = vec2(0.); +#ifdef FLAT_SHADING +if (extruded && !isStroke && !bool(picking.isActive)) { +vec3 normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz))); +fragColor.rgb = lighting_getLightColor(vColor.rgb, project_uCameraPosition, position_commonspace.xyz, normal); +} +#endif +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var jl=[0,0,0,255],L3={diskResolution:{type:"number",min:4,value:20},vertices:null,radius:{type:"number",min:0,value:1e3},angle:{type:"number",value:0},offset:{type:"array",value:[0,0]},coverage:{type:"number",min:0,max:1,value:1},elevationScale:{type:"number",min:0,value:1},radiusUnits:"meters",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,extruded:!0,wireframe:!1,filled:!0,stroked:!1,flatShading:!1,getPosition:{type:"accessor",value:t=>t.position},getFillColor:{type:"accessor",value:jl},getLineColor:{type:"accessor",value:jl},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0,getColor:{deprecatedFor:["getFillColor","getLineColor"]}},wr=class extends ne{static{this.layerName="ColumnLayer"}static{this.defaultProps=L3}getShaders(){let e={},{flatShading:r}=this.props;return r&&(e.FLAT_SHADING=1),super.getShaders({vs:C0,fs:M0,defines:e,modules:[ae,r?Zn:Mt,ue]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceElevations:{size:1,transition:!0,accessor:"getElevation"},instanceFillColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getFillColor",defaultValue:jl},instanceLineColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getLineColor",defaultValue:jl},instanceStrokeWidths:{size:1,accessor:"getLineWidth",transition:!0}})}updateState(e){super.updateState(e);let{props:r,oldProps:i,changeFlags:s}=e,n=s.extensionsChanged||r.flatShading!==i.flatShading;n&&(this.state.models?.forEach(a=>a.destroy()),this.setState(this._getModels()),this.getAttributeManager().invalidateAll());let o=this.getNumInstances();this.state.fillModel.setInstanceCount(o),this.state.wireframeModel.setInstanceCount(o),(n||r.diskResolution!==i.diskResolution||r.vertices!==i.vertices||(r.extruded||r.stroked)!==(i.extruded||i.stroked))&&this._updateGeometry(r)}getGeometry(e,r,i){let s=new fa({radius:1,height:i?2:0,vertices:r,nradial:e}),n=0;if(r)for(let o=0;o=e.length&&(r+=1-e.length/s);let n=r*s;return i[0]=e[n],i[1]=e[n+1],i[2]=s===3&&e[n+2]||0,i}isClosed(e){if(!this.normalize)return!!this.opts.loop;let{positionSize:r}=this,i=e.length-r;return e[0]===e[i]&&e[1]===e[i+1]&&(r===2||e[2]===e[i+2])}};function O0(t){return Array.isArray(t[0])}var N0=`#version 300 es +#define SHADER_NAME path-layer-vertex-shader +in vec2 positions; +in float instanceTypes; +in vec3 instanceStartPositions; +in vec3 instanceEndPositions; +in vec3 instanceLeftPositions; +in vec3 instanceRightPositions; +in vec3 instanceLeftPositions64Low; +in vec3 instanceStartPositions64Low; +in vec3 instanceEndPositions64Low; +in vec3 instanceRightPositions64Low; +in float instanceStrokeWidths; +in vec4 instanceColors; +in vec3 instancePickingColors; +uniform float widthScale; +uniform float widthMinPixels; +uniform float widthMaxPixels; +uniform float jointType; +uniform float capType; +uniform float miterLimit; +uniform bool billboard; +uniform int widthUnits; +uniform float opacity; +out vec4 vColor; +out vec2 vCornerOffset; +out float vMiterLength; +out vec2 vPathPosition; +out float vPathLength; +out float vJointType; +const float EPSILON = 0.001; +const vec3 ZERO_OFFSET = vec3(0.0); +float flipIfTrue(bool flag) { +return -(float(flag) * 2. - 1.); +} +vec3 getLineJoinOffset( +vec3 prevPoint, vec3 currPoint, vec3 nextPoint, +vec2 width +) { +bool isEnd = positions.x > 0.0; +float sideOfPath = positions.y; +float isJoint = float(sideOfPath == 0.0); +vec3 deltaA3 = (currPoint - prevPoint); +vec3 deltaB3 = (nextPoint - currPoint); +mat3 rotationMatrix; +bool needsRotation = !billboard && project_needs_rotation(currPoint, rotationMatrix); +if (needsRotation) { +deltaA3 = deltaA3 * rotationMatrix; +deltaB3 = deltaB3 * rotationMatrix; +} +vec2 deltaA = deltaA3.xy / width; +vec2 deltaB = deltaB3.xy / width; +float lenA = length(deltaA); +float lenB = length(deltaB); +vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0); +vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0); +vec2 perpA = vec2(-dirA.y, dirA.x); +vec2 perpB = vec2(-dirB.y, dirB.x); +vec2 tangent = dirA + dirB; +tangent = length(tangent) > 0. ? normalize(tangent) : perpA; +vec2 miterVec = vec2(-tangent.y, tangent.x); +vec2 dir = isEnd ? dirA : dirB; +vec2 perp = isEnd ? perpA : perpB; +float L = isEnd ? lenA : lenB; +float sinHalfA = abs(dot(miterVec, perp)); +float cosHalfA = abs(dot(dirA, miterVec)); +float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x); +float cornerPosition = sideOfPath * turnDirection; +float miterSize = 1.0 / max(sinHalfA, EPSILON); +miterSize = mix( +min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)), +miterSize, +step(0.0, cornerPosition) +); +vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition)) +* (sideOfPath + isJoint * turnDirection); +bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0)); +bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0)); +bool isCap = isStartCap || isEndCap; +if (isCap) { +offsetVec = mix(perp * sideOfPath, dir * capType * 4.0 * flipIfTrue(isStartCap), isJoint); +vJointType = capType; +} else { +vJointType = jointType; +} +vPathLength = L; +vCornerOffset = offsetVec; +vMiterLength = dot(vCornerOffset, miterVec * turnDirection); +vMiterLength = isCap ? isJoint : vMiterLength; +vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd); +vPathPosition = vec2( +dot(offsetFromStartOfPath, perp), +dot(offsetFromStartOfPath, dir) +); +geometry.uv = vPathPosition; +float isValid = step(instanceTypes, 3.5); +vec3 offset = vec3(offsetVec * width * isValid, 0.0); +if (needsRotation) { +offset = rotationMatrix * offset; +} +return offset; +} +void clipLine(inout vec4 position, vec4 refPosition) { +if (position.w < EPSILON) { +float r = (EPSILON - refPosition.w) / (position.w - refPosition.w); +position = refPosition + (position - refPosition) * r; +} +} +void main() { +geometry.pickingColor = instancePickingColors; +vColor = vec4(instanceColors.rgb, instanceColors.a * opacity); +float isEnd = positions.x; +vec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd); +vec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd); +vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd); +vec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd); +vec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd); +vec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd); +geometry.worldPosition = currPosition; +vec2 widthPixels = vec2(clamp( +project_size_to_pixel(instanceStrokeWidths * widthScale, widthUnits), +widthMinPixels, widthMaxPixels) / 2.0); +vec3 width; +if (billboard) { +vec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET); +vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position); +vec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET); +clipLine(prevPositionScreen, currPositionScreen); +clipLine(nextPositionScreen, currPositionScreen); +clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd)); +width = vec3(widthPixels, 0.0); +DECKGL_FILTER_SIZE(width, geometry); +vec3 offset = getLineJoinOffset( +prevPositionScreen.xyz / prevPositionScreen.w, +currPositionScreen.xyz / currPositionScreen.w, +nextPositionScreen.xyz / nextPositionScreen.w, +project_pixel_size_to_clipspace(width.xy) +); +DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry); +gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w); +} else { +prevPosition = project_position(prevPosition, prevPosition64Low); +currPosition = project_position(currPosition, currPosition64Low); +nextPosition = project_position(nextPosition, nextPosition64Low); +width = vec3(project_pixel_size(widthPixels), 0.0); +DECKGL_FILTER_SIZE(width, geometry); +vec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy); +geometry.position = vec4(currPosition + offset, 1.0); +gl_Position = project_common_position_to_clipspace(geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +} +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var F0=`#version 300 es +#define SHADER_NAME path-layer-fragment-shader +precision highp float; +uniform float miterLimit; +in vec4 vColor; +in vec2 vCornerOffset; +in float vMiterLength; +in vec2 vPathPosition; +in float vPathLength; +in float vJointType; +out vec4 fragColor; +void main(void) { +geometry.uv = vPathPosition; +if (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) { +if (vJointType > 0.5 && length(vCornerOffset) > 1.0) { +discard; +} +if (vJointType < 0.5 && vMiterLength > miterLimit + 1.0) { +discard; +} +} +fragColor = vColor; +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var D0=[0,0,0,255],z3={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:t=>t.path},getColor:{type:"accessor",value:D0},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},ep={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t},Pr=class extends ne{static{this.defaultProps=z3}static{this.layerName="PathLayer"}getShaders(){return super.getShaders({vs:N0,fs:F0,modules:[ae,ue]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:ep,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:ep,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:ep,defaultValue:D0},instancePickingColors:{size:4,type:"uint8",accessor:(i,{index:s,target:n})=>this.encodePickingColor(i&&i.__source?i.__source.index:s,n)}}),this.setState({pathTesselator:new ha({fp64:this.use64bitPositions()})})}updateState(e){super.updateState(e);let{props:r,changeFlags:i}=e,s=this.getAttributeManager();if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPath)){let{pathTesselator:o}=this.state,a=r.data.attributes||{};o.updateGeometry({data:r.data,geometryBuffer:a.getPath,buffers:a,normalize:!r._pathType,loop:r._pathType==="loop",getGeometry:r.getPath,positionFormat:r.positionFormat,wrapLongitude:r.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:i.dataChanged}),this.setState({numInstances:o.instanceCount,startIndices:o.vertexStarts}),i.dataChanged||s.invalidateAll()}i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),s.invalidateAll())}getPickingInfo(e){let r=super.getPickingInfo(e),{index:i}=r,s=this.props.data;return s[0]&&s[0].__source&&(r.object=s.find(n=>n.__source.index===i)),r}disablePickingIndex(e){let r=this.props.data;if(r[0]&&r[0].__source)for(let i=0;i=1&&t[0].length>=2&&Number.isFinite(t[0][0])}function n2(t){let e=t[0],r=t[t.length-1];return e[0]===r[0]&&e[1]===r[1]&&e[2]===r[2]}function o2(t,e,r,i){for(let s=0;sa/e));let n=js(t),o=i&&e===3;if(r){let a=n.length;n=n.slice();let c=[];for(let l=0;lc&&a>l||(c>l?(r||(n=n.slice()),j0(n,0,2,1)):(r||(n=n.slice()),j0(n,2,0,1)))}return(0,X0.default)(n,s,e)}var _a=class extends ei{constructor(e){let{fp64:r,IndexType:i=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:r?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:i,size:1}}})}get(e){let{attributes:r}=this;return e==="indices"?r.indices&&r.indices.subarray(0,this.vertexCount):r[e]}updateGeometry(e){super.updateGeometry(e);let r=this.buffers.indices;if(r)this.vertexCount=(r.value||r).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){let r=Gl(e,this.positionSize);return this.opts.resolution?ua(js(r),ma(r),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?Jd(js(r),ma(r),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):r}return e}getGeometrySize(e){if(K0(e)){let r=0;for(let i of e)r+=this.getGeometrySize(i);return r}return js(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,r){if(e&&K0(e))for(let i of e){let s=this.getGeometrySize(i);r.geometrySize=s,this.updateGeometryAttributes(i,r),r.vertexStart+=s,r.indexStart=this.indexStarts[r.geometryIndex+1]}else{let i=e;this._updateIndices(i,r),this._updatePositions(i,r),this._updateVertexValid(i,r)}}_updateIndices(e,{geometryIndex:r,vertexStart:i,indexStart:s}){let{attributes:n,indexStarts:o,typedArrayManager:a}=this,c=n.indices;if(!c||!e)return;let l=s,u=$0(e,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,s+u.length,{copy:!0});for(let f=0;f2?o[c*n+2]:0;s[a*3]=l,s[a*3+1]=u,s[a*3+2]=f}}_updateVertexValid(e,{vertexStart:r,geometrySize:i}){let{positionSize:s}=this,n=this.attributes.vertexValid,o=e&&ma(e);if(e&&e.edgeTypes?n.set(e.edgeTypes,r):n.fill(1,r,r+i),o)for(let a=0;a0&&!Number.isFinite(t[0])}var Zl=`uniform bool extruded; +uniform bool isWireframe; +uniform float elevationScale; +uniform float opacity; +in vec4 fillColors; +in vec4 lineColors; +in vec3 pickingColors; +out vec4 vColor; +struct PolygonProps { +vec3 positions; +vec3 positions64Low; +vec3 normal; +float elevations; +}; +vec3 project_offset_normal(vec3 vector) { +if (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT || +project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) { +return normalize(vector * project_uCommonUnitsPerWorldUnit); +} +return project_normal(vector); +} +void calculatePosition(PolygonProps props) { +vec3 pos = props.positions; +vec3 pos64Low = props.positions64Low; +vec3 normal = props.normal; +vec4 colors = isWireframe ? lineColors : fillColors; +geometry.worldPosition = props.positions; +geometry.pickingColor = pickingColors; +if (extruded) { +pos.z += props.elevations * elevationScale; +} +gl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +if (extruded) { +#ifdef IS_SIDE_VERTEX +normal = project_offset_normal(normal); +#else +normal = project_normal(normal); +#endif +geometry.normal = normal; +vec3 lightColor = lighting_getLightColor(colors.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal); +vColor = vec4(lightColor, colors.a * opacity); +} else { +vColor = vec4(colors.rgb, colors.a * opacity); +} +DECKGL_FILTER_COLOR(vColor, geometry); +} +`;var q0=`#version 300 es +#define SHADER_NAME solid-polygon-layer-vertex-shader +in vec3 vertexPositions; +in vec3 vertexPositions64Low; +in float elevations; +${Zl} +void main(void) { +PolygonProps props; +props.positions = vertexPositions; +props.positions64Low = vertexPositions64Low; +props.elevations = elevations; +props.normal = vec3(0.0, 0.0, 1.0); +calculatePosition(props); +} +`;var G0=`#version 300 es +#define SHADER_NAME solid-polygon-layer-vertex-shader-side +#define IS_SIDE_VERTEX +in vec2 positions; +in vec3 vertexPositions; +in vec3 nextVertexPositions; +in vec3 vertexPositions64Low; +in vec3 nextVertexPositions64Low; +in float elevations; +in float instanceVertexValid; +${Zl} +void main(void) { +if(instanceVertexValid < 0.5){ +gl_Position = vec4(0.); +return; +} +PolygonProps props; +vec3 pos; +vec3 pos64Low; +vec3 nextPos; +vec3 nextPos64Low; +#if RING_WINDING_ORDER_CW == 1 +pos = vertexPositions; +pos64Low = vertexPositions64Low; +nextPos = nextVertexPositions; +nextPos64Low = nextVertexPositions64Low; +#else +pos = nextVertexPositions; +pos64Low = nextVertexPositions64Low; +nextPos = vertexPositions; +nextPos64Low = vertexPositions64Low; +#endif +props.positions = mix(pos, nextPos, positions.x); +props.positions64Low = mix(pos64Low, nextPos64Low, positions.x); +props.normal = vec3( +pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y), +nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x), +0.0); +props.elevations = elevations * positions.y; +calculatePosition(props); +} +`;var Z0=`#version 300 es +#define SHADER_NAME solid-polygon-layer-fragment-shader +precision highp float; +in vec4 vColor; +out vec4 fragColor; +void main(void) { +fragColor = vColor; +geometry.uv = vec2(0.); +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var Ql=[0,0,0,255],a2={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:t=>t.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:Ql},getLineColor:{type:"accessor",value:Ql},material:!0},Jl={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t},zt=class extends ne{static{this.defaultProps=a2}static{this.layerName="SolidPolygonLayer"}getShaders(e){return super.getShaders({vs:e==="top"?q0:G0,fs:Z0,defines:{RING_WINDING_ORDER_CW:!this.props._normalize&&this.props._windingOrder==="CCW"?0:1},modules:[ae,Mt,ue]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){let{viewport:e}=this.context,{coordinateSystem:r}=this.props,{_full3d:i}=this.props;e.isGeospatial&&r===q.DEFAULT&&(r=q.LNGLAT);let s;r===q.LNGLAT&&(i?s=e.projectPosition.bind(e):s=e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new _a({preproject:s,fp64:this.use64bitPositions(),IndexType:Uint32Array})});let n=this.getAttributeManager(),o=!0;n.remove(["instancePickingColors"]),n.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:Jl,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,stepMode:"dynamic",transition:Jl,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:Jl,accessor:"getFillColor",defaultValue:Ql},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:Jl,accessor:"getLineColor",defaultValue:Ql},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(a,{index:c,target:l})=>this.encodePickingColor(a&&a.__source?a.__source.index:c,l)}})}getPickingInfo(e){let r=super.getPickingInfo(e),{index:i}=r,s=this.props.data;return s[0]&&s[0].__source&&(r.object=s.find(n=>n.__source.index===i)),r}disablePickingIndex(e){let r=this.props.data;if(r[0]&&r[0].__source)for(let i=0;ia.destroy()),this.setState(this._getModels()),n.invalidateAll())}updateGeometry({props:e,oldProps:r,changeFlags:i}){if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPolygon)){let{polygonTesselator:n}=this.state,o=e.data.attributes||{};n.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:o.getPolygon,buffers:o,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:i.dataChanged,full3d:e._full3d}),this.setState({numInstances:n.instanceCount,startIndices:n.vertexStarts}),i.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){let{id:e,filled:r,extruded:i}=this.props,s,n,o;if(r){let a=this.getShaders("top");a.defines.NON_INSTANCED_MODEL=1;let c=this.getAttributeManager().getBufferLayouts({isInstanced:!1});s=new te(this.context.device,{...a,id:`${e}-top`,topology:"triangle-list",uniforms:{isWireframe:!1},bufferLayout:c,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(i){let a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});n=new te(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:a,uniforms:{isWireframe:!1},geometry:new fe({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),o=new te(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:a,uniforms:{isWireframe:!0},geometry:new fe({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[n,o,s].filter(Boolean),topModel:s,sideModel:n,wireframeModel:o}}calculateIndices(e){let{polygonTesselator:r}=this.state;e.startIndices=r.indexStarts,e.value=r.get("indices")}calculatePositions(e){let{polygonTesselator:r}=this.state;e.startIndices=r.vertexStarts,e.value=r.get("positions")}calculateVertexValid(e){e.value=this.state.polygonTesselator.get("vertexValid")}};function eu({data:t,getIndex:e,dataRange:r,replace:i}){let{startRow:s=0,endRow:n=1/0}=r,o=t.length,a=o,c=o;for(let h=0;hh&&d>=s&&(a=h),d>=n){c=h;break}}let l=a,f=c-a!==i.length?t.slice(c):void 0;for(let h=0;ht.polygon},getFillColor:{type:"accessor",value:c2},getLineColor:{type:"accessor",value:J0},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0},ya=class extends et{static{this.layerName="PolygonLayer"}static{this.defaultProps=l2}initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&U.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:e}){let r=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getPolygon);if(r&&Array.isArray(e.dataChanged)){let i=this.state.paths.slice(),s=e.dataChanged.map(n=>eu({data:i,getIndex:o=>o.__source.index,dataRange:n,replace:this._getPaths(n)}));this.setState({paths:i,pathsDiff:s})}else r&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(e={}){let{data:r,getPolygon:i,positionFormat:s,_normalize:n}=this.props,o=[],a=s==="XY"?2:3,{startRow:c,endRow:l}=e,{iterable:u,objectInfo:f}=$e(r,c,l);for(let h of u){f.index++;let d=i(h,f);n&&(d=Gl(d,a));let{holeIndices:p}=d,g=d.positions||d;if(p)for(let _=0;_<=p.length;_++){let x=g.slice(p[_-1]||0,p[_]||g.length);o.push(this.getSubLayerRow({path:x},h,f.index))}else o.push(this.getSubLayerRow({path:g},h,f.index))}return o}renderLayers(){let{data:e,_dataDiff:r,stroked:i,filled:s,extruded:n,wireframe:o,_normalize:a,_windingOrder:c,elevationScale:l,transitions:u,positionFormat:f}=this.props,{lineWidthUnits:h,lineWidthScale:d,lineWidthMinPixels:p,lineWidthMaxPixels:g,lineJointRounded:_,lineMiterLimit:x,lineDashJustified:v}=this.props,{getFillColor:b,getLineColor:A,getLineWidth:C,getLineDashArray:M,getElevation:F,getPolygon:N,updateTriggers:D,material:L}=this.props,{paths:Y,pathsDiff:X}=this.state,$=this.getSubLayerClass("fill",zt),Z=this.getSubLayerClass("stroke",Pr),ge=this.shouldRenderSubLayer("fill",Y)&&new $({_dataDiff:r,extruded:n,elevationScale:l,filled:s,wireframe:o,_normalize:a,_windingOrder:c,getElevation:F,getFillColor:b,getLineColor:n&&o?A:J0,material:L,transitions:u},this.getSubLayerProps({id:"fill",updateTriggers:D&&{getPolygon:D.getPolygon,getElevation:D.getElevation,getFillColor:D.getFillColor,lineColors:n&&o,getLineColor:D.getLineColor}}),{data:e,positionFormat:f,getPolygon:N}),rt=!n&&i&&this.shouldRenderSubLayer("stroke",Y)&&new Z({_dataDiff:X&&(()=>X),widthUnits:h,widthScale:d,widthMinPixels:p,widthMaxPixels:g,jointRounded:_,miterLimit:x,dashJustified:v,_pathType:"loop",transitions:u&&{getWidth:u.getLineWidth,getColor:u.getLineColor,getPath:u.getPolygon},getColor:this.getSubLayerAccessor(A),getWidth:this.getSubLayerAccessor(C),getDashArray:this.getSubLayerAccessor(M)},this.getSubLayerProps({id:"stroke",updateTriggers:D&&{getWidth:D.getLineWidth,getColor:D.getLineColor,getDashArray:D.getLineDashArray}}),{data:Y,positionFormat:f,getPath:ot=>ot.path});return[!n&&ge,rt,n&&ge]}};function Q0(t,e){if(!t)return null;let r="startIndices"in t?t.startIndices[e]:e,i=t.featureIds.value[r];return r!==-1?u2(t,i,r):null}function u2(t,e,r){let i={properties:{...t.properties[e]}};for(let s in t.numericProps)i.properties[s]=t.numericProps[s].value[r];return i}function eT(t,e){let r={points:null,lines:null,polygons:null};for(let i in r){let s=t[i].globalFeatureIds.value;r[i]=new Uint8ClampedArray(s.length*3);let n=[];for(let o=0;o 0.0) { +float inFill = alpha; +float inBorder = smoothstep(outlineBuffer - gamma, outlineBuffer + gamma, distance); +color = mix(outlineColor, vColor, inFill); +alpha = inBorder; +} +} +float a = alpha * color.a; +if (a < alphaCutoff) { +discard; +} +fragColor = vec4(color.rgb, a * opacity); +} +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var op=192/256,rT=[],f2={getIconOffsets:{type:"accessor",value:t=>t.offsets},alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]}},Gi=class extends Er{static{this.defaultProps=f2}static{this.layerName="MultiIconLayer"}getShaders(){return{...super.getShaders(),fs:tT}}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({instanceOffsets:{size:2,accessor:"getIconOffsets"},instancePickingColors:{type:"uint8",size:3,accessor:(r,{index:i,target:s})=>this.encodePickingColor(i,s)}})}updateState(e){super.updateState(e);let{props:r,oldProps:i}=e,{outlineColor:s}=r;s!==i.outlineColor&&(s=s.map(n=>n/255),s[3]=Number.isFinite(s[3])?s[3]:1,this.setState({outlineColor:s})),!r.sdf&&r.outlineWidth&&U.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){let{sdf:r,smoothing:i,outlineWidth:s}=this.props,{outlineColor:n}=this.state,o=s?Math.max(i,op*(1-s)):-1;if(e.uniforms={...e.uniforms,sdfBuffer:op,outlineBuffer:o,gamma:i,sdf:!!r,outlineColor:n},super.draw(e),r&&s){let{iconManager:a}=this.state,c=a.getTexture(),l=this.state.model;c&&(l.setUniforms({outlineBuffer:op}),l.draw(this.context.renderPass))}}getInstanceOffset(e){return e?Array.from(e).flatMap(r=>super.getInstanceOffset(r)):rT}getInstanceColorMode(e){return 1}getInstanceIconFrame(e){return e?Array.from(e).flatMap(r=>super.getInstanceIconFrame(r)):rT}};var xa=class{constructor({fontSize:e=24,buffer:r=3,radius:i=8,cutoff:s=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=r,this.cutoff=s,this.radius=i;let c=this.size=e+r*4,l=this._createCanvas(c),u=this.ctx=l.getContext("2d",{willReadFrequently:!0});u.font=`${a} ${o} ${e}px ${n}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(c*c),this.gridInner=new Float64Array(c*c),this.f=new Float64Array(c),this.z=new Float64Array(c+1),this.v=new Uint16Array(c)}_createCanvas(e){let r=document.createElement("canvas");return r.width=r.height=e,r}draw(e){let{width:r,actualBoundingBoxAscent:i,actualBoundingBoxDescent:s,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(i),c=0,l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),u=Math.min(this.size-this.buffer,a+Math.ceil(s)),f=l+2*this.buffer,h=u+2*this.buffer,d=Math.max(f*h,0),p=new Uint8ClampedArray(d),g={data:p,width:f,height:h,glyphWidth:l,glyphHeight:u,glyphTop:a,glyphLeft:c,glyphAdvance:r};if(l===0||u===0)return g;let{ctx:_,buffer:x,gridInner:v,gridOuter:b}=this;_.clearRect(x,x,l,u),_.fillText(e,x,x+a);let A=_.getImageData(x,x,l,u);b.fill(1e20,0,d),v.fill(0,0,d);for(let C=0;C0?D*D:0,v[N]=D<0?D*D:0}}iT(b,0,0,f,h,f,this.f,this.v,this.z),iT(v,x,x,l,u,f,this.f,this.v,this.z);for(let C=0;C-1);c++,n[c]=a,o[c]=l,o[c+1]=1e20}for(let a=0,c=0;as&&(l=0,c++),n[f]={x:l+i,y:a+c*u+i,width:h,height:u,layoutWidth:h,layoutHeight:r},l+=h+i*2}return{mapping:n,xOffset:l,yOffset:a+c*u,canvasHeight:p2(a+(c+1)*u)}}function oT(t,e,r,i){let s=0;for(let n=e;ni&&(oa){let f=oT(t,a,c,s);l+f>i&&(oi&&(f=aT(t,a,c,i,s,n),o=n[n.length-1])),a=c,l+=f}return l}function m2(t,e,r,i,s=0,n){n===void 0&&(n=t.length);let o=[];return e==="break-all"?aT(t,s,n,r,i,o):g2(t,s,n,r,i,o),o}function _2(t,e,r,i,s,n){let o=0,a=0;for(let c=e;c0,f=[0,0],h=[0,0],d=0,p=0,g=0;for(let _=0;_<=o;_++){let x=n[_];if((x===` +`||_===o)&&(g=_),g>p){let v=u?m2(n,r,i,s,p,g):d2;for(let b=0;b<=v.length;b++){let A=b===0?p:v[b-1],C=b1||c>0){let d=t.constructor;h=new d(l);for(let p=0;p=0&&this._order.splice(r,1)}_appendOrder(e){this._order.push(e)}};function y2(){let t=[];for(let e=32;e<128;e++)t.push(String.fromCharCode(e));return t}var Zi={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:y2(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1},uT=1024,fT=.9,hT=1.2,pT=3,tu=new Xs(pT);function x2(t,e){let r;typeof e=="string"?r=new Set(Array.from(e)):r=new Set(e);let i=tu.get(t);if(!i)return r;for(let s in i.mapping)r.has(s)&&r.delete(s);return r}function T2(t,e){for(let r=0;r=pT,"Invalid cache limit"),tu=new Xs(t)}var Ta=class{constructor(){this.props={...Zi}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}get scale(){let{fontSize:e,buffer:r}=this.props;return(e*hT+r*2)/e}setProps(e={}){Object.assign(this.props,e),this._key=this._getKey();let r=x2(this._key,this.props.characterSet),i=tu.get(this._key);if(i&&r.size===0){this._atlas!==i&&(this._atlas=i);return}let s=this._generateFontAtlas(r,i);this._atlas=s,tu.set(this._key,s)}_generateFontAtlas(e,r){let{fontFamily:i,fontWeight:s,fontSize:n,buffer:o,sdf:a,radius:c,cutoff:l}=this.props,u=r&&r.data;u||(u=document.createElement("canvas"),u.width=uT);let f=u.getContext("2d",{willReadFrequently:!0});dT(f,i,n,s);let{mapping:h,canvasHeight:d,xOffset:p,yOffset:g}=nT({getFontWidth:_=>f.measureText(_).width,fontHeight:n*hT,buffer:o,characterSet:e,maxCanvasWidth:uT,...r&&{mapping:r.mapping,xOffset:r.xOffset,yOffset:r.yOffset}});if(u.height!==d){let _=f.getImageData(0,0,u.width,u.height);u.height=d,f.putImageData(_,0,0)}if(dT(f,i,n,s),a){let _=new xa({fontSize:n,buffer:o,radius:c,cutoff:l,fontFamily:i,fontWeight:`${s}`});for(let x of e){let{data:v,width:b,height:A,glyphTop:C}=_.draw(x);h[x].width=b,h[x].layoutOffsetY=n*fT-C;let M=f.createImageData(b,A);T2(v,M),f.putImageData(M,h[x].x,h[x].y)}}else for(let _ of e)f.fillText(_,h[_].x,h[_].y+o+n*fT);return{xOffset:p,yOffset:g,mapping:h,data:u,width:u.width,height:u.height}}_getKey(){let{fontFamily:e,fontWeight:r,fontSize:i,buffer:s,sdf:n,radius:o,cutoff:a}=this.props;return n?`${e} ${r} ${i} ${s} ${o} ${a}`:`${e} ${r} ${i} ${s}`}};var mT=`#version 300 es +#define SHADER_NAME text-background-layer-vertex-shader +in vec2 positions; +in vec3 instancePositions; +in vec3 instancePositions64Low; +in vec4 instanceRects; +in float instanceSizes; +in float instanceAngles; +in vec2 instancePixelOffsets; +in float instanceLineWidths; +in vec4 instanceFillColors; +in vec4 instanceLineColors; +in vec3 instancePickingColors; +uniform bool billboard; +uniform float opacity; +uniform float sizeScale; +uniform float sizeMinPixels; +uniform float sizeMaxPixels; +uniform vec4 padding; +uniform int sizeUnits; +out vec4 vFillColor; +out vec4 vLineColor; +out float vLineWidth; +out vec2 uv; +out vec2 dimensions; +vec2 rotate_by_angle(vec2 vertex, float angle) { +float angle_radian = radians(angle); +float cos_angle = cos(angle_radian); +float sin_angle = sin(angle_radian); +mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle); +return rotationMatrix * vertex; +} +void main(void) { +geometry.worldPosition = instancePositions; +geometry.uv = positions; +geometry.pickingColor = instancePickingColors; +uv = positions; +vLineWidth = instanceLineWidths; +float sizePixels = clamp( +project_size_to_pixel(instanceSizes * sizeScale, sizeUnits), +sizeMinPixels, sizeMaxPixels +); +dimensions = instanceRects.zw * sizePixels + padding.xy + padding.zw; +vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * sizePixels + mix(-padding.xy, padding.zw, positions); +pixelOffset = rotate_by_angle(pixelOffset, instanceAngles); +pixelOffset += instancePixelOffsets; +pixelOffset.y *= -1.0; +if (billboard) { +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +vec3 offset = vec3(pixelOffset, 0.0); +DECKGL_FILTER_SIZE(offset, geometry); +gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); +} else { +vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0); +DECKGL_FILTER_SIZE(offset_common, geometry); +gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); +DECKGL_FILTER_GL_POSITION(gl_Position, geometry); +} +vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * opacity); +DECKGL_FILTER_COLOR(vFillColor, geometry); +vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity); +DECKGL_FILTER_COLOR(vLineColor, geometry); +} +`;var _T=`#version 300 es +#define SHADER_NAME text-background-layer-fragment-shader +precision highp float; +uniform bool stroked; +in vec4 vFillColor; +in vec4 vLineColor; +in float vLineWidth; +in vec2 uv; +in vec2 dimensions; +out vec4 fragColor; +void main(void) { +geometry.uv = uv; +vec2 pixelPosition = uv * dimensions; +if (stroked) { +float distToEdge = min( +min(pixelPosition.x, dimensions.x - pixelPosition.x), +min(pixelPosition.y, dimensions.y - pixelPosition.y) +); +float isBorder = smoothedge(distToEdge, vLineWidth); +fragColor = mix(vFillColor, vLineColor, isBorder); +} else { +fragColor = vFillColor; +} +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var v2={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:t=>t.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}},Ji=class extends ne{static{this.defaultProps=v2}static{this.layerName="TextBackgroundLayer"}getShaders(){return super.getShaders({vs:mT,fs:_T,modules:[ae,ue]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instanceRects:{size:4,accessor:"getBoundingRect"},instancePixelOffsets:{size:2,transition:!0,accessor:"getPixelOffset"},instanceFillColors:{size:4,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e);let{changeFlags:r}=e;r.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){let{billboard:r,sizeScale:i,sizeUnits:s,sizeMinPixels:n,sizeMaxPixels:o,getLineWidth:a}=this.props,{padding:c}=this.props;c.length<4&&(c=[c[0],c[1],c[0],c[1]]);let l=this.state.model;l.setUniforms(e),l.setUniforms({billboard:r,stroked:!!a,padding:c,sizeUnits:pe[s],sizeScale:i,sizeMinPixels:n,sizeMaxPixels:o}),l.draw(this.context.renderPass)}_getModel(){let e=[0,0,1,0,1,1,0,1];return new te(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new fe({topology:"triangle-fan-webgl",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}};var yT={start:1,middle:0,end:-1},xT={top:1,center:0,bottom:-1},ap=[0,0,0,255],b2=1,S2={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,background:!1,getBackgroundColor:{type:"accessor",value:[255,255,255,255]},getBorderColor:{type:"accessor",value:ap},getBorderWidth:{type:"accessor",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:Zi.characterSet},fontFamily:Zi.fontFamily,fontWeight:Zi.fontWeight,lineHeight:b2,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:ap},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},getText:{type:"accessor",value:t=>t.text},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:ap},getSize:{type:"accessor",value:32},getAngle:{type:"accessor",value:0},getTextAnchor:{type:"accessor",value:"middle"},getAlignmentBaseline:{type:"accessor",value:"center"},getPixelOffset:{type:"accessor",value:[0,0]},backgroundColor:{deprecatedFor:["background","getBackgroundColor"]}},Qi=class extends et{constructor(){super(...arguments),this.getBoundingRect=(e,r)=>{let{size:[i,s]}=this.transformParagraph(e,r),{fontSize:n}=this.state.fontAtlasManager.props;i/=n,s/=n;let{getTextAnchor:o,getAlignmentBaseline:a}=this.props,c=yT[typeof o=="function"?o(e,r):o],l=xT[typeof a=="function"?a(e,r):a];return[(c-1)*i/2,(l-1)*s/2,i,s]},this.getIconOffsets=(e,r)=>{let{getTextAnchor:i,getAlignmentBaseline:s}=this.props,{x:n,y:o,rowWidth:a,size:[c,l]}=this.transformParagraph(e,r),u=yT[typeof i=="function"?i(e,r):i],f=xT[typeof s=="function"?s(e,r):s],h=n.length,d=new Array(h*2),p=0;for(let g=0;g0&&U.warn("v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(e){let{props:r,oldProps:i,changeFlags:s}=e;(s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged.getText))&&this._updateText(),(this._updateFontAtlas()||r.lineHeight!==i.lineHeight||r.wordBreak!==i.wordBreak||r.maxWidth!==i.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:e}){return e.object=e.index>=0?this.props.data[e.index]:null,e}_updateFontAtlas(){let{fontSettings:e,fontFamily:r,fontWeight:i}=this.props,{fontAtlasManager:s,characterSet:n}=this.state,o={...e,characterSet:n,fontFamily:r,fontWeight:i};if(!s.mapping)return s.setProps(o),!0;for(let a in o)if(o[a]!==s.props[a])return s.setProps(o),!0;return!1}_updateText(){let{data:e,characterSet:r}=this.props,i=e.attributes?.getText,{getText:s}=this.props,n=e.startIndices,o,a=r==="auto"&&new Set;if(i&&n){let{texts:c,characterCount:l}=lT({...ArrayBuffer.isView(i)?{value:i}:i,length:e.length,startIndices:n,characterSet:a});o=l,s=(u,{index:f})=>c[f]}else{let{iterable:c,objectInfo:l}=$e(e);n=[0],o=0;for(let u of c){l.index++;let f=Array.from(s(u,l)||"");a&&f.forEach(a.add,a),o+=f.length,n.push(o)}}this.setState({getText:s,startIndices:n,numInstances:o,characterSet:a||r})}transformParagraph(e,r){let{fontAtlasManager:i}=this.state,s=i.mapping,n=this.state.getText,{wordBreak:o,lineHeight:a,maxWidth:c}=this.props,l=n(e,r)||"";return cT(l,a,o,c*i.props.fontSize,s)}renderLayers(){let{startIndices:e,numInstances:r,getText:i,fontAtlasManager:{scale:s,atlas:n,mapping:o},styleVersion:a}=this.state,{data:c,_dataDiff:l,getPosition:u,getColor:f,getSize:h,getAngle:d,getPixelOffset:p,getBackgroundColor:g,getBorderColor:_,getBorderWidth:x,backgroundPadding:v,background:b,billboard:A,fontSettings:C,outlineWidth:M,outlineColor:F,sizeScale:N,sizeUnits:D,sizeMinPixels:L,sizeMaxPixels:Y,transitions:X,updateTriggers:$}=this.props,Z=this.getSubLayerClass("characters",Gi),ge=this.getSubLayerClass("background",Ji);return[b&&new ge({getFillColor:g,getLineColor:_,getLineWidth:x,padding:v,getPosition:u,getSize:h,getAngle:d,getPixelOffset:p,billboard:A,sizeScale:N,sizeUnits:D,sizeMinPixels:L,sizeMaxPixels:Y,transitions:X&&{getPosition:X.getPosition,getAngle:X.getAngle,getSize:X.getSize,getFillColor:X.getBackgroundColor,getLineColor:X.getBorderColor,getLineWidth:X.getBorderWidth,getPixelOffset:X.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:$.getPosition,getAngle:$.getAngle,getSize:$.getSize,getFillColor:$.getBackgroundColor,getLineColor:$.getBorderColor,getLineWidth:$.getBorderWidth,getPixelOffset:$.getPixelOffset,getBoundingRect:{getText:$.getText,getTextAnchor:$.getTextAnchor,getAlignmentBaseline:$.getAlignmentBaseline,styleVersion:a}}}),{data:c.attributes&&c.attributes.background?{length:c.length,attributes:c.attributes.background}:c,_dataDiff:l,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new Z({sdf:C.sdf,smoothing:Number.isFinite(C.smoothing)?C.smoothing:Zi.smoothing,outlineWidth:M/(C.radius||Zi.radius),outlineColor:F,iconAtlas:n,iconMapping:o,getPosition:u,getColor:f,getSize:h,getAngle:d,getPixelOffset:p,billboard:A,sizeScale:N*s,sizeUnits:D,sizeMinPixels:L*s,sizeMaxPixels:Y*s,transitions:X&&{getPosition:X.getPosition,getAngle:X.getAngle,getColor:X.getColor,getSize:X.getSize,getPixelOffset:X.getPixelOffset}},this.getSubLayerProps({id:"characters",updateTriggers:{all:$.getText,getPosition:$.getPosition,getAngle:$.getAngle,getColor:$.getColor,getSize:$.getSize,getPixelOffset:$.getPixelOffset,getIconOffsets:{getTextAnchor:$.getTextAnchor,getAlignmentBaseline:$.getAlignmentBaseline,styleVersion:a}}}),{data:c,_dataDiff:l,startIndices:e,numInstances:r,getIconOffsets:this.getIconOffsets,getIcon:i})]}static set fontAtlasCacheLimit(e){gT(e)}};var va={circle:{type:$i,props:{filled:"filled",stroked:"stroked",lineWidthMaxPixels:"lineWidthMaxPixels",lineWidthMinPixels:"lineWidthMinPixels",lineWidthScale:"lineWidthScale",lineWidthUnits:"lineWidthUnits",pointRadiusMaxPixels:"radiusMaxPixels",pointRadiusMinPixels:"radiusMinPixels",pointRadiusScale:"radiusScale",pointRadiusUnits:"radiusUnits",pointAntialiasing:"antialiasing",pointBillboard:"billboard",getFillColor:"getFillColor",getLineColor:"getLineColor",getLineWidth:"getLineWidth",getPointRadius:"getRadius"}},icon:{type:Er,props:{iconAtlas:"iconAtlas",iconMapping:"iconMapping",iconSizeMaxPixels:"sizeMaxPixels",iconSizeMinPixels:"sizeMinPixels",iconSizeScale:"sizeScale",iconSizeUnits:"sizeUnits",iconAlphaCutoff:"alphaCutoff",iconBillboard:"billboard",getIcon:"getIcon",getIconAngle:"getAngle",getIconColor:"getColor",getIconPixelOffset:"getPixelOffset",getIconSize:"getSize"}},text:{type:Qi,props:{textSizeMaxPixels:"sizeMaxPixels",textSizeMinPixels:"sizeMinPixels",textSizeScale:"sizeScale",textSizeUnits:"sizeUnits",textBackground:"background",textBackgroundPadding:"backgroundPadding",textFontFamily:"fontFamily",textFontWeight:"fontWeight",textLineHeight:"lineHeight",textMaxWidth:"maxWidth",textOutlineColor:"outlineColor",textOutlineWidth:"outlineWidth",textWordBreak:"wordBreak",textCharacterSet:"characterSet",textBillboard:"billboard",textFontSettings:"fontSettings",getText:"getText",getTextAngle:"getAngle",getTextColor:"getColor",getTextPixelOffset:"getPixelOffset",getTextSize:"getSize",getTextAnchor:"getTextAnchor",getTextAlignmentBaseline:"getAlignmentBaseline",getTextBackgroundColor:"getBackgroundColor",getTextBorderColor:"getBorderColor",getTextBorderWidth:"getBorderWidth"}}},ba={type:Pr,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},ru={type:zt,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function $s({type:t,props:e}){let r={};for(let i in e)r[i]=t.defaultProps[e[i]];return r}function iu(t,e){let{transitions:r,updateTriggers:i}=t.props,s={updateTriggers:{},transitions:r&&{getPosition:r.geometry}};for(let n in e){let o=e[n],a=t.props[n];n.startsWith("get")&&(a=t.getSubLayerAccessor(a),s.updateTriggers[o]=i[n],r&&(s.transitions[o]=r[n])),s[o]=a}return s}function vT(t){if(Array.isArray(t))return t;switch(U.assert(t.type,"GeoJSON does not have type"),t.type){case"Feature":return[t];case"FeatureCollection":return U.assert(Array.isArray(t.features),"GeoJSON does not have features array"),t.features;default:return[{geometry:t}]}}function cp(t,e,r={}){let i={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:s=0,endRow:n=t.length}=r;for(let o=s;o{a.push(r({geometry:{type:"Point",coordinates:f}},i,s))});break;case"LineString":c.push(r({geometry:t},i,s));break;case"MultiLineString":o.forEach(f=>{c.push(r({geometry:{type:"LineString",coordinates:f}},i,s))});break;case"Polygon":l.push(r({geometry:t},i,s)),o.forEach(f=>{u.push(r({geometry:{type:"LineString",coordinates:f}},i,s))});break;case"MultiPolygon":o.forEach(f=>{l.push(r({geometry:{type:"Polygon",coordinates:f}},i,s)),f.forEach(h=>{u.push(r({geometry:{type:"LineString",coordinates:h}},i,s))})});break;default:}}var A2={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function E2(t,e){let r=A2[t];for(U.assert(r,`Unknown GeoJSON type ${t}`);e&&--r>0;)e=e[0];return e&&Number.isFinite(e[0])}function bT(){return{points:{},lines:{},polygons:{},polygonsOutline:{}}}function su(t){return t.geometry.coordinates}function ST(t,e){let r=bT(),{pointFeatures:i,lineFeatures:s,polygonFeatures:n,polygonOutlineFeatures:o}=t;return r.points.data=i,r.points._dataDiff=e.pointFeatures&&(()=>e.pointFeatures),r.points.getPosition=su,r.lines.data=s,r.lines._dataDiff=e.lineFeatures&&(()=>e.lineFeatures),r.lines.getPath=su,r.polygons.data=n,r.polygons._dataDiff=e.polygonFeatures&&(()=>e.polygonFeatures),r.polygons.getPolygon=su,r.polygonsOutline.data=o,r.polygonsOutline._dataDiff=e.polygonOutlineFeatures&&(()=>e.polygonOutlineFeatures),r.polygonsOutline.getPath=su,r}function AT(t,e){let r=bT(),{points:i,lines:s,polygons:n}=t,o=eT(t,e);return r.points.data={length:i.positions.value.length/i.positions.size,attributes:{...i.attributes,getPosition:i.positions,instancePickingColors:{size:3,value:o.points}},properties:i.properties,numericProps:i.numericProps,featureIds:i.featureIds},r.lines.data={length:s.pathIndices.value.length-1,startIndices:s.pathIndices.value,attributes:{...s.attributes,getPath:s.positions,instancePickingColors:{size:3,value:o.lines}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},r.lines._pathType="open",r.polygons.data={length:n.polygonIndices.value.length-1,startIndices:n.polygonIndices.value,attributes:{...n.attributes,getPolygon:n.positions,pickingColors:{size:3,value:o.polygons}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},r.polygons._normalize=!1,n.triangles&&(r.polygons.data.attributes.indices=n.triangles.value),r.polygonsOutline.data={length:n.primitivePolygonIndices.value.length-1,startIndices:n.primitivePolygonIndices.value,attributes:{...n.attributes,getPath:n.positions,instancePickingColors:{size:3,value:o.polygons}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},r.polygonsOutline._pathType="open",r}var w2=["points","linestrings","polygons"],P2={...$s(va.circle),...$s(va.icon),...$s(va.text),...$s(ba),...$s(ru),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:t=>t.properties.icon},getText:{type:"accessor",value:t=>t.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}},Sa=class extends et{static{this.layerName="GeoJsonLayer"}static{this.defaultProps=P2}initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:e,changeFlags:r}){if(!r.dataChanged)return;let{data:i}=this.props,s=i&&"points"in i&&"polygons"in i&&"lines"in i;this.setState({binary:s}),s?this._updateStateBinary({props:e,changeFlags:r}):this._updateStateJSON({props:e,changeFlags:r})}_updateStateBinary({props:e,changeFlags:r}){let i=AT(e.data,this.encodePickingColor);this.setState({layerProps:i})}_updateStateJSON({props:e,changeFlags:r}){let i=vT(e.data),s=this.getSubLayerRow.bind(this),n={},o={};if(Array.isArray(r.dataChanged)){let c=this.state.features;for(let l in c)n[l]=c[l].slice(),o[l]=[];for(let l of r.dataChanged){let u=cp(i,s,l);for(let f in c)o[f].push(eu({data:n[f],getIndex:h=>h.__source.index,dataRange:l,replace:u[f]}))}}else n=cp(i,s);let a=ST(n,o);this.setState({features:n,featuresDiff:o,layerProps:a})}getPickingInfo(e){let r=super.getPickingInfo(e),{index:i,sourceLayer:s}=r;return r.featureType=w2.find(n=>s.id.startsWith(`${this.id}-${n}-`)),i>=0&&s.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(r.index=this.props.data.points.globalFeatureIds.value[i]),r}_updateAutoHighlight(e){let r=`${this.id}-points-`,i=e.featureType==="points";for(let s of this.getSubLayers())s.id.startsWith(r)===i&&s.updateAutoHighlight(e)}_renderPolygonLayer(){let{extruded:e,wireframe:r}=this.props,{layerProps:i}=this.state,s="polygons-fill",n=this.shouldRenderSubLayer(s,i.polygons?.data)&&this.getSubLayerClass(s,ru.type);if(n){let o=iu(this,ru.props),a=e&&r;return a||delete o.getLineColor,o.updateTriggers.lineColors=a,new n(o,this.getSubLayerProps({id:s,updateTriggers:o.updateTriggers}),i.polygons)}return null}_renderLineLayers(){let{extruded:e,stroked:r}=this.props,{layerProps:i}=this.state,s="polygons-stroke",n="linestrings",o=!e&&r&&this.shouldRenderSubLayer(s,i.polygonsOutline?.data)&&this.getSubLayerClass(s,ba.type),a=this.shouldRenderSubLayer(n,i.lines?.data)&&this.getSubLayerClass(n,ba.type);if(o||a){let c=iu(this,ba.props);return[o&&new o(c,this.getSubLayerProps({id:s,updateTriggers:c.updateTriggers}),i.polygonsOutline),a&&new a(c,this.getSubLayerProps({id:n,updateTriggers:c.updateTriggers}),i.lines)]}return null}_renderPointLayers(){let{pointType:e}=this.props,{layerProps:r,binary:i}=this.state,{highlightedObjectIndex:s}=this.props;!i&&Number.isFinite(s)&&(s=r.points.data.findIndex(a=>a.__source.index===s));let n=new Set(e.split("+")),o=[];for(let a of n){let c=`points-${a}`,l=va[a],u=l&&this.shouldRenderSubLayer(c,r.points?.data)&&this.getSubLayerClass(c,l.type);if(u){let f=iu(this,l.props),h=r.points;if(a==="text"&&i){let{instancePickingColors:d,...p}=h.data.attributes;h={...h,data:{...h.data,attributes:p}}}o.push(new u(f,this.getSubLayerProps({id:c,updateTriggers:f.updateTriggers,highlightedObjectIndex:s}),h))}}return o}renderLayers(){let{extruded:e}=this.props,r=this._renderPolygonLayer(),i=this._renderLineLayers(),s=this._renderPointLayers();return[!e&&r,i,s,e&&r]}getSubLayerAccessor(e){let{binary:r}=this.state;return!r||typeof e!="function"?super.getSubLayerAccessor(e):(i,s)=>{let{data:n,index:o}=s,a=Q0(n,o);return e(a,s)}}};var le={SUM:1,MEAN:2,MIN:3,MAX:4};function ET(t,e){return t+e}function R2(t,e){return e>t?e:t}function C2(t,e){return eN2(s,e);case le.SUM:return s=>I2(s,e);case le.MEAN:return s=>M2(s,e);case le.MAX:return s=>O2(s,e);default:return null}}function F2(t,e={}){return Number.isFinite(t)?t:r=>(e.index=r.index,t(r.source,e))}function wT(t,e={}){return r=>(e.indices=r.map(i=>i.index),t(r.map(i=>i.source),e))}var PT={projectPoints:!1,viewport:null,createBufferObjects:!0,moduleSettings:{}},ii=3402823466e29,lp=[32775,32774],up=[32776,32774],RT=[32776,32775],fp={[le.SUM]:32774,[le.MEAN]:32774,[le.MIN]:lp,[le.MAX]:up};var CT={size:1,operation:le.SUM,needMin:!1,needMax:!1,combineMaxMin:!1},MT=4;var IT=`#version 300 es +#define SHADER_NAME gpu-aggregation-to-grid-vs +in vec3 positions; +in vec3 positions64Low; +in vec3 weights; +uniform vec2 cellSize; +uniform vec2 gridSize; +uniform bool projectPoints; +uniform vec2 translation; +uniform vec3 scaling; +out vec3 vWeights; +vec2 project_to_pixel(vec4 pos) { +vec4 result; +pos.xy = pos.xy/pos.w; +result = pos + vec4(translation, 0., 0.); +result.xy = scaling.z > 0. ? result.xy * scaling.xy : result.xy; +return result.xy; +} +void main(void) { +vWeights = weights; +vec4 windowPos = vec4(positions, 1.); +if (projectPoints) { +windowPos = project_position_to_clipspace(positions, positions64Low, vec3(0)); +} +vec2 pos = project_to_pixel(windowPos); +vec2 pixelXY64[2]; +pixelXY64[0] = vec2(pos.x, 0.); +pixelXY64[1] = vec2(pos.y, 0.); +vec2 gridXY64[2]; +gridXY64[0] = div_fp64(pixelXY64[0], vec2(cellSize.x, 0)); +gridXY64[1] = div_fp64(pixelXY64[1], vec2(cellSize.y, 0)); +float x = floor(gridXY64[0].x); +float y = floor(gridXY64[1].x); +pos = vec2(x, y); +pos = (pos * (2., 2.) / (gridSize)) - (1., 1.); +vec2 offset = 1.0 / gridSize; +pos = pos + offset; +gl_Position = vec4(pos, 0.0, 1.0); +gl_PointSize = 1.0; +} +`;var OT=`#version 300 es +#define SHADER_NAME gpu-aggregation-to-grid-fs +precision highp float; +in vec3 vWeights; +out vec4 fragColor; +void main(void) { +fragColor = vec4(vWeights, 1.0); +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var NT=`#version 300 es +#define SHADER_NAME gpu-aggregation-all-vs-64 +in vec2 position; +uniform ivec2 gridSize; +out vec2 vTextureCoord; +void main(void) { +vec2 pos = vec2(-1.0, -1.0); +vec2 offset = 1.0 / vec2(gridSize); +pos = pos + offset; +gl_Position = vec4(pos, 0.0, 1.0); +int yIndex = gl_InstanceID / gridSize[0]; +int xIndex = gl_InstanceID - (yIndex * gridSize[0]); +vec2 yIndexFP64 = vec2(float(yIndex), 0.); +vec2 xIndexFP64 = vec2(float(xIndex), 0.); +vec2 gridSizeYFP64 = vec2(gridSize[1], 0.); +vec2 gridSizeXFP64 = vec2(gridSize[0], 0.); +vec2 texCoordXFP64 = div_fp64(yIndexFP64, gridSizeYFP64); +vec2 texCoordYFP64 = div_fp64(xIndexFP64, gridSizeXFP64); +vTextureCoord = vec2(texCoordYFP64.x, texCoordXFP64.x); +gl_PointSize = 1.0; +} +`;var FT=`#version 300 es +#define SHADER_NAME gpu-aggregation-all-fs +precision highp float; +in vec2 vTextureCoord; +uniform sampler2D uSampler; +uniform bool combineMaxMin; +out vec4 fragColor; +void main(void) { +vec4 textureColor = texture(uSampler, vec2(vTextureCoord.s, vTextureCoord.t)); +if (textureColor.a == 0.) { +discard; +} +fragColor.rgb = textureColor.rgb; +fragColor.a = combineMaxMin ? textureColor.r : textureColor.a; +} +`;var DT=`#version 300 es +#define SHADER_NAME gpu-aggregation-transform-mean-vs +in vec4 aggregationValues; +out vec4 meanValues; +void main() +{ +bool isCellValid = bool(aggregationValues.w > 0.); +meanValues.xyz = isCellValid ? aggregationValues.xyz/aggregationValues.w : vec3(0, 0, 0); +meanValues.w = aggregationValues.w; +gl_PointSize = 1.0; +} +`;var D2={minFilter:"nearest",magFilter:"nearest"};function Ks(t,e){let{width:r=1,height:i=1,data:s=null,parameters:n=D2}=e;return t.createTexture({data:s,format:"rgba32float",mipmaps:!1,sampler:n,width:r,height:i})}function Aa(t,e){let{id:r,width:i=1,height:s=1,texture:n}=e;return t.createFramebuffer({id:r,width:i,height:s,colorAttachments:[n]})}var L2=["aggregationBuffer","maxMinBuffer","minBuffer","maxBuffer"],LT={maxData:"maxBuffer",minData:"minBuffer",maxMinData:"maxMinBuffer"},k2=["float32-renderable-webgl","texture-blend-float-webgl"],Re=class{static getAggregationData({aggregationData:e,maxData:r,minData:i,maxMinData:s,pixelIndex:n}){let o=n*MT,a={};return e&&(a.cellCount=e[o+3],a.cellWeight=e[o]),s?(a.maxCellWieght=s[0],a.minCellWeight=s[3]):(r&&(a.maxCellWieght=r[0],a.totalCount=r[3]),i&&(a.minCellWeight=i[0],a.totalCount=i[3])),a}static getCellData({countsData:e,size:r=1}){let i=e.length/4,s=new Float32Array(i*r),n=new Uint32Array(i);for(let o=0;oe.features.has(r))}constructor(e,r={}){this.state={weightAttributes:{},textures:{},meanTextures:{},buffers:{},framebuffers:{},maxMinFramebuffers:{},minFramebuffers:{},maxFramebuffers:{},equations:{},shaderOptions:{},modelDirty:!1,resources:{},results:{}},this.id=r.id||"gpu-grid-aggregator",this.device=e;let i=["float32-renderable-webgl"];this._hasGPUSupport=i.every(s=>e.features.has(s)),this._hasGPUSupport&&this._setupModels()}delete(){let{gridAggregationModel:e,allAggregationModel:r,meanTransform:i}=this,{textures:s,framebuffers:n,maxMinFramebuffers:o,minFramebuffers:a,maxFramebuffers:c,meanTextures:l,resources:u}=this.state;e?.destroy(),r?.destroy(),i?.destroy(),U2([n,s,o,a,c,l,u])}run(e={}){this.setState({results:{}});let r=this._normalizeAggregationParams(e);return this._runAggregation(r)}getData(e){let r={},i=this.state.results;i[e].aggregationData||(i[e].aggregationData=i[e].aggregationBuffer.getData()),r.aggregationData=i[e].aggregationData;for(let s in LT){let n=LT[s];(i[e][s]||i[e][n])&&(i[e][s]=i[e][s]||i[e][n].getData(),r[s]=i[e][s])}return r}updateShaders(e={}){this.setState({shaderOptions:e,modelDirty:!0})}_normalizeAggregationParams(e){let r={...PT,...e},{weights:i}=r;return i&&(r.weights=B2(i)),r}setState(e){Object.assign(this.state,e)}_getAggregateData(e){let r={},{textures:i,framebuffers:s,maxMinFramebuffers:n,minFramebuffers:o,maxFramebuffers:a,resources:c}=this.state,{weights:l}=e;for(let u in l){r[u]={};let{needMin:f,needMax:h,combineMaxMin:d}=l[u];r[u].aggregationTexture=i[u],r[u].aggregationBuffer=this.device.readPixelsToBufferWebGL(s[u],{target:l[u].aggregationBuffer,sourceType:5126}),f&&h&&d?(r[u].maxMinBuffer=this.device.readPixelsToBufferWebGL(n[u],{target:l[u].maxMinBuffer,sourceType:5126}),r[u].maxMinTexture=c[`${u}-maxMinTexture`]):(f&&(r[u].minBuffer=this.device.readPixelsToBufferWebGL(o[u],{target:l[u].minBuffer,sourceType:5126}),r[u].minTexture=c[`${u}-minTexture`]),h&&(r[u].maxBuffer=this.device.readPixelsToBufferWebGL(a[u],{target:l[u].maxBuffer,sourceType:5126}),r[u].maxTexture=c[`${u}-maxTexture`]))}return this._trackGPUResultBuffers(r,l),r}_renderAggregateData(e){let{cellSize:r,projectPoints:i,attributes:s,moduleSettings:n,numCol:o,numRow:a,weights:c,translation:l,scaling:u}=e,{maxMinFramebuffers:f,minFramebuffers:h,maxFramebuffers:d}=this.state,p=[o,a],g={blend:!0,depthTest:!1,blendFunc:[1,1]},_={cellSize:r,gridSize:p,projectPoints:i,translation:l,scaling:u};for(let x in c){let{needMin:v,needMax:b}=c[x],A=v&&b&&c[x].combineMaxMin;this._renderToWeightsTexture({id:x,parameters:g,moduleSettings:n,uniforms:_,gridSize:p,attributes:s,weights:c}),A?this._renderToMaxMinTexture({id:x,parameters:{...g,blendEquation:RT},gridSize:p,minOrMaxFb:f[x],clearParams:{clearColor:[0,0,0,ii]},combineMaxMin:A}):(v&&this._renderToMaxMinTexture({id:x,parameters:{...g,blendEquation:lp},gridSize:p,minOrMaxFb:h[x],clearParams:{clearColor:[ii,ii,ii,0]},combineMaxMin:A}),b&&this._renderToMaxMinTexture({id:x,parameters:{...g,blendEquation:up},gridSize:p,minOrMaxFb:d[x],clearParams:{clearColor:[0,0,0,0]},combineMaxMin:A}))}}_renderToMaxMinTexture(e){let{id:r,gridSize:i,minOrMaxFb:s,combineMaxMin:n,clearParams:o={}}=e,{framebuffers:a}=this.state,{allAggregationModel:c}=this;this.device.withParametersWebGL({...o,framebuffer:s,viewport:[0,0,i[0],i[1]]},()=>{this.device.clearWebGL({color:!0}),c.setUniforms({gridSize:i,combineMaxMin:n}),c.setBindings({uSampler:a[r].texture}),c.draw()})}_renderToWeightsTexture(e){let{id:r,parameters:i,moduleSettings:s,uniforms:n,gridSize:o,weights:a}=e,{framebuffers:c,equations:l,weightAttributes:u}=this.state,{gridAggregationModel:f}=this,{operation:h}=a[r],d=h===le.MIN?[ii,ii,ii,0]:[0,0,0,0];if(this.device.withParametersWebGL({framebuffer:c[r],viewport:[0,0,o[0],o[1]],clearColor:d},()=>{this.device.clearWebGL({color:!0});let p={weights:u[r]};f.draw({parameters:{...i,blendEquation:l[r]},moduleSettings:s,uniforms:n,attributes:p})}),h===le.MEAN){let{meanTextures:p,textures:g}=this.state,_={_sourceTextures:{aggregationValues:p[r]},_targetTexture:g[r],elementCount:g[r].width*g[r].height};this.meanTransform?this.meanTransform.update(_):this.meanTransform=W2(this.device,_),this.meanTransform.run({parameters:{blend:!1,depthTest:!1}}),c[r].attach({36064:g[r]})}}_runAggregation(e){this._updateModels(e),this._setupFramebuffers(e),this._renderAggregateData(e);let r=this._getAggregateData(e);return this.setState({results:r}),r}_setupFramebuffers(e){let{textures:r,framebuffers:i,maxMinFramebuffers:s,minFramebuffers:n,maxFramebuffers:o,meanTextures:a,equations:c}=this.state,{weights:l}=e,{numCol:u,numRow:f}=e,h={width:u,height:f};for(let d in l){let{needMin:p,needMax:g,combineMaxMin:_,operation:x}=l[d];r[d]=l[d].aggregationTexture||r[d]||Ks(this.device,{id:`${d}-texture`,width:u,height:f}),r[d].resize(h);let v=r[d];x===le.MEAN&&(a[d]=a[d]||Ks(this.device,{id:`${d}-mean-texture`,width:u,height:f}),a[d].resize(h),v=a[d]),i[d]?i[d].attach({36064:v}):i[d]=Aa(this.device,{id:`${d}-fb`,width:u,height:f,texture:v}),i[d].resize(h),c[d]=fp[x]||fp[le.SUM],(p||g)&&(p&&g&&_?s[d]||(v=l[d].maxMinTexture||this._getMinMaxTexture(`${d}-maxMinTexture`),s[d]=Aa(this.device,{id:`${d}-maxMinFb`,texture:v})):(p&&(n[d]||(v=l[d].minTexture||this._getMinMaxTexture(`${d}-minTexture`),n[d]=Aa(this.device,{id:`${d}-minFb`,texture:v}))),g&&(o[d]||(v=l[d].maxTexture||this._getMinMaxTexture(`${d}-maxTexture`),o[d]=Aa(this.device,{id:`${d}-maxFb`,texture:v})))))}}_getMinMaxTexture(e){let{resources:r}=this.state;return r[e]||(r[e]=Ks(this.device,{id:"resourceName"})),r[e]}_setupModels({numCol:e=0,numRow:r=0}={}){let{shaderOptions:i}=this.state;if(this.gridAggregationModel?.destroy(),this.gridAggregationModel=z2(this.device,i),!this.allAggregationModel){let s=e*r;this.allAggregationModel=V2(this.device,s)}}_setupWeightAttributes(e){let{weightAttributes:r}=this.state,{weights:i}=e;for(let s in i)r[s]=e.attributes[s]}_trackGPUResultBuffers(e,r){let{resources:i}=this.state;for(let s in e)if(e[s]){for(let n of L2)if(e[s][n]&&r[s][n]!==e[s][n]){let o=`gpu-result-${s}-${n}`;i[o]&&i[o].delete(),i[o]=e[s][n]}}}_updateModels(e){let{vertexCount:r,attributes:i,numCol:s,numRow:n}=e,{modelDirty:o}=this.state;o&&(this._setupModels(e),this.setState({modelDirty:!1})),this._setupWeightAttributes(e),this.gridAggregationModel.setVertexCount(r),this.gridAggregationModel.setAttributes(i),this.allAggregationModel.setInstanceCount(s*n)}};function B2(t){let e={};for(let r in t)e[r]={...CT,...t[r]};return e}function U2(t){t=Array.isArray(t)?t:[t],t.forEach(e=>{for(let r in e)e[r].delete()})}function z2(t,e){let r=Fs({vs:IT,fs:OT,modules:[Wr,ae]},e);return new te(t,{id:"Grid-Aggregation-Model",vertexCount:1,drawMode:0,shaderAssembler:ro(),...r})}function V2(t,e){return new te(t,{id:"All-Aggregation-Model",vs:NT,fs:FT,modules:[Wr],vertexCount:1,topology:"point-list",isInstanced:!0,instanceCount:e,attributes:{position:[0,0]}})}function W2(t,e){return new $r(t,{vs:DT,_targetTextureVarying:"meanValues",...e})}var Et=[[255,255,178],[254,217,118],[254,178,76],[253,141,60],[240,59,32],[189,0,38]];function si(t,e=!1,r=Float32Array){let i;if(Number.isFinite(t[0]))i=new r(t);else{i=new r(t.length*4);let s=0;for(let n=0;n= domain.x && value <= domain.y) { +float domainRange = domain.y - domain.x; +if (domainRange <= 0.) { +outColor = colorRange[0]; +} else { +float rangeCount = float(RANGE_COUNT); +float rangeStep = domainRange / rangeCount; +float idx = floor((value - domain.x) / rangeStep); +idx = clamp(idx, 0., rangeCount - 1.); +int intIdx = int(idx); +outColor = colorRange[intIdx]; +} +} +outColor = outColor / 255.; +return outColor; +} +void main(void) { +vSampleCount = instanceCounts.a; +float weight = instanceCounts.r; +float maxWeight = texture(maxTexture, vec2(0.5)).r; +float step = weight / maxWeight; +vec4 minMaxColor = mix(minColor, maxColor, step) / 255.; +vec2 domain = colorDomain; +float domainMaxValid = float(colorDomain.y != 0.); +domain.y = mix(maxWeight, colorDomain.y, domainMaxValid); +vec4 rangeColor = quantizeScale(domain, colorRange, weight); +float rangeMinMax = float(shouldUseMinMax); +vec4 color = mix(rangeColor, minMaxColor, rangeMinMax); +vColor = vec4(color.rgb, color.a * opacity); +picking_setPickingColor(instancePickingColors); +gl_Position = vec4(instancePositions + positions * cellScale, 1.); +} +`;var BT=`#version 300 es +#define SHADER_NAME screen-grid-layer-fragment-shader +precision highp float; +in vec4 vColor; +in float vSampleCount; +out vec4 fragColor; +void main(void) { +if (vSampleCount <= 0.0) { +discard; +} +fragColor = vColor; +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var H2=[0,0,0,0],j2=[0,255,0,255],X2=["minColor","maxColor","colorRange","colorDomain"],$2={cellSizePixels:{type:"number",value:100,min:1},cellMarginPixels:{type:"number",value:2,min:0,max:5},colorDomain:null,colorRange:Et},qs=class extends ne{static{this.layerName="ScreenGridCellLayer"}static{this.defaultProps=$2}getShaders(){return{vs:kT,fs:BT,modules:[ue]}}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,update:this.calculateInstancePositions},instanceCounts:{size:4,noAlloc:!0}}),this.setState({model:this._getModel()})}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){super.updateState(e);let{oldProps:r,props:i,changeFlags:s}=e,n=this.getAttributeManager();i.numInstances!==r.numInstances?n.invalidateAll():r.cellSizePixels!==i.cellSizePixels&&n.invalidate("instancePositions"),this._updateUniforms(r,i,s)}draw({uniforms:e}){let{parameters:r,maxTexture:i}=this.props,s=this.props.minColor||H2,n=this.props.maxColor||j2,o=this.props.colorDomain||[1,0],a=this.state.model;a.setUniforms(e),a.setBindings({maxTexture:i}),a.setUniforms({minColor:s,maxColor:n,colorDomain:o}),a.setParameters({depthWriteEnabled:!1,...r}),a.draw(this.context.renderPass)}calculateInstancePositions(e,{numInstances:r}){let{width:i,height:s}=this.context.viewport,{cellSizePixels:n}=this.props,o=Math.ceil(i/n),{value:a,size:c}=e;for(let l=0;le[n]!==r[n])&&s.setUniforms({shouldUseMinMax:this._shouldUseMinMax()}),e.colorRange!==r.colorRange&&s.setUniforms({colorRange:si(r.colorRange)}),e.cellMarginPixels!==r.cellMarginPixels||e.cellSizePixels!==r.cellSizePixels||i.viewportChanged){let{width:n,height:o}=this.context.viewport,{cellSizePixels:a,cellMarginPixels:c}=this.props,l=a>c?c:0,u=new Float32Array([(a-l)/n*2,-(a-l)/o*2,1]);s.setUniforms({cellScale:u})}}};function UT(t,e){let r={};for(let i in t)e.includes(i)||(r[i]=t[i]);return r}var nt=class extends et{static{this.layerName="AggregationLayer"}initializeAggregationLayer(e){super.initializeState(this.context),this.setState({ignoreProps:UT(this.constructor._propTypes,e.data.props),dimensions:e})}updateState(e){super.updateState(e);let{changeFlags:r}=e;if(r.extensionsChanged){let i=this.getShaders({});i&&i.defines&&(i.defines.NON_INSTANCED_MODEL=1),this.updateShaders(i)}this._updateAttributes()}updateAttributes(e){this.setState({changedAttributes:e})}getAttributes(){return this.getAttributeManager().getAttributes()}getModuleSettings(){let{viewport:e,mousePosition:r,device:i}=this.context;return Object.assign(Object.create(this.props),{viewport:e,mousePosition:r,picking:{isActive:0},devicePixelRatio:i.canvasContext.cssToDeviceRatio()})}updateShaders(e){}isAggregationDirty(e,r={}){let{props:i,oldProps:s,changeFlags:n}=e,{compareAll:o=!1,dimension:a}=r,{ignoreProps:c}=this.state,{props:l,accessors:u=[]}=a,{updateTriggersChanged:f}=n;if(n.dataChanged)return!0;if(f){if(f.all)return!0;for(let h of u)if(f[h])return!0}if(o)return n.extensionsChanged?!0:$o({oldProps:s,newProps:i,ignoreProps:c,propTypes:this.constructor._propTypes});for(let h of l)if(i[h]!==s[h])return!0;return!1}isAttributeChanged(e){let{changedAttributes:r}=this.state;return e?r&&r[e]!==void 0:!Y2(r)}_getAttributeManager(){return new nr(this.context.device,{id:this.props.id,stats:this.context.stats})}};function Y2(t){let e=!0;for(let r in t){e=!1;break}return e}function nu(t,e,r){let i=r;return i.domain=()=>t,i.range=()=>e,i}function zT(t,e){return nu(t,e,i=>tI(t,e,i))}function K2(t,e){return nu(t,e,i=>rI(t,e,i))}function q2(t,e){let r=t.sort(VT),i=0,s=Math.max(1,e.length),n=new Array(s-1);for(;++iJ2(n,e,a);return o.thresholds=()=>n,nu(t,e,o)}function VT(t,e){return t-e}function G2(t,e){let r=t.length;if(e<=0||r<2)return t[0];if(e>=1)return t[r-1];let i=(r-1)*e,s=Math.floor(i),n=t[s],o=t[s+1];return n+(o-n)*(i-s)}function Z2(t,e){let r=0,i=t.length;for(;r>>1;VT(t[s],e)>0?i=s:r=s+1}return r}function J2(t,e,r){return e[Z2(t,r)]}function Q2(t,e,r,i){let s=`${i}`,n=e.get(s);return n===void 0&&(n=t.push(i),e.set(s,n)),r[(n-1)%r.length]}function eI(t,e){let r=new Map,i=[];for(let n of t){let o=`${n}`;r.has(o)||r.set(o,i.push(n))}return nu(t,e,n=>Q2(i,r,e,n))}function tI(t,e,r){let i=t[1]-t[0];if(i<=0)return U.warn("quantizeScale: invalid domain, returning range[0]")(),e[0];let s=i/e.length,n=Math.floor((r-t[0])/s),o=Math.max(Math.min(n,e.length-1),0);return e[o]}function rI(t,e,r){return(r-t[0])/(t[1]-t[0])*(e[1]-e[0])+e[0]}function WT(t){return t!=null}function iI(t){let e=[];return t.forEach(r=>{!e.includes(r)&&WT(r)&&e.push(r)}),e}function HT(t,e){return(typeof e=="function"?t.map(e):t).filter(WT)}function jT(t,e){return HT(t,e)}function XT(t,e){return iI(HT(t,e))}function $T(t,e,r){return Math.max(e,Math.min(r,t))}function YT(t){switch(t){case"quantize":return zT;case"linear":return K2;case"quantile":return q2;case"ordinal":return eI;default:return zT}}var qT=t=>t.length,sI=3402823466e29,GT=t=>t.points,ZT=t=>t.index,KT=(t,e)=>te?1:t>=e?0:NaN,nI={getValue:qT,getPoints:GT,getIndex:ZT,filterData:null},Rr=class{constructor(e=[],r=nI){this.aggregatedBins=this.getAggregatedBins(e,r),this._updateMinMaxValues(),this.binMap=this.getBinMap()}getAggregatedBins(e,r){let{getValue:i=qT,getPoints:s=GT,getIndex:n=ZT,filterData:o}=r,a=typeof o=="function",c=e.length,l=[],u=0;for(let f=0;f$T(a,0,100)),n=Math.ceil(i/100*(r-1)),o=Math.floor(s/100*(r-1));return[n,o]}getBinMap(){let e={};for(let r of this.aggregatedBins)e[r.i]=r;return e}_updateMinMaxValues(){let e=0,r=0,i=sI,s=0;for(let n of this.aggregatedBins)e=e>n.counts?e:n.counts,r=r>n.value?r:n.value,i=iKT(s.value,n.value))),!this.sortedBins.length)return[];let r=0,i=this.sortedBins.length-1;if(Array.isArray(e)){let s=this._percentileToIndex(e);r=s[0],i=s[1]}return[this.sortedBins[r].value,this.sortedBins[i].value]}getValueDomainByScale(e,[r=0,i=100]=[]){if(this.sortedBins||(this.sortedBins=this.aggregatedBins.sort((n,o)=>KT(n.value,o.value))),!this.sortedBins.length)return[];let s=this._percentileToIndex([r,i]);return this._getScaleDomain(e,s)}_getScaleDomain(e,[r,i]){let s=this.sortedBins;switch(e){case"quantize":case"linear":return[s[r].value,s[i].value];case"quantile":return jT(s.slice(r,i+1),n=>n.value);case"ordinal":return XT(s,n=>n.value);default:return[s[r].value,s[i].value]}}};var QT=6378e3;function ou(t){return Number.isFinite(t)?t:0}function au(t,e){let r=t.positions.value,i=1/0,s=-1/0,n=1/0,o=-1/0,a,c;for(let u=0;us?a:s,n=co?c:o;return{xMin:ou(n),xMax:ou(o),yMin:ou(i),yMax:ou(s)}}function oI(t,e,r,i){let{width:s,height:n}=i,o=r===q.CARTESIAN?[-s/2,-n/2]:[-180,-90];U.assert(r===q.CARTESIAN||r===q.LNGLAT||r===q.DEFAULT);let{xMin:a,yMin:c}=t;return[-1*(JT(a-o[0],e.xOffset)+o[0]),-1*(JT(c-o[1],e.yOffset)+o[1])]}function JT(t,e){let r=t<0?-1:1,i=r<0?Math.abs(t)+e:Math.abs(t);return i=Math.floor(i/e)*e,i*r}function hp(t,e,r=!0){if(!r)return{xOffset:e,yOffset:e};let{yMin:i,yMax:s}=t,n=(i+s)/2;return aI(e,n)}function cu(t,e,r,i){let s=hp(t,e,i!==q.CARTESIAN),n=oI(t,s,i,r),{xMin:o,yMin:a,xMax:c,yMax:l}=t,u=c-o+s.xOffset,f=l-a+s.yOffset,h=Math.ceil(u/s.xOffset),d=Math.ceil(f/s.yOffset);return{gridOffset:s,translation:n,width:u,height:f,numCol:h,numRow:d}}function aI(t,e){let r=cI(t),i=lI(e,t);return{yOffset:r,xOffset:i}}function cI(t){return t/QT*(180/Math.PI)}function lI(t,e){return e/QT*(180/Math.PI)/Math.cos(t*Math.PI/180)}function Gs(t,e){let r=uI(t,e),i=fI(r);return{gridHash:r.gridHash,gridOffset:r.gridOffset,data:i}}function uI(t,e){let{data:r=[],cellSize:i}=t,{attributes:s,viewport:n,projectPoints:o,numInstances:a}=e,c=s.positions.value,{size:l}=s.positions.getAccessor(),u=e.boundingBox||hI(s.positions,a),f=e.posOffset||[180,90],h=e.gridOffset||hp(u,i);if(h.xOffset<=0||h.yOffset<=0)return{gridHash:{},gridOffset:h,offsets:[0,0]};let{width:d,height:p}=n,g=Math.ceil(d/h.xOffset),_=Math.ceil(p/h.yOffset),x={},{iterable:v,objectInfo:b}=$e(r),A=new Array(3);for(let C of v){b.index++,A[0]=c[b.index*l],A[1]=c[b.index*l+1],A[2]=l>=3?c[b.index*l+2]:0;let[M,F]=o?n.project(A):A;if(Number.isFinite(M)&&Number.isFinite(F)){let N=Math.floor((F+f[1])/h.yOffset),D=Math.floor((M+f[0])/h.xOffset);if(!o||D>=0&&D=0&&N<_){let L=`${N}-${D}`;x[L]=x[L]||{count:0,points:[],lonIdx:D,latIdx:N},x[L].count+=1,x[L].points.push({source:C,index:b.index})}}}return{gridHash:x,gridOffset:h,offsets:[f[0]*-1,f[1]*-1]}}function fI({gridHash:t,gridOffset:e,offsets:r}){let i=new Array(Object.keys(t).length),s=0;for(let n in t){let o=n.split("-"),a=parseInt(o[0],10),c=parseInt(o[1],10),l=s++;i[l]={index:l,position:[r[0]+e.xOffset*c,r[1]+e.yOffset*a],...t[n]}}return i}function hI(t,e){let r=t.value,{size:i}=t.getAccessor(),s=1/0,n=-1/0,o=1/0,a=-1/0,c,l;for(let u=0;un?c:n,o=la?l:a);return{xMin:o,xMax:a,yMin:s,yMax:n}}var Cr=class extends nt{static{this.layerName="GridAggregationLayer"}initializeAggregationLayer({dimensions:e}){super.initializeAggregationLayer(e),this.setState({layerData:{},gpuGridAggregator:new Re(this.context.device,{id:`${this.id}-gpu-aggregator`}),cpuGridAggregator:Gs})}updateState(e){super.updateState(e),this.updateAggregationState(e);let{aggregationDataDirty:r,aggregationWeightsDirty:i,gpuAggregation:s}=this.state;if(this.getNumInstances()<=0)return;let n=!1;(r||s&&i)&&(this._updateAggregation(e),n=!0),!s&&(r||i)&&(this._updateWeightBins(),this._uploadAggregationResults(),n=!0),this.setState({aggregationDirty:n})}finalizeState(e){let{count:r}=this.state.weights;r&&r.aggregationBuffer&&r.aggregationBuffer.delete(),this.state.gpuGridAggregator?.delete(),super.finalizeState(e)}updateShaders(e){this.state.gpuAggregation&&this.state.gpuGridAggregator.updateShaders(e)}updateAggregationState(e){U.assert(!1)}allocateResources(e,r){if(this.state.numRow!==e||this.state.numCol!==r){let i=r*e*4*4,{weights:s}=this.state;for(let n in s){let o=s[n];o.aggregationBuffer&&o.aggregationBuffer.delete(),o.aggregationBuffer=this.context.device.createBuffer({byteLength:i,accessor:{size:4,type:5126,divisor:1}})}}}updateResults({aggregationData:e,maxMinData:r,maxData:i,minData:s}){let{count:n}=this.state.weights;n&&(n.aggregationData=e,n.maxMinData=r,n.maxData=i,n.minData=s)}_updateAggregation(e){let{cpuGridAggregator:r,gpuGridAggregator:i,gridOffset:s,posOffset:n,translation:o=[0,0],scaling:a=[0,0,0],boundingBox:c,projectPoints:l,gpuAggregation:u,numCol:f,numRow:h}=this.state,{props:d}=e,{viewport:p}=this.context,g=this.getAttributes(),_=this.getNumInstances();if(u){let{weights:x}=this.state;i.run({weights:x,cellSize:[s.xOffset,s.yOffset],numCol:f,numRow:h,translation:o,scaling:a,vertexCount:_,projectPoints:l,attributes:g,moduleSettings:this.getModuleSettings()})}else{let x=r(d,{gridOffset:s,projectPoints:l,attributes:g,viewport:p,posOffset:n,boundingBox:c});this.setState({layerData:x})}}_updateWeightBins(){let{getValue:e}=this.state,r=new Rr(this.state.layerData.data||[],{getValue:e});this.setState({sortedBins:r})}_uploadAggregationResults(){let{numCol:e,numRow:r}=this.state,{data:i}=this.state.layerData,{aggregatedBins:s,minValue:n,maxValue:o,totalCount:a}=this.state.sortedBins,c=4,l=e*r*c,u=new Float32Array(l).fill(0);for(let p of s){let{lonIdx:g,latIdx:_}=i[p.i],{value:x,counts:v}=p,b=(g+_*e)*c;u[b]=x,u[b+c-1]=v}let f=new Float32Array([o,0,0,n]),h=new Float32Array([o,0,0,a]),d=new Float32Array([n,0,0,a]);this.updateResults({aggregationData:u,maxMinData:f,maxData:h,minData:d})}};var dI={...qs.defaultProps,getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM"},ev="positions",pI={data:{props:["cellSizePixels"]},weights:{props:["aggregation"],accessors:["getWeight"]}},Ea=class extends Cr{static{this.layerName="ScreenGridLayer"}static{this.defaultProps=dI}initializeState(){super.initializeAggregationLayer({dimensions:pI,getCellSize:i=>i.cellSizePixels});let e={count:{size:1,operation:le.SUM,needMax:!0,maxTexture:Ks(this.context.device,{id:`${this.id}-max-texture`})}};this.setState({supported:!0,projectPoints:!0,weights:e,subLayerData:{attributes:{}},maxTexture:e.count.maxTexture,positionAttributeName:"positions",posOffset:[0,0],translation:[1,-1]}),this.getAttributeManager().add({[ev]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}shouldUpdateState({changeFlags:e}){return this.state.supported&&e.somethingChanged}updateState(e){super.updateState(e)}renderLayers(){if(!this.state.supported)return[];let{maxTexture:e,numRow:r,numCol:i,weights:s}=this.state,{updateTriggers:n}=this.props,{aggregationBuffer:o}=s.count,a=this.getSubLayerClass("cells",qs);return new a(this.props,this.getSubLayerProps({id:"cell-layer",updateTriggers:n}),{data:{attributes:{instanceCounts:o}},maxTexture:e,numInstances:r*i})}finalizeState(e){super.finalizeState(e);let{aggregationBuffer:r,maxBuffer:i,maxTexture:s}=this.state;r?.delete(),i?.delete(),s?.delete()}getPickingInfo({info:e}){let{index:r}=e;if(r>=0){let{gpuGridAggregator:i,gpuAggregation:s,weights:n}=this.state,o=s?i.getData("count"):n.count;e.object=Re.getAggregationData({pixelIndex:r,...o})}return e}updateResults({aggregationData:e,maxData:r}){let{count:i}=this.state.weights;i.aggregationData=e,i.aggregationBuffer.write(e),i.maxData=r,i.maxTexture.setImageData({data:r})}updateAggregationState(e){let r=e.props.cellSizePixels,i=e.oldProps.cellSizePixels!==r,{viewportChanged:s}=e.changeFlags,n=e.props.gpuAggregation;this.state.gpuAggregation!==e.props.gpuAggregation&&n&&!Re.isSupported(this.context.device)&&(U.warn("GPU Grid Aggregation not supported, falling back to CPU")(),n=!1);let o=n!==this.state.gpuAggregation;this.setState({gpuAggregation:n});let a=this.isAttributeChanged(ev),{dimensions:c}=this.state,{data:l,weights:u}=c,f=a||o||s||this.isAggregationDirty(e,{compareAll:n,dimension:l}),h=this.isAggregationDirty(e,{dimension:u});this.setState({aggregationDataDirty:f,aggregationWeightsDirty:h});let{viewport:d}=this.context;if(s||i){let{width:p,height:g}=d,_=Math.ceil(p/r),x=Math.ceil(g/r);this.allocateResources(x,_),this.setState({scaling:[p/2,-g/2,1],gridOffset:{xOffset:r,yOffset:r},width:p,height:g,numCol:_,numRow:x})}h&&this._updateAccessors(e),(f||h)&&this._resetResults()}_updateAccessors(e){let{getWeight:r,aggregation:i,data:s}=e.props,{count:n}=this.state.weights;n&&(n.getWeight=r,n.operation=le[i]),this.setState({getValue:Ys(i,r,{data:s})})}_resetResults(){let{count:e}=this.state.weights;e&&(e.aggregationData=null)}};function tv(){}var rv=["getBins","getDomain","getScaleFunc"],iv=[{key:"fillColor",accessor:"getFillColor",pickingInfo:"colorValue",getBins:{triggers:{value:{prop:"getColorValue",updateTrigger:"getColorValue"},weight:{prop:"getColorWeight",updateTrigger:"getColorWeight"},aggregation:{prop:"colorAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"lowerPercentile"},upperPercentile:{prop:"upperPercentile"},scaleType:{prop:"colorScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"colorDomain"},range:{prop:"colorRange"}},onSet:{props:"onSetColorDomain"}},nullValue:[0,0,0,0]},{key:"elevation",accessor:"getElevation",pickingInfo:"elevationValue",getBins:{triggers:{value:{prop:"getElevationValue",updateTrigger:"getElevationValue"},weight:{prop:"getElevationWeight",updateTrigger:"getElevationWeight"},aggregation:{prop:"elevationAggregation"},filterData:{prop:"_filterData",updateTrigger:"_filterData"}}},getDomain:{triggers:{lowerPercentile:{prop:"elevationLowerPercentile"},upperPercentile:{prop:"elevationUpperPercentile"},scaleType:{prop:"elevationScaleType"}}},getScaleFunc:{triggers:{domain:{prop:"elevationDomain"},range:{prop:"elevationRange"}},onSet:{props:"onSetElevationDomain"}},nullValue:-1}],gI=t=>t.cellSize,Mr=class{constructor(e){this.state={layerData:{data:void 0},dimensions:{}},this.changeFlags={},this.dimensionUpdaters={},this._getCellSize=e.getCellSize||gI,this._getAggregator=e.getAggregator,this._addDimension(e.dimensions||iv)}static defaultDimensions(){return iv}updateState(e,r){let{oldProps:i,props:s,changeFlags:n}=e;this.updateGetValueFuncs(i,s,n);let o=this.needsReProjectPoints(i,s,n),a=!1;return n.dataChanged||o?(this.getAggregatedData(s,r),a=!0):((this.getDimensionChanges(i,s,n)||[]).forEach(l=>typeof l=="function"&&l()),a=!0),this.setState({aggregationDirty:a}),this.state}setState(e){this.state={...this.state,...e}}setDimensionState(e,r){this.setState({dimensions:{...this.state.dimensions,[e]:{...this.state.dimensions[e],...r}}})}normalizeResult(e={}){return e.hexagons?{data:e.hexagons,...e}:e.layerData?{data:e.layerData,...e}:e}getAggregatedData(e,r){let s=this._getAggregator(e)(e,r);this.setState({layerData:this.normalizeResult(s)}),this.changeFlags={layerData:!0},this.getSortedBins(e)}updateGetValueFuncs(e,r,i){for(let s in this.dimensionUpdaters){let{value:n,weight:o,aggregation:a}=this.dimensionUpdaters[s].getBins.triggers,c=r[n.prop];this.needUpdateDimensionStep(this.dimensionUpdaters[s].getBins,e,r,i)&&(c?c=wT(c,{data:r.data}):c=Ys(r[a.prop],r[o.prop],{data:r.data})),c&&this.setDimensionState(s,{getValue:c})}}needsReProjectPoints(e,r,i){return this._getCellSize(e)!==this._getCellSize(r)||this._getAggregator(e)!==this._getAggregator(r)||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPosition)}addDimension(e){this._addDimension(e)}_addDimension(e=[]){e.forEach(r=>{let{key:i}=r;this.dimensionUpdaters[i]=this.getDimensionUpdaters(r),this.state.dimensions[i]={getValue:null,domain:null,sortedBins:null,scaleFunc:tv}})}getDimensionUpdaters({key:e,accessor:r,pickingInfo:i,getBins:s,getDomain:n,getScaleFunc:o,nullValue:a}){return{key:e,accessor:r,pickingInfo:i,getBins:{updater:this.getDimensionSortedBins.bind(this),...s},getDomain:{updater:this.getDimensionValueDomain.bind(this),...n},getScaleFunc:{updater:this.getDimensionScale.bind(this),...o},attributeAccessor:this.getSubLayerDimensionAttribute(e,a)}}needUpdateDimensionStep(e,r,i,s){return Object.values(e.triggers).some(n=>n.updateTrigger?s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged[n.updateTrigger]):r[n.prop]!==i[n.prop])}getDimensionChanges(e,r,i){let s=[];for(let n in this.dimensionUpdaters){let o=rv.find(a=>this.needUpdateDimensionStep(this.dimensionUpdaters[n][a],e,r,i));o&&s.push(this.dimensionUpdaters[n][o].updater.bind(this,r,this.dimensionUpdaters[n]))}return s.length?s:null}getUpdateTriggers(e){let r=e.updateTriggers||{},i={};for(let s in this.dimensionUpdaters){let{accessor:n}=this.dimensionUpdaters[s];i[n]={},rv.forEach(o=>{Object.values(this.dimensionUpdaters[s][o].triggers).forEach(({prop:a,updateTrigger:c})=>{if(c){let l=r[c];typeof l=="object"&&!Array.isArray(l)?Object.assign(i[n],l):l!==void 0&&(i[n][a]=l)}else i[n][a]=e[a]})})}return i}getSortedBins(e){for(let r in this.dimensionUpdaters)this.getDimensionSortedBins(e,this.dimensionUpdaters[r])}getDimensionSortedBins(e,r){let{key:i}=r,{getValue:s}=this.state.dimensions[i],n=new Rr(this.state.layerData.data||[],{getValue:s,filterData:e._filterData});this.setDimensionState(i,{sortedBins:n}),this.getDimensionValueDomain(e,r)}getDimensionValueDomain(e,r){let{getDomain:i,key:s}=r,{triggers:{lowerPercentile:n,upperPercentile:o,scaleType:a}}=i,c=this.state.dimensions[s].sortedBins.getValueDomainByScale(e[a.prop],[e[n.prop],e[o.prop]]);this.setDimensionState(s,{valueDomain:c}),this.getDimensionScale(e,r)}getDimensionScale(e,r){let{key:i,getScaleFunc:s,getDomain:n}=r,{domain:o,range:a}=s.triggers,{scaleType:c}=n.triggers,{onSet:l}=s,u=e[a.prop],f=e[o.prop]||this.state.dimensions[i].valueDomain,d=YT(c&&e[c.prop])(f,u);typeof l=="object"&&typeof e[l.props]=="function"&&e[l.props](d.domain()),this.setDimensionState(i,{scaleFunc:d})}getSubLayerDimensionAttribute(e,r){return i=>{let{sortedBins:s,scaleFunc:n}=this.state.dimensions[e],o=s.binMap[i.index];if(o&&o.counts===0)return r;let a=o&&o.value,c=n.domain();return a>=c[0]&&a<=c[c.length-1]?n(a):r}}getSubLayerAccessors(e){let r={};for(let i in this.dimensionUpdaters){let{accessor:s}=this.dimensionUpdaters[i];r[s]=this.getSubLayerDimensionAttribute(e,i)}return r}getPickingInfo({info:e}){let r=e.picked&&e.index>-1,i=null;if(r){let s=this.state.layerData.data[e.index],n={};for(let o in this.dimensionUpdaters){let{pickingInfo:a}=this.dimensionUpdaters[o],{sortedBins:c}=this.state.dimensions[o],l=c.binMap[s.index]&&c.binMap[s.index].value;n[a]=l}i=Object.assign(n,s,{points:s.filteredPoints||s.points})}return e.picked=!!i,e.object=i,e}getAccessor(e){return this.dimensionUpdaters.hasOwnProperty(e)?this.dimensionUpdaters[e].attributeAccessor:tv}};function sv(){}var mI={colorDomain:null,colorRange:Et,getColorValue:{type:"accessor",value:null},getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",lowerPercentile:{type:"number",min:0,max:100,value:0},upperPercentile:{type:"number",min:0,max:100,value:100},colorScaleType:"quantize",onSetColorDomain:sv,elevationDomain:null,elevationRange:[0,1e3],getElevationValue:{type:"accessor",value:null},getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationLowerPercentile:{type:"number",min:0,max:100,value:0},elevationUpperPercentile:{type:"number",min:0,max:100,value:100},elevationScale:{type:"number",min:0,value:1},elevationScaleType:"linear",onSetElevationDomain:sv,gridAggregator:Gs,cellSize:{type:"number",min:0,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:t=>t.position},extruded:!1,material:!0,_filterData:{type:"function",value:null,optional:!0}},ni=class extends nt{static{this.layerName="CPUGridLayer"}static{this.defaultProps=mI}initializeState(){let e=new Mr({getAggregator:i=>i.gridAggregator,getCellSize:i=>i.cellSize});this.state={cpuAggregator:e,aggregatorState:e.state},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(e){super.updateState(e),this.setState({aggregatorState:this.state.cpuAggregator.updateState(e,{viewport:this.context.viewport,attributes:this.getAttributes(),numInstances:this.getNumInstances()})})}getPickingInfo({info:e}){return this.state.cpuAggregator.getPickingInfo({info:e})}_onGetSublayerColor(e){return this.state.cpuAggregator.getAccessor("fillColor")(e)}_onGetSublayerElevation(e){return this.state.cpuAggregator.getAccessor("elevation")(e)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:e,extruded:r,cellSize:i,coverage:s,material:n,transitions:o}=this.props,{cpuAggregator:a}=this.state,c=this.getSubLayerClass("grid-cell",Ki),l=this._getSublayerUpdateTriggers();return new c({cellSize:i,coverage:s,material:n,elevationScale:e,extruded:r,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:o&&{getFillColor:o.getColorValue||o.getColorWeight,getElevation:o.getElevationValue||o.getElevationWeight}},this.getSubLayerProps({id:"grid-cell",updateTriggers:l}),{data:a.state.layerData.data})}};var Zs=Math.PI/3,_I=[0,Zs,2*Zs,3*Zs,4*Zs,5*Zs];function yI(t){return t[0]}function xI(t){return t[1]}function dp(){var t=0,e=0,r=1,i=1,s=yI,n=xI,o,a,c;function l(f){var h={},d=[],p,g=f.length;for(p=0;p1){var M=x-A,F=A+(xD*D+L*L&&(A=F+(b&1?1:-1)/2,b=N)}var Y=A+"-"+b,X=h[Y];X?X.push(_):(d.push(X=h[Y]=[_]),X.x=(A+(b&1)/2)*a,X.y=b*c)}return d}function u(f){var h=0,d=0;return _I.map(function(p){var g=Math.sin(p)*f,_=-Math.cos(p)*f,x=g-h,v=_-d;return h=g,d=_,[x,v]})}return l.hexagon=function(f){return"m"+u(f==null?o:+f).join("l")+"z"},l.centers=function(){for(var f=[],h=Math.round(e/c),d=Math.round(t/a),p=h*c;pg.screenCoord[0]).y(g=>g.screenCoord[1])(c).map((g,_)=>({position:s.unprojectFlat([g.x,g.y]),points:g,index:_})),radiusCommon:a}}function TI(t,e){let{attributes:r}=e,i=r.positions.value,{size:s}=r.positions.getAccessor(),n=1/0,o=1/0,a=-1/0,c=-1/0,l;for(l=0;lt.position},material:!0,_filterData:{type:"function",value:null,optional:!0}},wa=class extends nt{static{this.layerName="HexagonLayer"}static{this.defaultProps=bI}initializeState(){let e=new Mr({getAggregator:i=>i.hexagonAggregator,getCellSize:i=>i.radius});this.state={cpuAggregator:e,aggregatorState:e.state,vertices:null},this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"}})}updateState(e){if(super.updateState(e),e.changeFlags.propsOrDataChanged){let r=this.state.cpuAggregator.updateState(e,{viewport:this.context.viewport,attributes:this.getAttributes()});if(this.state.aggregatorState.layerData!==r.layerData){let{hexagonVertices:i}=r.layerData||{};this.setState({vertices:i&&this.convertLatLngToMeterOffset(i)})}this.setState({aggregatorState:r})}}convertLatLngToMeterOffset(e){let{viewport:r}=this.context;if(Array.isArray(e)&&e.length===6){let i=e[0],s=e[3],n=[(i[0]+s[0])/2,(i[1]+s[1])/2],o=r.projectFlat(n),{metersPerUnit:a}=r.getDistanceScales(n);return e.map(l=>{let u=r.projectFlat(l);return[(u[0]-o[0])*a[0],(u[1]-o[1])*a[1]]})}return U.error("HexagonLayer: hexagonVertices needs to be an array of 6 points")(),null}getPickingInfo({info:e}){return this.state.cpuAggregator.getPickingInfo({info:e})}_onGetSublayerColor(e){return this.state.cpuAggregator.getAccessor("fillColor")(e)}_onGetSublayerElevation(e){return this.state.cpuAggregator.getAccessor("elevation")(e)}_getSublayerUpdateTriggers(){return this.state.cpuAggregator.getUpdateTriggers(this.props)}renderLayers(){let{elevationScale:e,extruded:r,coverage:i,material:s,transitions:n}=this.props,{aggregatorState:o,vertices:a}=this.state,c=this.getSubLayerClass("hexagon-cell",wr),l=this._getSublayerUpdateTriggers(),u=a?{vertices:a,radius:1}:{radius:o.layerData.radiusCommon||1,radiusUnits:"common",angle:90};return new c({...u,diskResolution:6,elevationScale:e,extruded:r,coverage:i,material:s,getFillColor:this._onGetSublayerColor.bind(this),getElevation:this._onGetSublayerElevation.bind(this),transitions:n&&{getFillColor:n.getColorValue||n.getColorWeight,getElevation:n.getElevationValue||n.getElevationWeight}},this.getSubLayerProps({id:"hexagon-cell",updateTriggers:l}),{data:o.layerData.data})}};var W=.16666666666666666,P={N:[0,.5],E:[.5,0],S:[0,-.5],W:[-.5,0],NE:[.5,.5],NW:[-.5,.5],SE:[.5,-.5],SW:[-.5,-.5]},Js=[P.W,P.SW,P.S],Qs=[P.S,P.SE,P.E],en=[P.E,P.NE,P.N],tn=[P.NW,P.W,P.N],rn=[[-.5,W],[-.5,-W],[-W,-.5],[W,-.5]],sn=[[-W,-.5],[W,-.5],[.5,-W],[.5,W]],nn=[[.5,-W],[.5,W],[W,.5],[-W,.5]],on=[[-.5,W],[-.5,-W],[W,.5],[-W,.5]],av=[P.W,P.SW,P.SE,P.E],cv=[P.S,P.SE,P.NE,P.N],lv=[P.NW,P.W,P.E,P.NE],uv=[P.NW,P.SW,P.S,P.N],fv=[[-.5,W],[-.5,-W],[.5,-W],[.5,W]],hv=[[-W,-.5],[W,-.5],[W,.5],[-W,.5]],SI=[P.NW,P.SW,P.SE,P.NE],dv=[P.NW,P.SW,P.SE,P.E,P.N],pv=[P.W,P.SW,P.SE,P.NE,P.N],gv=[P.NW,P.W,P.S,P.SE,P.NE],mv=[P.NW,P.SW,P.S,P.E,P.NE],_v=[P.NW,P.W,[.5,-W],[.5,W],P.N],yv=[[-W,-.5],[W,-.5],P.E,P.NE,P.N],xv=[[-.5,W],[-.5,-W],P.S,P.SE,P.E],Tv=[P.W,P.SW,P.S,[W,.5],[-W,.5]],vv=[P.NW,P.W,[-W,-.5],[W,-.5],P.N],bv=[[-.5,W],[-.5,-W],P.E,P.NE,P.N],Sv=[P.S,P.SE,P.E,[W,.5],[-W,.5]],Av=[P.W,P.SW,P.S,[.5,-W],[.5,W]],Ev=[P.W,P.SW,P.SE,P.E,[W,.5],[-W,.5]],wv=[[-.5,W],[-.5,-W],P.S,P.SE,P.NE,P.N],Pv=[P.NW,P.W,[-W,-.5],[W,-.5],P.E,P.NE],Rv=[P.NW,P.SW,P.S,[.5,-W],[.5,W],P.N],an=[P.W,P.SW,P.S,P.E,P.NE,P.N],cn=[P.NW,P.W,P.S,P.SE,P.E,P.N],lu=[[-.5,W],[-.5,-W],[-W,-.5],[W,-.5],P.E,P.NE,P.N],uu=[P.W,P.SW,P.S,[.5,-W],[.5,W],[W,.5],[-W,.5]],fu=[P.NW,P.W,[-W,-.5],[W,-.5],[.5,-W],[.5,W],P.N],hu=[[-.5,W],[-.5,-W],P.S,P.SE,P.E,[W,.5],[-W,.5]],Cv=[[-.5,W],[-.5,-W],[-W,-.5],[W,-.5],[.5,-W],[.5,W],[W,.5],[-W,.5]],Mv={0:[],1:[[P.W,P.S]],2:[[P.S,P.E]],3:[[P.W,P.E]],4:[[P.N,P.E]],5:{0:[[P.W,P.S],[P.N,P.E]],1:[[P.W,P.N],[P.S,P.E]]},6:[[P.N,P.S]],7:[[P.W,P.N]],8:[[P.W,P.N]],9:[[P.N,P.S]],10:{0:[[P.W,P.N],[P.S,P.E]],1:[[P.W,P.S],[P.N,P.E]]},11:[[P.N,P.E]],12:[[P.W,P.E]],13:[[P.S,P.E]],14:[[P.W,P.S]],15:[]};function z(t){return parseInt(t,4)}var Iv={[z("0000")]:[],[z("2222")]:[],[z("2221")]:[Js],[z("2212")]:[Qs],[z("2122")]:[en],[z("1222")]:[tn],[z("0001")]:[Js],[z("0010")]:[Qs],[z("0100")]:[en],[z("1000")]:[tn],[z("2220")]:[rn],[z("2202")]:[sn],[z("2022")]:[nn],[z("0222")]:[on],[z("0002")]:[rn],[z("0020")]:[sn],[z("0200")]:[nn],[z("2000")]:[on],[z("0011")]:[av],[z("0110")]:[cv],[z("1100")]:[lv],[z("1001")]:[uv],[z("2211")]:[av],[z("2112")]:[cv],[z("1122")]:[lv],[z("1221")]:[uv],[z("2200")]:[fv],[z("2002")]:[hv],[z("0022")]:[fv],[z("0220")]:[hv],[z("1111")]:[SI],[z("1211")]:[dv],[z("2111")]:[pv],[z("1112")]:[gv],[z("1121")]:[mv],[z("1011")]:[dv],[z("0111")]:[pv],[z("1110")]:[gv],[z("1101")]:[mv],[z("1200")]:[_v],[z("0120")]:[yv],[z("0012")]:[xv],[z("2001")]:[Tv],[z("1022")]:[_v],[z("2102")]:[yv],[z("2210")]:[xv],[z("0221")]:[Tv],[z("1002")]:[vv],[z("2100")]:[bv],[z("0210")]:[Sv],[z("0021")]:[Av],[z("1220")]:[vv],[z("0122")]:[bv],[z("2012")]:[Sv],[z("2201")]:[Av],[z("0211")]:[Ev],[z("2110")]:[wv],[z("1102")]:[Pv],[z("1021")]:[Rv],[z("2011")]:[Ev],[z("0112")]:[wv],[z("1120")]:[Pv],[z("1201")]:[Rv],[z("2101")]:[an],[z("0121")]:[an],[z("1012")]:[cn],[z("1210")]:[cn],[z("0101")]:{0:[Js,en],1:[an],2:[an]},[z("1010")]:{0:[tn,Qs],1:[cn],2:[cn]},[z("2121")]:{0:[an],1:[an],2:[Js,en]},[z("1212")]:{0:[cn],1:[cn],2:[tn,Qs]},[z("2120")]:{0:[lu],1:[lu],2:[rn,en]},[z("2021")]:{0:[uu],1:[uu],2:[Js,nn]},[z("1202")]:{0:[fu],1:[fu],2:[tn,sn]},[z("0212")]:{0:[hu],1:[hu],2:[Qs,on]},[z("0102")]:{0:[rn,en],1:[lu],2:[lu]},[z("0201")]:{0:[Js,nn],1:[uu],2:[uu]},[z("1020")]:{0:[tn,sn],1:[fu],2:[fu]},[z("2010")]:{0:[Qs,on],1:[hu],2:[hu]},[z("2020")]:{0:[on,sn],1:[Cv],2:[rn,nn]},[z("0202")]:{0:[nn,rn],1:[Cv],2:[on,sn]}};var es={ISO_LINES:1,ISO_BANDS:2},AI={zIndex:0,zOffset:.005};function Pa(t,e){return Array.isArray(e)?t=e?1:0}function Ov(t){let{cellWeights:e,x:r,y:i,width:s,height:n}=t,o=t.threshold;t.thresholdValue&&(U.deprecated("thresholdValue","threshold")(),o=t.thresholdValue);let a=r<0,c=r>=s-1,l=i<0,u=i>=n-1,f=a||c||l||u,h={},d={};a||u?d.top=0:(h.top=e[(i+1)*s+r],d.top=Pa(h.top,o)),c||u?d.topRight=0:(h.topRight=e[(i+1)*s+r+1],d.topRight=Pa(h.topRight,o)),c||l?d.right=0:(h.right=e[i*s+r+1],d.right=Pa(h.right,o)),a||l?d.current=0:(h.current=e[i*s+r],d.current=Pa(h.current,o));let{top:p,topRight:g,right:_,current:x}=d,v=-1;Number.isFinite(o)&&(v=p<<3|g<<2|_<<1|x),Array.isArray(o)&&(v=p<<6|g<<4|_<<2|x);let b=0;return f||(b=Pa((h.top+h.topRight+h.right+h.current)/4,o)),{code:v,meanCode:b}}function pp(t){let{gridOrigin:e,cellSize:r,x:i,y:s,code:n,meanCode:o,type:a=es.ISO_LINES}=t,c={...AI,...t.thresholdData},l=a===es.ISO_BANDS?Iv[n]:Mv[n];Array.isArray(l)||(l=l[o]);let u=c.zIndex*c.zOffset,f=(i+1)*r[0],h=(s+1)*r[1],d=e[0]+f,p=e[1]+h;if(a===es.ISO_BANDS){let _=[];return l.forEach(x=>{let v=[];x.forEach(b=>{let A=d+b[0]*r[0],C=p+b[1]*r[1];v.push([A,C,u])}),_.push(v)}),_}let g=[];return l.forEach(_=>{_.forEach(x=>{let v=d+x[0]*r[0],b=p+x[1]*r[1];g.push([v,b,u])})}),g}function Nv({thresholdData:t,cellWeights:e,gridSize:r,gridOrigin:i,cellSize:s}){let n=[],o=[],a=r[0],c=r[1],l=0,u=0;for(let f of t){let{contour:h}=f,{threshold:d}=h;for(let p=-1;pt.position},getWeight:{type:"accessor",value:1},gpuAggregation:!1,aggregation:"SUM",contours:{type:"object",value:[{threshold:wI}],optional:!0,compare:3},zOffset:.005},Dv="positions",RI={data:{props:["cellSize"]},weights:{props:["aggregation"],accessors:["getWeight"]}},Ra=class extends Cr{static{this.layerName="ContourLayer"}static{this.defaultProps=PI}initializeState(){super.initializeAggregationLayer({dimensions:RI}),this.setState({contourData:{},projectPoints:!1,weights:{count:{size:1,operation:le.SUM}}}),this.getAttributeManager().add({[Dv]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},count:{size:3,accessor:"getWeight"}})}updateState(e){super.updateState(e);let r=!1,{oldProps:i,props:s}=e,{aggregationDirty:n}=this.state;(i.contours!==s.contours||i.zOffset!==s.zOffset)&&(r=!0,this._updateThresholdData(e.props)),this.getNumInstances()>0&&(n||r)&&this._generateContours()}renderLayers(){let{contourSegments:e,contourPolygons:r}=this.state.contourData,i=this.getSubLayerClass("lines",Xi),s=this.getSubLayerClass("bands",zt),n=e&&e.length>0&&new i(this.getSubLayerProps({id:"lines"}),{data:this.state.contourData.contourSegments,getSourcePosition:a=>a.start,getTargetPosition:a=>a.end,getColor:a=>a.contour.color||Fv,getWidth:a=>a.contour.strokeWidth||EI}),o=r&&r.length>0&&new s(this.getSubLayerProps({id:"bands"}),{data:this.state.contourData.contourPolygons,getPolygon:a=>a.vertices,getFillColor:a=>a.contour.color||Fv});return[n,o]}updateAggregationState(e){let{props:r,oldProps:i}=e,{cellSize:s,coordinateSystem:n}=r,{viewport:o}=this.context,a=i.cellSize!==s,c=r.gpuAggregation;this.state.gpuAggregation!==r.gpuAggregation&&c&&!Re.isSupported(this.context.device)&&(U.warn("GPU Grid Aggregation not supported, falling back to CPU")(),c=!1);let l=c!==this.state.gpuAggregation;this.setState({gpuAggregation:c});let{dimensions:u}=this.state,f=this.isAttributeChanged(Dv),{data:h,weights:d}=u,{boundingBox:p}=this.state;if(f&&(p=au(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:p})),f||a){let{gridOffset:x,translation:v,width:b,height:A,numCol:C,numRow:M}=cu(p,s,o,n);this.allocateResources(M,C),this.setState({gridOffset:x,boundingBox:p,translation:v,posOffset:v.slice(),gridOrigin:[-1*v[0],-1*v[1]],width:b,height:A,numCol:C,numRow:M})}let g=f||l||this.isAggregationDirty(e,{dimension:h,compareAll:c}),_=this.isAggregationDirty(e,{dimension:d});_&&this._updateAccessors(e),(g||_)&&this._resetResults(),this.setState({aggregationDataDirty:g,aggregationWeightsDirty:_})}_updateAccessors(e){let{getWeight:r,aggregation:i,data:s}=e.props,{count:n}=this.state.weights;n&&(n.getWeight=r,n.operation=le[i]),this.setState({getValue:Ys(i,r,{data:s})})}_resetResults(){let{count:e}=this.state.weights;e&&(e.aggregationData=null)}_generateContours(){let{numCol:e,numRow:r,gridOrigin:i,gridOffset:s,thresholdData:n}=this.state,{count:o}=this.state.weights,{aggregationData:a}=o;a||(a=o.aggregationBuffer.readSyncWebGL(),o.aggregationData=a);let{cellWeights:c}=Re.getCellData({countsData:a}),l=Nv({thresholdData:n,cellWeights:c,gridSize:[e,r],gridOrigin:i,cellSize:[s.xOffset,s.yOffset]});this.setState({contourData:l})}_updateThresholdData(e){let{contours:r,zOffset:i}=e,s=r.length,n=new Array(s);for(let o=0;o= (domain.x - EPSILON) && value <= (domain.y + EPSILON)) { +float domainRange = domain.y - domain.x; +if (domainRange <= 0.) { +outColor = colorRange[0]; +} else { +float rangeCount = float(RANGE_COUNT); +float rangeStep = domainRange / rangeCount; +float idx = floor((value - domain.x) / rangeStep); +idx = clamp(idx, 0., rangeCount - 1.); +int intIdx = int(idx); +outColor = colorRange[intIdx]; +} +} +return outColor; +} +float linearScale(vec2 domain, vec2 range, float value) { +if (value >= (domain.x - EPSILON) && value <= (domain.y + EPSILON)) { +return ((value - domain.x) / (domain.y - domain.x)) * (range.y - range.x) + range.x; +} +return -1.; +} +void main(void) { +vec2 clrDomain = colorDomainValid ? colorDomain : vec2(colorData.maxMinCount.a, colorData.maxMinCount.r); +vec4 color = quantizeScale(clrDomain, colorRange, colors.r); +float elevation = 0.0; +if (extruded) { +vec2 elvDomain = elevationDomainValid ? elevationDomain : vec2(elevationData.maxMinCount.a, elevationData.maxMinCount.r); +elevation = linearScale(elvDomain, elevationRange, elevations.r); +elevation = elevation * (positions.z + 1.0) / 2.0 * elevationScale; +} +float shouldRender = float(color.r > 0.0 && elevations.r >= 0.0); +float dotRadius = cellSize / 2. * coverage * shouldRender; +int yIndex = (gl_InstanceID / gridSize[0]); +int xIndex = gl_InstanceID - (yIndex * gridSize[0]); +vec2 instancePositionXFP64 = mul_fp64(vec2(gridOffset[0], gridOffsetLow[0]), vec2(float(xIndex), 0.)); +instancePositionXFP64 = sum_fp64(instancePositionXFP64, vec2(gridOrigin[0], gridOriginLow[0])); +vec2 instancePositionYFP64 = mul_fp64(vec2(gridOffset[1], gridOffsetLow[1]), vec2(float(yIndex), 0.)); +instancePositionYFP64 = sum_fp64(instancePositionYFP64, vec2(gridOrigin[1], gridOriginLow[1])); +vec3 centroidPosition = vec3(instancePositionXFP64[0], instancePositionYFP64[0], elevation); +vec3 centroidPosition64Low = vec3(instancePositionXFP64[1], instancePositionYFP64[1], 0.0); +geometry.worldPosition = centroidPosition; +vec3 pos = vec3(project_size(positions.xy + offset) * dotRadius, 0.); +picking_setPickingColor(instancePickingColors); +gl_Position = project_position_to_clipspace(centroidPosition, centroidPosition64Low, pos, geometry.position); +vec3 normals_commonspace = project_normal(normals); +if (extruded) { +vec3 lightColor = lighting_getLightColor(color.rgb, project_uCameraPosition, geometry.position.xyz, normals_commonspace); +vColor = vec4(lightColor, color.a * opacity) / 255.; +} else { +vColor = vec4(color.rgb, color.a * opacity) / 255.; +} +} +`;var kv=`#version 300 es +#define SHADER_NAME gpu-grid-cell-layer-fragment-shader +precision highp float; +in vec4 vColor; +out vec4 fragColor; +void main(void) { +fragColor = vColor; +fragColor = picking_filterColor(fragColor); +} +`;var gp=0,mp=1,CI={colorDomain:null,colorRange:Et,elevationDomain:null,elevationRange:[0,1e3],elevationScale:{type:"number",min:0,value:1},gridSize:{type:"array",value:[1,1]},gridOrigin:{type:"array",value:[0,0]},gridOffset:{type:"array",value:[0,0]},cellSize:{type:"number",min:0,max:1e3,value:1e3},offset:{type:"array",value:[1,1]},coverage:{type:"number",min:0,max:1,value:1},extruded:!0,material:!0},Ca=class extends ne{static{this.layerName="GPUGridCellLayer"}static{this.defaultProps=CI}getShaders(){return super.getShaders({vs:Lv,fs:kv,modules:[ae,Mt,ue,Wr]})}initializeState(){this.getAttributeManager().addInstanced({colors:{size:4,noAlloc:!0},elevations:{size:4,noAlloc:!0}});let r=this._getModel();this._setupUniformBuffer(r),this.setState({model:r})}_getModel(){return new te(this.context.device,{...this.getShaders(),id:this.props.id,geometry:new Fi,isInstanced:!0})}draw({uniforms:e}){let{cellSize:r,offset:i,extruded:s,elevationScale:n,coverage:o,gridSize:a,gridOrigin:c,gridOffset:l,elevationRange:u,colorMaxMinBuffer:f,elevationMaxMinBuffer:h}=this.props,d=this.state.model,p=[Ii(c[0]),Ii(c[1])],g=[Ii(l[0]),Ii(l[1])],_=this.getDomainUniforms(),x=si(this.props.colorRange);this.bindUniformBuffers(f,h),d.setUniforms(e),d.setUniforms(_),d.setUniforms({cellSize:r,offset:i,extruded:s,elevationScale:n,coverage:o,gridSize:a,gridOrigin:c,gridOriginLow:p,gridOffset:l,gridOffsetLow:g,colorRange:x,elevationRange:u}),d.draw(this.context.renderPass),this.unbindUniformBuffers(f,h)}bindUniformBuffers(e,r){e.bind({target:35345,index:gp}),r.bind({target:35345,index:mp})}unbindUniformBuffers(e,r){e.unbind({target:35345,index:gp}),r.unbind({target:35345,index:mp})}getDomainUniforms(){let{colorDomain:e,elevationDomain:r}=this.props,i={};return e!==null?(i.colorDomainValid=!0,i.colorDomain=e):i.colorDomainValid=!1,r!==null?(i.elevationDomainValid=!0,i.elevationDomain=r):i.elevationDomainValid=!1,i}_setupUniformBuffer(e){let r=e.pipeline.handle,i=this.context.gl,s=i.getUniformBlockIndex(r,"ColorData"),n=i.getUniformBlockIndex(r,"ElevationData");i.uniformBlockBinding(r,s,gp),i.uniformBlockBinding(r,n,mp)}};var MI={colorDomain:null,colorRange:Et,getColorWeight:{type:"accessor",value:1},colorAggregation:"SUM",elevationDomain:null,elevationRange:[0,1e3],getElevationWeight:{type:"accessor",value:1},elevationAggregation:"SUM",elevationScale:{type:"number",min:0,value:1},cellSize:{type:"number",min:1,max:1e3,value:1e3},coverage:{type:"number",min:0,max:1,value:1},getPosition:{type:"accessor",value:t=>t.position},extruded:!1,material:!0},II={data:{props:["cellSize","colorAggregation","elevationAggregation"]}},Bv="positions",oi=class extends Cr{static{this.layerName="GPUGridLayer"}static{this.defaultProps=MI}initializeState({device:e}){let r=Re.isSupported(e);r||U.error("GPUGridLayer is not supported on this browser, use GridLayer instead")(),super.initializeAggregationLayer({dimensions:II}),this.setState({gpuAggregation:!1,projectPoints:!1,isSupported:r,weights:{color:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:e.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})},elevation:{needMin:!0,needMax:!0,combineMaxMin:!0,maxMinBuffer:e.createBuffer({byteLength:4*4,accessor:{size:4,type:5126,divisor:1}})}},positionAttributeName:"positions"}),this.getAttributeManager().add({[Bv]:{size:3,accessor:"getPosition",type:"float64",fp64:this.use64bitPositions()},color:{size:3,accessor:"getColorWeight"},elevation:{size:3,accessor:"getElevationWeight"}})}updateState(e){if(this.state.isSupported===!1)return;super.updateState(e);let{aggregationDirty:r}=this.state;r&&this.setState({gridHash:null})}getHashKeyForIndex(e){let{numRow:r,numCol:i,boundingBox:s,gridOffset:n}=this.state,o=[i,r],a=[s.xMin,s.yMin],c=[n.xOffset,n.yOffset],l=Math.floor(e/o[0]),u=e-l*o[0],f=Math.floor((l*c[1]+a[1]+90+c[1]/2)/c[1]),h=Math.floor((u*c[0]+a[0]+180+c[0]/2)/c[0]);return`${f}-${h}`}getPositionForIndex(e){let{numRow:r,numCol:i,boundingBox:s,gridOffset:n}=this.state,o=[i,r],a=[s.xMin,s.yMin],c=[n.xOffset,n.yOffset],l=Math.floor(e/o[0]),u=e-l*o[0],f=l*c[1]+a[1];return[u*c[0]+a[0],f]}getPickingInfo({info:e,mode:r}){let{index:i}=e,s=null;if(i>=0){let n=this.state.gpuGridAggregator,o=this.getPositionForIndex(i),a=Re.getAggregationData({pixelIndex:i,...n.getData("color")}),c=Re.getAggregationData({pixelIndex:i,...n.getData("elevation")});if(s={colorValue:a.cellWeight,elevationValue:c.cellWeight,count:a.cellCount||c.cellCount,position:o,totalCount:a.totalCount||c.totalCount},r!=="hover"){let{props:l}=this,{gridHash:u}=this.state;if(!u){let{gridOffset:d,translation:p,boundingBox:g}=this.state,{viewport:_}=this.context,x=this.getAttributes();u=Gs(l,{gridOffset:d,attributes:x,viewport:_,translation:p,boundingBox:g}).gridHash,this.setState({gridHash:u})}let f=this.getHashKeyForIndex(i),h=u[f];Object.assign(s,h)}}return e.picked=!!s,e.object=s,e}renderLayers(){if(!this.state.isSupported)return null;let{elevationScale:e,extruded:r,cellSize:i,coverage:s,material:n,elevationRange:o,colorDomain:a,elevationDomain:c}=this.props,{weights:l,numRow:u,numCol:f,gridOrigin:h,gridOffset:d}=this.state,{color:p,elevation:g}=l,_=si(this.props.colorRange),x=this.getSubLayerClass("gpu-grid-cell",Ca);return new x({gridSize:[f,u],gridOrigin:h,gridOffset:[d.xOffset,d.yOffset],colorRange:_,elevationRange:o,colorDomain:a,elevationDomain:c,cellSize:i,coverage:s,material:n,elevationScale:e,extruded:r},this.getSubLayerProps({id:"gpu-grid-cell"}),{data:{attributes:{colors:p.aggregationBuffer,elevations:g.aggregationBuffer}},colorMaxMinBuffer:p.maxMinBuffer,elevationMaxMinBuffer:g.maxMinBuffer,numInstances:f*u})}finalizeState(e){let{color:r,elevation:i}=this.state.weights;[r,i].forEach(s=>{let{aggregationBuffer:n,maxMinBuffer:o}=s;o?.destroy(),n?.destroy()}),super.finalizeState(e)}updateAggregationState(e){let{props:r,oldProps:i}=e,{cellSize:s,coordinateSystem:n}=r,{viewport:o}=this.context,a=i.cellSize!==s,{dimensions:c}=this.state,l=this.isAttributeChanged(Bv),u=l||this.isAttributeChanged(),{boundingBox:f}=this.state;if(l&&(f=au(this.getAttributes(),this.getNumInstances()),this.setState({boundingBox:f})),l||a){let{gridOffset:d,translation:p,width:g,height:_,numCol:x,numRow:v}=cu(f,s,o,n);this.allocateResources(v,x),this.setState({gridOffset:d,translation:p,gridOrigin:[-1*p[0],-1*p[1]],width:g,height:_,numCol:x,numRow:v})}let h=u||this.isAggregationDirty(e,{dimension:c.data,compareAll:!0});h&&this._updateAccessors(e),this.setState({aggregationDataDirty:h})}_updateAccessors(e){let{colorAggregation:r,elevationAggregation:i}=e.props,{color:s,elevation:n}=this.state.weights;s.operation=le[r],n.operation=le[i]}};var OI={...oi.defaultProps,...ni.defaultProps,gpuAggregation:!1},Ma=class extends et{static{this.layerName="GridLayer"}static{this.defaultProps=OI}initializeState(){this.state={useGPUAggregation:!1}}updateState({props:e}){this.setState({useGPUAggregation:!1})}renderLayers(){let{data:e,updateTriggers:r}=this.props,i=this.state.useGPUAggregation?"GPU":"CPU",s=this.state.useGPUAggregation?this.getSubLayerClass("GPU",oi):this.getSubLayerClass("CPU",ni);return new s(this.props,this.getSubLayerProps({id:i,updateTriggers:r}),{data:e})}canUseGPUAggregation(e){let{gpuAggregation:r,lowerPercentile:i,upperPercentile:s,getColorValue:n,getElevationValue:o,colorScaleType:a}=e;return!(!r||!Re.isSupported(this.context.device)||i!==0||s!==100||n!==null||o!==null||a==="quantile"||a==="ordinal")}};function zv(t){let e=t.map(a=>a[0]),r=t.map(a=>a[1]),i=Math.min.apply(null,e),s=Math.max.apply(null,e),n=Math.min.apply(null,r),o=Math.max.apply(null,r);return[i,n,s,o]}function Vv(t,e){return e[0]>=t[0]&&e[2]<=t[2]&&e[1]>=t[1]&&e[3]<=t[3]}var Uv=new Float32Array(12);function _p(t,e=2){let r=0;for(let i of t)for(let s=0;s 0.) { +maxValue = colorDomain[1]; +minValue = colorDomain[0]; +} +vIntensityMax = intensity / maxValue; +vIntensityMin = intensity / minValue; +} +`;var Xv=`#version 300 es +#define SHADER_NAME triangle-layer-fragment-shader +precision highp float; +uniform float opacity; +uniform sampler2D weightsTexture; +uniform sampler2D colorTexture; +uniform float aggregationMode; +in vec2 vTexCoords; +in float vIntensityMin; +in float vIntensityMax; +out vec4 fragColor; +vec4 getLinearColor(float value) { +float factor = clamp(value * vIntensityMax, 0., 1.); +vec4 color = texture(colorTexture, vec2(factor, 0.5)); +color.a *= min(value * vIntensityMin, 1.0); +return color; +} +void main(void) { +vec4 weights = texture(weightsTexture, vTexCoords); +float weight = weights.r; +if (aggregationMode > 0.5) { +weight /= max(1.0, weights.a); +} +if (weight <= 0.) { +discard; +} +vec4 linearColor = getLinearColor(weight); +linearColor.a *= opacity; +fragColor = linearColor; +} +`;var Ia=class extends ne{static{this.layerName="TriangleLayer"}getShaders(){return{vs:jv,fs:Xv,modules:[ae]}}initializeState({device:e}){this.setState({model:this._getModel(e)})}_getModel(e){let{vertexCount:r,data:i,weightsTexture:s,maxTexture:n,colorTexture:o}=this.props;return new te(e,{...this.getShaders(),id:this.props.id,bindings:{weightsTexture:s,maxTexture:n,colorTexture:o},attributes:i.attributes,bufferLayout:[{name:"positions",format:"float32x3"},{name:"texCoords",format:"float32x2"}],topology:"triangle-fan-webgl",vertexCount:r})}draw({uniforms:e}){let{model:r}=this.state,{intensity:i,threshold:s,aggregationMode:n,colorDomain:o}=this.props;r.setUniforms({...e,intensity:i,threshold:s,aggregationMode:n,colorDomain:o}),r.draw(this.context.renderPass)}};var yp=`#version 300 es +in vec3 positions; +in vec3 positions64Low; +in float weights; +out vec4 weightsTexture; +uniform float radiusPixels; +uniform float textureWidth; +uniform vec4 commonBounds; +uniform float weightsScale; +void main() +{ +weightsTexture = vec4(weights * weightsScale, 0., 0., 1.); +float radiusTexels = project_pixel_size(radiusPixels) * textureWidth / (commonBounds.z - commonBounds.x); +gl_PointSize = radiusTexels * 2.; +vec3 commonPosition = project_position(positions, positions64Low); +gl_Position.xy = (commonPosition.xy - commonBounds.xy) / (commonBounds.zw - commonBounds.xy) ; +gl_Position.xy = (gl_Position.xy * 2.) - (1.); +gl_Position.w = 1.0; +} +`;var xp=`#version 300 es +in vec4 weightsTexture; +out vec4 fragColor; +float gaussianKDE(float u){ +return pow(2.71828, -u*u/0.05555)/(1.77245385*0.166666); +} +void main() +{ +float dist = length(gl_PointCoord - vec2(0.5, 0.5)); +if (dist > 0.5) { +discard; +} +fragColor = weightsTexture * gaussianKDE(2. * dist); +DECKGL_FILTER_COLOR(fragColor, geometry); +} +`;var $v=`#version 300 es +uniform sampler2D inTexture; +uniform float textureSize; +out vec4 outTexture; +void main() +{ +int yIndex = gl_VertexID / int(textureSize); +int xIndex = gl_VertexID - (yIndex * int(textureSize)); +vec2 uv = (0.5 + vec2(float(xIndex), float(yIndex))) / textureSize; +outTexture = texture(inTexture, uv); +gl_Position = vec4(0.0, 0.0, 0.0, 1.0); +gl_PointSize = 1.0; +} +`;var Yv=`#version 300 es +in vec4 outTexture; +out vec4 fragColor; +void main() { +fragColor = outTexture; +fragColor.g = outTexture.r / max(1.0, outTexture.a); +} +`;var NI=2,Tp={format:"rgba8unorm",mipmaps:!1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}},Kv=[0,0],FI={SUM:0,MEAN:1},DI={getPosition:{type:"accessor",value:t=>t.position},getWeight:{type:"accessor",value:1},intensity:{type:"number",min:0,value:1},radiusPixels:{type:"number",min:1,max:100,value:50},colorRange:Et,threshold:{type:"number",min:0,max:1,value:.05},colorDomain:{type:"array",value:null,optional:!0},aggregation:"SUM",weightsTextureSize:{type:"number",min:128,max:2048,value:2048},debounceTimeout:{type:"number",min:0,max:1e3,value:500}},LI=["float32-renderable-webgl","texture-blend-float-webgl"],kI={data:{props:["radiusPixels"]}},Oa=class extends nt{static{this.layerName="HeatmapLayer"}static{this.defaultProps=DI}initializeState(){super.initializeAggregationLayer(kI),this.setState({colorDomain:Kv}),this._setupTextureParams(),this._setupAttributes(),this._setupResources()}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState(e){super.updateState(e),this._updateHeatmapState(e)}_updateHeatmapState(e){let{props:r,oldProps:i}=e,s=this._getChangeFlags(e);(s.dataChanged||s.viewportChanged)&&(s.boundsChanged=this._updateBounds(s.dataChanged),this._updateTextureRenderingBounds()),s.dataChanged||s.boundsChanged?(clearTimeout(this.state.updateTimer),this.setState({isWeightMapDirty:!0})):s.viewportZoomChanged&&this._debouncedUpdateWeightmap(),r.colorRange!==i.colorRange&&this._updateColorTexture(e),this.state.isWeightMapDirty&&this._updateWeightmap(),this.setState({zoom:e.context.viewport.zoom})}renderLayers(){let{weightsTexture:e,triPositionBuffer:r,triTexCoordBuffer:i,maxWeightsTexture:s,colorTexture:n,colorDomain:o}=this.state,{updateTriggers:a,intensity:c,threshold:l,aggregation:u}=this.props,f=this.getSubLayerClass("triangle",Ia);return new f(this.getSubLayerProps({id:"triangle-layer",updateTriggers:a}),{coordinateSystem:q.DEFAULT,data:{attributes:{positions:r,texCoords:i}},vertexCount:4,maxTexture:s,colorTexture:n,aggregationMode:FI[u]||0,weightsTexture:e,intensity:c,threshold:l,colorDomain:o})}finalizeState(e){super.finalizeState(e);let{weightsTransform:r,weightsTexture:i,maxWeightTransform:s,maxWeightsTexture:n,triPositionBuffer:o,triTexCoordBuffer:a,colorTexture:c,updateTimer:l}=this.state;r?.destroy(),i?.destroy(),s?.destroy(),n?.destroy(),o?.destroy(),a?.destroy(),c?.destroy(),l&&clearTimeout(l)}_getAttributeManager(){return new nr(this.context.device,{id:this.props.id,stats:this.context.stats})}_getChangeFlags(e){let r={},{dimensions:i}=this.state;r.dataChanged=this.isAttributeChanged()&&"attribute changed"||this.isAggregationDirty(e,{compareAll:!0,dimension:i.data})&&"aggregation is dirty",r.viewportChanged=e.changeFlags.viewportChanged;let{zoom:s}=this.state;return(!e.context.viewport||e.context.viewport.zoom!==s)&&(r.viewportZoomChanged=!0),r}_createTextures(){let{textureSize:e,format:r}=this.state;this.setState({weightsTexture:this.context.device.createTexture({...Tp,width:e,height:e,format:r}),maxWeightsTexture:this.context.device.createTexture({...Tp,width:1,height:1,format:r})})}_setupAttributes(){this.getAttributeManager().add({positions:{size:3,type:"float64",accessor:"getPosition"},weights:{size:1,accessor:"getWeight"}}),this.setState({positionAttributeName:"positions"})}_setupTextureParams(){let{device:e}=this.context,{weightsTextureSize:r}=this.props,i=Math.min(r,e.limits.maxTextureDimension2D),s=LI.every(a=>e.features.has(a)),n=s?"rgba32float":"rgba8unorm",o=s?1:1/255;this.setState({textureSize:i,format:n,weightsScale:o}),s||U.warn(`HeatmapLayer: ${this.id} rendering to float texture not supported, falling back to low precision format`)()}_createWeightsTransform(e){let{weightsTransform:r}=this.state,{weightsTexture:i}=this.state,s=this.getAttributeManager();r?.destroy(),r=new $r(this.context.device,{id:`${this.id}-weights-transform`,bufferLayout:s.getBufferLayouts(),vertexCount:1,targetTexture:i,parameters:{depthWriteEnabled:!1,blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"},topology:"point-list",...e}),this.setState({weightsTransform:r})}_setupResources(){this._createTextures();let{device:e}=this.context,{textureSize:r,weightsTexture:i,maxWeightsTexture:s}=this.state,n=this.getShaders({vs:yp,fs:xp});this._createWeightsTransform(n);let o=this.getShaders({vs:$v,fs:Yv}),a=new $r(e,{id:`${this.id}-max-weights-transform`,bindings:{inTexture:i},uniforms:{textureSize:r},targetTexture:s,...o,vertexCount:r*r,topology:"point-list",parameters:{depthWriteEnabled:!1,blendColorOperation:"max",blendAlphaOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}});this.setState({weightsTexture:i,maxWeightsTexture:s,maxWeightTransform:a,zoom:null,triPositionBuffer:e.createBuffer({byteLength:48}),triTexCoordBuffer:e.createBuffer({byteLength:48})})}updateShaders(e){this._createWeightsTransform({vs:yp,fs:xp,...e})}_updateMaxWeightValue(){let{maxWeightTransform:e}=this.state;e.run({parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]})}_updateBounds(e=!1){let{viewport:r}=this.context,i=[r.unproject([0,0]),r.unproject([r.width,0]),r.unproject([r.width,r.height]),r.unproject([0,r.height])].map(a=>a.map(Math.fround)),s=zv(i),n={visibleWorldBounds:s,viewportCorners:i},o=!1;if(e||!this.state.worldBounds||!Vv(this.state.worldBounds,s)){let a=this._worldToCommonBounds(s),c=this._commonToWorldBounds(a);this.props.coordinateSystem===q.LNGLAT&&(c[1]=Math.max(c[1],-85.051129),c[3]=Math.min(c[3],85.051129),c[0]=Math.max(c[0],-360),c[2]=Math.min(c[2],360));let l=this._worldToCommonBounds(c);n.worldBounds=c,n.normalizedCommonBounds=l,o=!0}return this.setState(n),o}_updateTextureRenderingBounds(){let{triPositionBuffer:e,triTexCoordBuffer:r,normalizedCommonBounds:i,viewportCorners:s}=this.state,{viewport:n}=this.context;e.write(_p(s,3));let o=s.map(a=>Hv(n.projectPosition(a),i));r.write(_p(o,2))}_updateColorTexture(e){let{colorRange:r}=e.props,{colorTexture:i}=this.state,s=si(r,!1,Uint8Array);i&&i?.width===r.length?i.setSubImageData({data:s}):(i?.destroy(),i=this.context.device.createTexture({...Tp,data:s,width:r.length,height:1})),this.setState({colorTexture:i})}_updateWeightmap(){let{radiusPixels:e,colorDomain:r,aggregation:i}=this.props,{worldBounds:s,textureSize:n,weightsScale:o}=this.state,a=this.state.weightsTransform;this.state.isWeightMapDirty=!1;let c=this._worldToCommonBounds(s,{useLayerCoordinateSystem:!0});if(r&&i==="SUM"){let{viewport:g}=this.context,_=g.distanceScales.metersPerUnit[2]*(c[2]-c[0])/n;this.state.colorDomain=r.map(x=>x*_*o)}else this.state.colorDomain=r||Kv;let u=this.getAttributeManager().getAttributes(),f=this.getModuleSettings(),h=u.positions.buffer,d={radiusPixels:e,commonBounds:c,textureWidth:n,weightsScale:o},p=u.weights.buffer;a.model.setAttributes({positions:h,weights:p}),a.model.setVertexCount(this.getNumInstances()),a.model.setUniforms(d),a.model.updateModuleSettings(f),a.run({parameters:{viewport:[0,0,n,n]},clearColor:[0,0,0,0]}),this._updateMaxWeightValue()}_debouncedUpdateWeightmap(e=!1){let{updateTimer:r}=this.state,{debounceTimeout:i}=this.props;e?(r=null,this._updateBounds(!0),this._updateTextureRenderingBounds(),this.setState({isWeightMapDirty:!0})):(this.setState({isWeightMapDirty:!1}),clearTimeout(r),r=setTimeout(this._debouncedUpdateWeightmap.bind(this,!0),i)),this.setState({updateTimer:r})}_worldToCommonBounds(e,r={}){let{useLayerCoordinateSystem:i=!1}=r,[s,n,o,a]=e,{viewport:c}=this.context,{textureSize:l}=this.state,{coordinateSystem:u}=this.props,f=i&&(u===q.LNGLAT_OFFSETS||u===q.METER_OFFSETS),h=f?c.projectPosition(this.props.coordinateOrigin):[0,0],d=l*NI/c.scale,p,g;return i&&!f?(p=this.projectPosition([s,n,0]),g=this.projectPosition([o,a,0])):(p=c.projectPosition([s,n,0]),g=c.projectPosition([o,a,0])),Wv([p[0]-h[0],p[1]-h[1],g[0]-h[0],g[1]-h[1]],d,d)}_commonToWorldBounds(e){let[r,i,s,n]=e,{viewport:o}=this.context,a=o.unprojectPosition([r,i]),c=o.unprojectPosition([s,n]);return a.slice(0,2).concat(c.slice(0,2))}};var BI=Object.prototype.toString,un=Array.isArray||function(e){return BI.call(e)==="[object Array]"};function Sp(t){return typeof t=="function"}function UI(t){return un(t)?"array":typeof t}function bp(t){return t.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function qv(t,e){return t!=null&&typeof t=="object"&&e in t}function zI(t,e){return t!=null&&typeof t!="object"&&t.hasOwnProperty&&t.hasOwnProperty(e)}var VI=RegExp.prototype.test;function WI(t,e){return VI.call(t,e)}var HI=/\S/;function jI(t){return!WI(HI,t)}var XI={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function $I(t){return String(t).replace(/[&<>"'`=\/]/g,function(r){return XI[r]})}var YI=/\s*/,KI=/\s+/,Gv=/\s*=/,qI=/\s*\}/,GI=/#|\^|\/|>|\{|&|=|!/;function ZI(t,e){if(!t)return[];var r=!1,i=[],s=[],n=[],o=!1,a=!1,c="",l=0;function u(){if(o&&!a)for(;n.length;)delete s[n.pop()];else n=[];o=!1,a=!1}var f,h,d;function p(N){if(typeof N=="string"&&(N=N.split(KI,2)),!un(N)||N.length!==2)throw new Error("Invalid tags: "+N);f=new RegExp(bp(N[0])+"\\s*"),h=new RegExp("\\s*"+bp(N[1])),d=new RegExp("\\s*"+bp("}"+N[1]))}p(e||wt.tags);for(var g=new Fa(t),_,x,v,b,A,C;!g.eos();){if(_=g.pos,v=g.scanUntil(f),v)for(var M=0,F=v.length;M"?A=[x,v,_,g.pos,c,l,r]:A=[x,v,_,g.pos],l++,s.push(A),x==="#"||x==="^")i.push(A);else if(x==="/"){if(C=i.pop(),!C)throw new Error('Unopened section "'+v+'" at '+_);if(C[1]!==v)throw new Error('Unclosed section "'+C[1]+'" at '+_)}else x==="name"||x==="{"||x==="&"?a=!0:x==="="&&p(v)}if(u(),C=i.pop(),C)throw new Error('Unclosed section "'+C[1]+'" at '+g.pos);return QI(JI(s))}function JI(t){for(var e=[],r,i,s=0,n=t.length;s0?i[i.length-1][4]:e;break;default:r.push(s)}return e}function Fa(t){this.string=t,this.tail=t,this.pos=0}Fa.prototype.eos=function(){return this.tail===""};Fa.prototype.scan=function(e){var r=this.tail.match(e);if(!r||r.index!==0)return"";var i=r[0];return this.tail=this.tail.substring(i.length),this.pos+=i.length,i};Fa.prototype.scanUntil=function(e){var r=this.tail.search(e),i;switch(r){case-1:i=this.tail,this.tail="";break;case 0:i="";break;default:i=this.tail.substring(0,r),this.tail=this.tail.substring(r)}return this.pos+=i.length,i};function ln(t,e){this.view=t,this.cache={".":this.view},this.parent=e}ln.prototype.push=function(e){return new ln(e,this)};ln.prototype.lookup=function(e){var r=this.cache,i;if(r.hasOwnProperty(e))i=r[e];else{for(var s=this,n,o,a,c=!1;s;){if(e.indexOf(".")>0)for(n=s.view,o=e.split("."),a=0;n!=null&&a"?l=this.renderPartial(a,r,i,n):c==="&"?l=this.unescapedValue(a,r):c==="name"?l=this.escapedValue(a,r,n):c==="text"&&(l=this.rawValue(a)),l!==void 0&&(o+=l);return o};Ye.prototype.renderSection=function(e,r,i,s,n){var o=this,a="",c=r.lookup(e[1]);function l(h){return o.render(h,r,i,n)}if(c){if(un(c))for(var u=0,f=c.length;u0||!i)&&(n[o]=s+n[o]);return n.join(` +`)};Ye.prototype.renderPartial=function(e,r,i,s){if(i){var n=this.getConfigTags(s),o=Sp(i)?i(e[1]):i[e[1]];if(o!=null){var a=e[6],c=e[5],l=e[4],u=o;c==0&&l&&(u=this.indentPartial(o,l,a));var f=this.parse(u,n);return this.renderTokens(f,r,i,u,s)}}};Ye.prototype.unescapedValue=function(e,r){var i=r.lookup(e[1]);if(i!=null)return i};Ye.prototype.escapedValue=function(e,r,i){var s=this.getConfigEscape(i)||wt.escape,n=r.lookup(e[1]);if(n!=null)return typeof n=="number"&&s===wt.escape?String(n):s(n)};Ye.prototype.rawValue=function(e){return e[1]};Ye.prototype.getConfigTags=function(e){return un(e)?e:e&&typeof e=="object"?e.tags:void 0};Ye.prototype.getConfigEscape=function(e){if(e&&typeof e=="object"&&!un(e))return e.escape};var wt={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(t){Na.templateCache=t},get templateCache(){return Na.templateCache}},Na=new Ye;wt.clearCache=function(){return Na.clearCache()};wt.parse=function(e,r){return Na.parse(e,r)};wt.render=function(e,r,i,s){if(typeof e!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+UI(e)+'" was given as the first argument for mustache#render(template, view, partials)');return Na.render(e,r,i,s)};wt.escape=$I;wt.Scanner=Fa;wt.Context=ln;wt.Writer=Ye;var Ap=wt;function Ep(t,e,r){return r!==null?Ap.render(r,t.properties):e===null?Object.keys(t.properties).map(s=>`${s}: ${t.properties[s]}`).join("
"):t.properties[e]}function wp(t){let e={background:"white",color:"black","border-radius":"3px"};return({layer:r,object:i})=>{if(i){let s=typeof t=="object"?t[r.id]:t;return s&&{html:Ap.render(s,i),style:e}}return null}}var eO=new Vs({configuration:new ar({layers:vp})});function Jv(t,e){let[r,i]=e;console.log(r,i),t[r](...i)}function Zv(t){return t.map(e=>eO.convert(Object.assign(e,{onHover:({object:r})=>console.log(r)})))}function Qv(t,e){let r=null;return{addTooltip:function(i,s=null,n=null){let o={closeButton:!1,closeOnClick:!1},a=new t.Popup(o);e.on("mousemove",i,c=>{let l=c.features[0],u=Ep(l,s,n);a.setLngLat(c.lngLat).setHTML(u).addTo(e)}),e.on("mouseleave",i,()=>{a.remove()})},addControl:function(i,s,n){e.addControl(new t[i](s),n)},addPopup:function(i,s=null,n=null){let o={closeButton:!1},a=new t.Popup(o);e.on("click",i,c=>{let l=c.features[0],u=Ep(l,s,n);a.setLngLat(c.lngLat).setHTML(u).addTo(e)})},addMarker:function({lngLat:i,popup:s,options:n}){let o=new t.Marker(n).setLngLat(i);if(s){let a=new t.Popup(s.options).setHTML(s.text);o.setPopup(a)}o.addTo(e)},setSourceData:function(i,s){e.getSource(i).setData(s)},addDeckOverlay:function(i,s=null){let n=Zv(i);r=new Ls({interleaved:!0,layers:n,getTooltip:s?wp(s):null}),e.addControl(r)},setDeckLayers:function(i,s=null){console.log("Updating Deck.GL layers");let n=Zv(i);r.setProps({layers:n,getTooltip:s?wp(s):null})}}}function tO(t){let e="pymaplibregl",r=document.createElement("div");return r.id=e,r.style.height=t.get("height"),r}function rO(t,e){let r=new du.Map(t);return t.navigationControl===void 0&&(t.navigationControl=!0),t.navigationControl&&r.addControl(new du.NavigationControl),r.on("mouseover",()=>{r.getCanvas().style.cursor="pointer"}),r.on("mouseout",()=>{r.getCanvas().style.cursor=""}),r.on("click",i=>{e.set("lng_lat",i.lngLat),e.save_changes()}),r.once("load",()=>{r.resize()}),r}function iO({model:t,el:e}){console.log("maplibregl",du.version);let r=tO(t),i=Object.assign({container:r},t.get("map_options"));console.log(i);let s=rO(i,t),n=Qv(du,s),o=c=>{c.forEach(l=>{if(Object.keys(n).includes(l[0])){console.log("internal call",l);let[u,f]=l;n[u](...f);return}Jv(s,l)})},a=t.get("calls");s.on("load",()=>{console.log("init calls",a),o(a),t.set("_rendered",!0),t.save_changes()}),t.on("msg:custom",c=>{console.log("custom msg",c),o(c.calls)}),e.appendChild(r)}var jJ={render:iO};export{jJ as default}; /*! Bundled license information: +hammerjs/hammer.js: + (*! Hammer.JS - v2.0.7 - 2016-04-22 + * http://hammerjs.github.io/ + * + * Copyright (c) 2016 Jorik Tangelder; + * Licensed under the MIT license *) + mustache/mustache.mjs: (*! * mustache.js - Logic-less {{mustache}} templates with JavaScript diff --git a/maplibre/ui.py b/maplibre/ui.py index 346791c6..db1549d5 100644 --- a/maplibre/ui.py +++ b/maplibre/ui.py @@ -38,3 +38,26 @@ def output_maplibregl(id_: str, height: [int | str] = 200) -> Tag: class_=_shiny_output_class, style=f"height: {height}", ) + + +DECKGL_VERSION = "9.0.16" + +deckgl_dep = HTMLDependency( + name="deckgl", + version=DECKGL_VERSION, + source={"href": f"https://unpkg.com/deck.gl@{DECKGL_VERSION}/"}, + script={"src": "dist.min.js", "type": "module"}, +) + +DECKGL_VERSION = "9.0.16" + +deckgl_json_dep = HTMLDependency( + name="deckgljson", + version=DECKGL_VERSION, + source={"href": f"https://unpkg.com/@deck.gl/json@{DECKGL_VERSION}/"}, + script={"src": "dist.min.js", "type": "module"}, +) + + +def use_deckgl() -> Tag: + return ui.div(deckgl_dep, deckgl_json_dep) diff --git a/mkdocs.yml b/mkdocs.yml index 56aeae12..8cf66613 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -13,6 +13,7 @@ nav: - Get started: - Welcome to MapLibre: index.md - Layers: layers.md + - Deck.GL Layers: deckgl.md - Shiny: shiny.md - Jupyter: jupyter.md - Changelog: changelog.md @@ -23,17 +24,19 @@ nav: - Basemaps: api/basemaps.md - Markers and controls: api/controls.md - Examples: - - Every person in manhattan: examples/every_person_in_manhattan/index.md - - Vancouver property value: examples/vancouver_blocks/index.md - - Earthquake clusters: examples/earthquake_clusters/index.md - - Airport markers: examples/airports/index.md - - 3D Indoor mapping: examples/3d_indoor_mapping/index.md + - Every Person in Manhattan: examples/every_person_in_manhattan/index.md + - Vancouver Property Value: examples/vancouver_blocks/index.md + - Earthquake Clusters: examples/earthquake_clusters/index.md + - Airport Markers: examples/airports/index.md + - 3D Indoor Mapping: examples/3d_indoor_mapping/index.md - Custom basemap: examples/custom_basemap/index.md - GeoPandas: examples/geopandas/index.md - H3 Grid UK Road Safety: examples/road_safety/index.md - Where is the ISS: examples/where_is_the_iss/index.md - WMS: examples/wms/index.md - Layer Order: examples/layer_order/index.md + - Deck.GL Layer: examples/deckgl_layer/index.md + - Multiple Deck.GL Layers: examples/deckgl_multiple_layers/index.md plugins: - search: diff --git a/package-lock.json b/package-lock.json index 92d81e05..1a5f541b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,10 @@ "version": "0.1.1", "license": "MIT", "dependencies": { + "@deck.gl/aggregation-layers": "^9.0.16", + "@deck.gl/json": "^9.0.16", + "@deck.gl/layers": "^9.0.16", + "@deck.gl/mapbox": "^9.0.16", "mustache": "^4.2.0" }, "devDependencies": { @@ -16,6 +20,91 @@ "prettier": "3.1.1" } }, + "node_modules/@deck.gl/aggregation-layers": { + "version": "9.0.16", + "resolved": "https://registry.npmjs.org/@deck.gl/aggregation-layers/-/aggregation-layers-9.0.16.tgz", + "integrity": "sha512-bO9/lELi4InsfDTI+CMkMKlzit5uFEbqKzIz5SXgw+jXRFPD1Z4LJ1uFyzaLPAE0bHc8CGGIvRTKb+Mf+8Af1g==", + "dependencies": { + "@luma.gl/constants": "^9.0.14", + "@luma.gl/shadertools": "^9.0.14", + "@math.gl/web-mercator": "^4.0.0", + "d3-hexbin": "^0.2.1" + }, + "peerDependencies": { + "@deck.gl/core": "^9.0.0", + "@deck.gl/layers": "^9.0.0", + "@luma.gl/core": "^9.0.0", + "@luma.gl/engine": "^9.0.0" + } + }, + "node_modules/@deck.gl/core": { + "version": "9.0.16", + "resolved": "https://registry.npmjs.org/@deck.gl/core/-/core-9.0.16.tgz", + "integrity": "sha512-8VP+01/7/iJDkQMW9Cu5+YMRSKXYD19aGABZZLR0pZJ2MnoTJLZMivhwimYIjaKhKfA/3qqu3k8aakEDBU+Tdw==", + "peer": true, + "dependencies": { + "@loaders.gl/core": "^4.2.0", + "@loaders.gl/images": "^4.2.0", + "@luma.gl/constants": "^9.0.14", + "@luma.gl/core": "^9.0.14", + "@luma.gl/engine": "^9.0.14", + "@luma.gl/shadertools": "^9.0.14", + "@luma.gl/webgl": "^9.0.14", + "@math.gl/core": "^4.0.0", + "@math.gl/sun": "^4.0.0", + "@math.gl/web-mercator": "^4.0.0", + "@probe.gl/env": "^4.0.9", + "@probe.gl/log": "^4.0.9", + "@probe.gl/stats": "^4.0.9", + "@types/offscreencanvas": "^2019.6.4", + "gl-matrix": "^3.0.0", + "mjolnir.js": "^2.7.0" + } + }, + "node_modules/@deck.gl/json": { + "version": "9.0.16", + "resolved": "https://registry.npmjs.org/@deck.gl/json/-/json-9.0.16.tgz", + "integrity": "sha512-m0bRSmhHChBj9LtjB4A6dl4AEnGXU87K7f4fbcwZiatQ/aMLfzGjzv1sCSxhrShREn1tBWEudzAjQaDtb1tOGA==", + "dependencies": { + "expression-eval": "^5.0.0" + }, + "peerDependencies": { + "@deck.gl/core": "^9.0.0" + } + }, + "node_modules/@deck.gl/layers": { + "version": "9.0.16", + "resolved": "https://registry.npmjs.org/@deck.gl/layers/-/layers-9.0.16.tgz", + "integrity": "sha512-9piNu++TWLr5sXehmf+lbLFLl3txUnjdltOA2iGmdW/iIxC1DYVSHT7LI5WfQ0dxVHVp2Zgw9RyYs0aRmsumkQ==", + "dependencies": { + "@loaders.gl/images": "^4.2.0", + "@loaders.gl/schema": "^4.2.0", + "@mapbox/tiny-sdf": "^2.0.5", + "@math.gl/core": "^4.0.0", + "@math.gl/polygon": "^4.0.0", + "@math.gl/web-mercator": "^4.0.0", + "earcut": "^2.2.4" + }, + "peerDependencies": { + "@deck.gl/core": "^9.0.0", + "@loaders.gl/core": "^4.2.0", + "@luma.gl/core": "^9.0.0", + "@luma.gl/engine": "^9.0.0" + } + }, + "node_modules/@deck.gl/mapbox": { + "version": "9.0.16", + "resolved": "https://registry.npmjs.org/@deck.gl/mapbox/-/mapbox-9.0.16.tgz", + "integrity": "sha512-hBRiDf+WFx6tU+epjF8OazUk2PgD6iBp3uwVEKJafxgt3c9r1fiSCwKfBxZGRyBSDJ48SPsAkTKIks5tS7rfjQ==", + "dependencies": { + "@luma.gl/constants": "^9.0.14", + "@math.gl/web-mercator": "^4.0.0" + }, + "peerDependencies": { + "@deck.gl/core": "^9.0.0", + "@luma.gl/core": "^9.0.0" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.19.10", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.10.tgz", @@ -384,6 +473,203 @@ "node": ">=12" } }, + "node_modules/@loaders.gl/core": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/core/-/core-4.2.2.tgz", + "integrity": "sha512-d3YElSsqL29MaiOwzGB97v994SPotbTvJnooCqoQsYGoYYrECdIetv1/zlfDsh5UB2Wl/NaUMJrzyOqlLmDz5Q==", + "peer": true, + "dependencies": { + "@loaders.gl/loader-utils": "4.2.2", + "@loaders.gl/schema": "4.2.2", + "@loaders.gl/worker-utils": "4.2.2", + "@probe.gl/log": "^4.0.2" + } + }, + "node_modules/@loaders.gl/images": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/images/-/images-4.2.2.tgz", + "integrity": "sha512-R53rkexvVT0i4YXt++r8gLq3reB6kWTLvdJL81J3R4YJbM5+kNSe40jJOA94LFYlsTN+oirF4lkLTe5YXGZPYQ==", + "dependencies": { + "@loaders.gl/loader-utils": "4.2.2" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/loader-utils": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/loader-utils/-/loader-utils-4.2.2.tgz", + "integrity": "sha512-5udJQhFx1KNIcRBYkFMi8QZitAsK+m3PkZ9GejM8VpOSsJUHD2Yal3wBHOPTRsOjQ0zXG/nqM7BHOojjeetNTg==", + "dependencies": { + "@loaders.gl/schema": "4.2.2", + "@loaders.gl/worker-utils": "4.2.2", + "@probe.gl/stats": "^4.0.2" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/schema": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/schema/-/schema-4.2.2.tgz", + "integrity": "sha512-vrQ6vlGWWptJXDP1DrL5x/j70xmyt2l36QZcGyDYptrohTGvQLc3yrOEHuD5v96fXX5WR619pT3zSYhuf1FnIg==", + "dependencies": { + "@types/geojson": "^7946.0.7" + }, + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@loaders.gl/worker-utils": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@loaders.gl/worker-utils/-/worker-utils-4.2.2.tgz", + "integrity": "sha512-7Ad83VS/PmS0T3LXo+LB6cq5oHhAUW3GvYWizm4OfeuBDQRtYK7iRehgC13/BomkNtWIn0y7iAphlQMVrNdvhQ==", + "peerDependencies": { + "@loaders.gl/core": "^4.0.0" + } + }, + "node_modules/@luma.gl/constants": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@luma.gl/constants/-/constants-9.0.14.tgz", + "integrity": "sha512-mCZ5Sr39EX8AjPVy3v5W/XamaU6dtA5CEHCYLPdyMXEQ2snqsFut2Y4cOO/ySuOUccjEm4Y6Vb45BJKNMN8NyQ==" + }, + "node_modules/@luma.gl/core": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@luma.gl/core/-/core-9.0.14.tgz", + "integrity": "sha512-XkgCpVWGtfmEVTRbkkBu1HksjD1+3ZFqamNlCNgeWqsCcy0UZ2+iTF9qyxnT9K0QhdhnPgox6890A49C2iSRnw==", + "peer": true, + "dependencies": { + "@math.gl/types": "^4.0.0", + "@probe.gl/env": "^4.0.2", + "@probe.gl/log": "^4.0.2", + "@probe.gl/stats": "^4.0.2", + "@types/offscreencanvas": "^2019.6.4" + } + }, + "node_modules/@luma.gl/engine": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@luma.gl/engine/-/engine-9.0.14.tgz", + "integrity": "sha512-7PuvXbcovFfXgCWC4eAZAPMzNAf3rfFo7Cd9FB7AEKLIwdYYN6nmn/PNjsZREa8eXK5ExDC8jDJ6lqtWrTqlyg==", + "peer": true, + "dependencies": { + "@luma.gl/shadertools": "9.0.14", + "@math.gl/core": "^4.0.0", + "@probe.gl/log": "^4.0.2", + "@probe.gl/stats": "^4.0.2" + }, + "peerDependencies": { + "@luma.gl/core": "^9.0.0" + } + }, + "node_modules/@luma.gl/shadertools": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@luma.gl/shadertools/-/shadertools-9.0.14.tgz", + "integrity": "sha512-4UFh/oQ+sRwERzuPf2flgMhHIbENU1xnHvXUzpzE3Z/+/DNljb2oSeMkW74fgpVmM6MuyHZhU1hM5RRq/mW3Tw==", + "dependencies": { + "@math.gl/core": "^4.0.0", + "@math.gl/types": "^4.0.0" + }, + "peerDependencies": { + "@luma.gl/core": "^9.0.0" + } + }, + "node_modules/@luma.gl/webgl": { + "version": "9.0.14", + "resolved": "https://registry.npmjs.org/@luma.gl/webgl/-/webgl-9.0.14.tgz", + "integrity": "sha512-TcgXPWaKVEVbnzB6Cu49Ia70oZny/GNy57OLj82kW7+llrKY5bpfOaD5aSIDEV34nqmmlpML4agPJXEIzeP/BQ==", + "peer": true, + "dependencies": { + "@luma.gl/constants": "9.0.14", + "@probe.gl/env": "^4.0.2" + }, + "peerDependencies": { + "@luma.gl/core": "^9.0.0" + } + }, + "node_modules/@mapbox/tiny-sdf": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@mapbox/tiny-sdf/-/tiny-sdf-2.0.6.tgz", + "integrity": "sha512-qMqa27TLw+ZQz5Jk+RcwZGH7BQf5G/TrutJhspsca/3SHwmgKQ1iq+d3Jxz5oysPVYTGP6aXxCo5Lk9Er6YBAA==" + }, + "node_modules/@math.gl/core": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@math.gl/core/-/core-4.0.1.tgz", + "integrity": "sha512-9IewNjR9V66o+gYIIq5agFoHy6ZT6DRpRGQBfsUpZz4glAqOjVt64he8GGzjpmqfT+kKT4qwQ7nQl/hZLF15qA==", + "dependencies": { + "@math.gl/types": "4.0.1" + } + }, + "node_modules/@math.gl/polygon": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@math.gl/polygon/-/polygon-4.0.1.tgz", + "integrity": "sha512-pwtEbwW3N5qy09K/1FwRYW7M2u9XMPBfIe8BNpkbJh8uH3DPXQdT4uCNFiwrQPPQUQTDdlQyLu/0mRHm2R/fbg==", + "dependencies": { + "@math.gl/core": "4.0.1" + } + }, + "node_modules/@math.gl/sun": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@math.gl/sun/-/sun-4.0.1.tgz", + "integrity": "sha512-nDkQZ9PKd5iMySRM1j01hYG6MwA/MkKXZe4JvArggWUtPXL6nCcPSeiifPXQGIvE9eZdQkbn81StNY9q5l0cFg==", + "peer": true + }, + "node_modules/@math.gl/types": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@math.gl/types/-/types-4.0.1.tgz", + "integrity": "sha512-E9qBKAjVBiZD8Is7TbygiLGtYBP3GSLus6RUJSuzFQegdYXeVagvrs4UkBJxhrRAxw4crfH0Tq7IhTMKuuJNQw==" + }, + "node_modules/@math.gl/web-mercator": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@math.gl/web-mercator/-/web-mercator-4.0.1.tgz", + "integrity": "sha512-eJ0nDw8140kJorf8ASyKRC53rI+UG6vPxpsKJiGRD6lXsoKTeKYebeEAXiGDWTvi2AMe6+xngxTqqwm58fL3Fw==" + }, + "node_modules/@probe.gl/env": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@probe.gl/env/-/env-4.0.9.tgz", + "integrity": "sha512-AOmVMD0/j78mX+k4+qX7ZhE0sY9H+EaJgIO6trik0BwV6VcrwxTGCGFAeuRsIGhETDnye06tkLXccYatYxAYwQ==", + "peer": true + }, + "node_modules/@probe.gl/log": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@probe.gl/log/-/log-4.0.9.tgz", + "integrity": "sha512-ebuZaodSRE9aC+3bVC7cKRHT8garXeT1jTbj1R5tQRqQYc9iGeT3iemVOHx5bN9Q6gAs/0j54iPI+1DvWMAW4A==", + "peer": true, + "dependencies": { + "@probe.gl/env": "4.0.9" + } + }, + "node_modules/@probe.gl/stats": { + "version": "4.0.9", + "resolved": "https://registry.npmjs.org/@probe.gl/stats/-/stats-4.0.9.tgz", + "integrity": "sha512-Q9Xt/sJUQaMsbjRKjOscv2t7wXIymTrOEJ4a3da4FTCn7bkKvcdxdyFAQySCrtPxE+YZ5I5lXpWPgv9BwmpE1g==" + }, + "node_modules/@types/geojson": { + "version": "7946.0.14", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.14.tgz", + "integrity": "sha512-WCfD5Ht3ZesJUsONdhvm84dmzWOiOzOAqOncN0++w0lBw1o8OuDNJF2McvvCef/yBqb/HYRahp1BYtODFQ8bRg==" + }, + "node_modules/@types/hammerjs": { + "version": "2.0.45", + "resolved": "https://registry.npmjs.org/@types/hammerjs/-/hammerjs-2.0.45.tgz", + "integrity": "sha512-qkcUlZmX6c4J8q45taBKTL3p+LbITgyx7qhlPYOdOHZB7B31K0mXbP5YA7i7SgDeEGuI9MnumiKPEMrxg8j3KQ==", + "peer": true + }, + "node_modules/@types/offscreencanvas": { + "version": "2019.7.3", + "resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.3.tgz", + "integrity": "sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==", + "peer": true + }, + "node_modules/d3-hexbin": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/d3-hexbin/-/d3-hexbin-0.2.2.tgz", + "integrity": "sha512-KS3fUT2ReD4RlGCjvCEm1RgMtp2NFZumdMu4DBzQK8AZv3fXRM6Xm8I4fSU07UXvH4xxg03NwWKWdvxfS/yc4w==" + }, + "node_modules/earcut": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/earcut/-/earcut-2.2.4.tgz", + "integrity": "sha512-/pjZsA1b4RPHbeWZQn66SWS8nZZWLQQ23oE3Eam7aroEFGEvwKAsJfZ9ytiEMycfzXWpca4FA9QIOehf7PocBQ==" + }, "node_modules/esbuild": { "version": "0.19.10", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.10.tgz", @@ -422,6 +708,52 @@ "@esbuild/win32-x64": "0.19.10" } }, + "node_modules/expression-eval": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/expression-eval/-/expression-eval-5.0.1.tgz", + "integrity": "sha512-7SL4miKp19lI834/F6y156xlNg+i9Q41tteuGNCq9C06S78f1bm3BXuvf0+QpQxv369Pv/P2R7Hb17hzxLpbDA==", + "deprecated": "The expression-eval npm package is no longer maintained. The package was originally published as part of a now-completed personal project, and I do not have incentives to continue maintenance.", + "dependencies": { + "jsep": "^0.3.0" + } + }, + "node_modules/gl-matrix": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/gl-matrix/-/gl-matrix-3.4.3.tgz", + "integrity": "sha512-wcCp8vu8FT22BnvKVPjXa/ICBWRq/zjFfdofZy1WSpQZpphblv12/bOQLBC1rMM7SGOFS9ltVmKOHil5+Ml7gA==", + "peer": true + }, + "node_modules/hammerjs": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/hammerjs/-/hammerjs-2.0.8.tgz", + "integrity": "sha512-tSQXBXS/MWQOn/RKckawJ61vvsDpCom87JgxiYdGwHdOa0ht0vzUWDlfioofFCRU0L+6NGDt6XzbgoJvZkMeRQ==", + "peer": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/jsep": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/jsep/-/jsep-0.3.5.tgz", + "integrity": "sha512-AoRLBDc6JNnKjNcmonituEABS5bcfqDhQAWWXNTFrqu6nVXBpBAGfcoTGZMFlIrh9FjmE1CQyX9CTNwZrXMMDA==", + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/mjolnir.js": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/mjolnir.js/-/mjolnir.js-2.7.3.tgz", + "integrity": "sha512-Z5z/+FzZqOSO3juSVKV3zcm4R2eAlWwlKMcqHmyFEJAaLILNcDKnIbnb4/kbcGyIuhtdWrzu8WOIR7uM6I34aw==", + "peer": true, + "dependencies": { + "@types/hammerjs": "^2.0.41", + "hammerjs": "^2.0.8" + }, + "engines": { + "node": ">= 4", + "npm": ">= 3" + } + }, "node_modules/mustache": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", diff --git a/package.json b/package.json index afbf809e..c7523e14 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pymaplibregl", - "version": "0.1.1", + "version": "0.2.0", "description": "...", "main": "index.js", "directories": { @@ -23,6 +23,10 @@ "prettier": "3.1.1" }, "dependencies": { + "@deck.gl/aggregation-layers": "^9.0.16", + "@deck.gl/json": "^9.0.16", + "@deck.gl/layers": "^9.0.16", + "@deck.gl/mapbox": "^9.0.16", "mustache": "^4.2.0" } } diff --git a/pyproject.toml b/pyproject.toml index 66fe8da2..db48b33f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "maplibre" -version = "0.1.6" +version = "0.1.6.1" description = "Python bindings for MapLibre GL JS" authors = ["Stefan Kuethe "] readme = "README.md" diff --git a/srcjs/deck-layers.js b/srcjs/deck-layers.js new file mode 100644 index 00000000..b0dd40de --- /dev/null +++ b/srcjs/deck-layers.js @@ -0,0 +1,2 @@ +export * from "@deck.gl/layers"; +export * from "@deck.gl/aggregation-layers"; diff --git a/srcjs/index.js b/srcjs/index.js index 139a4eaf..785851c9 100644 --- a/srcjs/index.js +++ b/srcjs/index.js @@ -26,9 +26,9 @@ if (typeof Shiny !== "undefined") { renderValue(el, payload) { console.log("id:", el.id, "payload:", payload); - const pyMapLibreGL = new PyMapLibreGL( + const pyMapLibreGL = (window._maplibreWidget = new PyMapLibreGL( Object.assign({ container: el.id }, payload.mapData.mapOptions), - ); + )); const map = pyMapLibreGL.getMap(); map.on("load", () => { diff --git a/srcjs/ipywidget.js b/srcjs/ipywidget.js index d5f80d67..12879589 100644 --- a/srcjs/ipywidget.js +++ b/srcjs/ipywidget.js @@ -1,4 +1,5 @@ import maplibregl from "https://esm.sh/maplibre-gl@3.6.2"; + import { applyMapMethod, getCustomMapMethods } from "./mapmethods"; function createContainer(model) { @@ -39,7 +40,7 @@ function createMap(mapOptions, model) { return map; } -export function render({ model, el }) { +function render({ model, el }) { console.log("maplibregl", maplibregl.version); const container = createContainer(model); @@ -84,3 +85,5 @@ export function render({ model, el }) { el.appendChild(container); } + +export default { render }; diff --git a/srcjs/mapmethods.js b/srcjs/mapmethods.js index 573a2b0a..2feb135b 100644 --- a/srcjs/mapmethods.js +++ b/srcjs/mapmethods.js @@ -1,4 +1,12 @@ -import { getTextFromFeature } from "./utils"; +import { MapboxOverlay } from "@deck.gl/mapbox"; +import { JSONConfiguration, JSONConverter } from "@deck.gl/json"; +import * as deckLayerCatalog from "./deck-layers"; + +import { getTextFromFeature, getDeckTooltip } from "./utils"; + +const jsonConverter = new JSONConverter({ + configuration: new JSONConfiguration({ layers: deckLayerCatalog }), +}); function applyMapMethod(map, call) { const [methodName, params] = call; @@ -6,9 +14,21 @@ function applyMapMethod(map, call) { map[methodName](...params); } +function _convertDeckLayer(deckLayers) { + return deckLayers.map((deckLayer) => + jsonConverter.convert( + Object.assign(deckLayer, { + onHover: ({ object }) => console.log(object), + }), + ), + ); +} + // TODO: Duplicated code, use for Shiny and Ipywidget // Custom map methods function getCustomMapMethods(maplibregl, map) { + let deckOverlay = null; + return { addTooltip: function (layerId, property = null, template = null) { const popupOptions = { @@ -60,6 +80,27 @@ function getCustomMapMethods(maplibregl, map) { setSourceData: function (sourceId, data) { map.getSource(sourceId).setData(data); }, + + addDeckOverlay: function (deckLayers, tooltip = null) { + const layers = _convertDeckLayer(deckLayers); + // console.log("deckLayers", layers); + deckOverlay = new MapboxOverlay({ + interleaved: true, + layers: layers, + getTooltip: tooltip ? getDeckTooltip(tooltip) : null, + }); + map.addControl(deckOverlay); + }, + + setDeckLayers: function (deckLayers, tooltip = null) { + console.log("Updating Deck.GL layers"); + const layers = _convertDeckLayer(deckLayers); + // console.log("deckLayers", layers); + deckOverlay.setProps({ + layers, + getTooltip: tooltip ? getDeckTooltip(tooltip) : null, + }); + }, }; } diff --git a/srcjs/pymaplibregl.js b/srcjs/pymaplibregl.js index 6c6962ec..6590dc79 100644 --- a/srcjs/pymaplibregl.js +++ b/srcjs/pymaplibregl.js @@ -1,6 +1,19 @@ -// import { getCustomMapMethods } from "./mapmethods"; -import { getTextFromFeature } from "./utils"; +import { + getTextFromFeature, + getDeckTooltip, + getDeckMapLibrePopupTooltip, +} from "./utils"; + +function getJSONConverter() { + if (typeof deck === "undefined") { + return; + } + + const configuration = new deck.JSONConfiguration({ classes: deck }); + return new deck.JSONConverter({ configuration }); +} +// TODO: Rename to 'MapLibreWidget' export default class PyMapLibreGL { constructor(mapOptions) { this._id = mapOptions.container; @@ -16,8 +29,8 @@ export default class PyMapLibreGL { // TODO: Do not add by default this._map.addControl(new maplibregl.NavigationControl()); - // this.customMapMethods = getCustomMapMethods(maplibregl, this._map); - // console.log("Custom methods", Object.keys(this.customMapMethods)); + + this._JSONConverter = getJSONConverter(); } getMap() { @@ -94,6 +107,47 @@ export default class PyMapLibreGL { this._map.getSource(sourceId).setData(data); } + addDeckOverlay(deckLayers, tooltip = null) { + if (typeof this._JSONConverter === "undefined") { + console.log("deck or JSONConverter is undefined"); + return; + } + + const layers = this._convertDeckLayers(deckLayers, tooltip); + this._deckOverlay = new deck.MapboxOverlay({ + interleaved: true, + layers: layers, + // getTooltip: tooltip ? getDeckTooltip(tooltip) : null, + }); + this._map.addControl(this._deckOverlay); + } + + _convertDeckLayers(deckLayers, tooltip = null) { + return deckLayers.map((deckLayer) => { + const tooltip_ = + tooltip && typeof tooltip === "object" + ? tooltip[deckLayer.id] + : tooltip; + const getTooltip = getDeckMapLibrePopupTooltip(this._map, tooltip_); + deckLayer.onHover = ({ layer, coordinate, object }) => { + if (tooltip_) getTooltip({ coordinate, object }); + + // Add event listener + if (typeof Shiny !== "undefined") { + const inputName = `${this._id}_layer_${deckLayer.id}`; + Shiny.onInputChange(inputName, object); + } + }; + return this._JSONConverter.convert(deckLayer); + }); + } + + setDeckLayers(deckLayers, tooltip = null) { + console.log("Updating Deck.GL layers"); + const layers = this._convertDeckLayers(deckLayers, tooltip); + this._deckOverlay.setProps({ layers }); + } + render(calls) { calls.forEach(([name, params]) => { // Custom method @@ -106,6 +160,8 @@ export default class PyMapLibreGL { "addPopup", "addControl", "setSourceData", + "addDeckOverlay", + "setDeckLayers", ].includes(name) ) { console.log("Custom method", name, params); diff --git a/srcjs/utils.js b/srcjs/utils.js index cedd917b..a9e15b17 100644 --- a/srcjs/utils.js +++ b/srcjs/utils.js @@ -15,4 +15,40 @@ function getTextFromFeature(feature, property, template) { return feature.properties[property]; } -export { getTextFromFeature }; +// Use build-in tooltip of Deck.GL +function getDeckTooltip(template) { + const style = { + background: "white", + color: "black", + "border-radius": "3px", + }; + return ({ layer, object }) => { + if (object) { + const template_ = + typeof template === "object" ? template[layer.id] : template; + return ( + template_ && { html: mustache.render(template_, object), style: style } + ); + } + + return null; + }; +} + +// Use MapLibre Popup as tooltip for Deck.GL layers +function getDeckMapLibrePopupTooltip(map, tooltip) { + const popup = new maplibregl.Popup({ + closeOnClick: false, + closeButton: false, + }); + map.on("mouseout", (e) => popup.remove()); + return ({ coordinate, object }) => { + if (object) { + // console.log(tooltip); + popup.setHTML(mustache.render(tooltip, object)).setLngLat(coordinate); + popup.addTo(map); + } else popup.remove(); + }; +} + +export { getTextFromFeature, getDeckTooltip, getDeckMapLibrePopupTooltip };