mapboxgl-tools 0.0.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.html CHANGED
@@ -5,8 +5,61 @@
5
5
  <link rel="icon" type="image/svg+xml" href="favicon.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Vite App</title>
8
- <link href="https://api.mapbox.com/mapbox-gl-js/v3.1.2/mapbox-gl.css" rel="stylesheet">
9
- <script src="https://api.mapbox.com/mapbox-gl-js/v3.1.2/mapbox-gl.js"></script>
8
+ <style>
9
+ .mapboxgl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0 0 0/0)}.mapboxgl-canvas{left:0;position:absolute;top:0}.mapboxgl-map:-webkit-full-screen{height:100%;width:100%}.mapboxgl-canary{background-color:salmon}.mapboxgl-canvas-container.mapboxgl-interactive,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass{cursor:grab;-webkit-user-select:none;user-select:none}.mapboxgl-canvas-container.mapboxgl-interactive.mapboxgl-track-pointer{cursor:pointer}.mapboxgl-canvas-container.mapboxgl-interactive:active,.mapboxgl-ctrl-group button.mapboxgl-ctrl-compass:active{cursor:grabbing}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate .mapboxgl-canvas{touch-action:pan-x pan-y}.mapboxgl-canvas-container.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:pinch-zoom}.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan,.mapboxgl-canvas-container.mapboxgl-touch-zoom-rotate.mapboxgl-touch-drag-pan .mapboxgl-canvas{touch-action:none}.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-bottom-right,.mapboxgl-ctrl-top-left,.mapboxgl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.mapboxgl-ctrl-top-left{left:0;top:0}.mapboxgl-ctrl-top-right{right:0;top:0}.mapboxgl-ctrl-bottom-left{bottom:0;left:0}.mapboxgl-ctrl-bottom-right{bottom:0;right:0}.mapboxgl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.mapboxgl-ctrl-top-left .mapboxgl-ctrl{float:left;margin:10px 0 0 10px}.mapboxgl-ctrl-top-right .mapboxgl-ctrl{float:right;margin:10px 10px 0 0}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl{float:left;margin:0 0 10px 10px}.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl{float:right;margin:0 10px 10px 0}.mapboxgl-ctrl-group{background:#fff;border-radius:4px}.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (-ms-high-contrast:active){.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.mapboxgl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;overflow:hidden;padding:0;width:29px}.mapboxgl-ctrl-group button+button{border-top:1px solid #ddd}.mapboxgl-ctrl button .mapboxgl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (-ms-high-contrast:active){.mapboxgl-ctrl-icon{background-color:transparent}.mapboxgl-ctrl-group button+button{border-top:1px solid ButtonText}}.mapboxgl-ctrl-attrib-button:focus,.mapboxgl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.mapboxgl-ctrl button:disabled{cursor:not-allowed}.mapboxgl-ctrl button:disabled .mapboxgl-ctrl-icon{opacity:.25}.mapboxgl-ctrl-group button:first-child{border-radius:4px 4px 0 0}.mapboxgl-ctrl-group button:last-child{border-radius:0 0 4px 4px}.mapboxgl-ctrl-group button:only-child{border-radius:inherit}.mapboxgl-ctrl button:not(:disabled):hover{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.mapboxgl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-out .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M10 13c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h9c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-9z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-zoom-in .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M14.5 8.5c-.75 0-1.5.75-1.5 1.5v3h-3c-.75 0-1.5.75-1.5 1.5S9.25 16 10 16h3v3c0 .75.75 1.5 1.5 1.5S16 19.75 16 19v-3h3c.75 0 1.5-.75 1.5-1.5S19.75 13 19 13h-3v-3c0-.75-.75-1.5-1.5-1.5z'/%3E%3C/svg%3E")}}.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-fullscreen .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-shrink .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z'/%3E%3C/svg%3E")}}.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E")}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23999'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' viewBox='0 0 29 29'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath id='south' d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E")}}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23aaa'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-waiting .mapboxgl-ctrl-icon{animation:mapboxgl-spin 2s linear infinite}@media (-ms-high-contrast:active){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23fff'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23999'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-active-error .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e58978'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%2333b5e5'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate.mapboxgl-ctrl-geolocate-background-error .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23e54e33'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2' display='none'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23000'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' display='none'/%3E%3C/svg%3E")}.mapboxgl-ctrl button.mapboxgl-ctrl-geolocate:disabled .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill='%23666'%3E%3Cpath d='M10 4C9 4 9 5 9 5v.1A5 5 0 0 0 5.1 9H5s-1 0-1 1 1 1 1 1h.1A5 5 0 0 0 9 14.9v.1s0 1 1 1 1-1 1-1v-.1a5 5 0 0 0 3.9-3.9h.1s1 0 1-1-1-1-1-1h-.1A5 5 0 0 0 11 5.1V5s0-1-1-1zm0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7z'/%3E%3Ccircle id='dot' cx='10' cy='10' r='2'/%3E%3Cpath id='stroke' d='M14 5l1 1-9 9-1-1 9-9z' fill='%23f00'/%3E%3C/svg%3E")}}@keyframes mapboxgl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.mapboxgl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='0.3' stroke='%23000' stroke-width='3'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='0.9' fill='%23fff'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E");background-repeat:no-repeat;cursor:pointer;display:block;height:23px;margin:0 0 -4px -4px;overflow:hidden;width:88px}a.mapboxgl-ctrl-logo.mapboxgl-compact{width:23px}@media (-ms-high-contrast:active){a.mapboxgl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='1' stroke='%23000' stroke-width='3'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='1' fill='%23fff'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E")}}@media (-ms-high-contrast:black-on-white){a.mapboxgl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' fill-rule='evenodd' viewBox='0 0 88 23'%3E%3Cdefs%3E%3Cpath id='logo' d='M11.5 2.25c5.105 0 9.25 4.145 9.25 9.25s-4.145 9.25-9.25 9.25-9.25-4.145-9.25-9.25 4.145-9.25 9.25-9.25zM6.997 15.983c-.051-.338-.828-5.802 2.233-8.873a4.395 4.395 0 013.13-1.28c1.27 0 2.49.51 3.39 1.42.91.9 1.42 2.12 1.42 3.39 0 1.18-.449 2.301-1.28 3.13C12.72 16.93 7 16 7 16l-.003-.017zM15.3 10.5l-2 .8-.8 2-.8-2-2-.8 2-.8.8-2 .8 2 2 .8z'/%3E%3Cpath id='text' d='M50.63 8c.13 0 .23.1.23.23V9c.7-.76 1.7-1.18 2.73-1.18 2.17 0 3.95 1.85 3.95 4.17s-1.77 4.19-3.94 4.19c-1.04 0-2.03-.43-2.74-1.18v3.77c0 .13-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V8.23c0-.12.1-.23.23-.23h1.4zm-3.86.01c.01 0 .01 0 .01-.01.13 0 .22.1.22.22v7.55c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V15c-.7.76-1.69 1.19-2.73 1.19-2.17 0-3.94-1.87-3.94-4.19 0-2.32 1.77-4.19 3.94-4.19 1.03 0 2.02.43 2.73 1.18v-.75c0-.12.1-.23.23-.23h1.4zm26.375-.19a4.24 4.24 0 00-4.16 3.29c-.13.59-.13 1.19 0 1.77a4.233 4.233 0 004.17 3.3c2.35 0 4.26-1.87 4.26-4.19 0-2.32-1.9-4.17-4.27-4.17zM60.63 5c.13 0 .23.1.23.23v3.76c.7-.76 1.7-1.18 2.73-1.18 1.88 0 3.45 1.4 3.84 3.28.13.59.13 1.2 0 1.8-.39 1.88-1.96 3.29-3.84 3.29-1.03 0-2.02-.43-2.73-1.18v.77c0 .12-.1.23-.23.23h-1.4c-.13 0-.23-.1-.23-.23V5.23c0-.12.1-.23.23-.23h1.4zm-34 11h-1.4c-.13 0-.23-.11-.23-.23V8.22c.01-.13.1-.22.23-.22h1.4c.13 0 .22.11.23.22v.68c.5-.68 1.3-1.09 2.16-1.1h.03c1.09 0 2.09.6 2.6 1.55.45-.95 1.4-1.55 2.44-1.56 1.62 0 2.93 1.25 2.9 2.78l.03 5.2c0 .13-.1.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.8 0-1.46.7-1.59 1.62l.01 4.68c0 .13-.11.23-.23.23h-1.41c-.13 0-.23-.11-.23-.23v-4.59c0-.98-.74-1.71-1.62-1.71-.85 0-1.54.79-1.6 1.8v4.5c0 .13-.1.23-.23.23zm53.615 0h-1.61c-.04 0-.08-.01-.12-.03-.09-.06-.13-.19-.06-.28l2.43-3.71-2.39-3.65a.213.213 0 01-.03-.12c0-.12.09-.21.21-.21h1.61c.13 0 .24.06.3.17l1.41 2.37 1.4-2.37a.34.34 0 01.3-.17h1.6c.04 0 .08.01.12.03.09.06.13.19.06.28l-2.37 3.65 2.43 3.7c0 .05.01.09.01.13 0 .12-.09.21-.21.21h-1.61c-.13 0-.24-.06-.3-.17l-1.44-2.42-1.44 2.42a.34.34 0 01-.3.17zm-7.12-1.49c-1.33 0-2.42-1.12-2.42-2.51 0-1.39 1.08-2.52 2.42-2.52 1.33 0 2.42 1.12 2.42 2.51 0 1.39-1.08 2.51-2.42 2.52zm-19.865 0c-1.32 0-2.39-1.11-2.42-2.48v-.07c.02-1.38 1.09-2.49 2.4-2.49 1.32 0 2.41 1.12 2.41 2.51 0 1.39-1.07 2.52-2.39 2.53zm-8.11-2.48c-.01 1.37-1.09 2.47-2.41 2.47s-2.42-1.12-2.42-2.51c0-1.39 1.08-2.52 2.4-2.52 1.33 0 2.39 1.11 2.41 2.48l.02.08zm18.12 2.47c-1.32 0-2.39-1.11-2.41-2.48v-.06c.02-1.38 1.09-2.48 2.41-2.48s2.42 1.12 2.42 2.51c0 1.39-1.09 2.51-2.42 2.51z'/%3E%3C/defs%3E%3Cmask id='clip'%3E%3Crect x='0' y='0' width='100%25' height='100%25' fill='white'/%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/mask%3E%3Cg id='outline' opacity='1' stroke='%23fff' stroke-width='3' fill='%23fff'%3E%3Ccircle mask='url(%23clip)' cx='11.5' cy='11.5' r='9.25'/%3E%3Cuse xlink:href='%23text' mask='url(%23clip)'/%3E%3C/g%3E%3Cg id='fill' opacity='1' fill='%23000'%3E%3Cuse xlink:href='%23logo'/%3E%3Cuse xlink:href='%23text'/%3E%3C/g%3E%3C/svg%3E")}}.mapboxgl-ctrl.mapboxgl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.mapboxgl-ctrl-attrib.mapboxgl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.mapboxgl-ctrl-attrib.mapboxgl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show,.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-inner{display:none}.mapboxgl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E");border:0;border-radius:12px;box-sizing:border-box;cursor:pointer;display:none;height:24px;outline:none;position:absolute;right:0;top:0;width:24px}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-top-left .mapboxgl-ctrl-attrib-button{left:0}.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-button,.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-inner{display:block}.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-button{background-color:rgb(0 0 0/5%)}.mapboxgl-ctrl-bottom-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;right:0}.mapboxgl-ctrl-top-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{right:0;top:0}.mapboxgl-ctrl-top-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{left:0;top:0}.mapboxgl-ctrl-bottom-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;left:0}}@media screen and (-ms-high-contrast:active){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd' fill='%23fff'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}@media screen and (-ms-high-contrast:black-on-white){.mapboxgl-ctrl-attrib.mapboxgl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg' fill-rule='evenodd'%3E%3Cpath d='M4 10a6 6 0 1 0 12 0 6 6 0 1 0-12 0m5-3a1 1 0 1 0 2 0 1 1 0 1 0-2 0m0 3a1 1 0 1 1 2 0v3a1 1 0 1 1-2 0'/%3E%3C/svg%3E")}}.mapboxgl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.mapboxgl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.mapboxgl-ctrl-attrib .mapbox-improve-map{font-weight:700;margin-left:2px}.mapboxgl-attrib-empty{display:none}.mapboxgl-ctrl-scale{background-color:hsla(0,0%,100%,.75);border:2px solid #333;border-top:#333;box-sizing:border-box;color:#333;font-size:10px;padding:0 5px;white-space:nowrap}.mapboxgl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.mapboxgl-popup-anchor-top,.mapboxgl-popup-anchor-top-left,.mapboxgl-popup-anchor-top-right{flex-direction:column}.mapboxgl-popup-anchor-bottom,.mapboxgl-popup-anchor-bottom-left,.mapboxgl-popup-anchor-bottom-right{flex-direction:column-reverse}.mapboxgl-popup-anchor-left{flex-direction:row}.mapboxgl-popup-anchor-right{flex-direction:row-reverse}.mapboxgl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.mapboxgl-popup-anchor-top .mapboxgl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.mapboxgl-popup-anchor-left .mapboxgl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.mapboxgl-popup-anchor-right .mapboxgl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.mapboxgl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.mapboxgl-popup-close-button:hover{background-color:rgb(0 0 0/5%)}.mapboxgl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:10px 10px 15px;pointer-events:auto;position:relative}.mapboxgl-popup-anchor-top-left .mapboxgl-popup-content{border-top-left-radius:0}.mapboxgl-popup-anchor-top-right .mapboxgl-popup-content{border-top-right-radius:0}.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-content{border-bottom-left-radius:0}.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-content{border-bottom-right-radius:0}.mapboxgl-popup-track-pointer{display:none}.mapboxgl-popup-track-pointer *{pointer-events:none;user-select:none}.mapboxgl-map:hover .mapboxgl-popup-track-pointer{display:flex}.mapboxgl-map:active .mapboxgl-popup-track-pointer{display:none}.mapboxgl-marker{left:0;opacity:1;position:absolute;top:0;transition:opacity .2s;will-change:transform}.mapboxgl-user-location-dot,.mapboxgl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.mapboxgl-user-location-dot:before{animation:mapboxgl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.mapboxgl-user-location-dot:after{border:2px solid #fff;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,.35);box-sizing:border-box;content:"";height:19px;left:-2px;position:absolute;top:-2px;width:19px}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading{height:0;width:0}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after,.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{border-bottom:7.5px solid #4aa1eb;content:"";position:absolute}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:before{border-left:7.5px solid transparent;transform:translateY(-28px) skewY(-20deg)}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after{border-right:7.5px solid transparent;transform:translate(7.5px,-28px) skewY(20deg)}@keyframes mapboxgl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.mapboxgl-user-location-dot-stale{background-color:#aaa}.mapboxgl-user-location-dot-stale:after{display:none}.mapboxgl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.mapboxgl-crosshair,.mapboxgl-crosshair .mapboxgl-interactive,.mapboxgl-crosshair .mapboxgl-interactive:active{cursor:crosshair}.mapboxgl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}@media print{.mapbox-improve-map{display:none}}.mapboxgl-scroll-zoom-blocker,.mapboxgl-touch-pan-blocker{align-items:center;background:rgba(0,0,0,.7);color:#fff;display:flex;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;height:100%;justify-content:center;left:0;opacity:0;pointer-events:none;position:absolute;text-align:center;top:0;transition:opacity .75s ease-in-out;transition-delay:1s;width:100%}.mapboxgl-scroll-zoom-blocker-show,.mapboxgl-touch-pan-blocker-show{opacity:1;transition:opacity .1s ease-in-out}.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page,.mapboxgl-canvas-container.mapboxgl-touch-pan-blocker-override.mapboxgl-scrollable-page .mapboxgl-canvas{touch-action:pan-x pan-y}
10
+ </style>
11
+ <script>
12
+ /* Mapbox GL JS is Copyright © 2020 Mapbox and subject to the Mapbox Terms of Service ((https://www.mapbox.com/legal/tos/). */
13
+ (function (global, factory) {
14
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
15
+ typeof define === 'function' && define.amd ? define(factory) :
16
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.mapboxgl = factory());
17
+ })(this, (function () { 'use strict';
18
+
19
+ /* eslint-disable */
20
+
21
+ var shared, worker, mapboxgl;
22
+ // define gets called three times: one for each chunk. we rely on the order
23
+ // they're imported to know which is which
24
+ function define(_, chunk) {
25
+ if (!shared) {
26
+ shared = chunk;
27
+ } else if (!worker) {
28
+ worker = chunk;
29
+ } else {
30
+ var workerBundleString = "self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; (" + shared + ")(sharedChunk); (" + worker + ")(sharedChunk); self.onerror = null;"
31
+
32
+ var sharedChunk = {};
33
+ shared(sharedChunk);
34
+ mapboxgl = chunk(sharedChunk);
35
+ if (typeof window !== 'undefined' && window && window.URL && window.URL.createObjectURL) {
36
+ mapboxgl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }));
37
+ }
38
+ }
39
+ }
40
+
41
+
42
+ define(["exports"],(function(e){"use strict";var t="undefined"!=typeof self?self:{},i="3.1.2";let r;const n={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==r){const e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{r=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):e;}catch(t){r=e;}}return r},get API_TILEJSON_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return /^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return /^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!n.API_URL)return null;try{const e=new URL(n.API_URL);return "api.mapbox.cn"===e.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===e.hostname?"https://events.mapbox.com/events/v2":null}catch(e){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:"mapbox://styles/mapbox/standard",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},o={supported:!1,testSupport:function(e){!l&&a&&(c?h(e):s=e);}};let s,a,l=!1,c=!1;function h(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,a),e.isContextLost())return;o.supported=!0;}catch(e){}e.deleteTexture(t),l=!0;}t.document&&(a=t.document.createElement("img"),a.onload=function(){s&&h(s),s=null,c=!0;},a.onerror=function(){l=!0,s=null;},a.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const u="01";function d(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var p=f;function f(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=r;}f.prototype={sampleCurveX:function(e){return ((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return ((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return (3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)<t)return i;var o=this.sampleCurveDerivativeX(i);if(Math.abs(o)<1e-6)break;i-=n/o;}var s=0,a=1;for(i=e,r=0;r<20&&(n=this.sampleCurveX(i),!(Math.abs(n-e)<t));r++)e>n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}};var m=d(p),_=g;function g(e,t){this.x=e,this.y=t;}g.prototype={clone:function(){return new g(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),i=Math.sin(e),r=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=r,this},_rotateAround:function(e,t){var i=Math.cos(e),r=Math.sin(e),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-r*(this.y-t.y),this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},g.convert=function(e){return e instanceof g?e:Array.isArray(e)?new g(e[0],e[1]):e};var y=d(_);function x(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return !1;for(let i=0;i<e.length;i++)if(!x(e[i],t[i]))return !1;return !0}if("object"==typeof e&&null!==e&&null!==t){if("object"!=typeof t)return !1;if(Object.keys(e).length!==Object.keys(t).length)return !1;for(const i in e)if(!x(e[i],t[i]))return !1;return !0}return e===t}const v=Math.PI/180,b=180/Math.PI;function w(e){return e*v}function T(e){return e*b}const E=[[0,0],[1,0],[1,1],[0,1]];function M(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function A(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);return {min:new y(t,i),max:new y(r,n)}}function S(e,t,i=0,r=!0){const n=new y(i,i),o=e.sub(n),s=t.add(n),a=[o,new y(s.x,o.y),s,new y(o.x,s.y)];return r&&a.push(o.clone()),a}function I(e,t,i,r){const n=new m(e,t,i,r);return function(e){return n.solve(e)}}const C=I(.25,.1,.25,1);function z(e,t,i){return Math.min(i,Math.max(t,e))}function P(e,t,i){return (i=z((i-e)/(t-e),0,1))*i*(3-2*i)}function D(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function R(e,t,i){if(!e.length)return i(null,[]);let r=e.length;const n=new Array(e.length);let o=null;e.forEach(((e,s)=>{t(e,((e,t)=>{e&&(o=e),n[s]=t,0==--r&&i(o,n);}));}));}function L(e){const t=[];for(const i in e)t.push(e[i]);return t}function k(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function O(e,t){const i={};for(let r=0;r<t.length;r++){const n=t[r];n in e&&(i[n]=e[n]);}return i}let B=1;function F(){return B++}function N(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function U(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function V(e){return !!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function j(e,t){e.forEach((e=>{t[e]&&(t[e]=t[e].bind(t));}));}function G(e,t){return -1!==e.indexOf(t,e.length-t.length)}function q(e,t,i){const r={};for(const n in e)r[n]=t.call(i||this,e[n],n,e);return r}function Z(e,t,i){const r={};for(const n in e)t.call(i||this,e[n],n,e)&&(r[n]=e[n]);return r}function $(e){return Array.isArray(e)?e.map($):"object"==typeof e&&e?q(e,$):e}const W={};function H(e){W[e]||("undefined"!=typeof console&&console.warn(e),W[e]=!0);}function X(e,t,i){return (i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function Y(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n<o;s=n++)i=e[n],r=e[s],t+=(r.x-i.x)*(i.y+r.y);return t}function K([e,t,i]){const r=w(t+90),n=w(i);return {x:e*Math.cos(r)*Math.sin(n),y:e*Math.sin(r)*Math.sin(n),z:e*Math.cos(n),azimuthal:t,polar:i}}function J(e,t,i){const r=Math.sqrt(e*e+t*t+i*i),n=r>0?Math.acos(i/r)*b:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*b+90:0;return o<0&&(o+=360),[r,o,n]}function Q(){return "undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function ee(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((e,i,r,n)=>{const o=r||n;return t[i]=!o||o.toLowerCase(),""})),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e;}return t}let te=null;function ie(){return !!t.document.fullscreenElement||!!t.document.webkitFullscreenElement}function re(e){try{const i=t[e];return i.setItem("_mapbox_test_",1),i.removeItem("_mapbox_test_"),!0}catch(e){return !1}}function ne(e,t){return [e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function oe(e,t,i){e[4*t+0]=i[0],e[4*t+1]=i[1],e[4*t+2]=i[2],e[4*t+3]=i[3];}function se(e,t){return [Math.pow(e[0],2.2)*t,Math.pow(e[1],2.2)*t,Math.pow(e[2],2.2)*t]}function ae(e){return [Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]}const le="mapbox-tiles";let ce=500,he=50;let ue,de;function pe(){try{return t.caches}catch(e){}}function fe(){pe()&&!ue&&(ue=t.caches.open(le));}function me(e){const t=e.indexOf("?");if(t<0)return e;const i=function(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}(e),r=i.filter((e=>{const t=e.split("=");return "language"===t[0]||"worldview"===t[0]}));return r.length?`${e.slice(0,t)}?${r.join("&")}`:e.slice(0,t)}let _e=1/0;function ge(e){_e++,_e>he&&(e.getActor().send("enforceCacheSizeLimit",ce),_e=0);}const ye={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(ye);class xe extends Error{constructor(e,t,i){401===t&&De(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i;}toString(){return `${this.name}: ${this.message} (${this.status}): ${this.url}`}}const ve=Q()?()=>self.worker&&self.worker.referrer:()=>("blob:"===t.location.protocol?t.parent:t).location.href;const be=function(e,i){if(!(/^file:/.test(r=e.url)||/^file:/.test(ve())&&!/^\w+:/.test(r))){if(t.fetch&&t.Request&&t.AbortController&&t.Request.prototype.hasOwnProperty("signal"))return function(e,i){const r=new t.AbortController,n=new t.Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:ve(),referrerPolicy:e.referrerPolicy,signal:r.signal});let o=!1,s=!1;const a=(l=n.url).indexOf("sku=")>0&&De(l);var l;"json"===e.type&&n.headers.set("Accept","application/json");const c=(r,o,l)=>{if(s)return;if(r&&"SecurityError"!==r.message&&H(r.toString()),o&&l)return h(o);const c=Date.now();t.fetch(n).then((t=>{if(t.ok){const e=a?t.clone():null;return h(t,e,c)}return i(new xe(t.statusText,t.status,e.url))})).catch((t=>{"AbortError"!==t.name&&i(new Error(`${t.message} ${e.url}`));}));},h=(r,a,l)=>{("arrayBuffer"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text()).then((e=>{s||(a&&l&&function(e,i,r){if(fe(),!ue)return;const n={status:i.status,statusText:i.statusText,headers:new t.Headers};i.headers.forEach(((e,t)=>n.headers.set(t,e)));const o=ee(i.headers.get("Cache-Control")||"");if(o["no-store"])return;o["max-age"]&&n.headers.set("Expires",new Date(r+1e3*o["max-age"]).toUTCString());const s=n.headers.get("Expires");s&&(new Date(s).getTime()-r<42e4||function(e,t){if(void 0===de)try{new Response(new ReadableStream),de=!0;}catch(e){de=!1;}de?t(e.body):e.blob().then(t);}(i,(i=>{const r=new t.Response(i,n);fe(),ue&&ue.then((t=>t.put(me(e.url),r))).catch((e=>H(e.message)));})));}(n,a,l),o=!0,i(null,e,r.headers.get("Cache-Control"),r.headers.get("Expires")));})).catch((e=>{s||i(new Error(e.message));}));};return a?function(e,t){if(fe(),!ue)return t(null);const i=me(e.url);ue.then((e=>{e.match(i).then((r=>{const n=function(e){if(!e)return !1;const t=new Date(e.headers.get("Expires")||0),i=ee(e.headers.get("Cache-Control")||"");return t>Date.now()&&!i["no-cache"]}(r);e.delete(i),n&&e.put(i,r.clone()),t(null,r,n);})).catch(t);})).catch(t);}(n,c):c(null,null),{cancel:()=>{s=!0,o||r.abort();}}}(e,i);if(Q()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,i,void 0,!0)}var r;return function(e,i){const r=new t.XMLHttpRequest;r.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(r.responseType="arraybuffer");for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);return "json"===e.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===e.credentials,r.onerror=()=>{i(new Error(r.statusText));},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let t=r.response;if("json"===e.type)try{t=JSON.parse(r.response);}catch(e){return i(e)}i(null,t,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"));}else i(new xe(r.statusText,r.status,e.url));},r.send(e.body),{cancel:()=>r.abort()}}(e,i)},we=function(e,t){return be(k(e,{type:"json"}),t)},Te=function(e,t){return be(k(e,{type:"arrayBuffer"}),t)};function Ee(e){const i=t.document.createElement("a");return i.href=e,i.protocol===t.document.location.protocol&&i.host===t.document.location.host}const Me="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let Ae,Se;Ae=[],Se=0;const Ie=function(e,i){if(o.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Se>=n.MAX_PARALLEL_IMAGE_REQUESTS){const t={requestParameters:e,callback:i,cancelled:!1,cancel(){this.cancelled=!0;}};return Ae.push(t),t}Se++;let r=!1;const s=()=>{if(!r)for(r=!0,Se--;Ae.length&&Se<n.MAX_PARALLEL_IMAGE_REQUESTS;){const e=Ae.shift(),{requestParameters:t,callback:i,cancelled:r}=e;r||(e.cancel=Ie(t,i).cancel);}},a=Te(e,((e,r,n,o)=>{s(),e?i(e):r&&(t.createImageBitmap?function(e,i){const r=new t.Blob([new Uint8Array(e)],{type:"image/png"});t.createImageBitmap(r).then((e=>{i(null,e);})).catch((e=>{i(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));}));}(r,((e,t)=>i(e,t,n,o))):function(e,i){const r=new t.Image,n=t.URL;r.onload=()=>{i(null,r),n.revokeObjectURL(r.src),r.onload=null,t.requestAnimationFrame((()=>{r.src=Me;}));},r.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const o=new t.Blob([new Uint8Array(e)],{type:"image/png"});r.src=e.byteLength?n.createObjectURL(o):Me;}(r,((e,t)=>i(e,t,n,o))));}));return {cancel:()=>{a.cancel(),s();}}},Ce="NO_ACCESS_TOKEN";class ze{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken();}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return {token:["1",u,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt;}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!Pe(e))return e;const r=Be(e);return r.params.push(`sdk=js-${i}`),r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!Pe(e))return e;const i=Be(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeModelURL(e,t){if(!Pe(e))return e;const i=Be(e);return i.path=`/models/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t,i,r){if(!Pe(e))return e;const n=Be(e);return n.path=`/v4/${n.authority}.json`,n.params.push("secure"),i&&n.params.push(`language=${i}`),r&&n.params.push(`worldview=${r}`),this._makeAPIURL(n,this._customAccessToken||t)}normalizeSpriteURL(e,t,i,r){const n=Be(e);return Pe(e)?(n.path=`/styles/v1${n.path}/sprite${t}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${t}${i}`,Fe(n))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!Pe(e))return e;const r=Be(e);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||i&&"raster"!==r.authority&&512===i?"@2x":""}${o.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${n.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${n.TILE_URL_VERSION}${r.path}`);const s=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,s)}canonicalizeTileURL(e,t){const i=Be(e);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let r="mapbox://";i.path.match(/^\/raster\/v1\//)?r+=`raster/${i.path.replace(`/${n.RASTER_URL_PREFIX}/`,"")}`:r+=`tiles/${i.path.replace(`/${n.TILE_URL_VERSION}/`,"")}`;let o=i.params;return t&&(o=o.filter((e=>!e.match(/^access_token=/)))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(e,t){const i=!!t&&Pe(t),r=[];for(const t of e.tiles||[])De(t)?r.push(this.canonicalizeTileURL(t,i)):r.push(t);return r}_makeAPIURL(e,t){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=Be(n.API_URL);if(e.protocol=r.protocol,e.authority=r.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1);}if("/"!==r.path&&(e.path=`${r.path}${e.path}`),!n.REQUIRE_ACCESS_TOKEN)return Fe(e);if(t=t||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter((e=>-1===e.indexOf("access_token"))),e.params.push(`access_token=${t||""}`),Fe(e)}}function Pe(e){return 0===e.indexOf("mapbox:")}function De(e){return n.API_URL_REGEX.test(e)}function Re(e){return n.API_CDN_URL_REGEX.test(e)}function Le(e){return n.API_STYLE_REGEX.test(e)&&!ke(e)}function ke(e){return n.API_SPRITE_REGEX.test(e)}const Oe=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Be(e){const t=e.match(Oe);if(!t)throw new Error("Unable to parse URL object");return {protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function Fe(e){const t=e.params.length?`?${e.params.join("&")}`:"";return `${e.protocol}://${e.authority}${e.path}${t}`}const Ne="mapbox.eventData";function Ue(e){if(!e)return null;const i=e.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(decodeURIComponent(t.atob(i[1]).split("").map((e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(e){return null}}class Ve{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null;}getStorageKey(e){const i=Ue(n.ACCESS_TOKEN);let r="";return r=i&&i.u?t.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(Number("0x"+t))))):n.ACCESS_TOKEN||"",e?`${Ne}.${e}:${r}`:`${Ne}:${r}`}fetchEventData(){const e=re("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{const e=t.localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const n=t.localStorage.getItem(r);n&&(this.anonId=n);}catch(e){H("Unable to read from LocalStorage");}}saveEventData(){const e=re("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{t.localStorage.setItem(r,this.anonId),Object.keys(this.eventData).length>=1&&t.localStorage.setItem(i,JSON.stringify(this.eventData));}catch(e){H("Unable to write to LocalStorage");}}processRequests(e){}postEvent(e,t,i,r){if(!n.EVENTS_URL)return;const o=Be(n.EVENTS_URL);o.params.push(`access_token=${r||n.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(e).toISOString()},a=t?k(s,t):s,l={url:Fe(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=function(e,t){return be(k(e,{method:"POST"}),t)}(l,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r);}));}queueRequest(e,t){this.queue.push(e),this.processRequests(t);}}const je=new class extends Ve{constructor(e){super("appUserTurnstile"),this._customAccessToken=e;}postTurnstileEvent(e,t){n.EVENTS_URL&&n.ACCESS_TOKEN&&Array.isArray(e)&&e.some((e=>Pe(e)||De(e)))&&this.queueRequest(Date.now(),t);}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Ue(n.ACCESS_TOKEN),r=t?t.u:n.ACCESS_TOKEN;let o=r!==this.eventData.tokenU;V(this.anonId)||(this.anonId=N(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(s),i=(s-this.eventData.lastSuccess)/864e5;o=o||i>=1||i<-1||e.getDate()!==t.getDate();}else o=!0;o?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:i,skuId:u,"enabled.telemetry":!1,userId:this.anonId},(e=>{e||(this.eventData.lastSuccess=s,this.eventData.tokenU=r);}),e):this.processRequests();}},Ge=je.postTurnstileEvent.bind(je),qe=new class extends Ve{constructor(){super("map.load"),this.success={},this.skuToken="";}postMapLoadEvent(e,t,i,r){this.skuToken=t,this.errorCb=r,n.EVENTS_URL&&(i||n.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Ce)));}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:r}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),V(this.anonId)||(this.anonId=N()),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:i,skuId:u,skuToken:this.skuToken,userId:this.anonId},(e=>{e?this.errorCb(e):t&&(this.success[t]=!0);}),e));}},Ze=qe.postMapLoadEvent.bind(qe),$e=new class extends Ve{constructor(){super("gljs.performance");}postPerformanceEvent(e,t){n.EVENTS_URL&&(e||n.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e);}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:r,performanceData:n}=this.queue.shift(),o=function(e){const r=t.performance.getEntriesByType("resource"),n=t.performance.getEntriesByType("mark"),o=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const r of e[i]){const e=`${i}ResolveRangeMin`,n=`${i}ResolveRangeMax`,o=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,r.startTime),t[n]=Math.max(t[n]||-1/0,r.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e];};void 0!==r.transferSize&&0===r.transferSize&&a(s),a(o);}return t}(function(e,t){const i={};if(e)for(const r of e){const e=t(r);void 0===i[e]&&(i[e]=[]),i[e].push(r);}return i}(r,et)),s=t.devicePixelRatio,a=t.navigator.connection||t.navigator.mozConnection||t.navigator.webkitConnection,l={counters:[],metadata:[],attributes:[]},c=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()});};for(const e in o)c(l.counters,e,o[e]);if(e.interactionRange[0]!==1/0&&e.interactionRange[1]!==-1/0&&(c(l.counters,"interactionRangeMin",e.interactionRange[0]),c(l.counters,"interactionRangeMax",e.interactionRange[1])),n)for(const e of Object.keys(Je)){const t=Je[e],i=n.find((e=>e.name===t));i&&c(l.counters,t,i.startTime);}return c(l.counters,"visibilityHidden",e.visibilityHidden),c(l.attributes,"style",function(e){if(e)for(const t of e){const e=t.name.split("?")[0];if(Le(e)){const t=e.split("/").slice(-2);if(2===t.length)return `mapbox://styles/${t[0]}/${t[1]}`}}}(r)),c(l.attributes,"terrainEnabled",e.terrainEnabled?"true":"false"),c(l.attributes,"fogEnabled",e.fogEnabled?"true":"false"),c(l.attributes,"projection",e.projection),c(l.attributes,"zoom",e.zoom),c(l.metadata,"devicePixelRatio",s),c(l.metadata,"connectionEffectiveType",a?a.effectiveType:void 0),c(l.metadata,"navigatorUserAgent",t.navigator.userAgent),c(l.metadata,"screenWidth",t.screen.width),c(l.metadata,"screenHeight",t.screen.height),c(l.metadata,"windowWidth",t.innerWidth),c(l.metadata,"windowHeight",t.innerHeight),c(l.metadata,"mapWidth",e.width/s),c(l.metadata,"mapHeight",e.height/s),c(l.metadata,"webglRenderer",e.renderer),c(l.metadata,"webglVendor",e.vendor),c(l.metadata,"sdkVersion",i),c(l.metadata,"sdkIdentifier","mapbox-gl-js"),l}(n);for(const e of o.metadata);for(const e of o.counters);for(const e of o.attributes);this.postEvent(r,o,(()=>{}),e);}},We=$e.postPerformanceEvent.bind($e),He=new class extends Ve{constructor(){super("map.auth"),this.success={},this.skuToken="";}getSession(e,t,i,r){if(!n.API_URL||!n.SESSION_PATH)return;const o=Be(n.API_URL+n.SESSION_PATH);o.params.push(`sku=${t||""}`),o.params.push(`access_token=${r||n.ACCESS_TOKEN||""}`);const s={url:Fe(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(e,t){return be(k(e,{method:"GET"}),t)}(s,(e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r);}));}getSessionAPI(e,t,i,r){this.skuToken=t,this.errorCb=r,n.SESSION_PATH&&n.API_URL&&(i||n.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Ce)));}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,(e=>{e?this.errorCb(e):t&&(this.success[t]=!0);}),e);}},Xe=He.getSessionAPI.bind(He),Ye=new Set;function Ke(e,t){t?Ye.add(e):Ye.delete(e);}const Je={create:"create",load:"load",fullLoad:"fullLoad"},Qe={mark(e){t.performance.mark(e);},measure(e,i,r){t.performance.measure(e,i,r);}};function et(e){const t=e.name.split("?")[0];return Re(t)&&t.includes("mapbox-gl.js")?"javascript":Re(t)&&t.includes("mapbox-gl.css")?"css":function(e){return n.API_FONTS_REGEX.test(e)}(t)?"fontRange":ke(t)?"sprite":Le(t)?"style":function(e){return n.API_TILEJSON_REGEX.test(e)}(t)?"tilejson":"other"}const tt=t.performance;function it(e){const t=e?e.url.toString():void 0;return tt.getEntriesByName(t)}var rt=nt;function nt(e){return !function(e){return "undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return !1;var e,t,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{t=new Worker(r),e=!0;}catch(t){e=!1;}return t&&t.terminate(),URL.revokeObjectURL(r),e}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return !1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===ot[t=e&&e.failIfMajorPerformanceCaveat]&&(ot[t]=function(e){var t,i=function(e){var t=document.createElement("canvas"),i=Object.create(nt.webGLContextAttributes);return i.failIfMajorPerformanceCaveat=e,t.getContext("webgl",i)||t.getContext("experimental-webgl",i)}(e);if(!i)return !1;try{t=i.createShader(i.VERTEX_SHADER);}catch(e){return !1}return !(!t||i.isContextLost())&&(i.shaderSource(t,"void main() {}"),i.compileShader(t),!0===i.getShaderParameter(t,i.COMPILE_STATUS))}(t)),ot[t]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var t;}(e)}var ot={};let st,at,lt,ct,ht;function ut(){return null==st&&(st=t.OffscreenCanvas&&new t.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof t.createImageBitmap),st}nt.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const dt={now:()=>void 0!==ct?ct:t.performance.now(),setNow(e){ct=e;},restoreNow(){ct=void 0;},frame(e){const i=t.requestAnimationFrame(e);return {cancel:()=>t.cancelAnimationFrame(i)}},getImageData(e,i=0){const{width:r,height:n}=e;ht||(ht=t.document.createElement("canvas"));const o=ht.getContext("2d",{willReadFrequently:!0});if(!o)throw new Error("failed to create canvas 2d context");return (r>ht.width||n>ht.height)&&(ht.width=r,ht.height=n),o.clearRect(-i,-i,r+2*i,n+2*i),o.drawImage(e,0,0,r,n),o.getImageData(-i,-i,r+2*i,n+2*i)},resolveURL:e=>(at||(at=t.document.createElement("a")),at.href=e,at.href),get devicePixelRatio(){return t.devicePixelRatio},get prefersReducedMotion(){return !!t.matchMedia&&(null==lt&&(lt=t.matchMedia("(prefers-reduced-motion: reduce)")),lt.matches)},hasCanvasFingerprintNoise(){if(!ut())return !1;const e=new t.OffscreenCanvas(85,1),i=e.getContext("2d",{willReadFrequently:!0});let r=0;for(let t=0;t<e.width;++t)i.fillStyle=`rgba(${r++},${r++},${r++}, 255)`,i.fillRect(t,0,1,1);const n=i.getImageData(0,0,e.width,e.height);r=0;for(let e=0;e<n.data.length;++e)if(e%4!=3&&r++!==n.data[e])return !0;return !1}};function pt(e,i,r){const n=t.document.createElement(e);return void 0!==i&&(n.className=i),r&&r.appendChild(n),n}function ft(e,i,r){const n=t.document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(i))n.setAttributeNS(null,e,i[e]);return r&&r.appendChild(n),n}const mt=t.document&&t.document.documentElement.style,_t=mt&&void 0!==mt.userSelect?"userSelect":"WebkitUserSelect";let gt;function yt(){mt&&_t&&(gt=mt[_t],mt[_t]="none");}function xt(){mt&&_t&&(mt[_t]=gt);}function vt(e){e.preventDefault(),e.stopPropagation(),t.removeEventListener("click",vt,!0);}function bt(){t.addEventListener("click",vt,!0),t.setTimeout((()=>{t.removeEventListener("click",vt,!0);}),0);}function wt(e,t){const i=e.getBoundingClientRect();return Mt(e,i,t)}function Tt(e,t){const i=e.getBoundingClientRect(),r=[];for(let n=0;n<t.length;n++)r.push(Mt(e,i,t[n]));return r}function Et(e){return void 0!==t.InstallTrigger&&2===e.button&&e.ctrlKey&&t.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:e.button}function Mt(e,t,i){const r=e.offsetWidth===t.width?1:e.offsetWidth/t.width;return new y((i.clientX-t.left)*r,(i.clientY-t.top)*r)}function At(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t));}function St(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1);}}class It{constructor(e,t={}){k(this,t),this.type=e;}}class Ct extends It{constructor(e,t={}){super("error",k({error:e},t));}}class zt{on(e,t){return this._listeners=this._listeners||{},At(e,t,this._listeners),this}off(e,t){return St(e,t,this._listeners),St(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},At(e,t,this._oneTimeListeners),this):new Promise((t=>this.once(e,t)))}fire(e,t){"string"==typeof e&&(e=new It(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of r)St(i,t,this._oneTimeListeners),t.call(this,e);const n=this._eventedParent;n&&(k(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(e));}else e instanceof Ct&&console.error(e.error);return this}listens(e){return !!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var Pt=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"fragment":{"type":"boolean"},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360},"pitch":{"type":"number","default":0},"light":{"type":"light"},"lights":{"required":false,"type":"array","value":"light-3d"},"terrain":{"type":"terrain","optional":true},"fog":{"type":"fog"},"camera":{"type":"camera"},"imports":{"type":"array","value":"import"},"schema":{"type":"schema"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string","default":"mapbox://fonts/mapbox/{fontstack}/{range}.pbf"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"},"models":{"type":"models"}},"model":{"type":"string","required":true},"import":{"id":{"type":"string","required":true},"url":{"type":"string","required":true},"config":{"type":"config"},"data":{"type":"$root"}},"config":{"*":{"type":"*"}},"schema":{"*":{"type":"option"}},"option":{"default":{"type":"*","required":true},"type":{"type":"enum","values":{"string":1,"number":1,"boolean":1,"color":1}},"array":{"type":"boolean"},"minValue":{"type":"number"},"maxValue":{"type":"number"},"stepValue":{"type":"number"},"values":{"type":"array","value":"*"},"metadata":{"type":"*"}},"models":{"*":{"type":"model"}},"light-3d":{"id":{"type":"string","required":true},"properties":{"type":"properties"},"type":{"type":"enum","values":{"ambient":{},"directional":{},"flat":{}}}},"properties":["properties_light_directional","properties_light_ambient","properties_light_flat"],"properties_light_directional":{"direction":{"type":"array","default":[210,30],"minimum":[0,0],"maximum":[360,90],"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"cast-shadows":{"type":"boolean","default":false,"expression":{},"property-type":"data-constant"},"shadow-intensity":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_ambient":{"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"properties_light_flat":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_raster_array","source_geojson","source_video","source_image","source_model"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"scheme":{"type":"enum","values":{"xyz":1,"tms":1},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":1,"mapbox":1},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_array":{"type":{"required":true,"type":"enum","values":{"raster-array":1}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512},"attribution":{"type":"string"},"rasterLayers":{"type":"*"},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":1}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":1}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":1}},"url":{"required":false,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_model":{"type":{"required":true,"type":"enum","values":{"model":1,"batched-model":1}},"maxzoom":{"type":"number","default":18},"minzoom":{"type":"number","default":0},"tiles":{"type":"array","value":"string"}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"model":{},"background":{},"sky":{},"slot":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"slot":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky","layout_model"],"layout_background":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_model":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"model-id":{"type":"string","default":"","property-type":"data-driven","expression":{"parameters":["zoom","feature"]}}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":1,"round":1,"square":1},"default":"butt","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":1,"round":1,"miter":1},"default":"miter","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":1,"line":1,"line-center":1},"default":"point","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":1,"viewport-y":1,"source":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"symbol-z-elevate":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":1,"width":1,"height":1,"both":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":1,"viewport":1,"auto":1},"default":"auto","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":1,"left":1,"center":1,"right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","default":0,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":1,"left":1,"right":1,"top":1,"bottom":1,"top-left":1,"top-right":1,"bottom-left":1,"bottom-right":1},"default":"center","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":1,"vertical":1},"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":1,"uppercase":1,"lowercase":1},"default":"none","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","length":2,"default":[0,0],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":1,"none":1},"default":"visible","expression":{},"property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"property-type":"data-driven","expression":{"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":1,"!=":1,">":1,">=":1,"<":1,"<=":1,"in":1,"!in":1,"all":1,"any":1,"none":1,"has":1,"!has":1}},"geometry_type":{"type":"enum","values":{"Point":1,"LineString":1,"Polygon":1}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective","property-type":"data-constant"}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":1,"viewport":1},"property-type":"data-constant","expression":{"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky","paint_model"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"property-type":"data-constant","type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"property-type":"data-constant","type":"color","default":"#ffffff","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"property-type":"data-constant","type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"property-type":"data-constant","type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"property-type":"data-constant","type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-rounded-roof":{"property-type":"data-constant","type":"boolean","default":true,"expression":{"parameters":["zoom"]}},"fill-extrusion-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"property-type":"constant"},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"line-border-width":{"type":"number","private":true,"default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","private":true,"default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-image-cross-fade":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"transition":true},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"icon-color-saturation":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-color":{"type":"color","expression":{"interpolated":true,"parameters":["raster-value"]},"property-type":"color-ramp"},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","default":[0,1],"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"raster-array-band":{"type":"string","required":false,"property-type":"data-constant"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","default":90,"minimum":0,"maximum":180,"expression":{"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d","property-type":"data-constant"},"model-cast-shadows":{"type":"boolean","default":true,"expression":{},"property-type":"data-constant"},"model-receive-shadows":{"type":"boolean","default":true,"expression":{},"property-type":"data-constant"},"model-ambient-occlusion-intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant","transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');class Dt{constructor(e,t,i,r){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__);}}class Rt extends Dt{}function Lt(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function kt(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ot(e){if(Array.isArray(e))return e.map(Ot);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=Ot(e[i]);return t}return kt(e)}class Bt extends Error{constructor(e,t){super(t),this.message=t,this.key=e;}}var Ft=Bt;class Nt{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i;}concat(e){return new Nt(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return !!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var Ut=Nt;const Vt={kind:"null"},jt={kind:"number"},Gt={kind:"string"},qt={kind:"boolean"},Zt={kind:"color"},$t={kind:"object"},Wt={kind:"value"},Ht={kind:"collator"},Xt={kind:"formatted"},Yt={kind:"resolvedImage"};function Kt(e,t){return {kind:"array",itemType:e,N:t}}function Jt(e){if("array"===e.kind){const t=Jt(e.itemType);return "number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Qt=[Vt,jt,Gt,qt,Zt,Xt,$t,Kt(Wt),Yt];function ei(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!ei(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else {if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of Qt)if(!ei(e,t))return null}return `Expected ${Jt(e)} but found ${Jt(t)} instead.`}function ti(e,t){return t.some((t=>t.kind===e.kind))}function ii(e,t){return t.some((t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e))}var ri,ni={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function oi(e){return (e=Math.round(e))<0?0:e>255?255:e}function si(e){return oi("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function ai(e){return (t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t;}function li(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{ri={}.parseCSSColor=function(e){var t,i=e.replace(/ /g,"").toLowerCase();if(i in ni)return ni[i].slice();if("#"===i[0])return 4===i.length?(t=parseInt(i.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===i.length&&(t=parseInt(i.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var r=i.indexOf("("),n=i.indexOf(")");if(-1!==r&&n+1===i.length){var o=i.substr(0,r),s=i.substr(r+1,n-(r+1)).split(","),a=1;switch(o){case"rgba":if(4!==s.length)return null;a=ai(s.pop());case"rgb":return 3!==s.length?null:[si(s[0]),si(s[1]),si(s[2]),a];case"hsla":if(4!==s.length)return null;a=ai(s.pop());case"hsl":if(3!==s.length)return null;var l=(parseFloat(s[0])%360+360)%360/360,c=ai(s[1]),h=ai(s[2]),u=h<=.5?h*(c+1):h+c-h*c,d=2*h-u;return [oi(255*li(d,u,l+1/3)),oi(255*li(d,u,l)),oi(255*li(d,u,l-1/3)),a];default:return null}}return null};}catch(e){}class ci{constructor(e,t,i,r=1){this.r=e,this.g=t,this.b=i,this.a=r;}static parse(e){if(!e)return;if(e instanceof ci)return e;if("string"!=typeof e)return;const t=ri(e);return t?new ci(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,i,r]=this.toArray();return `rgba(${Math.round(e)},${Math.round(t)},${Math.round(i)},${r})`}toArray(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*i/r,r]}toArray01(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,i/r,r]}toArray01Scaled(e){const{r:t,g:i,b:r,a:n}=this;return 0===n?[0,0,0]:[t/n*e,i/n*e,r/n*e]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:i,a:r}=this;return [e,t,i,r]}toArray01Linear(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[Math.pow(e/r,2.2),Math.pow(t/r,2.2),Math.pow(i/r,2.2),r]}}ci.black=new ci(0,0,0,1),ci.white=new ci(1,1,1,1),ci.transparent=new ci(0,0,0,0),ci.red=new ci(1,0,0,1),ci.blue=new ci(0,0,1,1);var hi=ci;class ui{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"});}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class di{constructor(e,t,i,r,n){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n;}}class pi{constructor(e){this.sections=e;}static fromString(e){return new pi([new di(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((e=>0!==e.text.length||e.image&&0!==e.image.namePrimary.length))}static factory(e){return e instanceof pi?e:pi.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((e=>e.text)).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.namePrimary]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(i);}return e}}class fi{constructor(e){this.namePrimary=e.namePrimary,e.nameSecondary&&(this.nameSecondary=e.nameSecondary),this.available=e.available;}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(e,t){return e?new fi({namePrimary:e,nameSecondary:t,available:!1}):null}serialize(){return this.nameSecondary?["image",this.namePrimary,this.nameSecondary]:["image",this.namePrimary]}}function mi(e,t,i,r){return "number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function _i(e){if(null===e)return !0;if("string"==typeof e)return !0;if("boolean"==typeof e)return !0;if("number"==typeof e)return !0;if(e instanceof hi)return !0;if(e instanceof ui)return !0;if(e instanceof pi)return !0;if(e instanceof fi)return !0;if(Array.isArray(e)){for(const t of e)if(!_i(t))return !1;return !0}if("object"==typeof e){for(const t in e)if(!_i(e[t]))return !1;return !0}return !1}function gi(e){if(null===e)return Vt;if("string"==typeof e)return Gt;if("boolean"==typeof e)return qt;if("number"==typeof e)return jt;if(e instanceof hi)return Zt;if(e instanceof ui)return Ht;if(e instanceof pi)return Xt;if(e instanceof fi)return Yt;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=gi(t);if(i){if(i===e)continue;i=Wt;break}i=e;}return Kt(i||Wt,t)}return $t}function yi(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof hi||e instanceof pi||e instanceof fi?e.toString():JSON.stringify(e)}class xi{constructor(e,t){this.type=e,this.value=t;}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!_i(e[1]))return t.error("invalid value");const i=e[1];let r=gi(i);const n=t.expectedType;return "array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new xi(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}serialize(){return "array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof hi?["rgba"].concat(this.value.toArray()):this.value instanceof pi?this.value.serialize():this.value}}var vi=xi,bi=class{constructor(e){this.name="ExpressionEvaluationError",this.message=e;}toJSON(){return this.message}};const wi={string:Gt,number:jt,boolean:qt,object:$t};class Ti{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,r=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in wi)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=wi[i],r++;}else n=Wt;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++;}i=Kt(n,o);}else i=wi[n];const o=[];for(;r<e.length;r++){const i=t.parse(e[r],r,Wt);if(!i)return null;o.push(i);}return new Ti(i,o)}evaluate(e){for(let t=0;t<this.args.length;t++){const i=this.args[t].evaluate(e);if(!ei(this.type,gi(i)))return i;if(t===this.args.length-1)throw new bi(`Expected value to be of type ${Jt(this.type)}, but found ${Jt(gi(i))} instead.`)}return null}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r);}}return t.concat(this.args.map((e=>e.serialize())))}}var Ei=Ti;class Mi{constructor(e){this.type=Xt,this.sections=e;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,jt),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,Kt(Gt)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,Zt),!s))return null;const a=r[r.length-1];a.scale=e,a.font=i,a.textColor=s;}else {const o=t.parse(e[i],1,Wt);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null});}}return new Mi(r)}evaluate(e){return new pi(this.sections.map((t=>{const i=t.content.evaluate(e);return gi(i)===Yt?new di("",i,null,null,null):new di(yi(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)})))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor);}outputDefined(){return !1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i);}return e}}class Ai{constructor(e,t){this.type=Yt,this.inputPrimary=e,this.inputSecondary=t;}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");const i=t.parse(e[1],1,Gt);if(!i)return t.error("No image name provided.");if(2===e.length)return new Ai(i);const r=t.parse(e[2],1,Gt);return r?new Ai(i,r):t.error("Secondary image variant is not a string.")}evaluate(e){const t=fi.fromString(this.inputPrimary.evaluate(e),this.inputSecondary?this.inputSecondary.evaluate(e):void 0);return t&&e.availableImages&&(t.available=e.availableImages.indexOf(t.namePrimary)>-1,t.nameSecondary&&t.available&&e.availableImages&&(t.available=e.availableImages.indexOf(t.nameSecondary)>-1)),t}eachChild(e){e(this.inputPrimary),this.inputSecondary&&e(this.inputSecondary);}outputDefined(){return !1}serialize(){return this.inputSecondary?["image",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:["image",this.inputPrimary.serialize()]}}function Si(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}const Ii={"to-boolean":qt,"to-color":Zt,"to-number":jt,"to-string":Gt};class Ci{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0],r=[];let n=Vt;if("to-array"===i){if(!Array.isArray(e[1]))return null;const i=e[1].length;if(t.expectedType){if("array"!==t.expectedType.kind)return t.error(`Expected ${t.expectedType.kind} but found array.`);n=Kt(t.expectedType.itemType,i);}else {if(!(i>0&&_i(e[1][0])))return null;n=Kt(gi(e[1][0]),i);}for(let o=0;o<i;o++){const i=e[1][o];let s;if("array"===Si(i))s=t.parse(i,void 0,n.itemType);else {const e=Si(i);if(e!==n.itemType.kind)return t.error(`Expected ${n.itemType.kind} but found ${e}.`);s=t.registry.literal.parse(["literal",void 0===i?null:i],t);}if(!s)return null;r.push(s);}}else {if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");n=Ii[i];for(let i=1;i<e.length;i++){const n=t.parse(e[i],i,Wt);if(!n)return null;r.push(n);}}return new Ci(n,r)}evaluate(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){let t,i;for(const r of this.args){if(t=r.evaluate(e),i=null,t instanceof hi)return t;if("string"==typeof t){const i=e.parseColor(t);if(i)return i}else if(Array.isArray(t)&&(i=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:mi(t[0],t[1],t[2],t[3]),!i))return new hi(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new bi(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new bi(`Could not convert ${JSON.stringify(t)} to number.`)}return "formatted"===this.type.kind?pi.fromString(yi(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?fi.fromString(yi(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map((t=>t.evaluate(e))):yi(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new Mi([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Ai(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((t=>{e.push(t.serialize());})),e}}var zi=Ci;const Pi=["Unknown","Point","LineString","Polygon"];var Di=class{constructor(e){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.options=e;}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Pi[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(e){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=hi.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}};class Ri{constructor(e,t,i,r,n){this.name=e,this.type=t,this._evaluate=i,this.args=r,this._overloadIndex=n;}evaluate(e){if(!this._evaluate){const e=Ri.definitions[this.name];this._evaluate=Array.isArray(e)?e[2]:e.overloads[this._overloadIndex][1];}return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e);}outputDefined(){return !1}serialize(){return [this.name].concat(this.args.map((e=>e.serialize())))}static parse(e,t){const i=e[0],r=Ri.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=[];let a=null,l=-1;for(const[r,c]of o){if(Array.isArray(r)&&r.length!==e.length-1)continue;s.push(r),l++,a=new $r(t.registry,t.path,null,t.scope,void 0,t.options);const o=[];let h=!1;for(let t=1;t<e.length;t++){const i=e[t],n=Array.isArray(r)?r[t-1]:r.type,s=a.parse(i,1+o.length,n);if(!s){h=!0;break}o.push(s);}if(!h)if(Array.isArray(r)&&r.length!==o.length)a.error(`Expected ${r.length} arguments, but found ${o.length} instead.`);else {for(let e=0;e<o.length;e++){const t=Array.isArray(r)?r[e]:r.type,i=o[e];a.concat(e+1).checkSubtype(t,i.type);}if(0===a.errors.length)return new Ri(i,n,c,o,l)}}if(1===s.length)t.errors.push(...a.errors);else {const i=(s.length?s:o.map((([e])=>e))).map(Li).join(" | "),r=[];for(let i=1;i<e.length;i++){const n=t.parse(e[i],1+r.length);if(!n)return null;r.push(Jt(n.type));}t.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`);}return null}static register(e,t){Ri.definitions=t;for(const i in t)e[i]=Ri;}}function Li(e){return Array.isArray(e)?`(${e.map(Jt).join(", ")})`:`(${Jt(e.type)}...)`}var ki=Ri;class Oi{constructor(e,t,i){this.type=Ht,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t;}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const r=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,qt);if(!r)return null;const n=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,qt);if(!n)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,Gt),!o)?null:new Oi(r,n,o)}evaluate(e){return new ui(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale);}outputDefined(){return !1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}var Bi={exports:{}};Bi.exports=function(){function e(i,r,n,o,s){for(;o>n;){if(o-n>600){var a=o-n+1,l=r-n+1,c=Math.log(a),h=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*h*(a-h)/a)*(l-a/2<0?-1:1);e(i,r,Math.max(n,Math.floor(r-l*h/a+u)),Math.min(o,Math.floor(r+(a-l)*h/a+u)),s);}var d=i[r],p=n,f=o;for(t(i,n,r),s(i[o],d)>0&&t(i,n,o);p<f;){for(t(i,p,f),p++,f--;s(i[p],d)<0;)p++;for(;s(i[f],d)>0;)f--;}0===s(i[n],d)?t(i,n,f):t(i,++f,o),f<=r&&(n=f+1),r<=f&&(o=f-1);}}function t(e,t,i){var r=e[t];e[t]=e[i],e[i]=r;}function i(e,t){return e<t?-1:e>t?1:0}return function(t,r,n,o,s){e(t,r,n||0,o||t.length-1,s||i);}}();var Fi=d(Bi.exports);function Ni(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n<o;s=n++)i=e[n],r=e[s],t+=(r.x-i.x)*(i.y+r.y);return t}function Ui(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1]);}function Vi(e,t){return !(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function ji(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function Gi(e,t,i=!1){let r=!1;for(let a=0,l=t.length;a<l;a++){const l=t[a];for(let t=0,a=l.length,c=a-1;t<a;c=t++){const a=l[c],h=l[t];if(ji(e,a,h))return i;(o=a)[1]>(n=e)[1]!=(s=h)[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(r=!r);}}var n,o,s;return r}function qi(e,t,i,r){const n=r[0]-i[0],o=r[1]-i[1],s=(e[0]-i[0])*o-n*(e[1]-i[1]),a=(t[0]-i[0])*o-n*(t[1]-i[1]);return s>0&&a<0||s<0&&a>0}function Zi(e,t,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-n[1]*o[0]&&!(!qi(e,t,i,r)||!qi(i,r,e,t));var n,o;}const $i=8192;function Wi(e,t){const i=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return [Math.round(i*n*$i),Math.round(r*n*$i)]}function Hi(e,t){for(let i=0;i<t.length;i++)if(Gi(e,t[i]))return !0;return !1}function Xi(e,t,i){for(const r of i)for(let i=0,n=r.length,o=n-1;i<n;o=i++)if(Zi(e,t,r[o],r[i]))return !0;return !1}function Yi(e,t){for(let i=0;i<e.length;++i)if(!Gi(e[i],t))return !1;for(let i=0;i<e.length-1;++i)if(Xi(e[i],e[i+1],t))return !1;return !0}function Ki(e,t){for(let i=0;i<t.length;i++)if(Yi(e,t[i]))return !0;return !1}function Ji(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=[];for(let r=0;r<e[n].length;r++){const s=Wi(e[n][r],i);Ui(t,s),o.push(s);}r.push(o);}return r}function Qi(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=Ji(e[n],t,i);r.push(o);}return r}function er(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n;}Ui(t,e);}function tr(e,t,i,r){const n=Math.pow(2,r.z)*$i,o=[r.x*$i,r.y*$i],s=[];if(!e)return s;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];er(r,t,i,n),s.push(r);}return s}function ir(e,t,i,r){const n=Math.pow(2,r.z)*$i,o=[r.x*$i,r.y*$i],s=[];if(!e)return s;for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];Ui(t,i),e.push(i);}s.push(e);}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const r of e)er(r,t,i,n);}var a;return s}class rr{constructor(e,t){this.type=qt,this.geojson=e,this.geometries=t;}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(_i(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e<t.features.length;++e){const i=t.features[e].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new rr(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new rr(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new rr(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return !1;if("Polygon"===t.type){const o=Ji(t.coordinates,r,n),s=tr(e.geometry(),i,r,n);if(!Vi(i,r))return !1;for(const e of s)if(!Gi(e,o))return !1}if("MultiPolygon"===t.type){const o=Qi(t.coordinates,r,n),s=tr(e.geometry(),i,r,n);if(!Vi(i,r))return !1;for(const e of s)if(!Hi(e,o))return !1}return !0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if(!n)return !1;if("Polygon"===t.type){const o=Ji(t.coordinates,r,n),s=ir(e.geometry(),i,r,n);if(!Vi(i,r))return !1;for(const e of s)if(!Yi(e,o))return !1}if("MultiPolygon"===t.type){const o=Qi(t.coordinates,r,n),s=ir(e.geometry(),i,r,n);if(!Vi(i,r))return !1;for(const e of s)if(!Ki(e,o))return !1}return !0}(e,this.geometries)}return !1}eachChild(){}outputDefined(){return !0}serialize(){return ["within",this.geojson]}}var nr=rr,or={exports:{}};or.exports=function(){var e={kilometers:1,miles:1e3/1609.344,nauticalmiles:1e3/1852,meters:1e3,metres:1e3,yards:1e3/.9144,feet:1e3/.3048,inches:1e3/.0254},t=1/298.257223563,i=t*(2-t),r=Math.PI/180,n=function(t,n){if(void 0===t)throw new Error("No latitude given.");if(n&&!e[n])throw new Error("Unknown unit "+n+". Use one of: "+Object.keys(e).join(", "));var o=6378.137*r*(n?e[n]:1),s=Math.cos(t*r),a=1/(1-i*(1-s*s)),l=Math.sqrt(a);this.kx=o*l*s,this.ky=o*l*a*(1-i);},o={units:{configurable:!0}};function s(e,t){return e[0]===t[0]&&e[1]===t[1]}function a(e,t,i){var r=l(t[0]-e[0]);return [e[0]+r*i,e[1]+(t[1]-e[1])*i]}function l(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}return n.fromTile=function(e,t,i){var o=Math.PI*(1-2*(e+.5)/Math.pow(2,t)),s=Math.atan(.5*(Math.exp(o)-Math.exp(-o)))/r;return new n(s,i)},o.units.get=function(){return e},n.prototype.distance=function(e,t){var i=l(e[0]-t[0])*this.kx,r=(e[1]-t[1])*this.ky;return Math.sqrt(i*i+r*r)},n.prototype.bearing=function(e,t){var i=l(t[0]-e[0])*this.kx;return Math.atan2(i,(t[1]-e[1])*this.ky)/r},n.prototype.destination=function(e,t,i){var n=i*r;return this.offset(e,Math.sin(n)*t,Math.cos(n)*t)},n.prototype.offset=function(e,t,i){return [e[0]+t/this.kx,e[1]+i/this.ky]},n.prototype.lineDistance=function(e){for(var t=0,i=0;i<e.length-1;i++)t+=this.distance(e[i],e[i+1]);return t},n.prototype.area=function(e){for(var t=0,i=0;i<e.length;i++)for(var r=e[i],n=0,o=r.length,s=o-1;n<o;s=n++)t+=l(r[n][0]-r[s][0])*(r[n][1]+r[s][1])*(i?-1:1);return Math.abs(t)/2*this.kx*this.ky},n.prototype.along=function(e,t){var i=0;if(t<=0)return e[0];for(var r=0;r<e.length-1;r++){var n=e[r],o=e[r+1],s=this.distance(n,o);if((i+=s)>t)return a(n,o,(t-(i-s))/s)}return e[e.length-1]},n.prototype.pointToSegmentDistance=function(e,t,i){var r=t[0],n=t[1],o=l(i[0]-r)*this.kx,s=(i[1]-n)*this.ky,a=0;return 0===o&&0===s||((a=(l(e[0]-r)*this.kx*o+(e[1]-n)*this.ky*s)/(o*o+s*s))>1?(r=i[0],n=i[1]):a>0&&(r+=o/this.kx*a,n+=s/this.ky*a)),o=l(e[0]-r)*this.kx,s=(e[1]-n)*this.ky,Math.sqrt(o*o+s*s)},n.prototype.pointOnLine=function(e,t){for(var i,r,n,o,s=1/0,a=0;a<e.length-1;a++){var c=e[a][0],h=e[a][1],u=l(e[a+1][0]-c)*this.kx,d=(e[a+1][1]-h)*this.ky,p=0;0===u&&0===d||((p=(l(t[0]-c)*this.kx*u+(t[1]-h)*this.ky*d)/(u*u+d*d))>1?(c=e[a+1][0],h=e[a+1][1]):p>0&&(c+=u/this.kx*p,h+=d/this.ky*p));var f=(u=l(t[0]-c)*this.kx)*u+(d=(t[1]-h)*this.ky)*d;f<s&&(s=f,i=c,r=h,n=a,o=p);}return {point:[i,r],index:n,t:Math.max(0,Math.min(1,o))}},n.prototype.lineSlice=function(e,t,i){var r=this.pointOnLine(i,e),n=this.pointOnLine(i,t);if(r.index>n.index||r.index===n.index&&r.t>n.t){var o=r;r=n,n=o;}var a=[r.point],l=r.index+1,c=n.index;!s(i[l],a[0])&&l<=c&&a.push(i[l]);for(var h=l+1;h<=c;h++)a.push(i[h]);return s(i[c],n.point)||a.push(n.point),a},n.prototype.lineSliceAlong=function(e,t,i){for(var r=0,n=[],o=0;o<i.length-1;o++){var s=i[o],l=i[o+1],c=this.distance(s,l);if((r+=c)>e&&0===n.length&&n.push(a(s,l,(e-(r-c))/c)),r>=t)return n.push(a(s,l,(t-(r-c))/c)),n;r>e&&n.push(l);}return n},n.prototype.bufferPoint=function(e,t){var i=t/this.ky,r=t/this.kx;return [e[0]-r,e[1]-i,e[0]+r,e[1]+i]},n.prototype.bufferBBox=function(e,t){var i=t/this.ky,r=t/this.kx;return [e[0]-r,e[1]-i,e[2]+r,e[3]+i]},n.prototype.insideBBox=function(e,t){return l(e[0]-t[0])>=0&&l(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]},Object.defineProperties(n,o),n}();var sr=d(or.exports),ar={exports:{}};ar.exports=function(){var e=function(e,i){if(void 0===e&&(e=[]),void 0===i&&(i=t),this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r);};function t(e,t){return e<t?-1:e>t?1:0}return e.prototype.push=function(e){this.data.push(e),this.length++,this._up(this.length-1);},e.prototype.pop=function(){if(0!==this.length){var e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}},e.prototype.peek=function(){return this.data[0]},e.prototype._up=function(e){for(var t=this.data,i=this.compare,r=t[e];e>0;){var n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n;}t[e]=r;},e.prototype._down=function(e){for(var t=this.data,i=this.compare,r=this.length>>1,n=t[e];e<r;){var o=1+(e<<1),s=t[o],a=o+1;if(a<this.length&&i(t[a],s)<0&&(o=a,s=t[a]),i(s,n)>=0)break;t[e]=s,e=o;}t[e]=n;},e}();var lr=d(ar.exports),cr=8192;function hr(e,t){return t.dist-e.dist}const ur=100,dr=50;function pr(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return !1;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return !1;return !0}function fr(e){return e[1]-e[0]+1}function mr(e,t){const i=e[1]>=e[0]&&e[1]<t;return i||console.warn("Distance Expression: Index is out of range"),i}function _r(e,t){if(e[0]>e[1])return [null,null];const i=fr(e);if(t){if(2===i)return [e,null];const t=Math.floor(i/2);return [[e[0],e[0]+t],[e[0]+t,e[1]]]}{if(1===i)return [e,null];const t=Math.floor(i/2)-1;return [[e[0],e[0]+t],[e[0]+t+1,e[1]]]}}function gr(e,t){const i=[1/0,1/0,-1/0,-1/0];if(!mr(t,e.length))return i;for(let r=t[0];r<=t[1];++r)Ui(i,e[r]);return i}function yr(e){const t=[1/0,1/0,-1/0,-1/0];for(let i=0;i<e.length;++i)for(let r=0;r<e[i].length;++r)Ui(t,e[i][r]);return t}function xr(e,t,i){if(pr(e)||pr(t))return NaN;let r=0,n=0;return e[2]<t[0]&&(r=t[0]-e[2]),e[0]>t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(n=e[1]-t[3]),e[3]<t[1]&&(n=t[1]-e[3]),i.distance([0,0],[r,n])}function vr(e,t){const i=Math.pow(2,t.z);return [(n=(e.x/cr+t.x)/i,360*n-180),(r=(e.y/cr+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,n;}function br(e,t){const i=[];for(let r=0;r<e.length;++r)i.push(vr(e[r],t));return i}function wr(e,t,i){const r=i.pointOnLine(t,e).point;return i.distance(e,r)}function Tr(e,t,i,r,n){const o=i.slice(r[0],r[1]+1);let s=1/0;for(let i=t[0];i<=t[1];++i)if(0===(s=Math.min(s,wr(e[i],o,n))))return 0;return s}function Er(e,t,i,r,n){const o=Math.min(n.pointToSegmentDistance(e,i,r),n.pointToSegmentDistance(t,i,r)),s=Math.min(n.pointToSegmentDistance(i,e,t),n.pointToSegmentDistance(r,e,t));return Math.min(o,s)}function Mr(e,t,i,r,n){if(!mr(t,e.length)||!mr(r,i.length))return NaN;let o=1/0;for(let s=t[0];s<t[1];++s)for(let t=r[0];t<r[1];++t){if(Zi(e[s],e[s+1],i[t],i[t+1]))return 0;o=Math.min(o,Er(e[s],e[s+1],i[t],i[t+1],n));}return o}function Ar(e,t,i,r,n){if(!mr(t,e.length)||!mr(r,i.length))return NaN;let o=1/0;for(let s=t[0];s<=t[1];++s)for(let t=r[0];t<=r[1];++t)if(0===(o=Math.min(o,n.distance(e[s],i[t]))))return o;return o}function Sr(e,t,i){if(Gi(e,t,!0))return 0;let r=1/0;for(const n of t){const t=n.length;if(t<2)return console.warn("Distance Expression: Invalid polygon!"),NaN;if(n[0]!==n[t-1]&&0===(r=Math.min(r,i.pointToSegmentDistance(e,n[t-1],n[0]))))return r;if(0===(r=Math.min(r,wr(e,n,i))))return r}return r}function Ir(e,t,i,r){if(!mr(t,e.length))return NaN;for(let r=t[0];r<=t[1];++r)if(Gi(e[r],i,!0))return 0;let n=1/0;for(let o=t[0];o<t[1];++o)for(const t of i)for(let i=0,s=t.length,a=s-1;i<s;a=i++){if(Zi(e[o],e[o+1],t[a],t[i]))return 0;n=Math.min(n,Er(e[o],e[o+1],t[a],t[i],r));}return n}function Cr(e,t){for(const i of e)for(let e=0;e<=i.length-1;++e)if(Gi(i[e],t,!0))return !0;return !1}function zr(e,t,i,r=1/0){const n=yr(e),o=yr(t);if(r!==1/0&&xr(n,o,i)>=r)return r;if(Vi(n,o)){if(Cr(e,t))return 0}else if(Cr(t,e))return 0;let s=r;for(const r of e)for(let e=0,n=r.length,o=n-1;e<n;o=e++)for(const n of t)for(let t=0,a=n.length,l=a-1;t<a;l=t++){if(Zi(r[o],r[e],n[l],n[t]))return 0;s=Math.min(s,Er(r[o],r[e],n[l],n[t],i));}return s}function Pr(e,t,i,r,n,o,s){if(null===o||null===s)return;const a=xr(gr(r,o),gr(n,s),i);a<t&&e.push({dist:a,range1:o,range2:s});}function Dr(e,t,i,r,n=1/0){let o=Math.min(r.distance(e[0],i[0][0]),n);if(0===o)return o;const s=new lr([{dist:0,range1:[0,e.length-1],range2:[0,0]}],hr),a=t?dr:ur,l=yr(i);for(;s.length;){const n=s.pop();if(n.dist>=o)continue;const c=n.range1;if(fr(c)<=a){if(!mr(c,e.length))return NaN;if(t){const t=Ir(e,c,i,r);if(0===(o=Math.min(o,t)))return o}else for(let t=c[0];t<=c[1];++t){const n=Sr(e[t],i,r);if(0===(o=Math.min(o,n)))return o}}else {const i=_r(c,t);if(null!==i[0]){const t=xr(gr(e,i[0]),l,r);t<o&&s.push({dist:t,range1:i[0],range2:[0,0]});}if(null!==i[1]){const t=xr(gr(e,i[1]),l,r);t<o&&s.push({dist:t,range1:i[1],range2:[0,0]});}}}return o}function Rr(e,t,i,r,n,o=1/0){let s=Math.min(o,n.distance(e[0],i[0]));if(0===s)return s;const a=new lr([{dist:0,range1:[0,e.length-1],range2:[0,i.length-1]}],hr),l=t?dr:ur,c=r?dr:ur;for(;a.length;){const o=a.pop();if(o.dist>=s)continue;const h=o.range1,u=o.range2;if(fr(h)<=l&&fr(u)<=c){if(!mr(h,e.length)||!mr(u,i.length))return NaN;if(t&&r?s=Math.min(s,Mr(e,h,i,u,n)):t||r?t&&!r?s=Math.min(s,Tr(i,u,e,h,n)):!t&&r&&(s=Math.min(s,Tr(e,h,i,u,n))):s=Math.min(s,Ar(e,h,i,u,n)),0===s)return s}else {const o=_r(h,t),l=_r(u,r);Pr(a,s,n,e,i,o[0],l[0]),Pr(a,s,n,e,i,o[0],l[1]),Pr(a,s,n,e,i,o[1],l[0]),Pr(a,s,n,e,i,o[1],l[1]);}}return s}function Lr(e,t,i,r,n=1/0){let o=n;const s=gr(e,[0,e.length-1]);for(const n of i)if(!(o!==1/0&&xr(s,gr(n,[0,n.length-1]),r)>=o)&&(o=Math.min(o,Rr(e,t,n,!0,r,o)),0===o))return o;return o}function kr(e,t,i,r,n=1/0){let o=n;const s=gr(e,[0,e.length-1]);for(const n of i){if(o!==1/0&&xr(s,yr(n),r)>=o)continue;const i=Dr(e,t,n,r,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function Or(e){return "Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class Br{constructor(e,t){this.type=jt,this.geojson=e,this.geometries=t;}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(_i(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;e<t.features.length;++e)if(Or(t.features[e].geometry.type))return new Br(t,t.features[e].geometry)}else if("Feature"===t.type){if(Or(t.geometry.type))return new Br(t,t.geometry)}else if(Or(t.type))return new Br(t,t)}return t.error("'distance' expression needs to be an array with format ['Distance', GeoJSONObj].")}evaluate(e){const t=e.geometry(),i=e.canonicalID();if(null!=t&&null!=i){if("Point"===e.geometryType())return function(e,t,i){const r=[];for(const i of e)for(const e of i)r.push(vr(e,t));const n=new sr(r[0][1],"meters");return "Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type?Rr(r,!1,"Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,n):"MultiLineString"===i.type?Lr(r,!1,i.coordinates,n):"Polygon"===i.type||"MultiPolygon"===i.type?kr(r,!1,"Polygon"===i.type?[i.coordinates]:i.coordinates,n):null}(t,i,this.geometries);if("LineString"===e.geometryType())return function(e,t,i){const r=[];for(const i of e){const e=[];for(const r of i)e.push(vr(r,t));r.push(e);}const n=new sr(r[0][0][1],"meters");if("Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type)return Lr("Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,r,n);if("MultiLineString"===i.type){let e=1/0;for(let t=0;t<i.coordinates.length;t++){const o=Lr(i.coordinates[t],!0,r,n,e);if(isNaN(o))return o;if(0===(e=Math.min(e,o)))return e}return e}if("Polygon"===i.type||"MultiPolygon"===i.type){let e=1/0;for(let t=0;t<r.length;t++){const o=kr(r[t],!0,"Polygon"===i.type?[i.coordinates]:i.coordinates,n,e);if(isNaN(o))return o;if(0===(e=Math.min(e,o)))return e}return e}return null}(t,i,this.geometries);if("Polygon"===e.geometryType())return function(e,t,i){const r=[];for(const i of function(e,t){const i=e.length;if(i<=1)return [e];const r=[];let n,o;for(let t=0;t<i;t++){const i=Ni(e[t]);0!==i&&(e[t].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(n&&r.push(n),n=[e[t]]):n.push(e[t]));}return n&&r.push(n),r}(e)){const e=[];for(let r=0;r<i.length;++r)e.push(br(i[r],t));r.push(e);}const n=new sr(r[0][0][0][1],"meters");if("Point"===i.type||"MultiPoint"===i.type||"LineString"===i.type)return kr("Point"===i.type?[i.coordinates]:i.coordinates,"LineString"===i.type,r,n);if("MultiLineString"===i.type){let e=1/0;for(let t=0;t<i.coordinates.length;t++){const o=kr(i.coordinates[t],!0,r,n,e);if(isNaN(o))return o;if(0===(e=Math.min(e,o)))return e}return e}return "Polygon"===i.type||"MultiPolygon"===i.type?function(e,t,i){let r=1/0;for(const n of e)for(const e of t){const t=zr(n,e,i,r);if(isNaN(t))return t;if(0===(r=Math.min(r,t)))return r}return r}("Polygon"===i.type?[i.coordinates]:i.coordinates,r,n):null}(t,i,this.geometries);console.warn("Distance Expression: currently only evaluates valid Point/LineString/Polygon geometries.");}else console.warn("Distance Expression: requirs valid feature and canonical information.");return null}eachChild(){}outputDefined(){return !0}serialize(){return ["distance",this.geojson]}}var Fr=Br;function Nr(e){if(e instanceof ki){if("get"===e.name&&1===e.args.length)return !1;if("feature-state"===e.name)return !1;if("has"===e.name&&1===e.args.length)return !1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return !1;if(/^filter-/.test(e.name))return !1}if(e instanceof nr)return !1;if(e instanceof Fr)return !1;let t=!0;return e.eachChild((e=>{t&&!Nr(e)&&(t=!1);})),t}function Ur(e){if(e instanceof ki&&"feature-state"===e.name)return !1;let t=!0;return e.eachChild((e=>{t&&!Ur(e)&&(t=!1);})),t}function Vr(e){if(e instanceof ki&&"config"===e.name)return !1;let t=!0;return e.eachChild((e=>{t&&!Vr(e)&&(t=!1);})),t}function jr(e,t){if(e instanceof ki&&t.indexOf(e.name)>=0)return !1;let i=!0;return e.eachChild((e=>{i&&!jr(e,t)&&(i=!1);})),i}class Gr{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t;}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new Gr(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return !1}serialize(){return ["var",this.name]}}var qr=Gr;class Zr{constructor(e,t=[],i,r=new Ut,n=[],o){this.registry=e,this.path=t,this.key=t.map((e=>`[${e}]`)).join(""),this.scope=r,this.errors=n,this.expectedType=i,this.options=o;}parse(e,t,i,r,n={}){return t||i?this.concat(t,i,r)._parse(e,n):this._parse(e,n)}_parse(e,t){function i(e,t,i){return "assert"===i?new Ei(t,[e]):"coerce"===i?new zi(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r="string"==typeof e[0]?this.registry[e[0]]:void 0;if(r){let n=r.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,r=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"coerce");else n=i(n,e,t.typeAnnotation||"assert");}if(!(n instanceof vi)&&"resolvedImage"!==n.type.kind&&Wr(n)){const e=new Di(this.options);try{n=new vi(n.type,n.evaluate(e));}catch(e){return this.error(e.message),null}}return n}return zi.parse(["to-array",e],this)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const r="number"==typeof e?this.path.concat(e):this.path,n=i?this.scope.concat(i):this.scope;return new Zr(this.registry,r,t||null,n,this.errors,this.options)}error(e,...t){const i=`${this.key}${t.map((e=>`[${e}]`)).join("")}`;this.errors.push(new Ft(i,e));}checkSubtype(e,t){const i=ei(e,t);return i&&this.error(i),i}}var $r=Zr;function Wr(e){if(e instanceof qr)return Wr(e.boundExpression);if(e instanceof ki&&"error"===e.name)return !1;if(e instanceof ki&&"config"===e.name)return !1;if(e instanceof Oi)return !1;if(e instanceof nr)return !1;if(e instanceof Fr)return !1;const t=e instanceof zi||e instanceof Ei;let i=!0;return e.eachChild((e=>{i=t?i&&Wr(e):i&&e instanceof vi;})),!!i&&Nr(e)&&jr(e,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light"])}function Hr(e,t){const i=e.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=e[a],n=e[a+1],r<=t){if(a===i||t<n)return a;o=a+1;}else {if(!(r>t))throw new bi("Input is not a number.");s=a-1;}return 0}class Xr{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t);}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,jt);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let i=1;i<e.length;i+=2){const o=1===i?-1/0:e[i],s=e[i+1],a=i,l=i+1;if("number"!=typeof o)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c]);}return new Xr(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[Hr(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){const e=["step",this.input.serialize()];for(let t=0;t<this.labels.length;t++)t>0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var Yr=Xr;function Kr(e,t,i){return e*(1-i)+t*i}function Jr(e,t,i){return e.map(((e,r)=>Kr(e,t[r],i)))}var Qr=Object.freeze({__proto__:null,array:Jr,color:function(e,t,i){return new hi(Kr(e.r,t.r,i),Kr(e.g,t.g,i),Kr(e.b,t.b,i),Kr(e.a,t.a,i))},number:Kr});const en=.95047,tn=1.08883,rn=4/29,nn=6/29,on=3*nn*nn,sn=nn*nn*nn,an=Math.PI/180,ln=180/Math.PI;function cn(e){return e>sn?Math.pow(e,1/3):e/on+rn}function hn(e){return e>nn?e*e*e:on*(e-rn)}function un(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function dn(e){return (e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function pn(e){const t=dn(e.r),i=dn(e.g),r=dn(e.b),n=cn((.4124564*t+.3575761*i+.1804375*r)/en),o=cn((.2126729*t+.7151522*i+.072175*r)/1);return {l:116*o-16,a:500*(n-o),b:200*(o-cn((.0193339*t+.119192*i+.9503041*r)/tn)),alpha:e.a}}function fn(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*hn(t),i=en*hn(i),r=tn*hn(r),new hi(un(3.2404542*i-1.5371385*t-.4985314*r),un(-.969266*i+1.8760108*t+.041556*r),un(.0556434*i-.2040259*t+1.0572252*r),e.alpha)}function mn(e,t,i){const r=t-e;return e+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const _n={forward:pn,reverse:fn,interpolate:function(e,t,i){return {l:Kr(e.l,t.l,i),a:Kr(e.a,t.a,i),b:Kr(e.b,t.b,i),alpha:Kr(e.alpha,t.alpha,i)}}},gn={forward:function(e){const{l:t,a:i,b:r}=pn(e),n=Math.atan2(r,i)*ln;return {h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*an,i=e.c;return fn({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return {h:mn(e.h,t.h,i),c:Kr(e.c,t.c,i),l:Kr(e.l,t.l,i),alpha:Kr(e.alpha,t.alpha,i)}}};var yn=Object.freeze({__proto__:null,hcl:gn,lab:_n});class xn{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t);}static interpolationFactor(e,t,i,r){let n=0;if("exponential"===e.name)n=vn(t,e.base,i,r);else if("linear"===e.name)n=vn(t,1,i,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;n=new m(o[0],o[1],o[2],o[3]).solve(vn(t,1,i,r));}return n}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e};}else {if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.slice(1);if(4!==e.length||e.some((e=>"number"!=typeof e||e<0||e>1)))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e};}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,jt),!n)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=Zt:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e<o.length;e+=2){const i=o[e],r=o[e+1],n=e+3,l=e+4;if("number"!=typeof i)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(s.length&&s[s.length-1][0]>=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c]);}return "number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new xn(a,i,r,n,s):t.error(`Type ${Jt(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=Hr(t,r),s=xn.interpolationFactor(this.interpolation,r,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);return "interpolate"===this.operator?Qr[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?gn.reverse(gn.interpolate(gn.forward(a),gn.forward(l),s)):_n.reverse(_n.interpolate(_n.forward(a),_n.forward(l),s))}eachChild(e){e(this.input);for(const t of this.outputs)e(t);}outputDefined(){return this.outputs.every((e=>e.outputDefined()))}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const t=[this.operator,e,this.input.serialize()];for(let e=0;e<this.labels.length;e++)t.push(this.labels[e],this.outputs[e].serialize());return t}}function vn(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}var bn=xn;class wn{constructor(e,t){this.type=e,this.args=t;}static parse(e,t){if(e.length<2)return t.error("Expectected at least one argument.");let i=null;const r=t.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of e.slice(1)){const e=t.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,n.push(e);}const o=r&&n.some((e=>ei(r,e.type)));return new wn(o?Wt:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(e),i&&i instanceof fi&&!i.available&&(t||(t=i),i=null,r===this.args.length))return t;if(null!==i)break}return i}eachChild(e){this.args.forEach(e);}outputDefined(){return this.args.every((e=>e.outputDefined()))}serialize(){const e=["coalesce"];return this.eachChild((t=>{e.push(t.serialize());})),e}}var Tn=wn;class En{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t;}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result);}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let r=1;r<e.length-1;r+=2){const n=e[r];if("string"!=typeof n)return t.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return t.error("Variable names must contain only alphanumeric characters or '_'.",r);const o=t.parse(e[r+1],r+1);if(!o)return null;i.push([n,o]);}const r=t.parse(e[e.length-1],e.length-1,t.expectedType,i);return r?new En(i,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,i]of this.bindings)e.push(t,i.serialize());return e.push(this.result.serialize()),e}}var Mn=En;class An{constructor(e,t,i){this.type=e,this.index=t,this.input=i;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,jt),r=t.parse(e[2],2,Kt(t.expectedType||Wt));return i&&r?new An(r.type.itemType,i,r):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new bi(`Array index out of bounds: ${t} < 0.`);if(t>=i.length)throw new bi(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new bi(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input);}outputDefined(){return !1}serialize(){return ["at",this.index.serialize(),this.input.serialize()]}}var Sn=An;class In{constructor(e,t){this.type=qt,this.needle=e,this.haystack=t;}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Wt),r=t.parse(e[2],2,Wt);return i&&r?ti(i.type,[qt,Gt,jt,Vt,Wt])?new In(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Jt(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return !1;if(!ii(t,["boolean","string","number","null"]))throw new bi(`Expected first argument to be of type boolean, string, number or null, but found ${Jt(gi(t))} instead.`);if(!ii(i,["string","array"]))throw new bi(`Expected second argument to be of type array or string, but found ${Jt(gi(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack);}outputDefined(){return !0}serialize(){return ["in",this.needle.serialize(),this.haystack.serialize()]}}var Cn=In;class zn{constructor(e,t,i){this.type=jt,this.needle=e,this.haystack=t,this.fromIndex=i;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Wt),r=t.parse(e[2],2,Wt);if(!i||!r)return null;if(!ti(i.type,[qt,Gt,jt,Vt,Wt]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Jt(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,jt);return n?new zn(i,r,n):null}return new zn(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!ii(t,["boolean","string","number","null"]))throw new bi(`Expected first argument to be of type boolean, string, number or null, but found ${Jt(gi(t))} instead.`);if(!ii(i,["string","array"]))throw new bi(`Expected second argument to be of type array or string, but found ${Jt(gi(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return i.indexOf(t,r)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex);}outputDefined(){return !1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return ["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return ["index-of",this.needle.serialize(),this.haystack.serialize()]}}var Pn=zn;class Dn{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o;}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},o=[];for(let s=2;s<e.length-1;s+=2){let a=e[s];const l=e[s+1];Array.isArray(a)||(a=[a]);const c=t.concat(s);if(0===a.length)return c.error("Expected at least one branch label.");for(const e of a){if("number"!=typeof e&&"string"!=typeof e)return c.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,gi(e)))return null}else i=gi(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length;}const h=t.parse(l,s,r);if(!h)return null;r=r||h.type,o.push(h);}const s=t.parse(e[1],1,Wt);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,r);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new Dn(i,r,s,n,o,a):null}evaluate(e){const t=this.input.evaluate(e);return (gi(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise);}outputDefined(){return this.outputs.every((e=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),i=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e);}const n=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of i)e.push(1===r.length?n(r[0]):r.map(n)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}var Rn=Dn;class Ln{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i;}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let n=1;n<e.length-1;n+=2){const o=t.parse(e[n],n,qt);if(!o)return null;const s=t.parse(e[n+1],n+1,i);if(!s)return null;r.push([o,s]),i=i||s.type;}const n=t.parse(e[e.length-1],e.length-1,i);return n?new Ln(i,r,n):null}evaluate(e){for(const[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,i]of this.branches)e(t),e(i);e(this.otherwise);}outputDefined(){return this.branches.every((([e,t])=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild((t=>{e.push(t.serialize());})),e}}var kn=Ln;class On{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r;}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Wt),r=t.parse(e[2],2,jt);if(!i||!r)return null;if(!ti(i.type,[Kt(Wt),Gt,Wt]))return t.error(`Expected first argument to be of type array or string, but found ${Jt(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,jt);return n?new On(i.type,i,r,n):null}return new On(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!ii(t,["string","array"]))throw new bi(`Expected first argument to be of type array or string, but found ${Jt(gi(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(i,r)}return t.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex);}outputDefined(){return !1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return ["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return ["slice",this.input.serialize(),this.beginIndex.serialize()]}}var Bn=On;function Fn(e,t){return "=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function Nn(e,t,i,r){return 0===r.compare(t,i)}function Un(e,t,i){const r="=="!==e&&"!="!==e;return class n{constructor(e,t,i){this.type=qt,this.lhs=e,this.rhs=t,this.collator=i,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind;}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const i=e[0];let o=t.parse(e[1],1,Wt);if(!o)return null;if(!Fn(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Jt(o.type)}'.`);let s=t.parse(e[2],2,Wt);if(!s)return null;if(!Fn(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Jt(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Jt(o.type)}' and '${Jt(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Ei(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Ei(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,Ht),!a)return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=gi(o),i=gi(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new bi(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=gi(o),i=gi(s);if("string"!==e.kind||"string"!==i.kind)return t(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):t(n,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator);}outputDefined(){return !0}serialize(){const t=[e];return this.eachChild((e=>{t.push(e.serialize());})),t}}}const Vn=Un("==",(function(e,t,i){return t===i}),Nn),jn=Un("!=",(function(e,t,i){return t!==i}),(function(e,t,i,r){return !Nn(0,t,i,r)})),Gn=Un("<",(function(e,t,i){return t<i}),(function(e,t,i,r){return r.compare(t,i)<0})),qn=Un(">",(function(e,t,i){return t>i}),(function(e,t,i,r){return r.compare(t,i)>0})),Zn=Un("<=",(function(e,t,i){return t<=i}),(function(e,t,i,r){return r.compare(t,i)<=0})),$n=Un(">=",(function(e,t,i){return t>=i}),(function(e,t,i,r){return r.compare(t,i)>=0}));class Wn{constructor(e,t,i,r,n,o){this.type=Gt,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=n,this.maxFractionDigits=o;}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,jt);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parse(r.locale,1,Gt),!n))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,Gt),!o))return null;let s=null;if(r.unit&&(s=t.parse(r.unit,1,Gt),!s))return null;let a=null;if(r["min-fraction-digits"]&&(a=t.parse(r["min-fraction-digits"],1,jt),!a))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,jt),!l)?null:new Wn(i,n,o,s,a,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits);}outputDefined(){return !1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Hn{constructor(e){this.type=jt,this.input=e;}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Jt(i.type)} instead.`):new Hn(i):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new bi(`Expected value to be of type string or array, but found ${Jt(gi(t))} instead.`)}eachChild(e){e(this.input);}outputDefined(){return !1}serialize(){const e=["length"];return this.eachChild((t=>{e.push(t.serialize());})),e}}function Xn(e){return function(){e=1831565813+(e|=0)|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const Yn={"==":Vn,"!=":jn,">":qn,"<":Gn,">=":$n,"<=":Zn,array:Ei,at:Sn,boolean:Ei,case:kn,coalesce:Tn,collator:Oi,format:Mi,image:Ai,in:Cn,"index-of":Pn,interpolate:bn,"interpolate-hcl":bn,"interpolate-lab":bn,length:Hn,let:Mn,literal:vi,match:Rn,number:Ei,"number-format":Wn,object:Ei,slice:Bn,step:Yr,string:Ei,"to-boolean":zi,"to-color":zi,"to-number":zi,"to-string":zi,var:qr,within:nr,distance:Fr};function Kn(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=mi(t,i,r,o);if(s)throw new bi(s);return new hi(t/255*o,i/255*o,r/255*o,o)}function Jn(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=function(e,t,i,r){return "number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof i&&i>=0&&i<=100?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid hsla value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'h' must be between 0 and 360.`}(t,i,r,o);if(s)throw new bi(s);const a=`hsla(${t}, ${i}%, ${r}%, ${o})`,l=hi.parse(a);if(!l)throw new bi(`Failed to parse HSLA color: ${a}`);return l}function Qn(e,t){return e in t}function eo(e,t){const i=t[e];return void 0===i?null:i}function to(e,t){switch(e){case"string":return String(t);case"number":return +t;case"boolean":return !!t;case"color":return hi.parse(t)}return t}function io(e,t,i,r){return void 0!==r&&(e=r*Math.round(e/r)),void 0!==t&&e<t&&(e=t),void 0!==i&&e>i&&(e=i),e}function ro(e,t,i){i.length&&(t+=`${i}`);const r=e.getConfig(t);if(!r)return null;const{type:n,value:o,values:s,minValue:a,maxValue:l,stepValue:c}=r,h=r.default.evaluate(e);let u=o?o.evaluate(e):h;return n&&(u=to(n,u)),void 0!==o&&void 0!==u&&s&&!s.includes(u)&&(u=h,n&&(u=to(n,u))),void 0===u||void 0===a&&void 0===l&&void 0===c||("number"==typeof u?u=io(u,a,l,c):Array.isArray(u)&&(u=u.map((e=>"number"==typeof e?io(e,a,l,c):e)))),u}function no(e){return {type:e}}ki.register(Yn,{error:[{kind:"error"},[Gt],(e,[t])=>{throw new bi(t.evaluate(e))}],typeof:[Gt,[Wt],(e,[t])=>Jt(gi(t.evaluate(e)))],"to-rgba":[Kt(jt,4),[Zt],(e,[t])=>t.evaluate(e).toArray()],rgb:[Zt,[jt,jt,jt],Kn],rgba:[Zt,[jt,jt,jt,jt],Kn],hsl:[Zt,[jt,jt,jt],Jn],hsla:[Zt,[jt,jt,jt,jt],Jn],has:{type:qt,overloads:[[[Gt],(e,[t])=>Qn(t.evaluate(e),e.properties())],[[Gt,$t],(e,[t,i])=>Qn(t.evaluate(e),i.evaluate(e))]]},get:{type:Wt,overloads:[[[Gt],(e,[t])=>eo(t.evaluate(e),e.properties())],[[Gt,$t],(e,[t,i])=>eo(t.evaluate(e),i.evaluate(e))]]},config:{type:Wt,overloads:[[[Gt],(e,[t])=>ro(e,t.evaluate(e),"")],[[Gt,Gt],(e,[t,i])=>ro(e,t.evaluate(e),i.evaluate(e))]]},"feature-state":[Wt,[Gt],(e,[t])=>eo(t.evaluate(e),e.featureState||{})],properties:[$t,[],e=>e.properties()],"geometry-type":[Gt,[],e=>e.geometryType()],id:[Wt,[],e=>e.id()],zoom:[jt,[],e=>e.globals.zoom],pitch:[jt,[],e=>e.globals.pitch||0],"distance-from-center":[jt,[],e=>e.distanceFromCenter()],"measure-light":[jt,[Gt],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[jt,[],e=>e.globals.heatmapDensity||0],"line-progress":[jt,[],e=>e.globals.lineProgress||0],"raster-value":[jt,[],e=>e.globals.rasterValue||0],"sky-radial-progress":[jt,[],e=>e.globals.skyRadialProgress||0],accumulated:[Wt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[jt,no(jt),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[jt,no(jt),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:jt,overloads:[[[jt,jt],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[jt],(e,[t])=>-t.evaluate(e)]]},"/":[jt,[jt,jt],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[jt,[jt,jt],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[jt,[],()=>Math.LN2],pi:[jt,[],()=>Math.PI],e:[jt,[],()=>Math.E],"^":[jt,[jt,jt],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[jt,[jt],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[jt,[jt],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[jt,[jt],(e,[t])=>Math.log(t.evaluate(e))],log2:[jt,[jt],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[jt,[jt],(e,[t])=>Math.sin(t.evaluate(e))],cos:[jt,[jt],(e,[t])=>Math.cos(t.evaluate(e))],tan:[jt,[jt],(e,[t])=>Math.tan(t.evaluate(e))],asin:[jt,[jt],(e,[t])=>Math.asin(t.evaluate(e))],acos:[jt,[jt],(e,[t])=>Math.acos(t.evaluate(e))],atan:[jt,[jt],(e,[t])=>Math.atan(t.evaluate(e))],min:[jt,no(jt),(e,t)=>Math.min(...t.map((t=>t.evaluate(e))))],max:[jt,no(jt),(e,t)=>Math.max(...t.map((t=>t.evaluate(e))))],abs:[jt,[jt],(e,[t])=>Math.abs(t.evaluate(e))],round:[jt,[jt],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[jt,[jt],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[jt,[jt],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[qt,[Gt,Wt],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[qt,[Wt],(e,[t])=>e.id()===t.value],"filter-type-==":[qt,[Gt],(e,[t])=>e.geometryType()===t.value],"filter-<":[qt,[Gt,Wt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[qt,[Wt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[qt,[Gt,Wt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[qt,[Wt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[qt,[Gt,Wt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[qt,[Wt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[qt,[Gt,Wt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[qt,[Wt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[qt,[Wt],(e,[t])=>t.value in e.properties()],"filter-has-id":[qt,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[qt,[Kt(Gt)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[qt,[Kt(Wt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[qt,[Gt,Kt(Wt)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[qt,[Gt,Kt(Wt)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return !0;t[n]>e?r=n-1:i=n+1;}return !1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:qt,overloads:[[[qt,qt],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[no(qt),(e,t)=>{for(const i of t)if(!i.evaluate(e))return !1;return !0}]]},any:{type:qt,overloads:[[[qt,qt],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[no(qt),(e,t)=>{for(const i of t)if(i.evaluate(e))return !0;return !1}]]},"!":[qt,[qt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[qt,[Gt],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return !i||i(t.evaluate(e))}],upcase:[Gt,[Gt],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Gt,[Gt],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Gt,no(Wt),(e,t)=>t.map((t=>yi(t.evaluate(e)))).join("")],"resolved-locale":[Gt,[Ht],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[jt,[jt,jt,Wt],(e,t)=>{const[i,r,n]=t.map((t=>t.evaluate(e)));if(i>r)return i;if(i===r)return i;let o;if("string"==typeof n)o=function(e){let t=0;if(0===e.length)return t;for(let i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return t}(n);else {if("number"!=typeof n)throw new bi(`Invalid seed input: ${n}`);o=n;}return i+Xn(o)()*(r-i)}]});var oo=Yn;function so(e){return {result:"success",value:e}}function ao(e){return {result:"error",value:e}}function lo(e,t){return !!e&&!!e.parameters&&e.parameters.indexOf(t)>-1}function co(e){return "data-driven"===e["property-type"]}function ho(e){return lo(e.expression,"measure-light")}function uo(e){return lo(e.expression,"zoom")}function po(e){return !!e.expression&&e.expression.interpolated}function fo(e){return "object"==typeof e&&null!==e&&!Array.isArray(e)}function mo(e){return e}function _o(e,t){const i="color"===t.type,r=e.stops&&"object"==typeof e.stops[0][0],n=r||!(r||void 0!==e.property),o=e.type||(po(t)?"exponential":"interval");if(i&&((e=Lt({},e)).stops&&(e.stops=e.stops.map((e=>[e[0],hi.parse(e[1])]))),e.default=hi.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!yn[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let s,a,l;if("exponential"===o)s=vo;else if("interval"===o)s=xo;else if("categorical"===o){s=yo,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0];}else {if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=bo;}if(r){const i={},r=[];for(let t=0;t<e.stops.length;t++){const n=e.stops[t],o=n[0].zoom;void 0===i[o]&&(i[o]={zoom:o,type:e.type,property:e.property,default:e.default,stops:[]},r.push(o)),i[o].stops.push([n[0].value,n[1]]);}const n=[];for(const e of r)n.push([i[e].zoom,_o(i[e],t)]);const o={name:"linear"};return {kind:"composite",interpolationType:o,interpolationFactor:bn.interpolationFactor.bind(void 0,o),zoomStops:n.map((e=>e[0])),evaluate:({zoom:i},r)=>vo({stops:n,base:e.base},t,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return {kind:"camera",interpolationType:i,interpolationFactor:bn.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map((e=>e[0])),evaluate:({zoom:i})=>s(e,t,i,a,l)}}return {kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[e.property]:void 0;return void 0===n?go(e.default,t.default):s(e,t,n,a,l)}}}function go(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function yo(e,t,i,r,n){return go(typeof i===n?r[i]:void 0,e.default,t.default)}function xo(e,t,i){if("number"!==Si(i))return go(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=Hr(e.stops.map((e=>e[0])),i);return e.stops[n][1]}function vo(e,t,i){const r=void 0!==e.base?e.base:1;if("number"!==Si(i))return go(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const o=Hr(e.stops.map((e=>e[0])),i),s=function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}(i,r,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1];let c=Qr[t.type]||mo;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=yn[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),s));}return "function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,s)}}:c(a,l,s)}function bo(e,t,i){return "color"===t.type?i=hi.parse(i):"formatted"===t.type?i=pi.fromString(i.toString()):"resolvedImage"===t.type?i=fi.fromString(i.toString()):Si(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),go(i,e.default,t.default)}class wo{constructor(e,t,i){this.expression=e,this._warningHistory={},this._evaluator=new Di(i),this._defaultValue=t?function(e){return "color"===e.type&&(fo(e.default)||Array.isArray(e.default))?new hi(0,0,0,0):"color"===e.type?hi.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null;}evaluateWithoutErrorHandling(e,t,i,r,n,o,s,a){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,n,o,s,a){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new bi(`Expected value to be one of ${Object.keys(this._enumValues).map((e=>JSON.stringify(e))).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function To(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in oo}function Eo(e,t,i){const r=new $r(oo,[],t?function(e){const t={color:Zt,string:Gt,number:jt,enum:Gt,boolean:qt,formatted:Xt,resolvedImage:Yt};return "array"===e.type?Kt(t[e.value]||Wt,e.length):t[e.type]}(t):void 0,void 0,void 0,i),n=r.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return n?so(new wo(n,t,i)):ao(r.errors)}class Mo{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isLightConstant=i,this.isStateDependent="constant"!==e&&!Ur(t.expression),this.isConfigDependent=!Vr(t.expression);}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}}class Ao{constructor(e,t,i,r,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Ur(t.expression),this.isLightConstant=n,this.isConfigDependent=!Vr(t.expression),this.interpolationType=r;}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?bn.interpolationFactor(this.interpolationType,e,t,i):0}}function So(e,t,i){if("error"===(e=Eo(e,t,i)).result)return e;const r=e.value.expression,n=Nr(r);if(!n&&!co(t))return ao([new Ft("","data expressions not supported")]);const o=jr(r,["zoom","pitch","distance-from-center"]);if(!o&&!uo(t))return ao([new Ft("","zoom expressions not supported")]);const s=jr(r,["measure-light"]);if(!s&&!ho(t))return ao([new Ft("","measure-light expression not supported")]);const a=t.expression&&t.expression.relaxZoomRestriction,l=Co(r);return l||o||a?l instanceof Ft?ao([l]):l instanceof bn&&!po(t)?ao([new Ft("",'"interpolate" expressions cannot be used with this property')]):so(l?new Ao(n?"camera":"composite",e.value,l.labels,l instanceof bn?l.interpolation:void 0,s):new Mo(n?"constant":"source",e.value,s)):ao([new Ft("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Io{constructor(e,t){this._parameters=e,this._specification=t,Lt(this,_o(this._parameters,this._specification));}static deserialize(e){return new Io(e._parameters,e._specification)}static serialize(e){return {_parameters:e._parameters,_specification:e._specification}}}function Co(e){let t=null;if(e instanceof Mn)t=Co(e.result);else if(e instanceof Tn){for(const i of e.args)if(t=Co(i),t)break}else (e instanceof Yr||e instanceof bn)&&e.input instanceof ki&&"zoom"===e.input.name&&(t=e);return t instanceof Ft||e.eachChild((e=>{const i=Co(e);i instanceof Ft?t=i:t&&i&&t!==i&&(t=new Ft("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'));})),t}function zo(e){const t=e.key,i=e.value,r=e.valueSpec||{},n=e.objectElementValidators||{},o=e.style,s=e.styleSpec;let a=[];const l=Si(i);if("object"!==l)return [new Dt(t,i,`object expected, ${l} found`)];for(const e in i){const l=e.split(".")[0];let c;n[l]?c=n[l]:r[l]?c=ds:n["*"]?c=n["*"]:r["*"]&&(c=ds),c?a=a.concat(c({key:(t?`${t}.`:t)+e,value:i[e],valueSpec:r[l]||r["*"],style:o,styleSpec:s,object:i,objectKey:e},i)):a.push(new Rt(t,i[e],`unknown property "${e}"`));}for(const e in r)n[e]||r[e].required&&void 0===r[e].default&&void 0===i[e]&&a.push(new Dt(t,i,`missing required property "${e}"`));return a}function Po(e){const t=e.value,i=e.valueSpec,r=e.style,n=e.styleSpec,o=e.key,s=e.arrayElementValidator||ds;if("array"!==Si(t))return [new Dt(o,t,`array expected, ${Si(t)} found`)];if(i.length&&t.length!==i.length)return [new Dt(o,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.length<i["min-length"])return [new Dt(o,t,`array length at least ${i["min-length"]} expected, length ${t.length} found`)];let a={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum,function:void 0};n.$version<7&&(a.function=i.function),"object"===Si(i.value)&&(a=i.value);let l=[];for(let e=0;e<t.length;e++)l=l.concat(s({array:t,arrayIndex:e,value:t[e],valueSpec:a,style:r,styleSpec:n,key:`${o}[${e}]`},!0));return l}function Do(e){const t=e.key,i=e.value,r=e.valueSpec;let n=Si(i);if("number"===n&&i!=i&&(n="NaN"),"number"!==n)return [new Dt(t,i,`number expected, ${n} found`)];if("minimum"in r){let n=r.minimum;if("array"===Si(r.minimum)&&(n=r.minimum[e.arrayIndex]),i<n)return [new Dt(t,i,`${i} is less than the minimum value ${n}`)]}if("maximum"in r){let n=r.maximum;if("array"===Si(r.maximum)&&(n=r.maximum[e.arrayIndex]),i>n)return [new Dt(t,i,`${i} is greater than the maximum value ${n}`)]}return []}function Ro(e){const t=e.valueSpec,i=kt(e.value.type);let r,n,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Si(e.value.stops)&&"array"===Si(e.value.stops[0])&&"object"===Si(e.value.stops[0][0]),h=zo({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return [new Dt(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;return t=t.concat(Po({key:e.key,value:r,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:u})),"array"===Si(r)&&0===r.length&&t.push(new Dt(e.key,r,"array must have at least one stop")),t},default:function(e){return ds({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return "identity"===i&&a&&h.push(new Dt(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||h.push(new Dt(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!po(e.valueSpec)&&h.push(new Dt(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!co(e.valueSpec)?h.push(new Dt(e.key,e.value,"property functions not supported")):a&&!uo(e.valueSpec)&&h.push(new Dt(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||h.push(new Dt(e.key,e.value,'"property" property is required')),h;function u(e){let i=[];const r=e.value,a=e.key;if("array"!==Si(r))return [new Dt(a,r,`array expected, ${Si(r)} found`)];if(2!==r.length)return [new Dt(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Si(r[0]))return [new Dt(a,r,`object expected, ${Si(r[0])} found`)];if(void 0===r[0].zoom)return [new Dt(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return [new Dt(a,r,"object stop key must have value")];const t=kt(r[0].zoom);if("number"!=typeof t)return [new Dt(a,r[0].zoom,"stop zoom values must be numbers")];if(o&&o>t)return [new Dt(a,r[0].zoom,"stop zoom values must appear in ascending order")];t!==o&&(o=t,n=void 0,s={}),i=i.concat(zo({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Do,value:d}}));}else i=i.concat(d({key:`${a}[0]`,value:r[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},r));return To(Ot(r[1]))?i.concat([new Dt(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(ds({key:`${a}[1]`,value:r[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=Si(e.value),l=kt(e.value),c=null!==e.value?e.value:o;if(r){if(a!==r)return [new Dt(e.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return [new Dt(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return co(t)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Dt(e.key,c,r)]}return "categorical"!==i||"number"!==a||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&"number"==typeof l&&"number"==typeof n&&void 0!==n&&l<n?[new Dt(e.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in s?[new Dt(e.key,c,"stop domain values must be unique")]:(s[l]=!0,[])):[new Dt(e.key,c,`integer expected, found ${String(l)}`)]}}function Lo(e){const t=("property"===e.expressionContext?So:Eo)(Ot(e.value),e.valueSpec);if("error"===t.result)return t.value.map((t=>new Dt(`${e.key}${t.key}`,e.value,t.message)));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return [new Dt(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!Ur(i))return [new Dt(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return ko(i,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!jr(i,["zoom","feature-state"]))return [new Dt(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!Nr(i))return [new Dt(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return []}function ko(e,t){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const e of t.valueSpec.expression.parameters)i.delete(e);if(0===i.size)return [];const r=[];return e instanceof ki&&i.has(e.name)?[new Dt(t.key,t.value,`["${e.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(e.eachChild((e=>{r.push(...ko(e,t));})),r)}function Oo(e){const t=e.key,i=e.value,r=e.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(kt(i))&&n.push(new Dt(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(kt(i))&&n.push(new Dt(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function Bo(e){if(!0===e||!1===e)return !0;if(!Array.isArray(e)||0===e.length)return !1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return !1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!Bo(t)&&"boolean"!=typeof t)return !1;return !0;default:return !0}}function Fo(e,t="fill"){if(null==e)return {filter:()=>!0,needGeometry:!1,needFeature:!1};Bo(e)||(e=Zo(e));const i=e;let r=!0;try{r=function(e){if(!Vo(e))return e;let t=Ot(e);return Uo(t),t=No(t),t}(i);}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `);}const n=Pt[`filter_${t}`],o=Eo(r,n);let s=null;if("error"===o.result)throw new Error(o.value.map((e=>`${e.key}: ${e.message}`)).join(", "));s=(e,t,i)=>o.value.evaluate(e,t,{},i);let a=null,l=null;if(r!==i){const e=Eo(i,n);if("error"===e.result)throw new Error(e.value.map((e=>`${e.key}: ${e.message}`)).join(", "));a=(t,i,r,n,o)=>e.value.evaluate(t,i,{},r,void 0,void 0,n,o),l=!Nr(e.value.expression);}return {filter:s,dynamicFilter:a||void 0,needGeometry:qo(r),needFeature:!!l}}function No(e){if(!Array.isArray(e))return e;const t=function(e){if(jo.has(e[0]))for(let t=1;t<e.length;t++)if(Vo(e[t]))return !0;return e}(e);return !0===t?t:t.map((e=>No(e)))}function Uo(e){let t=!1;const i=[];if("case"===e[0]){for(let r=1;r<e.length-1;r+=2)t=t||Vo(e[r]),i.push(e[r+1]);i.push(e[e.length-1]);}else if("match"===e[0]){t=t||Vo(e[1]);for(let t=2;t<e.length-1;t+=2)i.push(e[t+1]);i.push(e[e.length-1]);}else if("step"===e[0]){t=t||Vo(e[1]);for(let t=1;t<e.length-1;t+=2)i.push(e[t+1]);}t&&(e.length=0,e.push("any",...i));for(let t=1;t<e.length;t++)Uo(e[t]);}function Vo(e){if(!Array.isArray(e))return !1;if("pitch"===(t=e[0])||"distance-from-center"===t)return !0;var t;for(let t=1;t<e.length;t++)if(Vo(e[t]))return !0;return !1}const jo=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function Go(e,t){return e<t?-1:e>t?1:0}function qo(e){if(!Array.isArray(e))return !1;if("within"===e[0]||"distance"===e[0])return !0;for(let t=1;t<e.length;t++)if(qo(e[t]))return !0;return !1}function Zo(e){if(!e)return !0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?$o(e[1],e[2],"=="):"!="===t?Xo($o(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?$o(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(Zo))):"all"===t?["all"].concat(e.slice(1).map(Zo)):"none"===t?["all"].concat(e.slice(1).map(Zo).map(Xo)):"in"===t?Wo(e[1],e.slice(2)):"!in"===t?Xo(Wo(e[1],e.slice(2))):"has"===t?Ho(e[1]):"!has"!==t||Xo(Ho(e[1]));var i;}function $o(e,t,i){switch(e){case"$type":return [`filter-type-${i}`,t];case"$id":return [`filter-id-${i}`,t];default:return [`filter-${i}`,e,t]}}function Wo(e,t){if(0===t.length)return !1;switch(e){case"$type":return ["filter-type-in",["literal",t]];case"$id":return ["filter-id-in",["literal",t]];default:return t.length>200&&!t.some((e=>typeof e!=typeof t[0]))?["filter-in-large",e,["literal",t.sort(Go)]]:["filter-in-small",e,["literal",t]]}}function Ho(e){switch(e){case"$type":return !0;case"$id":return ["filter-has-id"];default:return ["filter-has",e]}}function Xo(e){return ["!",e]}function Yo(e){return Bo(Ot(e.value))?Lo(Lt({},e,{expressionContext:"filter",valueSpec:e.styleSpec[`filter_${e.layerType||"fill"}`]})):Ko(e)}function Ko(e){const t=e.value,i=e.key;if("array"!==Si(t))return [new Dt(i,t,`array expected, ${Si(t)} found`)];const r=e.styleSpec;let n,o=[];if(t.length<1)return [new Dt(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Oo({key:`${i}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),kt(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===kt(t[1])&&o.push(new Dt(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new Dt(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(n=Si(t[1]),"string"!==n&&o.push(new Dt(`${i}[1]`,t[1],`string expected, ${n} found`)));for(let s=2;s<t.length;s++)n=Si(t[s]),"$type"===kt(t[1])?o=o.concat(Oo({key:`${i}[${s}]`,value:t[s],valueSpec:r.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==n&&"number"!==n&&"boolean"!==n&&o.push(new Dt(`${i}[${s}]`,t[s],`string, number, or boolean expected, ${n} found`));break;case"any":case"all":case"none":for(let r=1;r<t.length;r++)o=o.concat(Ko({key:`${i}[${r}]`,value:t[r],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":n=Si(t[1]),2!==t.length?o.push(new Dt(i,t,`filter array for "${t[0]}" operator must have 2 elements`)):"string"!==n&&o.push(new Dt(`${i}[1]`,t[1],`string expected, ${n} found`));}return o}function Jo(e,t){const i=e.key,r=e.style,n=e.layer,o=e.styleSpec,s=e.value,a=e.objectKey,l=o[`${t}_${e.layerType}`];if(!l)return [];const c=a.match(/^(.*)-transition$/);if("paint"===t&&c&&l[c[1]]&&l[c[1]].transition)return ds({key:i,value:s,valueSpec:o.transition,style:r,styleSpec:o});const h=e.valueSpec||l[a];if(!h)return [new Rt(i,s,`unknown property "${a}"`)];let u;if("string"===Si(s)&&co(h)&&!h.tokens&&(u=/^{([^}]+)}$/.exec(s))){const e=`\`{ "type": "identity", "property": ${u?JSON.stringify(u[1]):'"_"'} }\``;return [new Dt(i,s,`"${a}" does not support interpolation syntax\nUse an identity property function instead: ${e}.`)]}const d=[];if("symbol"===e.layerType)"text-field"!==a||!r||r.glyphs||r.imports||d.push(new Dt(i,s,'use of "text-field" requires a style "glyphs" property')),"text-font"===a&&fo(Ot(s))&&"identity"===kt(s.type)&&d.push(new Dt(i,s,'"text-font" does not support identity functions'));else if("model"===e.layerType&&"paint"===t&&n&&n.layout&&n.layout.hasOwnProperty("model-id")&&co(h)&&(ho(h)||uo(h))){const e=So(Ot(s),h),t=e.value.expression||e.value._styleExpression.expression;t&&!jr(t,["measure-light"])&&("model-emissive-strength"===a&&Nr(t)&&Ur(t)||d.push(new Dt(i,s,`${a} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`)));}return d.concat(ds({key:e.key,value:s,valueSpec:h,style:r,styleSpec:o,expressionContext:"property",propertyType:t,propertyKey:a}))}function Qo(e){return Jo(e,"paint")}function es(e){return Jo(e,"layout")}function ts(e){let t=[];const i=e.value,r=e.key,n=e.style,o=e.styleSpec;i.type||i.ref||t.push(new Dt(r,i,'either "type" or "ref" is required'));let s=kt(i.type);const a=kt(i.ref);if(i.id){const o=kt(i.id);for(let s=0;s<e.arrayIndex;s++){const e=n.layers[s];kt(e.id)===o&&t.push(new Dt(r,i.id,`duplicate layer id "${i.id}", previously used at line ${e.id.__line__}`));}}if("ref"in i){let e;["type","source","source-layer","filter","layout"].forEach((e=>{e in i&&t.push(new Dt(r,i[e],`"${e}" is prohibited for ref layers`));})),n.layers.forEach((t=>{kt(t.id)===a&&(e=t);})),e?e.ref?t.push(new Dt(r,i.ref,"ref cannot reference another ref layer")):s=kt(e.type):"string"==typeof a&&t.push(new Dt(r,i.ref,`ref layer "${a}" not found`));}else if("background"!==s&&"sky"!==s&&"slot"!==s)if(i.source){const e=n.sources&&n.sources[i.source],o=e&&kt(e.type);e?"vector"===o&&"raster"===s?t.push(new Dt(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===o&&"raster"!==s?t.push(new Dt(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s?t.push(new Dt(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||"geojson"===o&&e.lineMetrics||t.push(new Dt(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Dt(r,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new Dt(r,i.source,`source "${i.source}" not found`));}else t.push(new Dt(r,i,'missing required property "source"'));return t=t.concat(zo({key:r,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>ds({key:`${r}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:i,objectKey:"type"}),filter:e=>Yo(Lt({layerType:s},e)),layout:e=>zo({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>es(Lt({layerType:s},e))}}),paint:e=>zo({layer:i,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Qo(Lt({layerType:s,layer:i},e))}})}})),t}function is(e){const t=e.value,i=e.key,r=Si(t);return "string"!==r?[new Dt(i,t,`string expected, ${r} found`)]:[]}const rs={promoteId:function({key:e,value:t}){if("string"===Si(t))return is({key:e,value:t});{const i=[];for(const r in t)i.push(...is({key:`${e}.${r}`,value:t[r]}));return i}}};function ns(e){const t=e.value,i=e.key,r=e.styleSpec,n=e.style;if(!t.type)return [new Dt(i,t,'"type" is required')];const o=kt(t.type);let s=[];switch(["vector","raster","raster-dem"].includes(o)&&(t.url||t.tiles||s.push(new Dt(i,t,'Either "url" or "tiles" is required.'))),o){case"vector":case"raster":case"raster-dem":return s=s.concat(zo({key:i,value:t,valueSpec:r[`source_${o.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:rs})),s;case"geojson":if(s=zo({key:i,value:t,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:rs}),t.cluster)for(const e in t.clusterProperties){const[r,n]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;s.push(...Lo({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),s.push(...Lo({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}));}return s;case"video":return zo({key:i,value:t,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return zo({key:i,value:t,valueSpec:r.source_image,style:n,styleSpec:r});case"canvas":return [new Dt(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Oo({key:`${i}.type`,value:t.type,valueSpec:{values:os(r)},style:n,styleSpec:r})}}function os(e){return e.source.reduce(((t,i)=>{const r=e[i];return "enum"===r.type.type&&(t=t.concat(Object.keys(r.type.values))),t}),[])}function ss(e){const t=e.value;let i=[];if(!t)return i;const r=Si(t);return "string"!==r?(i=i.concat([new Dt(e.key,t,`string expected, "${r}" found`)]),i):(function(e){const t=-1===e.indexOf("://");try{return new URL(e,t?"http://example.com":void 0),!0}catch(e){return !1}}(t)||(i=i.concat([new Dt(e.key,t,`invalid url "${t}"`)])),i)}function as(e){const t=e.value,i=e.styleSpec,r=i.light,n=e.style;let o=[];const s=Si(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Dt("light",t,`object expected, ${s} found`)]),o;for(const e in t){const s=e.match(/^(.*)-transition$/);o=o.concat(s&&r[s[1]]&&r[s[1]].transition?ds({key:e,value:t[e],valueSpec:i.transition,style:n,styleSpec:i}):r[e]?ds({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i}):[new Dt(e,t[e],`unknown property "${e}"`)]);}return o}function ls(e){const t=e.value;let i=[];if(!t)return i;const r=Si(t);if("object"!==r)return i=i.concat([new Dt("light-3d",t,`object expected, ${r} found`)]),i;const n=e.styleSpec,o=n["light-3d"],s=e.key,a=e.style,l=e.style.lights;for(const e of ["type","id"])if(!(e in t))return i=i.concat([new Dt("light-3d",t,`missing property ${e} on light`)]),i;if(t.type&&l)for(let r=0;r<e.arrayIndex;r++){const e=kt(t.type),n=l[r];kt(n.type)===e&&i.push(new Dt(s,t.id,`duplicate light type "${t.type}", previously defined at line ${n.id.__line__}`));}const c=`properties_light_${t.type}`;if(!(c in n))return i=i.concat([new Dt("light-3d",t,`Invalid light type ${t.type}`)]),i;const h=n[c];for(const r in t)if("properties"===r){const o=t[r],s=Si(o);if("object"!==s)return i=i.concat([new Dt("properties",o,`object expected, ${s} found`)]),i;for(const t in o)i=i.concat(h[t]?ds({key:t,value:o[t],valueSpec:h[t],style:a,styleSpec:n}):[new Rt(e.key,o[t],`unknown property "${t}"`)]);}else {const e=r.match(/^(.*)-transition$/);i=i.concat(e&&o[e[1]]&&o[e[1]].transition?ds({key:r,value:t[r],valueSpec:n.transition,style:a,styleSpec:n}):o[r]?ds({key:r,value:t[r],valueSpec:o[r],style:a,styleSpec:n}):[new Rt(r,t[r],`unknown property "${r}"`)]);}return i}function cs(e){const t=e.value,i=e.key,r=e.style,n=e.styleSpec,o=n.terrain;let s=[];const a=Si(t);if(void 0===t)return s;if("null"===a)return s;if("object"!==a)return s=s.concat([new Dt("terrain",t,`object expected, ${a} found`)]),s;for(const e in t){const i=e.match(/^(.*)-transition$/);s=s.concat(i&&o[i[1]]&&o[i[1]].transition?ds({key:e,value:t[e],valueSpec:n.transition,style:r,styleSpec:n}):o[e]?ds({key:e,value:t[e],valueSpec:o[e],style:r,styleSpec:n}):[new Rt(e,t[e],`unknown property "${e}"`)]);}if(t.source){const e=r.sources&&r.sources[t.source],n=e&&kt(e.type);e?"raster-dem"!==n&&s.push(new Dt(i,t.source,`terrain cannot be used with a source of type ${String(n)}, it only be used with a "raster-dem" source type`)):s.push(new Dt(i,t.source,`source "${t.source}" not found`));}else s.push(new Dt(i,t,'terrain is missing required property "source"'));return s}function hs(e){const t=e.value,i=e.style,r=e.styleSpec,n=r.fog;let o=[];const s=Si(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Dt("fog",t,`object expected, ${s} found`)]),o;for(const e in t){const s=e.match(/^(.*)-transition$/);o=o.concat(s&&n[s[1]]&&n[s[1]].transition?ds({key:e,value:t[e],valueSpec:r.transition,style:i,styleSpec:r}):n[e]?ds({key:e,value:t[e],valueSpec:n[e],style:i,styleSpec:r}):[new Rt(e,t[e],`unknown property "${e}"`)]);}return o}const us={"*":()=>[],array:Po,boolean:function(e){const t=e.value,i=e.key,r=Si(t);return "boolean"!==r?[new Dt(i,t,`boolean expected, ${r} found`)]:[]},number:Do,color:function(e){const t=e.key,i=e.value,r=Si(i);return "string"!==r?[new Dt(t,i,`color expected, ${r} found`)]:null===ri(i)?[new Dt(t,i,`color expected, "${i}" found`)]:[]},enum:Oo,filter:Yo,function:Ro,layer:ts,object:zo,source:ns,model:ss,light:as,"light-3d":ls,terrain:cs,fog:hs,string:is,formatted:function(e){return 0===is(e).length?[]:Lo(e)},resolvedImage:function(e){return 0===is(e).length?[]:Lo(e)},projection:function(e){const t=e.value,i=e.styleSpec,r=i.projection,n=e.style;let o=[];const s=Si(t);if("object"===s)for(const e in t)o=o.concat(ds({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i}));else "string"!==s&&(o=o.concat([new Dt("projection",t,`object or string expected, ${s} found`)]));return o},import:function(e){const{value:t,styleSpec:i}=e,{data:r,...n}=t;Object.defineProperty(n,"__line__",{value:t.__line__,enumerable:!1});let o=zo(Lt({},e,{value:n,valueSpec:i.import}));return ""===kt(n.id)&&o.push(new Dt(`${e.key}.id`,n,"import id can't be an empty string")),r&&(o=o.concat(fs(r,i,{key:`${e.key}.data`}))),o}};function ds(e,t=!1){const i=e.value,r=e.valueSpec,n=e.styleSpec;if(r.expression&&fo(kt(i)))return Ro(e);if(r.expression&&To(Ot(i)))return Lo(e);if(r.type&&us[r.type]){const i=us[r.type](e);return !0===t&&i.length>0&&"array"===Si(e.value)?Lo(e):i}return zo(Lt({},e,{valueSpec:r.type?n[r.type]:r}))}function ps(e){const t=e.value,i=e.key,r=is(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new Dt(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new Dt(i,t,'"glyphs" url must include a "{range}" token'))),r}function fs(e,t=Pt,i={}){return ds({key:i.key||"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:ps,"*":()=>[]}})}function ms(e,t=Pt){return As(fs(e,t))}const _s=e=>As(ns(e)),gs=e=>As(as(e)),ys=e=>As(ls(e)),xs=e=>As(cs(e)),vs=e=>As(hs(e)),bs=e=>As(ts(e)),ws=e=>As(Yo(e)),Ts=e=>As(Qo(e)),Es=e=>As(es(e)),Ms=e=>As(ss(e));function As(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function Ss(e,t){let i=!1;if(t&&t.length)for(const r of t)r instanceof Rt?H(r.message):(e.fire(new Ct(new Error(r.message))),i=!0);return i}var Is=zs,Cs=3;function zs(e,t,i){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var n=new Int32Array(this.arrayBuffer);e=n[0],this.d=(t=n[1])+2*(i=n[2]);for(var o=0;o<this.d*this.d;o++){var s=n[Cs+o],a=n[Cs+o+1];r.push(s===a?null:n.subarray(s,a));}var l=n[Cs+r.length+1];this.keys=n.subarray(n[Cs+r.length],l),this.bboxes=n.subarray(l),this.insert=this._insertReadonly;}else {this.d=t+2*i;for(var c=0;c<this.d*this.d;c++)r.push([]);this.keys=[],this.bboxes=[];}this.n=t,this.extent=e,this.padding=i,this.scale=t/e,this.uid=0;var h=i/t*e;this.min=-h,this.max=e+h;}zs.prototype.insert=function(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n);},zs.prototype._insertReadonly=function(){throw "Cannot insert into a GridIndex created from an ArrayBuffer."},zs.prototype._insertCell=function(e,t,i,r,n,o){this.cells[n].push(o);},zs.prototype.query=function(e,t,i,r,n){var o=this.min,s=this.max;if(e<=o&&t<=o&&s<=i&&s<=r&&!n)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(e,t,i,r,this._queryCell,a,{},n),a},zs.prototype._queryCell=function(e,t,i,r,n,o,s,a){var l=this.cells[n];if(null!==l)for(var c=this.keys,h=this.bboxes,u=0;u<l.length;u++){var d=l[u];if(void 0===s[d]){var p=4*d;(a?a(h[p+0],h[p+1],h[p+2],h[p+3]):e<=h[p+2]&&t<=h[p+3]&&i>=h[p+0]&&r>=h[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1;}}},zs.prototype._forEachCell=function(e,t,i,r,n,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=l;d<=h;d++)for(var p=c;p<=u;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&n.call(this,e,t,i,r,f,o,s,a))return}},zs.prototype._convertFromCellCoord=function(e){return (e-this.padding)/this.scale},zs.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},zs.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=Cs+this.cells.length+1+1,i=0,r=0;r<this.cells.length;r++)i+=this.cells[r].length;var n=new Int32Array(t+i+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;for(var o=t,s=0;s<e.length;s++){var a=e[s];n[Cs+s]=o,n.set(a,o),o+=a.length;}return n[Cs+e.length]=o,n.set(this.keys,o),n[Cs+e.length+1]=o+=this.keys.length,n.set(this.bboxes,o),o+=this.bboxes.length,n.buffer};var Ps=d(Is);const Ds={};function Rs(e,t,i={}){Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Ds[t]={klass:e,omit:i.omit||[]};}Rs(Object,"Object"),Ps.serialize=function(e,t){const i=e.toArrayBuffer();return t&&t.add(i),{buffer:i}},Ps.deserialize=function(e){return new Ps(e.buffer)},Object.defineProperty(Ps,"name",{value:"Grid"}),Rs(Ps,"Grid"),Rs(hi,"Color"),Rs(Error,"Error"),Rs(xe,"AJAXError"),Rs(fi,"ResolvedImage"),Rs(Io,"StylePropertyFunction"),Rs(wo,"StyleExpression",{omit:["_evaluator"]}),Rs(Ao,"ZoomDependentExpression"),Rs(Mo,"ZoomConstantExpression"),Rs(ki,"CompoundExpression",{omit:["_evaluate"]});for(const e in oo)Ds[oo[e]._classRegistryKey]||Rs(oo[e],`Expression${e}`);function Ls(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function ks(e){return t.ImageBitmap&&e instanceof t.ImageBitmap}function Os(e,i){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp)return e;if(Ls(e)||ks(e))return i&&i.add(e),e;if(ArrayBuffer.isView(e)){const t=e;return i&&i.add(t.buffer),t}if(e instanceof t.ImageData)return i&&i.add(e.data.buffer),e;if(Array.isArray(e)){const t=[];for(const r of e)t.push(Os(r,i));return t}if(e instanceof Map){const t={$name:"Map"};for(const[i,r]of e.entries())t[i]=Os(r);return t}if("object"==typeof e){const t=e.constructor,r=t._classRegistryKey;if(!r)throw new Error(`can't serialize object of unregistered class ${r}`);const n=t.serialize?t.serialize(e,i):{};if(!t.serialize){for(const t in e)e.hasOwnProperty(t)&&(Ds[r].omit.indexOf(t)>=0||(n[t]=Os(e[t],i)));e instanceof Error&&(n.message=e.message);}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return "Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof e)}function Bs(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||Ls(e)||ks(e)||ArrayBuffer.isView(e)||e instanceof t.ImageData)return e;if(Array.isArray(e))return e.map(Bs);if("object"==typeof e){const t=e.$name||"Object";if("Map"===t){const t=new Map;for(const i of Object.keys(e))"$name"!==i&&t.set(i,Bs(e[i]));return t}const{klass:i}=Ds[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const r=Object.create(i.prototype);for(const t of Object.keys(e))"$name"!==t&&(r[t]=Bs(e[t]));return r}throw new Error("can't deserialize object of type "+typeof e)}const Fs={"Latin-1 Supplement":e=>e>=128&&e<=255,Arabic:e=>e>=1536&&e<=1791,"Arabic Supplement":e=>e>=1872&&e<=1919,"Arabic Extended-A":e=>e>=2208&&e<=2303,"Hangul Jamo":e=>e>=4352&&e<=4607,"Unified Canadian Aboriginal Syllabics":e=>e>=5120&&e<=5759,Khmer:e=>e>=6016&&e<=6143,"Unified Canadian Aboriginal Syllabics Extended":e=>e>=6320&&e<=6399,"General Punctuation":e=>e>=8192&&e<=8303,"Letterlike Symbols":e=>e>=8448&&e<=8527,"Number Forms":e=>e>=8528&&e<=8591,"Miscellaneous Technical":e=>e>=8960&&e<=9215,"Control Pictures":e=>e>=9216&&e<=9279,"Optical Character Recognition":e=>e>=9280&&e<=9311,"Enclosed Alphanumerics":e=>e>=9312&&e<=9471,"Geometric Shapes":e=>e>=9632&&e<=9727,"Miscellaneous Symbols":e=>e>=9728&&e<=9983,"Miscellaneous Symbols and Arrows":e=>e>=11008&&e<=11263,"CJK Radicals Supplement":e=>e>=11904&&e<=12031,"Kangxi Radicals":e=>e>=12032&&e<=12255,"Ideographic Description Characters":e=>e>=12272&&e<=12287,"CJK Symbols and Punctuation":e=>e>=12288&&e<=12351,Hiragana:e=>e>=12352&&e<=12447,Katakana:e=>e>=12448&&e<=12543,Bopomofo:e=>e>=12544&&e<=12591,"Hangul Compatibility Jamo":e=>e>=12592&&e<=12687,Kanbun:e=>e>=12688&&e<=12703,"Bopomofo Extended":e=>e>=12704&&e<=12735,"CJK Strokes":e=>e>=12736&&e<=12783,"Katakana Phonetic Extensions":e=>e>=12784&&e<=12799,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"CJK Unified Ideographs Extension A":e=>e>=13312&&e<=19903,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Yi Syllables":e=>e>=40960&&e<=42127,"Yi Radicals":e=>e>=42128&&e<=42191,"Hangul Jamo Extended-A":e=>e>=43360&&e<=43391,"Hangul Syllables":e=>e>=44032&&e<=55215,"Hangul Jamo Extended-B":e=>e>=55216&&e<=55295,"Private Use Area":e=>e>=57344&&e<=63743,"CJK Compatibility Ideographs":e=>e>=63744&&e<=64255,"Arabic Presentation Forms-A":e=>e>=64336&&e<=65023,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Arabic Presentation Forms-B":e=>e>=65136&&e<=65279,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519,"CJK Unified Ideographs Extension B":e=>e>=131072&&e<=173791};function Ns(e){for(const t of e)if(js(t.charCodeAt(0)))return !0;return !1}function Us(e){for(const t of e)if(!Vs(t.charCodeAt(0)))return !1;return !0}function Vs(e){return !(Fs.Arabic(e)||Fs["Arabic Supplement"](e)||Fs["Arabic Extended-A"](e)||Fs["Arabic Presentation Forms-A"](e)||Fs["Arabic Presentation Forms-B"](e))}function js(e){return !(746!==e&&747!==e&&(e<4352||!(Fs["Bopomofo Extended"](e)||Fs.Bopomofo(e)||Fs["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||Fs["CJK Compatibility Ideographs"](e)||Fs["CJK Compatibility"](e)||Fs["CJK Radicals Supplement"](e)||Fs["CJK Strokes"](e)||!(!Fs["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Fs["CJK Unified Ideographs Extension A"](e)||Fs["CJK Unified Ideographs"](e)||Fs["Enclosed CJK Letters and Months"](e)||Fs["Hangul Compatibility Jamo"](e)||Fs["Hangul Jamo Extended-A"](e)||Fs["Hangul Jamo Extended-B"](e)||Fs["Hangul Jamo"](e)||Fs["Hangul Syllables"](e)||Fs.Hiragana(e)||Fs["Ideographic Description Characters"](e)||Fs.Kanbun(e)||Fs["Kangxi Radicals"](e)||Fs["Katakana Phonetic Extensions"](e)||Fs.Katakana(e)&&12540!==e||!(!Fs["Halfwidth and Fullwidth Forms"](e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!Fs["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||Fs["Unified Canadian Aboriginal Syllabics"](e)||Fs["Unified Canadian Aboriginal Syllabics Extended"](e)||Fs["Vertical Forms"](e)||Fs["Yijing Hexagram Symbols"](e)||Fs["Yi Syllables"](e)||Fs["Yi Radicals"](e))))}function Gs(e){return !(js(e)||function(e){return !!(Fs["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||Fs["General Punctuation"](e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||Fs["Letterlike Symbols"](e)||Fs["Number Forms"](e)||Fs["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||Fs["Control Pictures"](e)&&9251!==e||Fs["Optical Character Recognition"](e)||Fs["Enclosed Alphanumerics"](e)||Fs["Geometric Shapes"](e)||Fs["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Fs["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Fs["CJK Symbols and Punctuation"](e)||Fs.Katakana(e)||Fs["Private Use Area"](e)||Fs["CJK Compatibility Forms"](e)||Fs["Small Form Variants"](e)||Fs["Halfwidth and Fullwidth Forms"](e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function qs(e){return e>=1424&&e<=2303||Fs["Arabic Presentation Forms-A"](e)||Fs["Arabic Presentation Forms-B"](e)}function Zs(e,t){return !(!t&&qs(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||Fs.Khmer(e))}function $s(e){for(const t of e)if(qs(t.charCodeAt(0)))return !0;return !1}const Ws="deferred",Hs="loading",Xs="loaded";let Ys=null,Ks="unavailable",Js=null;const Qs=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Ks="error"),Ys&&Ys(e);};function ea(){ta.fire(new It("pluginStateChange",{pluginStatus:Ks,pluginURL:Js}));}const ta=new zt,ia=function(){return Ks},ra=function(){if(Ks!==Ws||!Js)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Ks=Hs,ea(),Js&&Te({url:Js},(e=>{e?Qs(e):(Ks=Xs,ea());}));},na={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Ks===Xs||null!=na.applyArabicShaping,isLoading:()=>Ks===Hs,setState(e){Ks=e.pluginStatus,Js=e.pluginURL;},isParsed:()=>null!=na.applyArabicShaping&&null!=na.processBidirectionalText&&null!=na.processStyledBidirectionalText,getPluginURL:()=>Js};class oa{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch,this.brightness=t.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0);}isSupportedScript(e){return function(e,t){for(const i of e)if(!Zs(i.charCodeAt(0),t))return !1;return !0}(e,na.isLoaded())}}class sa{constructor(e,t,i){this.property=e,this.value=t,this.expression=function(e,t,i){if(fo(e))return new Io(e,t);if(To(e)||Array.isArray(e)&&e.length>0){const r=So(e,t,i);if("error"===r.result)throw new Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(", "));return r.value}{let i=e;return "string"==typeof e&&"color"===t.type&&(i=hi.parse(e)),{kind:"constant",isConfigDependent:!1,evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i);}isDataDriven(){return "source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class aa{constructor(e,t){this.property=e,this.value=new sa(e,void 0,t);}transitioned(e,t){return new ca(this.property,this.value,t,k({},e.transition,this.transition),e.now)}untransitioned(){return new ca(this.property,this.value,null,{},0)}}class la{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._options=t,this.isConfigDependent=!1;}getValue(e){return $(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new aa(this._values[e].property,this._options)),this._values[e].value=new sa(this._values[e].property,null===t?void 0:$(t),this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].value.expression.isConfigDependent;}setTransitionOrValue(e,t){t&&(this._options=t);const i=this._properties.properties;if(e)for(const t in e){const r=e[t];if(G(t,"-transition")){const e=t.slice(0,-11);i[e]&&this.setTransition(e,r);}else i[t]&&this.setValue(t,r);}}getTransition(e){return $(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new aa(this._values[e].property)),this._values[e].transition=$(t)||void 0;}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r);}return e}transitioned(e,t){const i=new ha(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new ha(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class ca{constructor(e,t,i,r,n){const o=r.delay||0,s=r.duration||0;n=n||0,this.property=e,this.value=t,this.begin=n+o,this.end=this.begin+s,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i);}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return o.possiblyEvaluate(e,t,i);{const s=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,t,i),n,M(s))}}return n}}class ha{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues);}possiblyEvaluate(e,t,i){const r=new pa(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return !0;return !1}}class ua{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultPropertyValues),this._options=t,this.isConfigDependent=!1;}getValue(e){return $(this._values[e].value)}setValue(e,t){this._values[e]=new sa(this._values[e].property,null===t?void 0:$(t),this._options),this.isConfigDependent=this.isConfigDependent||this._values[e].expression.isConfigDependent;}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);}return e}possiblyEvaluate(e,t,i){const r=new pa(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}}class da{constructor(e,t,i){this.property=e,this.value=t,this.parameters=i;}isConstant(){return "constant"===this.value.kind}constantOr(e){return "constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,r){return this.property.evaluate(this.value,this.parameters,e,t,i,r)}}class pa{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues);}get(e){return this._values[e]}}class fa{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,i){const r=Qr[this.specification.type];return r?r(e,t,i):e}}class ma{constructor(e,t){this.specification=e,this.overrides=t;}possiblyEvaluate(e,t,i,r){return new da(this,"constant"===e.expression.kind||"camera"===e.expression.kind?{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)}:e.expression,t)}interpolate(e,t,i){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new da(this,{kind:"constant",value:void 0},e.parameters);const r=Qr[this.specification.type];return r?new da(this,{kind:"constant",value:r(e.value.value,t.value.value,i)},e.parameters):e}evaluate(e,t,i,r,n,o){return "constant"===e.kind?e.value:e.evaluate(t,i,r,n,o)}}class _a{constructor(e){this.specification=e;}possiblyEvaluate(e,t,i,r){return !!e.expression.evaluate(t,null,{},i,r)}interpolate(){return !1}}class ga{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new oa(0,{});for(const i in e){const r=e[i];r.specification.overridable&&this.overridableProperties.push(i);const n=this.defaultPropertyValues[i]=new sa(r,void 0),o=this.defaultTransitionablePropertyValues[i]=new aa(r);this.defaultTransitioningPropertyValues[i]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[i]=n.possiblyEvaluate(t);}}}Rs(ma,"DataDrivenProperty"),Rs(fa,"DataConstantProperty"),Rs(_a,"ColorRampProperty");const ya="";function xa(e){return e.indexOf(ya)>=0}function va(e,t){return t?`${e}${ya}${t}`:e}function ba(e){const t=e.indexOf(ya);return t>=0?e.slice(0,t):e}const wa="-transition";class Ta extends zt{constructor(e,t,i){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&"slot"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),this.options=i,e.slot&&(this.slot=e.slot),t.layout&&(this._unevaluatedLayout=new ua(t.layout,i),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),t.paint)){this._transitionablePaint=new la(t.paint,i);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new pa(t.paint);}}setScope(e){this.scope=e,this.fqid=va(this.id,e);}getLayoutProperty(e){return "visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,i={}){if(null!=t&&this._validate(Es,`layers.${this.id}.layout.${e}`,e,t,i))return;if("custom"===this.type&&"visibility"===e)return void(this.visibility=t);const r=this._unevaluatedLayout;r._properties.properties[e]&&(r.setValue(e,t),this.isConfigDependent=this.isConfigDependent||r.isConfigDependent,"visibility"===e&&this.possiblyEvaluateVisibility());}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0});}getPaintProperty(e){return G(e,wa)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(Ts,`layers.${this.id}.paint.${e}`,e,t,i))return !1;const r=this._transitionablePaint,n=r._properties.properties;if(G(e,wa)){const i=e.slice(0,-11);return n[i]&&r.setTransition(i,t||void 0),!1}if(!n[e])return !1;const o=r._values[e],s=o.value.isDataDriven(),a=o.value;r.setValue(e,t),this.isConfigDependent=this.isConfigDependent||r.isConfigDependent,this._handleSpecialPaintPropertyUpdate(e);const l=r._values[e].value,c=l.isDataDriven(),h=G(e,"pattern")||"line-dasharray"===e;return c||s||h||this._handleOverridablePaintPropertyUpdate(e,a,l)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return !1}isHidden(e){return !!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t);}serialize(){return Z({id:this.id,type:this.type,slot:this.slot,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()},((e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length)))}_validate(e,t,i,r,n={}){return (!n||!1!==n.validate)&&Ss(this,e.call(ms,{key:t,layerType:this.type,objectKey:i,value:r,styleSpec:Pt,style:{glyphs:!0,sprite:!0}}))}is3D(){return !1}isSky(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}hasShadowPass(){return !1}canCastShadows(){return !1}hasLightBeamPass(){return !1}cutoffRange(){return 0}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof da&&co(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return !0}return !1}compileFilter(){this._filterCompiled||(this._featureFilter=Fo(this.filter),this._filterCompiled=!0);}invalidateCompiledFilter(){this._filterCompiled=!1;}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(){this._stats&&(this._stats.numRenderedVerticesInShadowPass=0,this._stats.numRenderedVerticesInTransparentPass=0);}}class Ea{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set;}isDirty(){return this._changed}setDirty(){this._changed=!0;}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty();}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e];}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty();}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty();}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id];}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty();}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty();}resetUpdatedImages(){this._updatedImages.clear();}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear();}}const Ma={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Aa{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class Sa{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.add(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews());}clear(){this.length=0;}resize(e){this.reserve(e),this.length=e;}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t);}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null;}}function Ia(e,t=1){let i=0,r=0;return {members:e.map((e=>{const n=Ma[e.type].BYTES_PER_ELEMENT,o=i=Ca(i,Math.max(t,n)),s=e.components||1;return r=Math.max(r,n),i+=n*s,{name:e.name,type:e.type,components:s,offset:o}})),size:Ca(i,Math.max(r,t)),alignment:t}}function Ca(e,t){return Math.ceil(e/t)*t}class za extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}za.prototype.bytesPerElement=4,Rs(za,"StructArrayLayout2i4");class Pa extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}Pa.prototype.bytesPerElement=6,Rs(Pa,"StructArrayLayout3i6");class Da extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}Da.prototype.bytesPerElement=8,Rs(Da,"StructArrayLayout4i8");class Ra extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=o,e}}Ra.prototype.bytesPerElement=10,Rs(Ra,"StructArrayLayout5i10");class La extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=6*e,c=12*e,h=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[h+2]=a,e}}La.prototype.bytesPerElement=12,Rs(La,"StructArrayLayout2i4ub1f12");class ka extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}ka.prototype.bytesPerElement=16,Rs(ka,"StructArrayLayout4f16");class Oa extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=6*e,a=3*e;return this.uint16[s+0]=t,this.uint16[s+1]=i,this.uint16[s+2]=r,this.uint16[s+3]=n,this.float32[a+2]=o,e}}Oa.prototype.bytesPerElement=12,Rs(Oa,"StructArrayLayout4ui1f12");class Ba extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.uint16[o+0]=t,this.uint16[o+1]=i,this.uint16[o+2]=r,this.uint16[o+3]=n,e}}Ba.prototype.bytesPerElement=8,Rs(Ba,"StructArrayLayout4ui8");class Fa extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}Fa.prototype.bytesPerElement=12,Rs(Fa,"StructArrayLayout6i12");class Na extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,o,s,a,l,c,h,u)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=n,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,e}}Na.prototype.bytesPerElement=24,Rs(Na,"StructArrayLayout4i4ui4i24");class Ua extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,e}}Ua.prototype.bytesPerElement=20,Rs(Ua,"StructArrayLayout3i3f20");class Va extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}Va.prototype.bytesPerElement=4,Rs(Va,"StructArrayLayout1ul4");class ja extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}ja.prototype.bytesPerElement=4,Rs(ja,"StructArrayLayout2ui4");class Ga extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,n,o,s,a,l,c,h,u,d)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=h,this.uint32[m+8]=u,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}Ga.prototype.bytesPerElement=40,Rs(Ga,"StructArrayLayout5i4f1i1ul2ui40");class qa extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,e}}qa.prototype.bytesPerElement=16,Rs(qa,"StructArrayLayout3i2i2i16");class Za extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,e}}Za.prototype.bytesPerElement=16,Rs(Za,"StructArrayLayout2f1f2i16");class $a extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=12*e,s=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=i,this.float32[s+1]=r,this.float32[s+2]=n,e}}$a.prototype.bytesPerElement=12,Rs($a,"StructArrayLayout2ub2f12");class Wa extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}Wa.prototype.bytesPerElement=6,Rs(Wa,"StructArrayLayout3ui6");class Ha extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b){const w=30*e,T=15*e,E=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=h,this.uint16[w+16]=u,this.uint16[w+17]=d,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[E+58]=b,e}}Ha.prototype.bytesPerElement=60,Rs(Ha,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Xa extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,M,A,S,I,C,z,P){const D=this.length;return this.resize(D+1),this.emplace(D,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,M,A,S,I,C,z,P)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,M,A,S,I,C,z,P,D){const R=20*e,L=40*e,k=80*e;return this.float32[R+0]=t,this.float32[R+1]=i,this.int16[L+4]=r,this.int16[L+5]=n,this.int16[L+6]=o,this.int16[L+7]=s,this.int16[L+8]=a,this.int16[L+9]=l,this.int16[L+10]=c,this.int16[L+11]=h,this.int16[L+12]=u,this.uint16[L+13]=d,this.uint16[L+14]=p,this.uint16[L+15]=f,this.uint16[L+16]=m,this.uint16[L+17]=_,this.uint16[L+18]=g,this.uint16[L+19]=y,this.uint16[L+20]=x,this.uint16[L+21]=v,this.uint16[L+22]=b,this.uint16[L+23]=w,this.uint16[L+24]=T,this.uint16[L+25]=E,this.uint16[L+26]=M,this.uint16[L+27]=A,this.uint32[R+14]=S,this.float32[R+15]=I,this.float32[R+16]=C,this.float32[R+17]=z,this.float32[R+18]=P,this.uint8[k+76]=D,e}}Xa.prototype.bytesPerElement=80,Rs(Xa,"StructArrayLayout2f9i15ui1ul4f1ub80");class Ya extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}Ya.prototype.bytesPerElement=4,Rs(Ya,"StructArrayLayout1f4");class Ka extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,this.float32[s+4]=o,e}}Ka.prototype.bytesPerElement=20,Rs(Ka,"StructArrayLayout5f20");class Ja extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,e}}Ja.prototype.bytesPerElement=28,Rs(Ja,"StructArrayLayout7f28");class Qa extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=r,this.uint16[o+4]=n,e}}Qa.prototype.bytesPerElement=12,Rs(Qa,"StructArrayLayout1ul3ui12");class el extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}el.prototype.bytesPerElement=2,Rs(el,"StructArrayLayout1ui2");class tl extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}tl.prototype.bytesPerElement=12,Rs(tl,"StructArrayLayout3f12");class il extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}il.prototype.bytesPerElement=8,Rs(il,"StructArrayLayout2f8");class rl extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=16*e;return this.float32[g+0]=t,this.float32[g+1]=i,this.float32[g+2]=r,this.float32[g+3]=n,this.float32[g+4]=o,this.float32[g+5]=s,this.float32[g+6]=a,this.float32[g+7]=l,this.float32[g+8]=c,this.float32[g+9]=h,this.float32[g+10]=u,this.float32[g+11]=d,this.float32[g+12]=p,this.float32[g+13]=f,this.float32[g+14]=m,this.float32[g+15]=_,e}}rl.prototype.bytesPerElement=64,Rs(rl,"StructArrayLayout16f64");class nl extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=10*e,c=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=i,this.uint16[l+2]=r,this.uint16[l+3]=n,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,e}}nl.prototype.bytesPerElement=20,Rs(nl,"StructArrayLayout4ui3f20");class ol extends Sa{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer);}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint8[1*e+0]=t,e}}ol.prototype.bytesPerElement=1,Rs(ol,"StructArrayLayout1ub1");class sl extends Aa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}sl.prototype.size=40;class al extends Ga{get(e){return new sl(this,e)}}Rs(al,"CollisionBoxArray");class ll extends Aa{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e;}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e;}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e;}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e;}}ll.prototype.size=60;class cl extends Ha{get(e){return new ll(this,e)}}Rs(cl,"PlacedSymbolArray");class hl extends Aa{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(e){this._structArray.uint32[this._pos4+14]=e;}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(e){this._structArray.float32[this._pos4+18]=e;}get hasIconTextFit(){return this._structArray.uint8[this._pos1+76]}}hl.prototype.size=80;class ul extends Xa{get(e){return new hl(this,e)}}Rs(ul,"SymbolInstanceArray");class dl extends Ya{getoffsetX(e){return this.float32[1*e+0]}}Rs(dl,"GlyphOffsetArray");class pl extends za{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Rs(pl,"SymbolLineVertexArray");class fl extends Aa{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}fl.prototype.size=12;class ml extends Qa{get(e){return new fl(this,e)}}Rs(ml,"FeatureIndexArray");class _l extends ja{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Rs(_l,"FillExtrusionCentroidArray");const gl=Ia([{name:"a_pos",components:2,type:"Int16"}],4),yl=Ia([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class xl{constructor(e=[]){this.segments=e;}_prepareSegment(e,t,i,r){let n=this.segments[this.segments.length-1];return e>xl.MAX_VERTEX_ARRAY_LENGTH&&H(`Max vertices per segment is ${xl.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>xl.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:t,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}prepareSegment(e,t,i,r){return this._prepareSegment(e,t.length,i.length,r)}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy();}static simpleSegment(e,t,i,r){return new xl([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function vl(e,t){return 256*(e=z(Math.floor(e),0,255))+z(Math.floor(t),0,255)}xl.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Rs(xl,"SegmentVector");const bl=Ia([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),wl=Ia([{name:"a_dash",components:4,type:"Uint16"}]);var Tl={exports:{}},El={exports:{}};!function(e){e.exports=function(e,t){var i,r,n,o,s,a,l,c;for(r=e.length-(i=3&e.length),n=t,s=3432918353,a=461845907,c=0;c<r;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295;}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0};}(El);var Ml=El.exports,Al={exports:{}};!function(e){e.exports=function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16);}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0};}(Al);var Sl=Ml,Il=Al.exports;Tl.exports=Sl,Tl.exports.murmur3=Sl,Tl.exports.murmur2=Il;var Cl=d(Tl.exports);class zl{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1;}add(e,t,i,r){this.ids.push(Pl(e)),this.positions.push(t,i,r);}eachPosition(e,t){const i=Pl(e);let r=0,n=this.ids.length-1;for(;r<n;){const e=r+n>>1;this.ids[e]>=i?n=e:r=e+1;}for(;this.ids[r]===i;)t(this.positions[3*r],this.positions[3*r+1],this.positions[3*r+2]),r++;}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return Dl(i,r,0,i.length-1),t&&(t.add(i.buffer),t.add(r.buffer)),{ids:i,positions:r}}static deserialize(e){const t=new zl;let i;t.ids=e.ids,t.positions=e.positions;for(const e of t.ids)e!==i&&t.uniqueIds.push(e),i=e;return t.indexed=!0,t}}function Pl(e){const t=+e;return !isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:Cl(String(e))}function Dl(e,t,i,r){for(;i<r;){const n=e[i+r>>1];let o=i-1,s=r+1;for(;;){do{o++;}while(e[o]<n);do{s--;}while(e[s]>n);if(o>=s)break;Rl(e,o,s),Rl(t,3*o,3*s),Rl(t,3*o+1,3*s+1),Rl(t,3*o+2,3*s+2);}s-i<r-s?(Dl(e,t,i,s),i=s+1):(Dl(e,t,s+1,r),r=s);}}function Rl(e,t,i){const r=e[t];e[t]=e[i],e[i]=r;}Rs(zl,"FeaturePositionMap");class Ll{constructor(e){this.gl=e.gl,this.initialized=!1;}fetchUniformLocation(e,t){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,t),this.initialized=!0),!!this.location}}class kl extends Ll{constructor(e){super(e),this.current=0;}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i));}}class Ol extends Ll{constructor(e){super(e),this.current=0;}set(e,t,i){this.fetchUniformLocation(e,t)&&this.current!==i&&(this.current=i,this.gl.uniform1f(this.location,i));}}class Bl extends Ll{constructor(e){super(e),this.current=[0,0];}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])));}}class Fl extends Ll{constructor(e){super(e),this.current=[0,0,0];}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2])));}}class Nl extends Ll{constructor(e){super(e),this.current=[0,0,0,0];}set(e,t,i){this.fetchUniformLocation(e,t)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]&&i[3]===this.current[3]||(this.current=i,this.gl.uniform4f(this.location,i[0],i[1],i[2],i[3])));}}class Ul extends Ll{constructor(e){super(e),this.current=hi.transparent;}set(e,t,i){this.fetchUniformLocation(e,t)&&(i.r===this.current.r&&i.g===this.current.g&&i.b===this.current.b&&i.a===this.current.a||(this.current=i,this.gl.uniform4f(this.location,i.r,i.g,i.b,i.a)));}}const Vl=new Float32Array(16);class jl extends Ll{constructor(e){super(e),this.current=Vl;}set(e,t,i){if(this.fetchUniformLocation(e,t)){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let e=1;e<16;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}}}const Gl=new Float32Array(9);class ql extends Ll{constructor(e){super(e),this.current=Gl;}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}}const Zl=new Float32Array(4);class $l extends Ll{constructor(e){super(e),this.current=Zl;}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<4;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}}function Wl(e){return [vl(255*e.r,255*e.g),vl(255*e.b,255*e.a)]}class Hl{constructor(e,t,i){this.value=e,this.uniformNames=t.map((e=>`u_${e}`)),this.type=i;}setUniform(e,t,i,r,n){t.set(e,n,r.constantOr(this.value));}getBinding(e,t){return "color"===this.type?new Ul(e):new Ol(e)}}class Xl{constructor(e,t){this.uniformNames=t.map((e=>`u_${e}`)),this.pattern=null,this.pixelRatio=1;}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br);}setUniform(e,t,i,r,n){const o="u_pattern"===n||"u_dash"===n?this.pattern:"u_pixel_ratio"===n?this.pixelRatio:null;o&&t.set(e,n,o);}getBinding(e,t){return "u_pattern"===t||"u_dash"===t?new Nl(e):new Ol(e)}}class Yl{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r;}populatePaintArray(e,t,i,r,n,o,s){const a=this.paintVertexArray.length,l=this.expression.evaluate(new oa(0,{brightness:o}),t,{},n,r,s);this.paintVertexArray.resize(e),this._setPaintValue(a,e,l);}updatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate({zoom:0,brightness:s},i,r,void 0,n);this._setPaintValue(e,t,a);}_setPaintValue(e,t,i){if("color"===this.type){const r=Wl(i);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1]);}else {for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i));}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy();}}class Kl{constructor(e,t,i,r,n,o){this.expression=e,this.uniformNames=t.map((e=>`u_${e}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=t.map((e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o;}populatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate(new oa(this.zoom,{brightness:o}),t,{},n,r,s),l=this.expression.evaluate(new oa(this.zoom+1,{brightness:o}),t,{},n,r,s),c=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(c,e,a,l);}updatePaintArray(e,t,i,r,n,o,s){const a=this.expression.evaluate({zoom:this.zoom,brightness:s},i,r,void 0,n),l=this.expression.evaluate({zoom:this.zoom+1,brightness:s},i,r,void 0,n);this._setPaintValue(e,t,a,l);}_setPaintValue(e,t,i,r){if("color"===this.type){const n=Wl(i),o=Wl(r);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n[0],n[1],o[0],o[1]);}else {for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r));}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy();}setUniform(e,t,i,r,n){const o=this.useIntegerZoom?Math.floor(i.zoom):i.zoom,s=z(this.expression.interpolationFactor(o,this.zoom,this.zoom+1),0,1);t.set(e,n,s);}getBinding(e,t){return new Ol(e)}}class Jl{constructor(e,t,i,r,n){this.expression=e,this.layerId=n,this.paintVertexAttributes=("array"===i?wl:bl).members;for(let e=0;e<t.length;++e);this.paintVertexArray=new r;}populatePaintArray(e,t,i){const r=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(r,e,t.patterns&&t.patterns[this.layerId],i);}updatePaintArray(e,t,i,r,n,o,s){this._setPaintValues(e,t,i.patterns&&i.patterns[this.layerId],o);}_setPaintValues(e,t,i,r){if(!r||!i)return;const n=r[i];if(!n)return;const{tl:o,br:s,pixelRatio:a}=n;for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,o[0],o[1],s[0],s[1],a);}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent||!this.expression.isLightConstant));}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy();}}class Ql{constructor(e,t,i=(()=>!0)){this.binders={},this._buffers=[];const r=[];for(const n in e.paint._values){const o=e.paint.get(n);if(!i(n))continue;if(!(o instanceof da&&co(o.property.specification)))continue;const s=ic(n,e.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,h="line-dasharray"===n||n.endsWith("pattern"),u="line-dasharray"===n&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==a.kind||u)if("source"===a.kind||u||h){const t=oc(n,l,"source");this.binders[n]=h?new Jl(a,s,l,t,e.id):new Yl(a,s,l,t),r.push(`/a_${n}`);}else {const e=oc(n,l,"composite");this.binders[n]=new Kl(a,s,l,c,t,e),r.push(`/z_${n}`);}else this.binders[n]=h?new Xl(a.value,s):new Hl(a.value,s,l),r.push(`/u_${n}`);}this.cacheKey=r.sort().join("");}getMaxValue(e){const t=this.binders[e];return t instanceof Yl||t instanceof Kl?t.maxValue:0}populatePaintArrays(e,t,i,r,n,o,s){for(const a in this.binders){const l=this.binders[a];(l instanceof Yl||l instanceof Kl||l instanceof Jl)&&l.populatePaintArray(e,t,i,r,n,o,s);}}setConstantPatternPositions(e){for(const t in this.binders){const i=this.binders[t];i instanceof Xl&&i.setConstantPatternPositions(e);}}updatePaintArrays(e,t,i,r,n,o,s,a){let l=!1;const c=Object.keys(e),h=0!==c.length,u=h?c:t.uniqueIds;for(const c in this.binders){const d=this.binders[c];if((d instanceof Yl||d instanceof Kl||d instanceof Jl)&&(!0===d.expression.isStateDependent||!1===d.expression.isLightConstant)){const p=n.paint.get(c);d.expression=p.value;for(const i of u){const n=e[i.toString()];t.eachPosition(i,((e,t,i)=>{const l=r.feature(e);d.updatePaintArray(t,i,l,n,o,s,a);}));}if(!h)for(const t of i.uniqueIds){const n=e[t.toString()];i.eachPosition(t,((e,t,i)=>{const l=r.feature(e);d.updatePaintArray(t,i,l,n,o,s,a);}));}l=!0;}}return l}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof Hl||i instanceof Xl)&&e.push(...i.uniformNames.map((e=>`#define HAS_UNIFORM_${e}`)));}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Yl||i instanceof Kl||i instanceof Jl)for(let t=0;t<i.paintVertexAttributes.length;t++)e.push(i.paintVertexAttributes[t].name);}return e}getBinderUniforms(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Hl||i instanceof Xl||i instanceof Kl)for(const t of i.uniformNames)e.push(t);}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const t=[];for(const i in this.binders){const r=this.binders[i];if(r instanceof Hl||r instanceof Xl||r instanceof Kl)for(const n of r.uniformNames)t.push({name:n,property:i,binding:r.getBinding(e,n)});}return t}setUniforms(e,t,i,r,n){for(const{name:t,property:o,binding:s}of i)this.binders[o].setUniform(e,s,n,r.get(o),t);}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof Yl||t instanceof Kl||t instanceof Jl)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer);}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof Yl||i instanceof Kl||i instanceof Jl)&&i.upload(e);}this.updatePaintBuffers();}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof Yl||t instanceof Kl||t instanceof Jl)&&t.destroy();}}}class ec{constructor(e,t,i=(()=>!0)){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new Ql(r,t,i);this.needsUpload=!1,this._featureMap=new zl,this._featureMapWithoutIds=new zl,this._bufferOffset=0,this._idlessCounter=0;}populatePaintArrays(e,t,i,r,n,o,s,a){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r,n,o,s,a);void 0!==t.id?this._featureMap.add(t.id,i,this._bufferOffset,e):(this._featureMapWithoutIds.add(this._idlessCounter,i,this._bufferOffset,e),this._idlessCounter+=1),this._bufferOffset=e,this.needsUpload=!0;}updatePaintArrays(e,t,i,r,n,o){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,s,r,n,o||0)||this.needsUpload;}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1;}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy();}}const tc={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-emissive-strength":["emissive_strength"],"icon-emissive-strength":["emissive_strength"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function ic(e,t){return tc[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const rc={"line-pattern":{source:Oa,composite:Oa},"fill-pattern":{source:Oa,composite:Oa},"fill-extrusion-pattern":{source:Oa,composite:Oa},"line-dasharray":{source:Ba,composite:Ba}},nc={color:{source:il,composite:ka},number:{source:Ya,composite:il}};function oc(e,t,i){const r=rc[e];return r&&r[i]||nc[t][i]}Rs(Hl,"ConstantBinder"),Rs(Xl,"PatternConstantBinder"),Rs(Yl,"SourceExpressionBinder"),Rs(Jl,"PatternCompositeBinder"),Rs(Kl,"CompositeExpressionBinder"),Rs(Ql,"ProgramConfiguration",{omit:["_buffers"]}),Rs(ec,"ProgramConfigurationSet");class sc{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]));}setNorthEast(e){return this._ne=e instanceof Wd?new Wd(e.lng,e.lat):Wd.convert(e),this}setSouthWest(e){return this._sw=e instanceof Wd?new Wd(e.lng,e.lat):Wd.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof Wd)r=e,n=e;else {if(!(e instanceof sc))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(sc.convert(e)):this.extend(Wd.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(Wd.convert(e)):this;if(r=e._sw,n=e._ne,!r||!n)return this}return t||i?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new Wd(r.lng,r.lat),this._ne=new Wd(n.lng,n.lat)),this}getCenter(){return new Wd((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new Wd(this.getWest(),this.getNorth())}getSouthEast(){return new Wd(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return [this._sw.toArray(),this._ne.toArray()]}toString(){return `LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return !(this._sw&&this._ne)}contains(e){const{lng:t,lat:i}=Wd.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(e){return !e||e instanceof sc?e:new sc(e)}}var ac={},lc={};Object.defineProperty(lc,"__esModule",{value:!0}),lc.setMatrixArrayType=function(e){lc.ARRAY_TYPE=hc=e;},lc.toRadian=function(e){return e*dc},lc.equals=function(e,t){return Math.abs(e-t)<=cc*Math.max(1,Math.abs(e),Math.abs(t))},lc.RANDOM=lc.ARRAY_TYPE=lc.EPSILON=void 0;var cc=1e-6;lc.EPSILON=cc;var hc="undefined"!=typeof Float32Array?Float32Array:Array;lc.ARRAY_TYPE=hc;var uc=Math.random;lc.RANDOM=uc;var dc=Math.PI/180;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var pc={};function fc(e){return fc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fc(e)}Object.defineProperty(pc,"__esModule",{value:!0}),pc.create=function(){var e=new mc.ARRAY_TYPE(4);return mc.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e},pc.clone=function(e){var t=new mc.ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},pc.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},pc.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e},pc.fromValues=function(e,t,i,r){var n=new mc.ARRAY_TYPE(4);return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n},pc.set=function(e,t,i,r,n){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e},pc.transpose=function(e,t){if(e===t){var i=t[1];e[1]=t[2],e[2]=i;}else e[0]=t[0],e[1]=t[2],e[2]=t[1],e[3]=t[3];return e},pc.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*o-n*r;return s?(e[0]=o*(s=1/s),e[1]=-r*s,e[2]=-n*s,e[3]=i*s,e):null},pc.adjoint=function(e,t){var i=t[0];return e[0]=t[3],e[1]=-t[1],e[2]=-t[2],e[3]=i,e},pc.determinant=function(e){return e[0]*e[3]-e[2]*e[1]},pc.multiply=gc,pc.rotate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+o*a,e[1]=n*l+s*a,e[2]=r*-a+o*l,e[3]=n*-a+s*l,e},pc.scale=function(e,t,i){var r=t[1],n=t[2],o=t[3],s=i[0],a=i[1];return e[0]=t[0]*s,e[1]=r*s,e[2]=n*a,e[3]=o*a,e},pc.fromRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=-i,e[3]=r,e},pc.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e},pc.str=function(e){return "mat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},pc.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},pc.LDU=function(e,t,i,r){return e[2]=r[2]/r[0],i[0]=r[0],i[1]=r[1],i[3]=r[3]-e[2]*i[1],[e,t,i]},pc.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e},pc.subtract=yc,pc.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},pc.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(i-s)<=mc.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-a)<=mc.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-l)<=mc.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(o-c)<=mc.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},pc.multiplyScalar=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e},pc.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e},pc.sub=pc.mul=void 0;var mc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==fc(e)&&"function"!=typeof e)return {default:e};var i=_c(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(lc);function _c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (_c=function(e){return e?i:t})(e)}function gc(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],h=i[3];return e[0]=r*a+o*l,e[1]=n*a+s*l,e[2]=r*c+o*h,e[3]=n*c+s*h,e}function yc(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e}pc.mul=gc,pc.sub=yc;var xc={};function vc(e){return vc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},vc(e)}Object.defineProperty(xc,"__esModule",{value:!0}),xc.create=function(){var e=new bc.ARRAY_TYPE(6);return bc.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[4]=0,e[5]=0),e[0]=1,e[3]=1,e},xc.clone=function(e){var t=new bc.ARRAY_TYPE(6);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},xc.copy=function(e,t){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},xc.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e},xc.fromValues=function(e,t,i,r,n,o){var s=new bc.ARRAY_TYPE(6);return s[0]=e,s[1]=t,s[2]=i,s[3]=r,s[4]=n,s[5]=o,s},xc.set=function(e,t,i,r,n,o,s){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e},xc.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=i*o-r*n;return l?(e[0]=o*(l=1/l),e[1]=-r*l,e[2]=-n*l,e[3]=i*l,e[4]=(n*a-o*s)*l,e[5]=(r*s-i*a)*l,e):null},xc.determinant=function(e){return e[0]*e[3]-e[1]*e[2]},xc.multiply=Tc,xc.rotate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=Math.sin(i),h=Math.cos(i);return e[0]=r*h+o*c,e[1]=n*h+s*c,e[2]=r*-c+o*h,e[3]=n*-c+s*h,e[4]=a,e[5]=l,e},xc.scale=function(e,t,i){var r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=i[0],c=i[1];return e[0]=t[0]*l,e[1]=r*l,e[2]=n*c,e[3]=o*c,e[4]=s,e[5]=a,e},xc.translate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=i[0],h=i[1];return e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=r*c+o*h+a,e[5]=n*c+s*h+l,e},xc.fromRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=-i,e[3]=r,e[4]=0,e[5]=0,e},xc.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=t[1],e[4]=0,e[5]=0,e},xc.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e[4]=t[0],e[5]=t[1],e},xc.str=function(e){return "mat2d("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+")"},xc.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],1)},xc.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e},xc.subtract=Ec,xc.multiplyScalar=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e},xc.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e},xc.exactEquals=function(e,t){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]},xc.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=t[0],c=t[1],h=t[2],u=t[3],d=t[4],p=t[5];return Math.abs(i-l)<=bc.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(r-c)<=bc.EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(n-h)<=bc.EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(o-u)<=bc.EPSILON*Math.max(1,Math.abs(o),Math.abs(u))&&Math.abs(s-d)<=bc.EPSILON*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(a-p)<=bc.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))},xc.sub=xc.mul=void 0;var bc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==vc(e)&&"function"!=typeof e)return {default:e};var i=wc(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(lc);function wc(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (wc=function(e){return e?i:t})(e)}function Tc(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=i[0],h=i[1],u=i[2],d=i[3],p=i[4],f=i[5];return e[0]=r*c+o*h,e[1]=n*c+s*h,e[2]=r*u+o*d,e[3]=n*u+s*d,e[4]=r*p+o*f+a,e[5]=n*p+s*f+l,e}function Ec(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e}xc.mul=Tc,xc.sub=Ec;var Mc={};function Ac(e){return Ac="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ac(e)}Object.defineProperty(Mc,"__esModule",{value:!0}),Mc.create=function(){var e=new Sc.ARRAY_TYPE(9);return Sc.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e},Mc.fromMat4=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},Mc.clone=function(e){var t=new Sc.ARRAY_TYPE(9);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},Mc.copy=function(e,t){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},Mc.fromValues=function(e,t,i,r,n,o,s,a,l){var c=new Sc.ARRAY_TYPE(9);return c[0]=e,c[1]=t,c[2]=i,c[3]=r,c[4]=n,c[5]=o,c[6]=s,c[7]=a,c[8]=l,c},Mc.set=function(e,t,i,r,n,o,s,a,l,c){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e[8]=c,e},Mc.identity=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},Mc.transpose=function(e,t){if(e===t){var i=t[1],r=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=r,e[7]=n;}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e},Mc.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=h*s-a*c,d=-h*o+a*l,p=c*o-s*l,f=i*u+r*d+n*p;return f?(e[0]=u*(f=1/f),e[1]=(-h*r+n*c)*f,e[2]=(a*r-n*s)*f,e[3]=d*f,e[4]=(h*i-n*l)*f,e[5]=(-a*i+n*o)*f,e[6]=p*f,e[7]=(-c*i+r*l)*f,e[8]=(s*i-r*o)*f,e):null},Mc.adjoint=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e[0]=s*h-a*c,e[1]=n*c-r*h,e[2]=r*a-n*s,e[3]=a*l-o*h,e[4]=i*h-n*l,e[5]=n*o-i*a,e[6]=o*c-s*l,e[7]=r*l-i*c,e[8]=i*s-r*o,e},Mc.determinant=function(e){var t=e[3],i=e[4],r=e[5],n=e[6],o=e[7],s=e[8];return e[0]*(s*i-r*o)+e[1]*(-s*t+r*n)+e[2]*(o*t-i*n)},Mc.multiply=Cc,Mc.translate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=i[0],p=i[1];return e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=d*r+p*s+c,e[7]=d*n+p*a+h,e[8]=d*o+p*l+u,e},Mc.rotate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=Math.sin(i),p=Math.cos(i);return e[0]=p*r+d*s,e[1]=p*n+d*a,e[2]=p*o+d*l,e[3]=p*s-d*r,e[4]=p*a-d*n,e[5]=p*l-d*o,e[6]=c,e[7]=h,e[8]=u,e},Mc.scale=function(e,t,i){var r=i[0],n=i[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=n*t[3],e[4]=n*t[4],e[5]=n*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},Mc.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=t[0],e[7]=t[1],e[8]=1,e},Mc.fromRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},Mc.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=t[1],e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},Mc.fromMat2d=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=0,e[3]=t[2],e[4]=t[3],e[5]=0,e[6]=t[4],e[7]=t[5],e[8]=1,e},Mc.fromQuat=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,h=r*s,u=r*a,d=n*s,p=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return e[0]=1-u-f,e[3]=h-g,e[6]=d+_,e[1]=h+g,e[4]=1-c-f,e[7]=p-m,e[2]=d-_,e[5]=p+m,e[8]=1-c-u,e},Mc.normalFromMat4=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*a-r*s,x=i*l-n*s,v=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,E=h*m-u*f,M=h*_-d*f,A=h*g-p*f,S=u*_-d*m,I=u*g-p*m,C=d*g-p*_,z=y*C-x*I+v*S+b*A-w*M+T*E;return z?(e[0]=(a*C-l*I+c*S)*(z=1/z),e[1]=(l*A-s*C-c*M)*z,e[2]=(s*I-a*A+c*E)*z,e[3]=(n*I-r*C-o*S)*z,e[4]=(i*C-n*A+o*M)*z,e[5]=(r*A-i*I-o*E)*z,e[6]=(m*T-_*w+g*b)*z,e[7]=(_*v-f*T-g*x)*z,e[8]=(f*w-m*v+g*y)*z,e):null},Mc.projection=function(e,t,i){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/i,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e},Mc.str=function(e){return "mat3("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+")"},Mc.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},Mc.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e[8]=t[8]+i[8],e},Mc.subtract=zc,Mc.multiplyScalar=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*i,e},Mc.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e[6]=t[6]+i[6]*r,e[7]=t[7]+i[7]*r,e[8]=t[8]+i[8]*r,e},Mc.exactEquals=function(e,t){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]},Mc.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=t[0],d=t[1],p=t[2],f=t[3],m=t[4],_=t[5],g=t[6],y=t[7],x=t[8];return Math.abs(i-u)<=Sc.EPSILON*Math.max(1,Math.abs(i),Math.abs(u))&&Math.abs(r-d)<=Sc.EPSILON*Math.max(1,Math.abs(r),Math.abs(d))&&Math.abs(n-p)<=Sc.EPSILON*Math.max(1,Math.abs(n),Math.abs(p))&&Math.abs(o-f)<=Sc.EPSILON*Math.max(1,Math.abs(o),Math.abs(f))&&Math.abs(s-m)<=Sc.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(a-_)<=Sc.EPSILON*Math.max(1,Math.abs(a),Math.abs(_))&&Math.abs(l-g)<=Sc.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(c-y)<=Sc.EPSILON*Math.max(1,Math.abs(c),Math.abs(y))&&Math.abs(h-x)<=Sc.EPSILON*Math.max(1,Math.abs(h),Math.abs(x))},Mc.sub=Mc.mul=void 0;var Sc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Ac(e)&&"function"!=typeof e)return {default:e};var i=Ic(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(lc);function Ic(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (Ic=function(e){return e?i:t})(e)}function Cc(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=i[0],p=i[1],f=i[2],m=i[3],_=i[4],g=i[5],y=i[6],x=i[7],v=i[8];return e[0]=d*r+p*s+f*c,e[1]=d*n+p*a+f*h,e[2]=d*o+p*l+f*u,e[3]=m*r+_*s+g*c,e[4]=m*n+_*a+g*h,e[5]=m*o+_*l+g*u,e[6]=y*r+x*s+v*c,e[7]=y*n+x*a+v*h,e[8]=y*o+x*l+v*u,e}function zc(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e[6]=t[6]-i[6],e[7]=t[7]-i[7],e[8]=t[8]-i[8],e}Mc.mul=Cc,Mc.sub=zc;var Pc={};function Dc(e){return Dc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Dc(e)}Object.defineProperty(Pc,"__esModule",{value:!0}),Pc.create=function(){var e=new Rc.ARRAY_TYPE(16);return Rc.ARRAY_TYPE!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},Pc.clone=function(e){var t=new Rc.ARRAY_TYPE(16);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},Pc.copy=function(e,t){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},Pc.fromValues=function(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){var _=new Rc.ARRAY_TYPE(16);return _[0]=e,_[1]=t,_[2]=i,_[3]=r,_[4]=n,_[5]=o,_[6]=s,_[7]=a,_[8]=l,_[9]=c,_[10]=h,_[11]=u,_[12]=d,_[13]=p,_[14]=f,_[15]=m,_},Pc.set=function(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e[8]=c,e[9]=h,e[10]=u,e[11]=d,e[12]=p,e[13]=f,e[14]=m,e[15]=_,e},Pc.identity=kc,Pc.transpose=function(e,t){if(e===t){var i=t[1],r=t[2],n=t[3],o=t[6],s=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=i,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=o,e[11]=t[14],e[12]=n,e[13]=s,e[14]=a;}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e},Pc.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*a-r*s,x=i*l-n*s,v=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,E=h*m-u*f,M=h*_-d*f,A=h*g-p*f,S=u*_-d*m,I=u*g-p*m,C=d*g-p*_,z=y*C-x*I+v*S+b*A-w*M+T*E;return z?(e[0]=(a*C-l*I+c*S)*(z=1/z),e[1]=(n*I-r*C-o*S)*z,e[2]=(m*T-_*w+g*b)*z,e[3]=(d*w-u*T-p*b)*z,e[4]=(l*A-s*C-c*M)*z,e[5]=(i*C-n*A+o*M)*z,e[6]=(_*v-f*T-g*x)*z,e[7]=(h*T-d*v+p*x)*z,e[8]=(s*I-a*A+c*E)*z,e[9]=(r*A-i*I-o*E)*z,e[10]=(f*w-m*v+g*y)*z,e[11]=(u*v-h*w-p*y)*z,e[12]=(a*M-s*S-l*E)*z,e[13]=(i*S-r*M+n*E)*z,e[14]=(m*x-f*b-_*y)*z,e[15]=(h*b-u*x+d*y)*z,e):null},Pc.adjoint=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15];return e[0]=a*(d*g-p*_)-u*(l*g-c*_)+m*(l*p-c*d),e[1]=-(r*(d*g-p*_)-u*(n*g-o*_)+m*(n*p-o*d)),e[2]=r*(l*g-c*_)-a*(n*g-o*_)+m*(n*c-o*l),e[3]=-(r*(l*p-c*d)-a*(n*p-o*d)+u*(n*c-o*l)),e[4]=-(s*(d*g-p*_)-h*(l*g-c*_)+f*(l*p-c*d)),e[5]=i*(d*g-p*_)-h*(n*g-o*_)+f*(n*p-o*d),e[6]=-(i*(l*g-c*_)-s*(n*g-o*_)+f*(n*c-o*l)),e[7]=i*(l*p-c*d)-s*(n*p-o*d)+h*(n*c-o*l),e[8]=s*(u*g-p*m)-h*(a*g-c*m)+f*(a*p-c*u),e[9]=-(i*(u*g-p*m)-h*(r*g-o*m)+f*(r*p-o*u)),e[10]=i*(a*g-c*m)-s*(r*g-o*m)+f*(r*c-o*a),e[11]=-(i*(a*p-c*u)-s*(r*p-o*u)+h*(r*c-o*a)),e[12]=-(s*(u*_-d*m)-h*(a*_-l*m)+f*(a*d-l*u)),e[13]=i*(u*_-d*m)-h*(r*_-n*m)+f*(r*d-n*u),e[14]=-(i*(a*_-l*m)-s*(r*_-n*m)+f*(r*l-n*a)),e[15]=i*(a*d-l*u)-s*(r*d-n*u)+h*(r*l-n*a),e},Pc.determinant=function(e){var t=e[0],i=e[1],r=e[2],n=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11],p=e[12],f=e[13],m=e[14],_=e[15];return (t*s-i*o)*(u*_-d*m)-(t*a-r*o)*(h*_-d*f)+(t*l-n*o)*(h*m-u*f)+(i*a-r*s)*(c*_-d*p)-(i*l-n*s)*(c*m-u*p)+(r*l-n*a)*(c*f-h*p)},Pc.multiply=Oc,Pc.translate=function(e,t,i){var r,n,o,s,a,l,c,h,u,d,p,f,m=i[0],_=i[1],g=i[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],e[0]=r=t[0],e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=h,e[8]=u,e[9]=d,e[10]=p,e[11]=f,e[12]=r*m+a*_+u*g+t[12],e[13]=n*m+l*_+d*g+t[13],e[14]=o*m+c*_+p*g+t[14],e[15]=s*m+h*_+f*g+t[15]),e},Pc.scale=function(e,t,i){var r=i[0],n=i[1],o=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},Pc.rotate=function(e,t,i,r){var n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,M,A,S,I=r[0],C=r[1],z=r[2],P=Math.hypot(I,C,z);return P<Rc.EPSILON?null:(I*=P=1/P,C*=P,z*=P,n=Math.sin(i),o=Math.cos(i),l=t[1],c=t[2],h=t[3],d=t[5],p=t[6],f=t[7],_=t[9],g=t[10],y=t[11],w=I*C*(s=1-o)-z*n,T=C*C*s+o,E=z*C*s+I*n,M=I*z*s+C*n,A=C*z*s-I*n,S=z*z*s+o,e[0]=(a=t[0])*(x=I*I*s+o)+(u=t[4])*(v=C*I*s+z*n)+(m=t[8])*(b=z*I*s-C*n),e[1]=l*x+d*v+_*b,e[2]=c*x+p*v+g*b,e[3]=h*x+f*v+y*b,e[4]=a*w+u*T+m*E,e[5]=l*w+d*T+_*E,e[6]=c*w+p*T+g*E,e[7]=h*w+f*T+y*E,e[8]=a*M+u*A+m*S,e[9]=l*M+d*A+_*S,e[10]=c*M+p*A+g*S,e[11]=h*M+f*A+y*S,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},Pc.rotateX=function(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*n+c*r,e[5]=s*n+h*r,e[6]=a*n+u*r,e[7]=l*n+d*r,e[8]=c*n-o*r,e[9]=h*n-s*r,e[10]=u*n-a*r,e[11]=d*n-l*r,e},Pc.rotateY=function(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],h=t[9],u=t[10],d=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n-c*r,e[1]=s*n-h*r,e[2]=a*n-u*r,e[3]=l*n-d*r,e[8]=o*r+c*n,e[9]=s*r+h*n,e[10]=a*r+u*n,e[11]=l*r+d*n,e},Pc.rotateZ=function(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],h=t[5],u=t[6],d=t[7];return t!==e&&(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[0]=o*n+c*r,e[1]=s*n+h*r,e[2]=a*n+u*r,e[3]=l*n+d*r,e[4]=c*n-o*r,e[5]=h*n-s*r,e[6]=u*n-a*r,e[7]=d*n-l*r,e},Pc.fromTranslation=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e},Pc.fromScaling=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},Pc.fromRotation=function(e,t,i){var r,n,o,s=i[0],a=i[1],l=i[2],c=Math.hypot(s,a,l);return c<Rc.EPSILON?null:(s*=c=1/c,a*=c,l*=c,r=Math.sin(t),n=Math.cos(t),e[0]=s*s*(o=1-n)+n,e[1]=a*s*o+l*r,e[2]=l*s*o-a*r,e[3]=0,e[4]=s*a*o-l*r,e[5]=a*a*o+n,e[6]=l*a*o+s*r,e[7]=0,e[8]=s*l*o+a*r,e[9]=a*l*o-s*r,e[10]=l*l*o+n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)},Pc.fromXRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r,e[6]=i,e[7]=0,e[8]=0,e[9]=-i,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},Pc.fromYRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=0,e[2]=-i,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=i,e[9]=0,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},Pc.fromZRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=0,e[4]=-i,e[5]=r,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},Pc.fromRotationTranslation=Bc,Pc.fromQuat2=function(e,t){var i=new Rc.ARRAY_TYPE(3),r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=r*r+n*n+o*o+s*s;return u>0?(i[0]=2*(a*s+h*r+l*o-c*n)/u,i[1]=2*(l*s+h*n+c*r-a*o)/u,i[2]=2*(c*s+h*o+a*n-l*r)/u):(i[0]=2*(a*s+h*r+l*o-c*n),i[1]=2*(l*s+h*n+c*r-a*o),i[2]=2*(c*s+h*o+a*n-l*r)),Bc(e,t,i),e},Pc.getTranslation=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},Pc.getScaling=Fc,Pc.getRotation=function(e,t){var i=new Rc.ARRAY_TYPE(3);Fc(i,t);var r=1/i[0],n=1/i[1],o=1/i[2],s=t[0]*r,a=t[1]*n,l=t[2]*o,c=t[4]*r,h=t[5]*n,u=t[6]*o,d=t[8]*r,p=t[9]*n,f=t[10]*o,m=s+h+f,_=0;return m>0?(_=2*Math.sqrt(m+1),e[3]=.25*_,e[0]=(u-p)/_,e[1]=(d-l)/_,e[2]=(a-c)/_):s>h&&s>f?(_=2*Math.sqrt(1+s-h-f),e[3]=(u-p)/_,e[0]=.25*_,e[1]=(a+c)/_,e[2]=(d+l)/_):h>f?(_=2*Math.sqrt(1+h-s-f),e[3]=(d-l)/_,e[0]=(a+c)/_,e[1]=.25*_,e[2]=(u+p)/_):(_=2*Math.sqrt(1+f-s-h),e[3]=(a-c)/_,e[0]=(d+l)/_,e[1]=(u+p)/_,e[2]=.25*_),e},Pc.fromRotationTranslationScale=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3],l=n+n,c=o+o,h=s+s,u=n*l,d=n*c,p=n*h,f=o*c,m=o*h,_=s*h,g=a*l,y=a*c,x=a*h,v=r[0],b=r[1],w=r[2];return e[0]=(1-(f+_))*v,e[1]=(d+x)*v,e[2]=(p-y)*v,e[3]=0,e[4]=(d-x)*b,e[5]=(1-(u+_))*b,e[6]=(m+g)*b,e[7]=0,e[8]=(p+y)*w,e[9]=(m-g)*w,e[10]=(1-(u+f))*w,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e},Pc.fromRotationTranslationScaleOrigin=function(e,t,i,r,n){var o=t[0],s=t[1],a=t[2],l=t[3],c=o+o,h=s+s,u=a+a,d=o*c,p=o*h,f=o*u,m=s*h,_=s*u,g=a*u,y=l*c,x=l*h,v=l*u,b=r[0],w=r[1],T=r[2],E=n[0],M=n[1],A=n[2],S=(1-(m+g))*b,I=(p+v)*b,C=(f-x)*b,z=(p-v)*w,P=(1-(d+g))*w,D=(_+y)*w,R=(f+x)*T,L=(_-y)*T,k=(1-(d+m))*T;return e[0]=S,e[1]=I,e[2]=C,e[3]=0,e[4]=z,e[5]=P,e[6]=D,e[7]=0,e[8]=R,e[9]=L,e[10]=k,e[11]=0,e[12]=i[0]+E-(S*E+z*M+R*A),e[13]=i[1]+M-(I*E+P*M+L*A),e[14]=i[2]+A-(C*E+D*M+k*A),e[15]=1,e},Pc.fromQuat=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,h=r*s,u=r*a,d=n*s,p=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return e[0]=1-u-f,e[1]=h+g,e[2]=d-_,e[3]=0,e[4]=h-g,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+_,e[9]=p-m,e[10]=1-c-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},Pc.frustum=function(e,t,i,r,n,o,s){var a=1/(i-t),l=1/(n-r),c=1/(o-s);return e[0]=2*o*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(i+t)*a,e[9]=(n+r)*l,e[10]=(s+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*c,e[15]=0,e},Pc.perspectiveNO=Nc,Pc.perspectiveZO=function(e,t,i,r,n){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=n*(o=1/(r-n)),e[14]=n*r*o):(e[10]=-1,e[14]=-r),e},Pc.perspectiveFromFieldOfView=function(e,t,i,r){var n=Math.tan(t.upDegrees*Math.PI/180),o=Math.tan(t.downDegrees*Math.PI/180),s=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),l=2/(s+a),c=2/(n+o);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=-(s-a)*l*.5,e[9]=(n-o)*c*.5,e[10]=r/(i-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*i/(i-r),e[15]=0,e},Pc.orthoNO=Uc,Pc.orthoZO=function(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=o*c,e[15]=1,e},Pc.lookAt=function(e,t,i,r){var n,o,s,a,l,c,h,u,d,p,f=t[0],m=t[1],_=t[2],g=r[0],y=r[1],x=r[2],v=i[0],b=i[1],w=i[2];return Math.abs(f-v)<Rc.EPSILON&&Math.abs(m-b)<Rc.EPSILON&&Math.abs(_-w)<Rc.EPSILON?kc(e):(h=f-v,u=m-b,d=_-w,n=y*(d*=p=1/Math.hypot(h,u,d))-x*(u*=p),o=x*(h*=p)-g*d,s=g*u-y*h,(p=Math.hypot(n,o,s))?(n*=p=1/p,o*=p,s*=p):(n=0,o=0,s=0),a=u*s-d*o,l=d*n-h*s,c=h*o-u*n,(p=Math.hypot(a,l,c))?(a*=p=1/p,l*=p,c*=p):(a=0,l=0,c=0),e[0]=n,e[1]=a,e[2]=h,e[3]=0,e[4]=o,e[5]=l,e[6]=u,e[7]=0,e[8]=s,e[9]=c,e[10]=d,e[11]=0,e[12]=-(n*f+o*m+s*_),e[13]=-(a*f+l*m+c*_),e[14]=-(h*f+u*m+d*_),e[15]=1,e)},Pc.targetTo=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=r[0],l=r[1],c=r[2],h=n-i[0],u=o-i[1],d=s-i[2],p=h*h+u*u+d*d;p>0&&(h*=p=1/Math.sqrt(p),u*=p,d*=p);var f=l*d-c*u,m=c*h-a*d,_=a*u-l*h;return (p=f*f+m*m+_*_)>0&&(f*=p=1/Math.sqrt(p),m*=p,_*=p),e[0]=f,e[1]=m,e[2]=_,e[3]=0,e[4]=u*_-d*m,e[5]=d*f-h*_,e[6]=h*m-u*f,e[7]=0,e[8]=h,e[9]=u,e[10]=d,e[11]=0,e[12]=n,e[13]=o,e[14]=s,e[15]=1,e},Pc.str=function(e){return "mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"},Pc.frob=function(e){return Math.hypot(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},Pc.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e[8]=t[8]+i[8],e[9]=t[9]+i[9],e[10]=t[10]+i[10],e[11]=t[11]+i[11],e[12]=t[12]+i[12],e[13]=t[13]+i[13],e[14]=t[14]+i[14],e[15]=t[15]+i[15],e},Pc.subtract=Vc,Pc.multiplyScalar=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12]*i,e[13]=t[13]*i,e[14]=t[14]*i,e[15]=t[15]*i,e},Pc.multiplyScalarAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e[4]=t[4]+i[4]*r,e[5]=t[5]+i[5]*r,e[6]=t[6]+i[6]*r,e[7]=t[7]+i[7]*r,e[8]=t[8]+i[8]*r,e[9]=t[9]+i[9]*r,e[10]=t[10]+i[10]*r,e[11]=t[11]+i[11]*r,e[12]=t[12]+i[12]*r,e[13]=t[13]+i[13]*r,e[14]=t[14]+i[14]*r,e[15]=t[15]+i[15]*r,e},Pc.exactEquals=function(e,t){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]},Pc.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],p=e[11],f=e[12],m=e[13],_=e[14],g=e[15],y=t[0],x=t[1],v=t[2],b=t[3],w=t[4],T=t[5],E=t[6],M=t[7],A=t[8],S=t[9],I=t[10],C=t[11],z=t[12],P=t[13],D=t[14],R=t[15];return Math.abs(i-y)<=Rc.EPSILON*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-x)<=Rc.EPSILON*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-v)<=Rc.EPSILON*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(o-b)<=Rc.EPSILON*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-w)<=Rc.EPSILON*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(a-T)<=Rc.EPSILON*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-E)<=Rc.EPSILON*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-M)<=Rc.EPSILON*Math.max(1,Math.abs(c),Math.abs(M))&&Math.abs(h-A)<=Rc.EPSILON*Math.max(1,Math.abs(h),Math.abs(A))&&Math.abs(u-S)<=Rc.EPSILON*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(d-I)<=Rc.EPSILON*Math.max(1,Math.abs(d),Math.abs(I))&&Math.abs(p-C)<=Rc.EPSILON*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(f-z)<=Rc.EPSILON*Math.max(1,Math.abs(f),Math.abs(z))&&Math.abs(m-P)<=Rc.EPSILON*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(_-D)<=Rc.EPSILON*Math.max(1,Math.abs(_),Math.abs(D))&&Math.abs(g-R)<=Rc.EPSILON*Math.max(1,Math.abs(g),Math.abs(R))},Pc.sub=Pc.mul=Pc.ortho=Pc.perspective=void 0;var Rc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==Dc(e)&&"function"!=typeof e)return {default:e};var i=Lc(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(lc);function Lc(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (Lc=function(e){return e?i:t})(e)}function kc(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Oc(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*r+v*a+b*u+w*m,e[1]=x*n+v*l+b*d+w*_,e[2]=x*o+v*c+b*p+w*g,e[3]=x*s+v*h+b*f+w*y,e[4]=(x=i[4])*r+(v=i[5])*a+(b=i[6])*u+(w=i[7])*m,e[5]=x*n+v*l+b*d+w*_,e[6]=x*o+v*c+b*p+w*g,e[7]=x*s+v*h+b*f+w*y,e[8]=(x=i[8])*r+(v=i[9])*a+(b=i[10])*u+(w=i[11])*m,e[9]=x*n+v*l+b*d+w*_,e[10]=x*o+v*c+b*p+w*g,e[11]=x*s+v*h+b*f+w*y,e[12]=(x=i[12])*r+(v=i[13])*a+(b=i[14])*u+(w=i[15])*m,e[13]=x*n+v*l+b*d+w*_,e[14]=x*o+v*c+b*p+w*g,e[15]=x*s+v*h+b*f+w*y,e}function Bc(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=r+r,l=n+n,c=o+o,h=r*a,u=r*l,d=r*c,p=n*l,f=n*c,m=o*c,_=s*a,g=s*l,y=s*c;return e[0]=1-(p+m),e[1]=u+y,e[2]=d-g,e[3]=0,e[4]=u-y,e[5]=1-(h+m),e[6]=f+_,e[7]=0,e[8]=d+g,e[9]=f-_,e[10]=1-(h+p),e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}function Fc(e,t){var i=t[4],r=t[5],n=t[6],o=t[8],s=t[9],a=t[10];return e[0]=Math.hypot(t[0],t[1],t[2]),e[1]=Math.hypot(i,r,n),e[2]=Math.hypot(o,s,a),e}function Nc(e,t,i,r,n){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0?(e[10]=(n+r)*(o=1/(r-n)),e[14]=2*n*r*o):(e[10]=-1,e[14]=-2*r),e}function Uc(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=(s+o)*c,e[15]=1,e}function Vc(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e[4]=t[4]-i[4],e[5]=t[5]-i[5],e[6]=t[6]-i[6],e[7]=t[7]-i[7],e[8]=t[8]-i[8],e[9]=t[9]-i[9],e[10]=t[10]-i[10],e[11]=t[11]-i[11],e[12]=t[12]-i[12],e[13]=t[13]-i[13],e[14]=t[14]-i[14],e[15]=t[15]-i[15],e}Pc.perspective=Nc,Pc.ortho=Uc,Pc.mul=Oc,Pc.sub=Vc;var jc={},Gc={};function qc(e){return qc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qc(e)}Object.defineProperty(Gc,"__esModule",{value:!0}),Gc.create=Wc,Gc.clone=function(e){var t=new Zc.ARRAY_TYPE(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},Gc.length=Hc,Gc.fromValues=function(e,t,i){var r=new Zc.ARRAY_TYPE(3);return r[0]=e,r[1]=t,r[2]=i,r},Gc.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},Gc.set=function(e,t,i,r){return e[0]=t,e[1]=i,e[2]=r,e},Gc.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e},Gc.subtract=Xc,Gc.multiply=Yc,Gc.divide=Kc,Gc.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e},Gc.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e},Gc.min=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e},Gc.max=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e},Gc.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e},Gc.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e},Gc.scaleAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e},Gc.distance=Jc,Gc.squaredDistance=Qc,Gc.squaredLength=eh,Gc.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e},Gc.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e},Gc.normalize=function(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},Gc.dot=th,Gc.cross=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=n*l-o*a,e[1]=o*s-r*l,e[2]=r*a-n*s,e},Gc.lerp=function(e,t,i,r){var n=t[0],o=t[1],s=t[2];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e},Gc.hermite=function(e,t,i,r,n,o){var s=o*o,a=s*(2*o-3)+1,l=s*(o-2)+o,c=s*(o-1),h=s*(3-2*o);return e[0]=t[0]*a+i[0]*l+r[0]*c+n[0]*h,e[1]=t[1]*a+i[1]*l+r[1]*c+n[1]*h,e[2]=t[2]*a+i[2]*l+r[2]*c+n[2]*h,e},Gc.bezier=function(e,t,i,r,n,o){var s=1-o,a=s*s,l=o*o,c=a*s,h=3*o*a,u=3*l*s,d=l*o;return e[0]=t[0]*c+i[0]*h+r[0]*u+n[0]*d,e[1]=t[1]*c+i[1]*h+r[1]*u+n[1]*d,e[2]=t[2]*c+i[2]*h+r[2]*u+n[2]*d,e},Gc.random=function(e,t){t=t||1;var i=2*Zc.RANDOM()*Math.PI,r=2*Zc.RANDOM()-1,n=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(i)*n,e[1]=Math.sin(i)*n,e[2]=r*t,e},Gc.transformMat4=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return e[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,e[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,e},Gc.transformMat3=function(e,t,i){var r=t[0],n=t[1],o=t[2];return e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8],e},Gc.transformQuat=function(e,t,i){var r=i[0],n=i[1],o=i[2],s=t[0],a=t[1],l=t[2],c=n*l-o*a,h=o*s-r*l,u=r*a-n*s,d=n*u-o*h,p=o*c-r*u,f=r*h-n*c,m=2*i[3];return h*=m,u*=m,p*=2,f*=2,e[0]=s+(c*=m)+(d*=2),e[1]=a+h+p,e[2]=l+u+f,e},Gc.rotateX=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0],o[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),o[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},Gc.rotateY=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),o[1]=n[1],o[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},Gc.rotateZ=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),o[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),o[2]=n[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},Gc.angle=function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],s=t[1],a=t[2],l=Math.sqrt(i*i+r*r+n*n)*Math.sqrt(o*o+s*s+a*a),c=l&&th(e,t)/l;return Math.acos(Math.min(Math.max(c,-1),1))},Gc.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e},Gc.str=function(e){return "vec3("+e[0]+", "+e[1]+", "+e[2]+")"},Gc.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},Gc.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],s=t[1],a=t[2];return Math.abs(i-o)<=Zc.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-s)<=Zc.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-a)<=Zc.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))},Gc.forEach=Gc.sqrLen=Gc.len=Gc.sqrDist=Gc.dist=Gc.div=Gc.mul=Gc.sub=void 0;var Zc=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==qc(e)&&"function"!=typeof e)return {default:e};var i=$c(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(lc);function $c(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return ($c=function(e){return e?i:t})(e)}function Wc(){var e=new Zc.ARRAY_TYPE(3);return Zc.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Hc(e){return Math.hypot(e[0],e[1],e[2])}function Xc(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function Yc(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function Kc(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e}function Jc(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])}function Qc(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return i*i+r*r+n*n}function eh(e){var t=e[0],i=e[1],r=e[2];return t*t+i*i+r*r}function th(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}Gc.sub=Xc,Gc.mul=Yc,Gc.div=Kc,Gc.dist=Jc,Gc.sqrDist=Qc,Gc.len=Hc,Gc.sqrLen=eh;var ih,rh=(ih=Wc(),function(e,t,i,r,n,o){var s,a;for(t||(t=3),i||(i=0),a=r?Math.min(r*t+i,e.length):e.length,s=i;s<a;s+=t)ih[0]=e[s],ih[1]=e[s+1],ih[2]=e[s+2],n(ih,ih,o),e[s]=ih[0],e[s+1]=ih[1],e[s+2]=ih[2];return e});Gc.forEach=rh;var nh={};function oh(e){return oh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},oh(e)}Object.defineProperty(nh,"__esModule",{value:!0}),nh.create=lh,nh.clone=function(e){var t=new sh.ARRAY_TYPE(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},nh.fromValues=function(e,t,i,r){var n=new sh.ARRAY_TYPE(4);return n[0]=e,n[1]=t,n[2]=i,n[3]=r,n},nh.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},nh.set=function(e,t,i,r,n){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e},nh.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e},nh.subtract=ch,nh.multiply=hh,nh.divide=uh,nh.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e},nh.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e},nh.min=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e[2]=Math.min(t[2],i[2]),e[3]=Math.min(t[3],i[3]),e},nh.max=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e[3]=Math.max(t[3],i[3]),e},nh.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e[3]=Math.round(t[3]),e},nh.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e},nh.scaleAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e[3]=t[3]+i[3]*r,e},nh.distance=dh,nh.squaredDistance=ph,nh.length=fh,nh.squaredLength=mh,nh.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},nh.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},nh.normalize=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*i+r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=r*s,e[2]=n*s,e[3]=o*s,e},nh.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},nh.cross=function(e,t,i,r){var n=i[0]*r[1]-i[1]*r[0],o=i[0]*r[2]-i[2]*r[0],s=i[0]*r[3]-i[3]*r[0],a=i[1]*r[2]-i[2]*r[1],l=i[1]*r[3]-i[3]*r[1],c=i[2]*r[3]-i[3]*r[2],h=t[0],u=t[1],d=t[2],p=t[3];return e[0]=u*c-d*l+p*a,e[1]=-h*c+d*s-p*o,e[2]=h*l-u*s+p*n,e[3]=-h*a+u*o-d*n,e},nh.lerp=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e[3]=a+r*(i[3]-a),e},nh.random=function(e,t){var i,r,n,o,s,a;t=t||1;do{s=(i=2*sh.RANDOM()-1)*i+(r=2*sh.RANDOM()-1)*r;}while(s>=1);do{a=(n=2*sh.RANDOM()-1)*n+(o=2*sh.RANDOM()-1)*o;}while(a>=1);var l=Math.sqrt((1-s)/a);return e[0]=t*i,e[1]=t*r,e[2]=t*n*l,e[3]=t*o*l,e},nh.transformMat4=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,e},nh.transformQuat=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2],c=i[3],h=c*r+a*o-l*n,u=c*n+l*r-s*o,d=c*o+s*n-a*r,p=-s*r-a*n-l*o;return e[0]=h*c+p*-s+u*-l-d*-a,e[1]=u*c+p*-a+d*-s-h*-l,e[2]=d*c+p*-l+h*-a-u*-s,e[3]=t[3],e},nh.zero=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},nh.str=function(e){return "vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},nh.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]},nh.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(i-s)<=sh.EPSILON*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(r-a)<=sh.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-l)<=sh.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(o-c)<=sh.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},nh.forEach=nh.sqrLen=nh.len=nh.sqrDist=nh.dist=nh.div=nh.mul=nh.sub=void 0;var sh=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==oh(e)&&"function"!=typeof e)return {default:e};var i=ah(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(lc);function ah(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (ah=function(e){return e?i:t})(e)}function lh(){var e=new sh.ARRAY_TYPE(4);return sh.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function ch(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e[3]=t[3]-i[3],e}function hh(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e}function uh(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e[3]=t[3]/i[3],e}function dh(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2],t[3]-e[3])}function ph(e,t){var i=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2],o=t[3]-e[3];return i*i+r*r+n*n+o*o}function fh(e){return Math.hypot(e[0],e[1],e[2],e[3])}function mh(e){var t=e[0],i=e[1],r=e[2],n=e[3];return t*t+i*i+r*r+n*n}nh.sub=ch,nh.mul=hh,nh.div=uh,nh.dist=dh,nh.sqrDist=ph,nh.len=fh,nh.sqrLen=mh;var _h=function(){var e=lh();return function(t,i,r,n,o,s){var a,l;for(i||(i=4),r||(r=0),l=n?Math.min(n*i+r,t.length):t.length,a=r;a<l;a+=i)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],e[3]=t[a+3],o(e,e,s),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2],t[a+3]=e[3];return t}}();function gh(e){return gh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gh(e)}nh.forEach=_h,Object.defineProperty(jc,"__esModule",{value:!0}),jc.create=Eh,jc.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},jc.setAxisAngle=Mh,jc.getAxisAngle=function(e,t){var i=2*Math.acos(t[3]),r=Math.sin(i/2);return r>yh.EPSILON?(e[0]=t[0]/r,e[1]=t[1]/r,e[2]=t[2]/r):(e[0]=1,e[1]=0,e[2]=0),i},jc.getAngle=function(e,t){var i=Dh(e,t);return Math.acos(2*i*i-1)},jc.multiply=Ah,jc.rotateX=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+s*a,e[1]=n*l+o*a,e[2]=o*l-n*a,e[3]=s*l-r*a,e},jc.rotateY=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l-o*a,e[1]=n*l+s*a,e[2]=o*l+r*a,e[3]=s*l-n*a,e},jc.rotateZ=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*a,e[1]=n*l-r*a,e[2]=o*l+s*a,e[3]=s*l-o*a,e},jc.calculateW=function(e,t){var i=t[0],r=t[1],n=t[2];return e[0]=i,e[1]=r,e[2]=n,e[3]=Math.sqrt(Math.abs(1-i*i-r*r-n*n)),e},jc.exp=Sh,jc.ln=Ih,jc.pow=function(e,t,i){return Ih(e,t),Ph(e,e,i),Sh(e,e),e},jc.slerp=Ch,jc.random=function(e){var t=yh.RANDOM(),i=yh.RANDOM(),r=yh.RANDOM(),n=Math.sqrt(1-t),o=Math.sqrt(t);return e[0]=n*Math.sin(2*Math.PI*i),e[1]=n*Math.cos(2*Math.PI*i),e[2]=o*Math.sin(2*Math.PI*r),e[3]=o*Math.cos(2*Math.PI*r),e},jc.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*i+r*r+n*n+o*o,a=s?1/s:0;return e[0]=-i*a,e[1]=-r*a,e[2]=-n*a,e[3]=o*a,e},jc.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},jc.fromMat3=zh,jc.fromEuler=function(e,t,i,r){var n=.5*Math.PI/180;t*=n,i*=n,r*=n;var o=Math.sin(t),s=Math.cos(t),a=Math.sin(i),l=Math.cos(i),c=Math.sin(r),h=Math.cos(r);return e[0]=o*l*h-s*a*c,e[1]=s*a*h+o*l*c,e[2]=s*l*c-o*a*h,e[3]=s*l*h+o*a*c,e},jc.str=function(e){return "quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},jc.setAxes=jc.sqlerp=jc.rotationTo=jc.equals=jc.exactEquals=jc.normalize=jc.sqrLen=jc.squaredLength=jc.len=jc.length=jc.lerp=jc.dot=jc.scale=jc.mul=jc.add=jc.set=jc.copy=jc.fromValues=jc.clone=void 0;var yh=Th(lc),xh=Th(Mc),vh=Th(Gc),bh=Th(nh);function wh(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (wh=function(e){return e?i:t})(e)}function Th(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==gh(e)&&"function"!=typeof e)return {default:e};var i=wh(t);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}function Eh(){var e=new yh.ARRAY_TYPE(4);return yh.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Mh(e,t,i){i*=.5;var r=Math.sin(i);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i),e}function Ah(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],h=i[3];return e[0]=r*h+s*a+n*c-o*l,e[1]=n*h+s*l+o*a-r*c,e[2]=o*h+s*c+r*l-n*a,e[3]=s*h-r*a-n*l-o*c,e}function Sh(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=Math.sqrt(i*i+r*r+n*n),a=Math.exp(o),l=s>0?a*Math.sin(s)/s:0;return e[0]=i*l,e[1]=r*l,e[2]=n*l,e[3]=a*Math.cos(s),e}function Ih(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=Math.sqrt(i*i+r*r+n*n),a=s>0?Math.atan2(s,o)/s:0;return e[0]=i*a,e[1]=r*a,e[2]=n*a,e[3]=.5*Math.log(i*i+r*r+n*n+o*o),e}function Ch(e,t,i,r){var n,o,s,a,l,c=t[0],h=t[1],u=t[2],d=t[3],p=i[0],f=i[1],m=i[2],_=i[3];return (o=c*p+h*f+u*m+d*_)<0&&(o=-o,p=-p,f=-f,m=-m,_=-_),1-o>yh.EPSILON?(n=Math.acos(o),s=Math.sin(n),a=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/s):(a=1-r,l=r),e[0]=a*c+l*p,e[1]=a*h+l*f,e[2]=a*u+l*m,e[3]=a*d+l*_,e}function zh(e,t){var i,r=t[0]+t[4]+t[8];if(r>0)i=Math.sqrt(r+1),e[3]=.5*i,e[0]=(t[5]-t[7])*(i=.5/i),e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else {var n=0;t[4]>t[0]&&(n=1),t[8]>t[3*n+n]&&(n=2);var o=(n+1)%3,s=(n+2)%3;i=Math.sqrt(t[3*n+n]-t[3*o+o]-t[3*s+s]+1),e[n]=.5*i,e[3]=(t[3*o+s]-t[3*s+o])*(i=.5/i),e[o]=(t[3*o+n]+t[3*n+o])*i,e[s]=(t[3*s+n]+t[3*n+s])*i;}return e}jc.clone=bh.clone,jc.fromValues=bh.fromValues,jc.copy=bh.copy,jc.set=bh.set,jc.add=bh.add,jc.mul=Ah;var Ph=bh.scale;jc.scale=Ph;var Dh=bh.dot;jc.dot=Dh,jc.lerp=bh.lerp;var Rh=bh.length;jc.length=Rh,jc.len=Rh;var Lh=bh.squaredLength;jc.squaredLength=Lh,jc.sqrLen=Lh;var kh=bh.normalize;jc.normalize=kh,jc.exactEquals=bh.exactEquals,jc.equals=bh.equals;var Oh,Bh,Fh,Nh=(Oh=vh.create(),Bh=vh.fromValues(1,0,0),Fh=vh.fromValues(0,1,0),function(e,t,i){var r=vh.dot(t,i);return r<-.999999?(vh.cross(Oh,Bh,t),vh.len(Oh)<1e-6&&vh.cross(Oh,Fh,t),vh.normalize(Oh,Oh),Mh(e,Oh,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(vh.cross(Oh,t,i),e[0]=Oh[0],e[1]=Oh[1],e[2]=Oh[2],e[3]=1+r,kh(e,e))});jc.rotationTo=Nh;var Uh,Vh,jh=(Uh=Eh(),Vh=Eh(),function(e,t,i,r,n,o){return Ch(Uh,t,n,o),Ch(Vh,i,r,o),Ch(e,Uh,Vh,2*o*(1-o)),e});jc.sqlerp=jh;var Gh,qh=(Gh=xh.create(),function(e,t,i,r){return Gh[0]=i[0],Gh[3]=i[1],Gh[6]=i[2],Gh[1]=r[0],Gh[4]=r[1],Gh[7]=r[2],Gh[2]=-t[0],Gh[5]=-t[1],Gh[8]=-t[2],kh(e,zh(e,Gh))});jc.setAxes=qh;var Zh={};function $h(e){return $h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$h(e)}Object.defineProperty(Zh,"__esModule",{value:!0}),Zh.create=function(){var e=new Wh.ARRAY_TYPE(8);return Wh.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0),e[3]=1,e},Zh.clone=function(e){var t=new Wh.ARRAY_TYPE(8);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},Zh.fromValues=function(e,t,i,r,n,o,s,a){var l=new Wh.ARRAY_TYPE(8);return l[0]=e,l[1]=t,l[2]=i,l[3]=r,l[4]=n,l[5]=o,l[6]=s,l[7]=a,l},Zh.fromRotationTranslationValues=function(e,t,i,r,n,o,s){var a=new Wh.ARRAY_TYPE(8);a[0]=e,a[1]=t,a[2]=i,a[3]=r;var l=.5*n,c=.5*o,h=.5*s;return a[4]=l*r+c*i-h*t,a[5]=c*r+h*e-l*i,a[6]=h*r+l*t-c*e,a[7]=-l*e-c*t-h*i,a},Zh.fromRotationTranslation=Jh,Zh.fromTranslation=function(e,t){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=.5*t[0],e[5]=.5*t[1],e[6]=.5*t[2],e[7]=0,e},Zh.fromRotation=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},Zh.fromMat4=function(e,t){var i=Hh.create();Xh.getRotation(i,t);var r=new Wh.ARRAY_TYPE(3);return Xh.getTranslation(r,t),Jh(e,i,r),e},Zh.copy=Qh,Zh.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e},Zh.set=function(e,t,i,r,n,o,s,a,l){return e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e},Zh.getDual=function(e,t){return e[0]=t[4],e[1]=t[5],e[2]=t[6],e[3]=t[7],e},Zh.setDual=function(e,t){return e[4]=t[0],e[5]=t[1],e[6]=t[2],e[7]=t[3],e},Zh.getTranslation=function(e,t){var i=t[4],r=t[5],n=t[6],o=t[7],s=-t[0],a=-t[1],l=-t[2],c=t[3];return e[0]=2*(i*c+o*s+r*l-n*a),e[1]=2*(r*c+o*a+n*s-i*l),e[2]=2*(n*c+o*l+i*a-r*s),e},Zh.translate=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=.5*i[0],l=.5*i[1],c=.5*i[2],h=t[4],u=t[5],d=t[6],p=t[7];return e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=s*a+n*c-o*l+h,e[5]=s*l+o*a-r*c+u,e[6]=s*c+r*l-n*a+d,e[7]=-r*a-n*l-o*c+p,e},Zh.rotateX=function(e,t,i){var r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=a*s+h*r+l*o-c*n,d=l*s+h*n+c*r-a*o,p=c*s+h*o+a*n-l*r,f=h*s-a*r-l*n-c*o;return Hh.rotateX(e,t,i),e[4]=u*(s=e[3])+f*(r=e[0])+d*(o=e[2])-p*(n=e[1]),e[5]=d*s+f*n+p*r-u*o,e[6]=p*s+f*o+u*n-d*r,e[7]=f*s-u*r-d*n-p*o,e},Zh.rotateY=function(e,t,i){var r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=a*s+h*r+l*o-c*n,d=l*s+h*n+c*r-a*o,p=c*s+h*o+a*n-l*r,f=h*s-a*r-l*n-c*o;return Hh.rotateY(e,t,i),e[4]=u*(s=e[3])+f*(r=e[0])+d*(o=e[2])-p*(n=e[1]),e[5]=d*s+f*n+p*r-u*o,e[6]=p*s+f*o+u*n-d*r,e[7]=f*s-u*r-d*n-p*o,e},Zh.rotateZ=function(e,t,i){var r=-t[0],n=-t[1],o=-t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=a*s+h*r+l*o-c*n,d=l*s+h*n+c*r-a*o,p=c*s+h*o+a*n-l*r,f=h*s-a*r-l*n-c*o;return Hh.rotateZ(e,t,i),e[4]=u*(s=e[3])+f*(r=e[0])+d*(o=e[2])-p*(n=e[1]),e[5]=d*s+f*n+p*r-u*o,e[6]=p*s+f*o+u*n-d*r,e[7]=f*s-u*r-d*n-p*o,e},Zh.rotateByQuatAppend=function(e,t,i){var r=i[0],n=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],h=t[3];return e[0]=a*s+h*r+l*o-c*n,e[1]=l*s+h*n+c*r-a*o,e[2]=c*s+h*o+a*n-l*r,e[3]=h*s-a*r-l*n-c*o,e[4]=(a=t[4])*s+(h=t[7])*r+(l=t[5])*o-(c=t[6])*n,e[5]=l*s+h*n+c*r-a*o,e[6]=c*s+h*o+a*n-l*r,e[7]=h*s-a*r-l*n-c*o,e},Zh.rotateByQuatPrepend=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],h=i[3];return e[0]=r*h+s*a+n*c-o*l,e[1]=n*h+s*l+o*a-r*c,e[2]=o*h+s*c+r*l-n*a,e[3]=s*h-r*a-n*l-o*c,e[4]=r*(h=i[7])+s*(a=i[4])+n*(c=i[6])-o*(l=i[5]),e[5]=n*h+s*l+o*a-r*c,e[6]=o*h+s*c+r*l-n*a,e[7]=s*h-r*a-n*l-o*c,e},Zh.rotateAroundAxis=function(e,t,i,r){if(Math.abs(r)<Wh.EPSILON)return Qh(e,t);var n=Math.hypot(i[0],i[1],i[2]);r*=.5;var o=Math.sin(r),s=o*i[0]/n,a=o*i[1]/n,l=o*i[2]/n,c=Math.cos(r),h=t[0],u=t[1],d=t[2],p=t[3];e[0]=h*c+p*s+u*l-d*a,e[1]=u*c+p*a+d*s-h*l,e[2]=d*c+p*l+h*a-u*s,e[3]=p*c-h*s-u*a-d*l;var f=t[4],m=t[5],_=t[6],g=t[7];return e[4]=f*c+g*s+m*l-_*a,e[5]=m*c+g*a+_*s-f*l,e[6]=_*c+g*l+f*a-m*s,e[7]=g*c-f*s-m*a-_*l,e},Zh.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e[4]=t[4]+i[4],e[5]=t[5]+i[5],e[6]=t[6]+i[6],e[7]=t[7]+i[7],e},Zh.multiply=eu,Zh.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e},Zh.lerp=function(e,t,i,r){var n=1-r;return tu(t,i)<0&&(r=-r),e[0]=t[0]*n+i[0]*r,e[1]=t[1]*n+i[1]*r,e[2]=t[2]*n+i[2]*r,e[3]=t[3]*n+i[3]*r,e[4]=t[4]*n+i[4]*r,e[5]=t[5]*n+i[5]*r,e[6]=t[6]*n+i[6]*r,e[7]=t[7]*n+i[7]*r,e},Zh.invert=function(e,t){var i=ru(t);return e[0]=-t[0]/i,e[1]=-t[1]/i,e[2]=-t[2]/i,e[3]=t[3]/i,e[4]=-t[4]/i,e[5]=-t[5]/i,e[6]=-t[6]/i,e[7]=t[7]/i,e},Zh.conjugate=function(e,t){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},Zh.normalize=function(e,t){var i=ru(t);if(i>0){i=Math.sqrt(i);var r=t[0]/i,n=t[1]/i,o=t[2]/i,s=t[3]/i,a=t[4],l=t[5],c=t[6],h=t[7],u=r*a+n*l+o*c+s*h;e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=(a-r*u)/i,e[5]=(l-n*u)/i,e[6]=(c-o*u)/i,e[7]=(h-s*u)/i;}return e},Zh.str=function(e){return "quat2("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+")"},Zh.exactEquals=function(e,t){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]},Zh.equals=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],h=t[0],u=t[1],d=t[2],p=t[3],f=t[4],m=t[5],_=t[6],g=t[7];return Math.abs(i-h)<=Wh.EPSILON*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(r-u)<=Wh.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(n-d)<=Wh.EPSILON*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(o-p)<=Wh.EPSILON*Math.max(1,Math.abs(o),Math.abs(p))&&Math.abs(s-f)<=Wh.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(a-m)<=Wh.EPSILON*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(l-_)<=Wh.EPSILON*Math.max(1,Math.abs(l),Math.abs(_))&&Math.abs(c-g)<=Wh.EPSILON*Math.max(1,Math.abs(c),Math.abs(g))},Zh.sqrLen=Zh.squaredLength=Zh.len=Zh.length=Zh.dot=Zh.mul=Zh.setReal=Zh.getReal=void 0;var Wh=Kh(lc),Hh=Kh(jc),Xh=Kh(Pc);function Yh(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (Yh=function(e){return e?i:t})(e)}function Kh(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==$h(e)&&"function"!=typeof e)return {default:e};var i=Yh(t);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}function Jh(e,t,i){var r=.5*i[0],n=.5*i[1],o=.5*i[2],s=t[0],a=t[1],l=t[2],c=t[3];return e[0]=s,e[1]=a,e[2]=l,e[3]=c,e[4]=r*c+n*l-o*a,e[5]=n*c+o*s-r*l,e[6]=o*c+r*a-n*s,e[7]=-r*s-n*a-o*l,e}function Qh(e,t){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}function eu(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=i[4],l=i[5],c=i[6],h=i[7],u=t[4],d=t[5],p=t[6],f=t[7],m=i[0],_=i[1],g=i[2],y=i[3];return e[0]=r*y+s*m+n*g-o*_,e[1]=n*y+s*_+o*m-r*g,e[2]=o*y+s*g+r*_-n*m,e[3]=s*y-r*m-n*_-o*g,e[4]=r*h+s*a+n*c-o*l+u*y+f*m+d*g-p*_,e[5]=n*h+s*l+o*a-r*c+d*y+f*_+p*m-u*g,e[6]=o*h+s*c+r*l-n*a+p*y+f*g+u*_-d*m,e[7]=s*h-r*a-n*l-o*c+f*y-u*m-d*_-p*g,e}Zh.getReal=Hh.copy,Zh.setReal=Hh.copy,Zh.mul=eu;var tu=Hh.dot;Zh.dot=tu;var iu=Hh.length;Zh.length=iu,Zh.len=iu;var ru=Hh.squaredLength;Zh.squaredLength=ru,Zh.sqrLen=ru;var nu={};function ou(e){return ou="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ou(e)}Object.defineProperty(nu,"__esModule",{value:!0}),nu.create=lu,nu.clone=function(e){var t=new su.ARRAY_TYPE(2);return t[0]=e[0],t[1]=e[1],t},nu.fromValues=function(e,t){var i=new su.ARRAY_TYPE(2);return i[0]=e,i[1]=t,i},nu.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},nu.set=function(e,t,i){return e[0]=t,e[1]=i,e},nu.add=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e},nu.subtract=cu,nu.multiply=hu,nu.divide=uu,nu.ceil=function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e},nu.floor=function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e},nu.min=function(e,t,i){return e[0]=Math.min(t[0],i[0]),e[1]=Math.min(t[1],i[1]),e},nu.max=function(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e},nu.round=function(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e},nu.scale=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},nu.scaleAndAdd=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e},nu.distance=du,nu.squaredDistance=pu,nu.length=fu,nu.squaredLength=mu,nu.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},nu.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},nu.normalize=function(e,t){var i=t[0],r=t[1],n=i*i+r*r;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e},nu.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},nu.cross=function(e,t,i){var r=t[0]*i[1]-t[1]*i[0];return e[0]=e[1]=0,e[2]=r,e},nu.lerp=function(e,t,i,r){var n=t[0],o=t[1];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e},nu.random=function(e,t){t=t||1;var i=2*su.RANDOM()*Math.PI;return e[0]=Math.cos(i)*t,e[1]=Math.sin(i)*t,e},nu.transformMat2=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[2]*n,e[1]=i[1]*r+i[3]*n,e},nu.transformMat2d=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[2]*n+i[4],e[1]=i[1]*r+i[3]*n+i[5],e},nu.transformMat3=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[3]*n+i[6],e[1]=i[1]*r+i[4]*n+i[7],e},nu.transformMat4=function(e,t,i){var r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e},nu.rotate=function(e,t,i,r){var n=t[0]-i[0],o=t[1]-i[1],s=Math.sin(r),a=Math.cos(r);return e[0]=n*a-o*s+i[0],e[1]=n*s+o*a+i[1],e},nu.angle=function(e,t){var i=e[0],r=e[1],n=t[0],o=t[1],s=Math.sqrt(i*i+r*r)*Math.sqrt(n*n+o*o);return Math.acos(Math.min(Math.max(s&&(i*n+r*o)/s,-1),1))},nu.zero=function(e){return e[0]=0,e[1]=0,e},nu.str=function(e){return "vec2("+e[0]+", "+e[1]+")"},nu.exactEquals=function(e,t){return e[0]===t[0]&&e[1]===t[1]},nu.equals=function(e,t){var i=e[0],r=e[1],n=t[0],o=t[1];return Math.abs(i-n)<=su.EPSILON*Math.max(1,Math.abs(i),Math.abs(n))&&Math.abs(r-o)<=su.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))},nu.forEach=nu.sqrLen=nu.sqrDist=nu.dist=nu.div=nu.mul=nu.sub=nu.len=void 0;var su=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==ou(e)&&"function"!=typeof e)return {default:e};var i=au(void 0);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}(lc);function au(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (au=function(e){return e?i:t})(e)}function lu(){var e=new su.ARRAY_TYPE(2);return su.ARRAY_TYPE!=Float32Array&&(e[0]=0,e[1]=0),e}function cu(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e}function hu(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e}function uu(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e}function du(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}function pu(e,t){var i=t[0]-e[0],r=t[1]-e[1];return i*i+r*r}function fu(e){return Math.hypot(e[0],e[1])}function mu(e){var t=e[0],i=e[1];return t*t+i*i}nu.len=fu,nu.sub=cu,nu.mul=hu,nu.div=uu,nu.dist=du,nu.sqrDist=pu,nu.sqrLen=mu;var _u=function(){var e=lu();return function(t,i,r,n,o,s){var a,l;for(i||(i=2),r||(r=0),l=n?Math.min(n*i+r,t.length):t.length,a=r;a<l;a+=i)e[0]=t[a],e[1]=t[a+1],o(e,e,s),t[a]=e[0],t[a+1]=e[1];return t}}();function gu(e){return gu="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gu(e)}nu.forEach=_u,Object.defineProperty(ac,"__esModule",{value:!0});var yu=ac.vec4=Du=ac.vec3=ac.vec2=ac.quat2=Iu=ac.quat=Au=ac.mat4=Eu=ac.mat3=ac.mat2d=bu=ac.mat2=ac.glMatrix=void 0,xu=ku(lc);ac.glMatrix=xu;var vu=ku(pc),bu=ac.mat2=vu,wu=ku(xc);ac.mat2d=wu;var Tu=ku(Mc),Eu=ac.mat3=Tu,Mu=ku(Pc),Au=ac.mat4=Mu,Su=ku(jc),Iu=ac.quat=Su,Cu=ku(Zh);ac.quat2=Cu;var zu=ku(nu);ac.vec2=zu;var Pu=ku(Gc),Du=ac.vec3=Pu,Ru=ku(nh);function Lu(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,i=new WeakMap;return (Lu=function(e){return e?i:t})(e)}function ku(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==gu(e)&&"function"!=typeof e)return {default:e};var i=Lu(t);if(i&&i.has(e))return i.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=n?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(r,o,s):r[o]=e[o];}return r.default=e,i&&i.set(e,r),r}yu=ac.vec4=Ru;const Ou=Ia([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Bu}=Ou,Fu=Ia([{name:"a_pos_3",components:3,type:"Int16"}]);var Nu=Ia([{name:"a_pos",type:"Int16",components:2}]),Uu={};!function(e,t){!function(e){function t(e,t,r){var n=i(256*e,256*(t=Math.pow(2,r)-t-1),r),o=i(256*(e+1),256*(t+1),r);return n[0]+","+n[1]+","+o[0]+","+o[1]}function i(e,t,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return [e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}e.getURL=function(e,i,r,n,o,s){return s=s||{},e+"?"+["bbox="+t(r,n,o),"format="+(s.format||"image/png"),"service="+(s.service||"WMS"),"version="+(s.version||"1.1.1"),"request="+(s.request||"GetMap"),"srs="+(s.srs||"EPSG:3857"),"width="+(s.width||256),"height="+(s.height||256),"layers="+i].join("&")},e.getTileBBox=t,e.getMercCoords=i,Object.defineProperty(e,"__esModule",{value:!0});}(t);}(0,Uu);var Vu=Uu;class ju{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=Zu(0,e,e,t,i);}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const i=Vu.getTileBBox(this.x,this.y,this.z),r=function(e,t,i){let r,n="";for(let o=e;o>0;o--)r=1<<o-1,n+=(t&r?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===t?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",r).replace("{bbox-epsg-3857}",i)}toString(){return `${this.z}/${this.x}/${this.y}`}}class Gu{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Zu(e,t.z,t.z,t.x,t.y);}}class qu{constructor(e,t,i,r,n){this.overscaledZ=e,this.wrap=t,this.canonical=new ju(i,+r,+n),this.key=0===t&&e===i?this.canonical.key:Zu(t,e,i,r,n);}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const t=this.canonical.z-e;return e>this.canonical.z?new qu(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new qu(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Zu(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return Zu(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return !1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ<this.overscaledZ&&e.canonical.z<this.canonical.z&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return [new qu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return [new qu(t,this.wrap,t,i,r),new qu(t,this.wrap,t,i+1,r),new qu(t,this.wrap,t,i,r+1),new qu(t,this.wrap,t,i+1,r+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new qu(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new qu(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Gu(this.wrap,this.canonical)}toString(){return `${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Zu(e,t,i,r,n){const o=1<<Math.min(i,22);let s=o*(n%o)+r%o;return e&&i<22&&(s+=o*o*((e<0?-2*e-1:2*e)%(1<<2*(22-i)))),16*(32*s+i)+(t-i)}const $u=[e=>{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<<e.canonical.z)-1,i--),new qu(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>{let t=e.canonical.x+1,i=e.wrap;return t===1<<e.canonical.z&&(t=0,i++),new qu(e.overscaledZ,i,e.canonical.z,t,e.canonical.y)},e=>new qu(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<<e.canonical.z:e.canonical.y)-1),e=>new qu(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<<e.canonical.z)-1?0:e.canonical.y+1)];Rs(ju,"CanonicalTileID"),Rs(qu,"OverscaledTileID",{omit:["projMatrix","expandedProjMatrix"]});class Wu{constructor(e,t){this.pos=e,this.dir=t;}intersectsPlane(e,t,i){const r=Du.dot(t,this.dir);if(Math.abs(r)<1e-6)return !1;const n=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/r;return i[0]=this.pos[0]+this.dir[0]*n,i[1]=this.pos[1]+this.dir[1]*n,i[2]=this.pos[2]+this.dir[2]*n,!0}closestPointOnSphere(e,t,i){if(Du.equals(this.pos,e)||0===t)return i[0]=i[1]=i[2]=0,!1;const[r,n,o]=this.dir,s=this.pos[0]-e[0],a=this.pos[1]-e[1],l=this.pos[2]-e[2],c=r*r+n*n+o*o,h=2*(s*r+a*n+l*o),u=h*h-4*c*(s*s+a*a+l*l-t*t);if(u<0){const e=Math.max(-h/2,0),c=s+r*e,u=a+n*e,d=l+o*e,p=Math.hypot(c,u,d);return i[0]=c*t/p,i[1]=u*t/p,i[2]=d*t/p,!1}{const e=(-h-Math.sqrt(u))/(2*c);if(e<0){const e=Math.hypot(s,a,l);return i[0]=s*t/e,i[1]=a*t/e,i[2]=l*t/e,!1}return i[0]=s+r*e,i[1]=a+n*e,i[2]=l+o*e,!0}}}class Hu{constructor(e,t,i,r,n){this.TL=e,this.TR=t,this.BR=i,this.BL=r,this.horizon=n;}static fromInvProjectionMatrix(e,t,i){const r=[-1,1,1],n=[1,1,1],o=[1,-1,1],s=[-1,-1,1],a=Du.transformMat4(r,r,e),l=Du.transformMat4(n,n,e),c=Du.transformMat4(o,o,e),h=Du.transformMat4(s,s,e);return new Hu(a,l,c,h,t/i)}}function Xu(e,t,i){let r=1/0,n=-1/0;const o=[];for(const s of e){Du.sub(o,s,t);const e=Du.dot(o,i);r=Math.min(r,e),n=Math.max(n,e);}return [r,n]}function Yu(e,t){let i=!0;for(let r=0;r<e.planes.length;r++){const n=e.planes[r];let o=0;for(let e=0;e<t.length;e++)o+=Du.dot(n,t[e])+n[3]>=0;if(0===o)return 0;o!==t.length&&(i=!1);}return i?2:1}function Ku(e,t){for(const i of e.projections){const r=Xu(t,e.points[0],i.axis);if(i.projection[1]<r[0]||i.projection[0]>r[1])return 0}return 1}function Ju(e,t){let i=0;const r=[0,0,0,0];for(let n=0;n<e.length;n++)r[0]=e[n][0],r[1]=e[n][1],r[2]=e[n][2],r[3]=1,yu.dot(r,t)>=0&&i++;return i}class Qu{constructor(e,t){this.points=e||new Array(8).fill([0,0,0]),this.planes=t||new Array(6).fill([0,0,0,0]),this.bounds=ed.fromPoints(this.points),this.projections=[],this.frustumEdges=[Du.sub([],this.points[2],this.points[3]),Du.sub([],this.points[0],this.points[3]),Du.sub([],this.points[4],this.points[0]),Du.sub([],this.points[5],this.points[1]),Du.sub([],this.points[6],this.points[2]),Du.sub([],this.points[7],this.points[3])];for(const e of this.frustumEdges){const t=[0,-e[2],e[1]],i=[e[2],0,-e[0]];this.projections.push({axis:t,projection:Xu(this.points,this.points[0],t)}),this.projections.push({axis:i,projection:Xu(this.points,this.points[0],i)});}}static fromInvProjectionMatrix(e,t,i,r){const n=Math.pow(2,i),o=[[-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]].map((i=>{const o=yu.transformMat4([],i,e),s=1/o[3]/t*n;return yu.mul(o,o,[s,s,r?1/o[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const t=Du.sub([],o[e[0]],o[e[1]]),i=Du.sub([],o[e[2]],o[e[1]]),r=Du.normalize([],Du.cross([],t,i)),n=-Du.dot(r,o[e[1]]);return r.concat(n)})),a=[];for(let e=0;e<o.length;e++)a.push([o[e][0],o[e][1],o[e][2]]);return new Qu(a,s)}intersectsPrecise(e,t,i){for(let i=0;i<t.length;i++)if(!Ju(e,t[i]))return 0;for(let t=0;t<this.planes.length;t++)if(!Ju(e,this.planes[t]))return 0;for(const t of i)for(const i of this.frustumEdges){const r=Du.cross([],t,i),n=Du.length(r);if(0===n)continue;Du.scale(r,r,1/n);const o=Xu(this.points,this.points[0],r),s=Xu(e,this.points[0],r);if(o[0]>s[1]||s[0]>o[1])return 0}return 1}}class ed{static fromPoints(e){const t=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const r of e)Du.min(t,t,r),Du.max(i,i,r);return new ed(t,i)}static fromTileIdAndHeight(e,t,i){const r=1<<e.canonical.z,n=e.canonical.x,o=e.canonical.y;return new ed([n/r,o/r,t],[(n+1)/r,(o+1)/r,i])}static applyTransform(e,t){const i=e.getCorners();for(let e=0;e<i.length;++e)Du.transformMat4(i[e],i[e],t);return ed.fromPoints(i)}static projectAabbCorners(e,t){const i=e.getCorners();for(let e=0;e<i.length;++e)Du.transformMat4(i[e],i[e],t);return i}constructor(e,t){this.min=e,this.max=t,this.center=Du.scale([],Du.add([],this.min,this.max),.5);}quadrant(e){const t=[e%2==0,e<2],i=Du.clone(this.min),r=Du.clone(this.max);for(let e=0;e<t.length;e++)i[e]=t[e]?this.min[e]:this.center[e],r[e]=t[e]?this.center[e]:this.max[e];return r[2]=this.max[2],new ed(i,r)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,t=this.max;return [[e[0],e[1],e[2]],[t[0],e[1],e[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],t[2]],[e[0],t[1],t[2]]]}intersects(e){return this.intersectsAabb(e.bounds)?Yu(e,this.getCorners()):0}intersectsFlat(e){return this.intersectsAabb(e.bounds)?Yu(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsPrecise(e,t){return t||this.intersects(e)?Ku(e,this.getCorners()):0}intersectsPreciseFlat(e,t){return t||this.intersectsFlat(e)?Ku(e,[[this.min[0],this.min[1],0],[this.max[0],this.min[1],0],[this.max[0],this.max[1],0],[this.min[0],this.max[1],0]]):0}intersectsAabb(e){for(let t=0;t<3;++t)if(this.min[t]>e.max[t]||e.min[t]>this.max[t])return !1;return !0}intersectsAabbXY(e){return !(this.min[0]>e.max[0]||e.min[0]>this.max[0]||this.min[1]>e.max[1]||e.min[1]>this.max[1])}encapsulate(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e.min[t]),this.max[t]=Math.max(this.max[t],e.max[t]);}encapsulatePoint(e){for(let t=0;t<3;t++)this.min[t]=Math.min(this.min[t],e[t]),this.max[t]=Math.max(this.max[t],e[t]);}closestPoint(e){return [Math.max(Math.min(this.max[0],e[0]),this.min[0]),Math.max(Math.min(this.max[1],e[1]),this.min[1]),Math.max(Math.min(this.max[2],e[2]),this.min[2])]}}Rs(ed,"Aabb");const td=5,id=6,rd=cr/Math.PI/2,nd=16383,od=64,sd=[od,32,16],ad=-rd,ld=rd,cd=[new ed([ad,ad,ad],[ld,ld,ld]),new ed([ad,ad,ad],[0,0,ld]),new ed([0,ad,ad],[ld,0,ld]),new ed([ad,0,ad],[0,ld,ld]),new ed([0,0,ad],[ld,ld,ld])];function hd(e){return e*rd/qd}function ud(e,t,i,r=!0){const n=Du.scale([],e._camera.position,e.worldSize),o=[t,i,1,1];yu.transformMat4(o,o,e.pixelMatrixInverse),yu.scale(o,o,1/o[3]);const s=Du.sub([],o,n),a=Du.normalize([],s),l=e.globeMatrix,c=[l[12],l[13],l[14]],h=Du.sub([],c,n),u=Du.length(h),d=Du.normalize([],h),p=e.worldSize/(2*Math.PI),f=Du.dot(d,a),m=Math.asin(p/u);if(m<Math.acos(f)){if(!r)return null;const e=[],t=[];Du.scale(e,a,u/f),Du.normalize(t,Du.sub(t,e,h)),Du.normalize(a,Du.add(a,h,Du.scale(a,t,Math.tan(m)*u)));}const _=[];new Wu(n,a).closestPointOnSphere(c,p,_);const g=Du.normalize([],ne(l,0)),y=Du.normalize([],ne(l,1)),x=Du.normalize([],ne(l,2)),v=Du.dot(g,_),b=Du.dot(y,_),w=Du.dot(x,_),E=T(Math.asin(-b/p));let M=T(Math.atan2(v,w));M=e.center.lng+function(e,t){const i=(t-e+180)%360-180;return i<-180?i+360:i}(e.center.lng,M);const A=Kd(M),S=z(Jd(E),0,1);return new lp(A,S)}class dd{constructor(e,t,i){this.a=Du.sub([],e,i),this.b=Du.sub([],t,i),this.center=i;const r=Du.normalize([],this.a),n=Du.normalize([],this.b);this.angle=Math.acos(Du.dot(r,n));}}function pd(e,t){if(0===e.angle)return null;let i;return i=0===e.a[t]?1/e.angle*.5*Math.PI:1/e.angle*Math.atan(e.b[t]/e.a[t]/Math.sin(e.angle)-1/Math.tan(e.angle)),i<0||i>1?null:function(e,t,i,r){const n=Math.sin(i);return e*(Math.sin((1-r)*i)/n)+t*(Math.sin(r*i)/n)}(e.a[t],e.b[t],e.angle,z(i,0,1))+e.center[t]}function fd(e){if(e.z<=1)return cd[e.z+2*e.y+e.x];const t=vd(xd(e));return ed.fromPoints(t)}function md(e,t,i){return Du.scale(e,e,1-i),Du.scaleAndAdd(e,e,t,i)}function _d(e,t){const i=Dd(t.zoom);if(0===i)return fd(e);const r=xd(e),n=vd(r),o=Kd(r.getWest())*t.worldSize,s=Kd(r.getEast())*t.worldSize,a=Jd(r.getNorth())*t.worldSize,l=Jd(r.getSouth())*t.worldSize,c=[o,a,0],h=[s,a,0],u=[o,l,0],d=[s,l,0],p=Au.invert([],t.globeMatrix);return Du.transformMat4(c,c,p),Du.transformMat4(h,h,p),Du.transformMat4(u,u,p),Du.transformMat4(d,d,p),n[0]=md(n[0],u,i),n[1]=md(n[1],d,i),n[2]=md(n[2],h,i),n[3]=md(n[3],c,i),ed.fromPoints(n)}function gd(e,t,i){for(const r of e)Du.transformMat4(r,r,t),Du.scale(r,r,i);}function yd(e,t,i,r){const n=t/e.worldSize,o=e.globeMatrix;if(i.z<=1){const e=fd(i).getCorners();return gd(e,o,n),ed.fromPoints(e)}const s=xd(i,r),a=vd(s);gd(a,o,n);const l=Number.MAX_VALUE,c=[-l,-l,-l],h=[l,l,l];if(s.contains(e.center)){for(const e of a)Du.min(h,h,e),Du.max(c,c,e);c[2]=0;const t=e.point,i=[t.x*n,t.y*n,0];return Du.min(h,h,i),Du.max(c,c,i),new ed(h,c)}const u=[o[12]*n,o[13]*n,o[14]*n],d=s.getCenter(),p=z(e.center.lat,-rp,rp),f=z(d.lat,-rp,rp),m=Kd(e.center.lng),_=Jd(p);let g=m-Kd(d.lng);const y=_-Jd(f);g>.5?g-=1:g<-.5&&(g+=1);let x=0;if(Math.abs(g)>Math.abs(y))x=g>=0?1:3;else {x=y>=0?0:2;const e=[o[4]*n,o[5]*n,o[6]*n],t=-Math.sin(w(y>=0?s.getSouth():s.getNorth()))*rd;Du.scaleAndAdd(u,u,e,t);}const v=a[x],b=a[(x+1)%4],T=new dd(v,b,u),E=[pd(T,0)||v[0],pd(T,1)||v[1],pd(T,2)||v[2]],M=Dd(e.zoom);if(M>0){const r=function({x:e,y:t,z:i},r,n,o,s){const a=1/(1<<i);let l=e*a,c=l+a,h=t*a,u=h+a,d=0;const p=(l+c)/2-o;return p>.5?d=-1:p<-.5&&(d=1),l=((l+d)*r-(o*=r))*n+o,c=((c+d)*r-o)*n+o,h=(h*r-(s*=r))*n+s,u=(u*r-s)*n+s,[[l,u,0],[c,u,0],[c,h,0],[l,h,0]]}(i,t,e._pixelsPerMercatorPixel,m,_);for(let e=0;e<a.length;e++)md(a[e],r[e],M);const n=Du.add([],r[x],r[(x+1)%4]);Du.scale(n,n,.5),md(E,n,M);}for(const e of a)Du.min(h,h,e),Du.max(c,c,e);return h[2]=Math.min(v[2],b[2]),Du.min(h,h,E),Du.max(c,c,E),new ed(h,c)}function xd({x:e,y:t,z:i},r=!1){const n=1/(1<<i),o=new Wd(ep(e*n),t===(1<<i)-1&&r?-90:tp((t+1)*n)),s=new Wd(ep((e+1)*n),0===t&&r?90:tp(t*n));return new sc(o,s)}function vd(e){const t=w(e.getNorth()),i=w(e.getSouth()),r=Math.cos(t),n=Math.cos(i),o=Math.sin(t),s=Math.sin(i),a=e.getWest(),l=e.getEast();return [bd(n,s,a),bd(n,s,l),bd(r,o,l),bd(r,o,a)]}function bd(e,t,i,r=rd){return i=w(i),[e*Math.sin(i)*r,-t*r,e*Math.cos(i)*r]}function wd(e,t,i){return bd(Math.cos(w(e)),Math.sin(w(e)),t,i)}function Td(e,t,i,r){const n=1<<i.z,o=(e/cr+i.x)/n;return wd(tp((t/cr+i.y)/n),ep(o),r)}function Ed({min:e,max:t}){return nd/Math.max(t[0]-e[0],t[1]-e[1],t[2]-e[2])}const Md=new Float64Array(16);function Ad(e){const t=Ed(e),i=Au.fromScaling(Md,[t,t,t]);return Au.translate(i,i,Du.negate([],e.min))}function Sd(e){const t=Au.fromTranslation(Md,e.min),i=1/Ed(e);return Au.scale(t,t,[i,i,i])}function Id(e){const t=cr/(2*Math.PI);return e/(2*Math.PI)/t}function Cd(e,t){return cr/(512*Math.pow(2,e))*Ed(fd(t))}function zd(e,t,i,r,n){const o=Id(i),s=[e,t,-i/(2*Math.PI)],a=Au.identity(new Float64Array(16));return Au.translate(a,a,s),Au.scale(a,a,[o,o,o]),Au.rotateX(a,a,w(-n)),Au.rotateY(a,a,w(-r)),a}function Pd(e){const t=e.pixelsPerMeter,i=t/Qd(1,e.center.lat),r=Au.identity(new Float64Array(16));return Au.translate(r,r,[e.point.x,e.point.y,0]),Au.scale(r,r,[i,i,t]),Float32Array.from(r)}function Dd(e){return P(td,id,e)}function Rd(e,t,i){const r=Au.identity(new Float64Array(16)),n=(t/(1<<e)-.5)*Math.PI*2;return Au.rotateY(r,i.globeMatrix,n),Float32Array.from(r)}function Ld(e,t,i){const r=Dd(i.zoom),n=e.style.map._antialias,o=t.options.extStandardDerivativesForceOff||e.terrain&&e.terrain.exaggeration()>0;return 0===r&&!n&&!o}function kd(e,t,i,r){const n=t.getNorth(),o=t.getSouth(),s=t.getWest(),a=t.getEast(),l=1<<e.z,c=a-s,h=n-o,u=c/od,d=-h/sd[i],p=[0,u,0,d,0,0,n,s,0];if(e.z>0){const e=180/r;Eu.multiply(p,p,[e/c+1,0,0,0,e/h+1,0,-.5*e/u,.5*e/d,1]);}return p[2]=l,p[5]=e.x,p[8]=e.y,p}function Od(e){const t=rp-5;e=z(e,-t,t)/t*90;const i=Math.pow(Math.abs(Math.sin(w(e))),3);return Math.round(i*(sd.length-1))}function Bd(e){const t=[0,0,0],i=Au.identity(new Float64Array(16));return Au.multiply(i,e.pixelMatrix,e.globeMatrix),Du.transformMat4(t,t,i),new y(t[0],t[1])}function Fd(e,t){const i=wd(t.lat,t.lng),r=function(e){const t=wd(e._center.lat,e._center.lng),i=Du.fromValues(0,1,0);let r=Du.cross([],i,t);const n=Au.fromRotation([],-e.angle,t);r=Du.transformMat4(r,r,n),Au.fromRotation(n,-e._pitch,r);const o=Du.normalize([],t);return Du.scale(o,o,hd(e.cameraToCenterDistance/e.pixelsPerMeter)),Du.transformMat4(o,o,n),Du.add([],t,o)}(e),n=Du.subtract([],r,i);return Du.angle(n,i)}function Nd(e,t){return Fd(e,t)>Math.PI/2*1.01}const Ud=w(85),Vd=Math.cos(Ud),jd=Math.sin(Ud);class Gd{constructor(e){this._createGrid(e),this._createPoles(e);}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const e of this._poleSegments)e.destroy();for(const e of this._gridSegments)e.withSkirts.destroy(),e.withoutSkirts.destroy();}_fillGridMeshWithLods(e,t){const i=new za,r=new Wa,n=[],o=e+1+2,s=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,i)=>{let r=e===o-1?e-2:0===e?e:e-1;return r+=i?24575:0,[r,t]};for(let e=0;e<o;++e)i.emplaceBack(...l(e,0,!0));for(let e=0;e<s;++e)for(let t=0;t<o;++t)i.emplaceBack(...l(t,e,(0===t||t===o-1)&&!0));for(let e=0;e<t.length;++e){const r=t[e];for(let e=0;e<o;++e)i.emplaceBack(...l(e,r,!0));}for(let e=0;e<t.length;++e){const s=r.length,l=t[e]+1+2,c=new Wa;for(let i=0;i<l-1;i++){const n=i===l-2,s=n?o*(a-t.length+e-i):o;for(let e=0;e<o-1;e++){const t=i*o+e;0===i||n||0===e||e===o-2?(c.emplaceBack(t+1,t,t+s),c.emplaceBack(t+s,t+s+1,t+1)):(r.emplaceBack(t+1,t,t+s),r.emplaceBack(t+s,t+s+1,t+1));}}const h=xl.simpleSegment(0,s,i.length,r.length-s);for(let e=0;e<c.uint16.length;e+=3)r.emplaceBack(c.uint16[e],c.uint16[e+1],c.uint16[e+2]);const u=xl.simpleSegment(0,s,i.length,r.length-s);n.push({withoutSkirts:h,withSkirts:u});}return {vertices:i,indices:r,segments:n}}_createGrid(e){const t=this._fillGridMeshWithLods(od,sd);this._gridSegments=t.segments,this._gridBuffer=e.createVertexBuffer(t.vertices,Nu.members),this._gridIndexBuffer=e.createIndexBuffer(t.indices,!0);}_createPoles(e){const t=new Wa;for(let e=0;e<=od;e++)t.emplaceBack(0,e+1,e+2);this._poleIndexBuffer=e.createIndexBuffer(t,!0);const i=new Ka,r=new Ka,n=new Ka,o=new Ka;this._poleSegments=[];for(let e=0,t=0;e<td;e++){const s=360/(1<<e);i.emplaceBack(0,-rd,0,.5,0),r.emplaceBack(0,-rd,0,.5,1),n.emplaceBack(0,-rd,0,.5,.5),o.emplaceBack(0,-rd,0,.5,.5);for(let e=0;e<=od;e++){let t=e/od,a=0;const l=Kr(0,s,t),[c,h,u]=bd(Vd,jd,l,rd);i.emplaceBack(c,h,u,t,a),r.emplaceBack(c,h,u,t,1-a);const d=w(l);t=.5+.5*Math.sin(d),a=.5+.5*Math.cos(d),n.emplaceBack(c,h,u,t,a),o.emplaceBack(c,h,u,t,1-a);}this._poleSegments.push(xl.simpleSegment(t,0,66,64)),t+=66;}this._poleNorthVertexBuffer=e.createVertexBuffer(i,Bu,!1),this._poleSouthVertexBuffer=e.createVertexBuffer(r,Bu,!1),this._texturedPoleNorthVertexBuffer=e.createVertexBuffer(n,Bu,!1),this._texturedPoleSouthVertexBuffer=e.createVertexBuffer(o,Bu,!1);}getGridBuffers(e,t){return [this._gridBuffer,this._gridIndexBuffer,t?this._gridSegments[e].withSkirts:this._gridSegments[e].withoutSkirts]}getPoleBuffers(e,t){return [t?this._texturedPoleNorthVertexBuffer:this._poleNorthVertexBuffer,t?this._texturedPoleSouthVertexBuffer:this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[e]]}}const qd=6371008.8,Zd=2*Math.PI*qd;class $d{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${t})`);if(this.lng=+e,this.lat=+t,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new $d(D(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return qd*Math.acos(Math.min(n,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new sc(new $d(this.lng-i,this.lat-t),new $d(this.lng+i,this.lat+t))}toEcef(e){const t=hd(e);return wd(this.lat,this.lng,rd+t)}static convert(e){if(e instanceof $d)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new $d(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new $d(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}var Wd=$d;const Hd=0,Xd=25.5;function Yd(e){return Zd*Math.cos(e*Math.PI/180)}function Kd(e){return (180+e)/360}function Jd(e){return (180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Qd(e,t){return e/Yd(t)}function ep(e){return 360*e-180}function tp(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function ip(e,t){return e*Yd(tp(t))}const rp=85.051129;function np(e){return Math.cos(w(z(e,-rp,rp)))}function op(e,t){const i=z(t,Hd,Xd),r=Math.pow(2,i);return np(e)*Zd/(512*r)}function sp(e){return 1/Math.cos(e*Math.PI/180)}function ap(e,t=0){const i=Math.exp(Math.PI*(1-(e.y+t/cr)/(1<<e.z)*2));return 80150034*i/(i*i+1)/cr/(1<<e.z)}class lp{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i;}static fromLngLat(e,t=0){const i=Wd.convert(e);return new lp(Kd(i.lng),Jd(i.lat),Qd(t,i.lat))}toLngLat(){return new Wd(ep(this.x),tp(this.y))}toAltitude(){return ip(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Zd*sp(tp(this.y))}}function cp(e,t,i,r,n,o,s,a,l){const c=(t+r)/2,h=(i+n)/2,u=new y(c,h);a(u),function(e,t,i,r,n,o){const s=i-n,a=r-o;return Math.abs((r-t)*s-(i-e)*a)/Math.hypot(s,a)}(u.x,u.y,o.x,o.y,s.x,s.y)>=l?(cp(e,t,i,c,h,o,u,a,l),cp(e,c,h,r,n,u,s,a,l)):e.push(s);}function hp(e,t,i){let r=e[0],n=r.x,o=r.y;t(r);const s=[r];for(let a=1;a<e.length;a++){const l=e[a],{x:c,y:h}=l;t(l),cp(s,n,o,c,h,r,l,t,i),n=c,o=h,r=l;}return s}function up(e,t,i,r){if(r(t,i)){const n=t.add(i)._mult(.5);up(e,t,n,r),up(e,n,i,r);}else e.push(i);}function dp(e,t){let i=e[0];const r=[i];for(let n=1;n<e.length;n++){const o=e[n];up(r,i,o,t),i=o;}return r}const pp=Math.pow(2,14)-1,fp=-pp-1;function mp(e,t){const i=Math.round(e.x*t),r=Math.round(e.y*t);return e.x=z(i,fp,pp),e.y=z(r,fp,pp),(i<e.x||i>e.x+1||r<e.y||r>e.y+1)&&H("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function _p(e,t,i){const r=e.loadGeometry(),n=e.extent,o=cr/n;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<<t.z,{scale:s,x:a,y:l,projection:c}=i,h=e=>{const i=ep((t.x+e.x/n)/o),r=tp((t.y+e.y/n)/o),h=c.project(i,r);e.x=(h.x*s-a)*n,e.y=(h.y*s-l)*n;};for(let t=0;t<r.length;t++)if(1!==e.type)r[t]=hp(r[t],h,1);else {const e=[];for(const i of r[t])i.x<0||i.x>=n||i.y<0||i.y>=n||(h(i),e.push(i));r[t]=e;}}for(const e of r)for(const t of e)mp(t,o);return r}function gp(e,t){return {type:e.type,id:e.id,properties:e.properties,geometry:t?_p(e):[]}}function yp(e,t,i,r,n){e.emplaceBack(2*t+(r+1)/2,2*i+(n+1)/2);}function xp(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r);}class vp{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new za,this.indexArray=new Wa,this.segments=new xl,this.programConfigurations=new ec(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id));}populate(e,t,i,r){const n=this.layers[0],o=[];let s=null;"circle"===n.type&&(s=n.layout.get("circle-sort-key"));for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=gp(t,e);if(!this.layers[0]._featureFilter.filter(new oa(this.zoom),c,i))continue;const h=s?s.evaluate(c,{},i):void 0,u={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:_p(t,i,r),patterns:{},sortKey:h};o.push(u);}s&&o.sort(((e,t)=>e.sortKey-t.sortKey));let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new Fa,a=r.projection);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r,l=e[o].feature;this.addFeature(r,n,o,t.availableImages,i,a,t.brightness),t.featureIndex.insert(l,n,o,s,this.index);}}update(e,t,i,r,n){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,i,r,n);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gl.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,yl.members))),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy());}addFeature(e,t,i,r,n,o,s){for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=cr||r<0||r>=cr)continue;if(o){const e=o.projectTilePoint(i,r,n),t=o.upVector(n,i,r),s=this.globeExtVertexArray;xp(s,e,t),xp(s,e,t),xp(s,e,t),xp(s,e,t);}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;yp(this.layoutVertexArray,i,r,-1,-1),yp(this.layoutVertexArray,i,r,1,-1),yp(this.layoutVertexArray,i,r,1,1),yp(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},r,n,s);}}function bp(e,t){for(let i=0;i<e.length;i++)if(zp(t,e[i]))return !0;for(let i=0;i<t.length;i++)if(zp(e,t[i]))return !0;return !!Mp(e,t)}function wp(e,t,i){return !!zp(e,t)||!!Sp(t,e,i)}function Tp(e,t){if(1===e.length)return Cp(t,e[0]);for(let i=0;i<t.length;i++){const r=t[i];for(let t=0;t<r.length;t++)if(zp(e,r[t]))return !0}for(let i=0;i<e.length;i++)if(Cp(t,e[i]))return !0;for(let i=0;i<t.length;i++)if(Mp(e,t[i]))return !0;return !1}function Ep(e,t,i){if(e.length>1){if(Mp(e,t))return !0;for(let r=0;r<t.length;r++)if(Sp(t[r],e,i))return !0}for(let r=0;r<e.length;r++)if(Sp(e[r],t,i))return !0;return !1}function Mp(e,t){if(0===e.length||0===t.length)return !1;for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++)if(Ap(r,n,t[e],t[e+1]))return !0}return !1}function Ap(e,t,i,r){return X(e,i,r)!==X(t,i,r)&&X(e,t,i)!==X(e,t,r)}function Sp(e,t,i){const r=i*i;if(1===t.length)return e.distSqr(t[0])<r;for(let i=1;i<t.length;i++)if(Ip(e,t[i-1],t[i])<r)return !0;return !1}function Ip(e,t,i){const r=t.distSqr(i);if(0===r)return e.distSqr(t);const n=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return e.distSqr(n<0?t:n>1?i:i.sub(t)._mult(n)._add(t))}function Cp(e,t){let i,r,n,o=!1;for(let s=0;s<e.length;s++){i=e[s];for(let e=0,s=i.length-1;e<i.length;s=e++)r=i[e],n=i[s],r.y>t.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(o=!o);}return o}function zp(e,t){let i=!1;for(let r=0,n=e.length-1;r<e.length;n=r++){const o=e[r],s=e[n];o.y>t.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i);}return i}function Pp(e,t,i,r,n){for(const o of e)if(t<=o.x&&i<=o.y&&r>=o.x&&n>=o.y)return !0;const o=[new y(t,i),new y(t,n),new y(r,n),new y(r,i)];if(e.length>2)for(const t of o)if(zp(e,t))return !0;for(let t=0;t<e.length-1;t++)if(Dp(e[t],e[t+1],o))return !0;return !1}function Dp(e,t,i){const r=i[0],n=i[2];if(e.x<r.x&&t.x<r.x||e.x>n.x&&t.x>n.x||e.y<r.y&&t.y<r.y||e.y>n.y&&t.y>n.y)return !1;const o=X(e,t,i[0]);return o!==X(e,t,i[1])||o!==X(e,t,i[2])||o!==X(e,t,i[3])}function Rp(e,t,i,r,n,o){let s=t.y-e.y,a=e.x-t.x;if(o=o||0){const e=s*s+a*a;if(0===e)return !0;const t=Math.sqrt(e);s/=t,a/=t;}return !((i.x-e.x)*s+(i.y-e.y)*a-o<0||(r.x-e.x)*s+(r.y-e.y)*a-o<0||(n.x-e.x)*s+(n.y-e.y)*a-o<0)}function Lp(e,t,i,r,n,o,s){return !(Rp(e,t,r,n,o,s)||Rp(t,i,r,n,o,s)||Rp(i,e,r,n,o,s)||Rp(r,n,e,t,i,s)||Rp(n,o,e,t,i,s)||Rp(o,r,e,t,i,s))}function kp(e,t,i){const r=t.paint.get(e).value;return "constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Op(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Bp(e,t,i,r,n){if(!t[0]&&!t[1])return e;const o=y.convert(t)._mult(n);"viewport"===i&&o._rotate(-r);const s=[];for(let t=0;t<e.length;t++)s.push(e[t].sub(o));return s}function Fp(e,t,i,r){const n=y.convert(e)._mult(r);return "viewport"===t&&n._rotate(-i),n}Rs(vp,"CircleBucket",{omit:["layers"]});const Np=new ga({"circle-sort-key":new ma(Pt.layout_circle["circle-sort-key"]),visibility:new fa(Pt.layout_circle.visibility)});var Up={paint:new ga({"circle-radius":new ma(Pt.paint_circle["circle-radius"]),"circle-color":new ma(Pt.paint_circle["circle-color"]),"circle-blur":new ma(Pt.paint_circle["circle-blur"]),"circle-opacity":new ma(Pt.paint_circle["circle-opacity"]),"circle-translate":new fa(Pt.paint_circle["circle-translate"]),"circle-translate-anchor":new fa(Pt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new fa(Pt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new fa(Pt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new ma(Pt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new ma(Pt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new ma(Pt.paint_circle["circle-stroke-opacity"]),"circle-emissive-strength":new fa(Pt.paint_circle["circle-emissive-strength"])}),layout:Np};const Vp=Au.create(),jp=(e,t,i,r,n,o)=>{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=Cd(s.zoom,t.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e]);}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(s.projection),u_matrix:e.translatePosMatrix(t.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:dt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:Vp,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:o.paint.get("circle-emissive-strength")};if(a){c.u_inv_rot_matrix=r,c.u_merc_center=n,c.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],c.u_zoom_transition=Dd(s.zoom);const e=n[0]*cr,i=n[1]*cr;c.u_up_dir=s.projection.upVector(new ju(0,0,0),e,i);}return c},Gp=e=>{const t=[];return "map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t};function qp(e,t,i,r,n,o,s,a,l){if(o&&e.queryGeometry.isAboveHorizon)return !1;o&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,h=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const u of t)for(const t of u){const u=t.add(a),d=n&&i.elevation?i.elevation.exaggeration()*n.getElevationAt(u.x,u.y,!0):0,p=i.projection.projectTilePoint(u.x,u.y,c);if(d>0){const e=i.projection.upVector(c,u.x,u.y);p.x+=e[0]*h*d,p.y+=e[1]*h*d,p.z+=e[2]*h*d;}const f=o?u:Zp(p.x,p.y,p.z,r),m=o?e.tilespaceRays.map((e=>Hp(e,d))):e.queryGeometry.screenGeometry,_=yu.transformMat4([],[p.x,p.y,p.z,1],r);if(!s&&o?l*=_[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/_[3]),o){const e=tp((t.y/cr+c.y)/(1<<c.z));l/=i.projection.pixelsPerMeter(e,1)/Qd(1,e);}if(wp(m,f,l))return !0}return !1}function Zp(e,t,i,r){const n=yu.transformMat4([],[e,t,i,1],r);return new y(n[0]/n[3],n[1]/n[3])}const $p=Du.fromValues(0,0,0),Wp=Du.fromValues(0,0,1);function Hp(e,t){const i=Du.create();return $p[2]=t,e.intersectsPlane($p,Wp,i),new y(i[0],i[1])}class Xp extends vp{}function Yp(e,{width:t,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==t*i*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(t*i*r);return e.width=t,e.height=i,e.data=n,e}function Kp(e,t,i){const{width:r,height:n}=t;r===e.width&&n===e.height||(Jp(e,t,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,r),height:Math.min(e.height,n)},i),e.width=r,e.height=n,e.data=t.data);}function Jp(e,t,i,r,n,o){if(0===n.width||0===n.height)return t;if(n.width>e.width||n.height>e.height||i.x>e.width-n.width||i.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;for(let l=0;l<n.height;l++){const c=((i.y+l)*e.width+i.x)*o,h=((r.y+l)*t.width+r.x)*o;for(let e=0;e<n.width*o;e++)a[h+e]=s[c+e];}return t}Rs(Xp,"HeatmapBucket",{omit:["layers"]});class Qp{constructor(e,t){Yp(this,e,1,t);}resize(e){Kp(this,new Qp(e),1);}clone(){return new Qp({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){Jp(e,t,i,r,n,1);}}class ef{constructor(e,t){Yp(this,e,4,t);}resize(e){Kp(this,new ef(e),4);}replace(e,t){t?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e;}clone(){return new ef({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){Jp(e,t,i,r,n,4);}}class tf{constructor(e,t){this.width=e.width,this.height=e.height,this.data=t instanceof Uint8Array?new Float32Array(t.buffer):t;}}Rs(Qp,"AlphaImage"),Rs(ef,"RGBAImage");const rf=new ga({visibility:new fa(Pt.layout_heatmap.visibility)});var nf={paint:new ga({"heatmap-radius":new ma(Pt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new ma(Pt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new fa(Pt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new _a(Pt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new fa(Pt.paint_heatmap["heatmap-opacity"])}),layout:rf};function of(e){const t={},i=e.resolution||256,r=e.clips?e.clips.length:1,n=e.image||new ef({width:i,height:r}),o=(i,r,o)=>{t[e.evaluationKey]=o;const s=e.expression.evaluate(t);s&&(n.data[i+r+0]=Math.floor(255*s.r/s.a),n.data[i+r+1]=Math.floor(255*s.g/s.a),n.data[i+r+2]=Math.floor(255*s.b/s.a),n.data[i+r+3]=Math.floor(255*s.a));};if(e.clips)for(let t=0,n=0;t<r;++t,n+=4*i)for(let r=0,s=0;r<i;r++,s+=4){const a=r/(i-1),{start:l,end:c}=e.clips[t];o(n,s,l*(1-a)+c*a);}else for(let e=0,t=0;e<i;e++,t+=4)o(0,t,e/(i-1));return n}const sf=new ga({visibility:new fa(Pt.layout_hillshade.visibility)});var af={paint:new ga({"hillshade-illumination-direction":new fa(Pt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new fa(Pt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new fa(Pt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new fa(Pt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new fa(Pt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new fa(Pt.paint_hillshade["hillshade-accent-color"]),"hillshade-emissive-strength":new fa(Pt.paint_hillshade["hillshade-emissive-strength"])}),layout:sf};const lf=Ia([{name:"a_pos",components:2,type:"Int16"}],4),{members:cf}=lf;var hf={exports:{}};function uf(e,t,i){i=i||2;var r,n,o,s,a,l,c,h=t&&t.length,u=h?t[0]*i:e.length,d=df(e,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(h&&(d=function(e,t,i,r){var n,o,s,a=[];for(n=0,o=t.length;n<o;n++)(s=df(e,t[n]*r,n<o-1?t[n+1]*r:e.length,r,!1))===s.next&&(s.steiner=!0),a.push(Tf(s));for(a.sort(xf),n=0;n<a.length;n++)i=vf(a[n],i);return i}(e,t,d,i)),e.length>80*i){r=o=e[0],n=s=e[1];for(var f=i;f<u;f+=i)(a=e[f])<r&&(r=a),(l=e[f+1])<n&&(n=l),a>o&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-r,s-n))?32767/c:0;}return ff(d,p,i,r,n,c,0),p}function df(e,t,i,r,n){var o,s;if(n===Of(e,t,i,r)>0)for(o=t;o<i;o+=r)s=Rf(o,e[o],e[o+1],s);else for(o=i-r;o>=t;o-=r)s=Rf(o,e[o],e[o+1],s);return s&&Sf(s,s.next)&&(Lf(s),s=s.next),s}function pf(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!Sf(r,r.next)&&0!==Af(r.prev,r,r.next))r=r.next;else {if(Lf(r),(r=t=r.prev)===r.next)break;i=!0;}}while(i||r!==t);return t}function ff(e,t,i,r,n,o,s){if(e){!s&&o&&function(e,t,i,r){var n=e;do{0===n.z&&(n.z=wf(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){var t,i,r,n,o,s,a,l,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;t<c&&(a++,r=r.nextZ);t++);for(l=c;a>0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r;}o.nextZ=null,c*=2;}while(s>1)}(n);}(e,r,n,o);for(var a,l,c=e;e.prev!==e.next;)if(a=e.prev,l=e.next,o?_f(e,r,n,o):mf(e))t.push(a.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),Lf(e),e=l.next,c=l.next;else if((e=l)===c){s?1===s?ff(e=gf(pf(e),t,i),t,i,r,n,o,2):2===s&&yf(e,t,i,r,n,o):ff(pf(e),t,i,r,n,o,1);break}}}function mf(e){var t=e.prev,i=e,r=e.next;if(Af(t,i,r)>=0)return !1;for(var n=t.x,o=i.x,s=r.x,a=t.y,l=i.y,c=r.y,h=n<o?n<s?n:s:o<s?o:s,u=a<l?a<c?a:c:l<c?l:c,d=n>o?n>s?n:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c,f=r.next;f!==t;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&Ef(n,a,o,l,s,c,f.x,f.y)&&Af(f.prev,f,f.next)>=0)return !1;f=f.next;}return !0}function _f(e,t,i,r){var n=e.prev,o=e,s=e.next;if(Af(n,o,s)>=0)return !1;for(var a=n.x,l=o.x,c=s.x,h=n.y,u=o.y,d=s.y,p=a<l?a<c?a:c:l<c?l:c,f=h<u?h<d?h:d:u<d?u:d,m=a>l?a>c?a:c:l>c?l:c,_=h>u?h>d?h:d:u>d?u:d,g=wf(p,f,t,i,r),y=wf(m,_,t,i,r),x=e.prevZ,v=e.nextZ;x&&x.z>=g&&v&&v.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&Ef(a,h,l,u,c,d,x.x,x.y)&&Af(x.prev,x,x.next)>=0)return !1;if(x=x.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&Ef(a,h,l,u,c,d,v.x,v.y)&&Af(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}for(;x&&x.z>=g;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=_&&x!==n&&x!==s&&Ef(a,h,l,u,c,d,x.x,x.y)&&Af(x.prev,x,x.next)>=0)return !1;x=x.prevZ;}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=_&&v!==n&&v!==s&&Ef(a,h,l,u,c,d,v.x,v.y)&&Af(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}return !0}function gf(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!Sf(n,o)&&If(n,r,r.next,o)&&Pf(n,o)&&Pf(o,n)&&(t.push(n.i/i|0),t.push(r.i/i|0),t.push(o.i/i|0),Lf(r),Lf(r.next),r=e=o),r=r.next;}while(r!==e);return pf(r)}function yf(e,t,i,r,n,o){var s=e;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Mf(s,a)){var l=Df(s,a);return s=pf(s,s.next),l=pf(l,l.next),ff(s,t,i,r,n,o,0),void ff(l,t,i,r,n,o,0)}a=a.next;}s=s.next;}while(s!==e)}function xf(e,t){return e.x-t.x}function vf(e,t){var i=function(e,t){var i,r=t,n=e.x,o=e.y,s=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s&&(s=a,i=r.x<r.next.x?r:r.next,a===n))return i}r=r.next;}while(r!==t);if(!i)return null;var l,c=i,h=i.x,u=i.y,d=1/0;r=i;do{n>=r.x&&r.x>=h&&n!==r.x&&Ef(o<u?n:s,o,h,u,o<u?s:n,o,r.x,r.y)&&(l=Math.abs(o-r.y)/(n-r.x),Pf(r,e)&&(l<d||l===d&&(r.x>i.x||r.x===i.x&&bf(i,r)))&&(i=r,d=l)),r=r.next;}while(r!==c);return i}(e,t);if(!i)return t;var r=Df(i,e);return pf(r,r.next),pf(i,i.next)}function bf(e,t){return Af(e.prev,e,t.prev)<0&&Af(t.next,e,e.next)<0}function wf(e,t,i,r,n){return (e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Tf(e){var t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next;}while(t!==e);return i}function Ef(e,t,i,r,n,o,s,a){return (n-s)*(t-a)>=(e-s)*(o-a)&&(e-s)*(r-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(n-s)*(r-a)}function Mf(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&If(i,i.next,e,t))return !0;i=i.next;}while(i!==e);return !1}(e,t)&&(Pf(e,t)&&Pf(t,e)&&function(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;}while(i!==e);return r}(e,t)&&(Af(e.prev,e,t.prev)||Af(e,t.prev,t))||Sf(e,t)&&Af(e.prev,e,e.next)>0&&Af(t.prev,t,t.next)>0)}function Af(e,t,i){return (t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Sf(e,t){return e.x===t.x&&e.y===t.y}function If(e,t,i,r){var n=zf(Af(e,t,i)),o=zf(Af(e,t,r)),s=zf(Af(i,r,e)),a=zf(Af(i,r,t));return n!==o&&s!==a||!(0!==n||!Cf(e,i,t))||!(0!==o||!Cf(e,r,t))||!(0!==s||!Cf(i,e,r))||!(0!==a||!Cf(i,t,r))}function Cf(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function zf(e){return e>0?1:e<0?-1:0}function Pf(e,t){return Af(e.prev,e,e.next)<0?Af(e,t,e.next)>=0&&Af(e,e.prev,t)>=0:Af(e,t,e.prev)<0||Af(e,e.next,t)<0}function Df(e,t){var i=new kf(e.i,e.x,e.y),r=new kf(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function Rf(e,t,i,r){var n=new kf(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Lf(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ);}function kf(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1;}function Of(e,t,i,r){for(var n=0,o=t,s=i-r;o<i;o+=r)n+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return n}hf.exports=uf,hf.exports.default=uf,uf.deviation=function(e,t,i,r){var n=t&&t.length,o=Math.abs(Of(e,0,n?t[0]*i:e.length,i));if(n)for(var s=0,a=t.length;s<a;s++)o-=Math.abs(Of(e,t[s]*i,s<a-1?t[s+1]*i:e.length,i));var l=0;for(s=0;s<r.length;s+=3){var c=r[s]*i,h=r[s+1]*i,u=r[s+2]*i;l+=Math.abs((e[c]-e[u])*(e[h+1]-e[c+1])-(e[c]-e[h])*(e[u+1]-e[c+1]));}return 0===o&&0===l?0:Math.abs((l-o)/o)},uf.flatten=function(e){for(var t=e[0][0].length,i={vertices:[],holes:[],dimensions:t},r=0,n=0;n<e.length;n++){for(var o=0;o<e[n].length;o++)for(var s=0;s<t;s++)i.vertices.push(e[n][o][s]);n>0&&i.holes.push(r+=e[n-1].length);}return i};var Bf=d(hf.exports);function Ff(e,t){const i=e.length;if(i<=1)return [e];const r=[];let n,o;for(let t=0;t<i;t++){const i=Y(e[t]);0!==i&&(e[t].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(n&&r.push(n),n=[e[t]]):n.push(e[t]));}if(n&&r.push(n),t>1)for(let e=0;e<r.length;e++)r[e].length<=t||(Fi(r[e],t,1,r[e].length-1,Nf),r[e]=r[e].slice(0,t));return r}function Nf(e,t){return t.area-e.area}function Uf(e,t,i){const r=i.patternDependencies;let n=!1;for(const i of t){const t=i.paint.get(`${e}-pattern`);t.isConstant()||(n=!0);const o=t.constantOr(null);o&&(n=!0,r[o]=!0);}return n}function Vf(e,t,i,r,n){const o=n.patternDependencies;for(const s of t){const t=s.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:r},i,{},n.availableImages);e=e&&e.name?e.name:e,o[e]=!0,i.patterns[s.id]=e;}}return i}class jf{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new za,this.indexArray=new Wa,this.indexArray2=new ja,this.programConfigurations=new ec(e.layers,e.zoom),this.segments=new xl,this.segments2=new xl,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.projection=e.projection;}populate(e,t,i,r){this.hasPattern=Uf("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,h=gp(s,e);if(!this.layers[0]._featureFilter.filter(new oa(this.zoom),h,i))continue;const u=n?n.evaluate(h,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?h.geometry:_p(s,i,r),patterns:{},sortKey:u};o.push(d);}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const e=Vf("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e);}else this.addFeature(r,n,o,i,{},t.availableImages,t.brightness);t.featureIndex.insert(e[o].feature,n,o,s,this.index);}}update(e,t,i,r,n){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,i,r,n);}addFeatures(e,t,i,r,n,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r,o);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,cf),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(e,t,i,r,n,o=[],s){for(const e of Ff(t,500)){let t=0;for(const i of e)t+=i.length;const i=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(n.length/2);const i=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(r+t.length-1,r),n.push(t[0].x),n.push(t[0].y);for(let e=1;e<t.length;e++)this.layoutVertexArray.emplaceBack(t[e].x,t[e].y),this.indexArray2.emplaceBack(r+e-1,r+e),n.push(t[e].x),n.push(t[e].y);i.vertexLength+=t.length,i.primitiveLength+=t.length;}const s=Bf(n,o);for(let e=0;e<s.length;e+=3)this.indexArray.emplaceBack(r+s[e],r+s[e+1],r+s[e+2]);i.vertexLength+=t,i.primitiveLength+=s.length/3;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r,s);}}Rs(jf,"FillBucket",{omit:["layers","patternFeatures"]});const Gf=new ga({"fill-sort-key":new ma(Pt.layout_fill["fill-sort-key"]),visibility:new fa(Pt.layout_fill.visibility)});var qf={paint:new ga({"fill-antialias":new fa(Pt.paint_fill["fill-antialias"]),"fill-opacity":new ma(Pt.paint_fill["fill-opacity"]),"fill-color":new ma(Pt.paint_fill["fill-color"]),"fill-outline-color":new ma(Pt.paint_fill["fill-outline-color"]),"fill-translate":new fa(Pt.paint_fill["fill-translate"]),"fill-translate-anchor":new fa(Pt.paint_fill["fill-translate-anchor"]),"fill-pattern":new ma(Pt.paint_fill["fill-pattern"]),"fill-emissive-strength":new fa(Pt.paint_fill["fill-emissive-strength"])}),layout:Gf};const Zf=Ia([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),$f=Ia([{name:"a_pos_end",components:4,type:"Int16"},{name:"a_angular_offset_factor",components:1,type:"Int16"}]),Wf=Ia([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Hf=Ia([{name:"a_hidden_by_landmark",components:1,type:"Uint8"}]),Xf=Ia([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:Yf}=Zf;var Kf={},Jf=_,Qf=em;function em(e,t,i,r,n){this.properties={},this.extent=i,this.type=0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=n,e.readFields(tm,this,t);}function tm(e,t,i){1==e?t.id=i.readVarint():2==e?function(e,t){for(var i=e.readVarint()+e.pos;e.pos<i;){var r=t._keys[e.readVarint()],n=t._values[e.readVarint()];t.properties[r]=n;}}(i,t):3==e?t.type=i.readVarint():4==e&&(t._geometry=i.pos);}function im(e){for(var t,i,r=0,n=0,o=e.length,s=o-1;n<o;s=n++)r+=((i=e[s]).x-(t=e[n]).x)*(t.y+i.y);return r}em.types=["Unknown","Point","LineString","Polygon"],em.prototype.loadGeometry=function(){var e=this._pbf;e.pos=this._geometry;for(var t,i=e.readVarint()+e.pos,r=1,n=0,o=0,s=0,a=[];e.pos<i;){if(n<=0){var l=e.readVarint();r=7&l,n=l>>3;}if(n--,1===r||2===r)o+=e.readSVarint(),s+=e.readSVarint(),1===r&&(t&&a.push(t),t=[]),t.push(new Jf(o,s));else {if(7!==r)throw new Error("unknown command "+r);t&&t.push(t[0].clone());}}return t&&a.push(t),a},em.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;e.pos<t;){if(r<=0){var h=e.readVarint();i=7&h,r=h>>3;}if(r--,1===i||2===i)(n+=e.readSVarint())<s&&(s=n),n>a&&(a=n),(o+=e.readSVarint())<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return [s,l,a,c]},em.prototype.toGeoJSON=function(e,t,i){var r,n,o=this.extent*Math.pow(2,i),s=this.extent*e,a=this.extent*t,l=this.loadGeometry(),c=em.types[this.type];function h(e){for(var t=0;t<e.length;t++){var i=e[t];e[t]=[360*(i.x+s)/o-180,360/Math.PI*Math.atan(Math.exp((180-360*(i.y+a)/o)*Math.PI/180))-90];}}switch(this.type){case 1:var u=[];for(r=0;r<l.length;r++)u[r]=l[r][0];h(l=u);break;case 2:for(r=0;r<l.length;r++)h(l[r]);break;case 3:for(l=function(e){var t=e.length;if(t<=1)return [e];for(var i,r,n=[],o=0;o<t;o++){var s=im(e[o]);0!==s&&(void 0===r&&(r=s<0),r===s<0?(i&&n.push(i),i=[e[o]]):i.push(e[o]));}return i&&n.push(i),n}(l),r=0;r<l.length;r++)for(n=0;n<l[r].length;n++)h(l[r][n]);}1===l.length?l=l[0]:c="Multi"+c;var d={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return "id"in this&&(d.id=this.id),d};var rm=Qf,nm=om;function om(e,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(sm,this,t),this.length=this._features.length;}function sm(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){for(var t=null,i=e.readVarint()+e.pos;e.pos<i;){var r=e.readVarint()>>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null;}return t}(i));}om.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new rm(this._pbf,t,this.extent,this._keys,this._values)};var am=nm;function lm(e,t,i){if(3===e){var r=new am(i,i.readVarint()+i.pos);r.length&&(t[r.name]=r);}}var cm=Kf.VectorTile=function(e,t){this.layers=e.readFields(lm,{},t);},hm=Kf.VectorTileFeature=Qf;function um(e,t,i,r){const n=[],o=0===r?(e,t,i,r,n,o)=>{e.push(new y(o,i+(o-t)/(r-t)*(n-i)));}:(e,t,i,r,n,o)=>{e.push(new y(t+(o-i)/(n-i)*(r-t),o));};for(const s of e){const e=[];for(const n of s){if(n.length<=2)continue;const s=[];for(let e=0;e<n.length-1;e++){const a=n[e].x,l=n[e].y,c=n[e+1].x,h=n[e+1].y,u=0===r?a:l,d=0===r?c:h;u<t?d>t&&o(s,a,l,c,h,t):u>i?d<i&&o(s,a,l,c,h,i):s.push(n[e]),d<t&&u>=t&&o(s,a,l,c,h,t),d>i&&u<=i&&o(s,a,l,c,h,i);}let a=n[n.length-1];const l=0===r?a.x:a.y;l>=t&&l<=i&&s.push(a),s.length&&(a=s[s.length-1],s[0].x===a.x&&s[0].y===a.y||s.push(s[0]),e.push(s));}e.length&&n.push(e);}return n}Kf.VectorTileLayer=nm;class dm{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i;}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}var pm={
43
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
44
+ read:function(e,t,i,r,n){var o,s,a=8*n-r-1,l=(1<<a)-1,c=l>>1,h=-7,u=i?n-1:0,d=i?-1:1,p=e[t+u];for(u+=d,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+e[t+u],u+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+e[t+u],u+=d,h-=8);if(0===o)o=1-c;else {if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c;}return (p?-1:1)*s*Math.pow(2,o-r)},write:function(e,t,i,r,n,o){var s,a,l,c=8*o-n-1,h=(1<<c)-1,u=h>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(t*l-1)*Math.pow(2,n),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,n),s=0));n>=8;e[i+p]=255&a,p+=f,a/=256,n-=8);for(s=s<<n|a,c+=n;c>0;e[i+p]=255&s,p+=f,s/=256,c-=8);e[i+p-f]|=128*m;}},fm=_m,mm=pm;function _m(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length;}_m.Varint=0,_m.Fixed64=1,_m.Bytes=2,_m.Fixed32=5;var gm=4294967296,ym=1/gm,xm="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function vm(e){return e.type===_m.Bytes?e.readVarint()+e.pos:e.pos+1}function bm(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function wm(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=e;n--)i.buf[n+r]=i.buf[n];}function Tm(e,t){for(var i=0;i<e.length;i++)t.writeVarint(e[i]);}function Em(e,t){for(var i=0;i<e.length;i++)t.writeSVarint(e[i]);}function Mm(e,t){for(var i=0;i<e.length;i++)t.writeFloat(e[i]);}function Am(e,t){for(var i=0;i<e.length;i++)t.writeDouble(e[i]);}function Sm(e,t){for(var i=0;i<e.length;i++)t.writeBoolean(e[i]);}function Im(e,t){for(var i=0;i<e.length;i++)t.writeFixed32(e[i]);}function Cm(e,t){for(var i=0;i<e.length;i++)t.writeSFixed32(e[i]);}function zm(e,t){for(var i=0;i<e.length;i++)t.writeFixed64(e[i]);}function Pm(e,t){for(var i=0;i<e.length;i++)t.writeSFixed64(e[i]);}function Dm(e,t){return (e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function Rm(e,t,i){e[i]=t,e[i+1]=t>>>8,e[i+2]=t>>>16,e[i+3]=t>>>24;}function Lm(e,t){return (e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}_m.prototype={destroy:function(){this.buf=null;},readFields:function(e,t,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,o=this.pos;this.type=7&r,e(n,t,this),this.pos===o&&this.skip(r);}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Dm(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Lm(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Dm(this.buf,this.pos)+Dm(this.buf,this.pos+4)*gm;return this.pos+=8,e},readSFixed64:function(){var e=Dm(this.buf,this.pos)+Lm(this.buf,this.pos+4)*gm;return this.pos+=8,e},readFloat:function(){var e=mm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=mm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:function(e,t,i){var r,n,o=i.buf;if(r=(112&(n=o[i.pos++]))>>4,n<128)return bm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<3,n<128)return bm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<10,n<128)return bm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<17,n<128)return bm(e,r,t);if(r|=(127&(n=o[i.pos++]))<<24,n<128)return bm(e,r,t);if(r|=(1&(n=o[i.pos++]))<<31,n<128)return bm(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&xm?function(e,t,i){return xm.decode(e.subarray(t,i))}(this.buf,t,e):function(e,t,i){for(var r="",n=t;n<i;){var o,s,a,l=e[n],c=null,h=l>239?4:l>223?3:l>191?2:1;if(n+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(o=e[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===h?(s=e[n+2],128==(192&(o=e[n+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(s=e[n+2],a=e[n+3],128==(192&(o=e[n+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=h;}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==_m.Bytes)return e.push(this.readVarint(t));var i=vm(this);for(e=e||[];this.pos<i;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==_m.Bytes)return e.push(this.readSVarint());var t=vm(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==_m.Bytes)return e.push(this.readBoolean());var t=vm(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==_m.Bytes)return e.push(this.readFloat());var t=vm(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==_m.Bytes)return e.push(this.readDouble());var t=vm(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==_m.Bytes)return e.push(this.readFixed32());var t=vm(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==_m.Bytes)return e.push(this.readSFixed32());var t=vm(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==_m.Bytes)return e.push(this.readFixed64());var t=vm(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==_m.Bytes)return e.push(this.readSFixed64());var t=vm(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=7&e;if(t===_m.Varint)for(;this.buf[this.pos++]>127;);else if(t===_m.Bytes)this.pos=this.readVarint()+this.pos;else if(t===_m.Fixed32)this.pos+=4;else {if(t!==_m.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8;}},writeTag:function(e,t){this.writeVarint(e<<3|t);},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var i=new Uint8Array(t);i.set(this.buf),this.buf=i,this.length=t;}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),Rm(this.buf,e,this.pos),this.pos+=4;},writeSFixed32:function(e){this.realloc(4),Rm(this.buf,e,this.pos),this.pos+=4;},writeFixed64:function(e){this.realloc(8),Rm(this.buf,-1&e,this.pos),Rm(this.buf,Math.floor(e*ym),this.pos+4),this.pos+=8;},writeSFixed64:function(e){this.realloc(8),Rm(this.buf,-1&e,this.pos),Rm(this.buf,Math.floor(e*ym),this.pos+4),this.pos+=8;},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7);}(i,0,t),function(e,t){var i=(7&e)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))));}(r,t);}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))));},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e);},writeBoolean:function(e){this.writeVarint(Boolean(e));},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,i){for(var r,n,o=0;o<t.length;o++){if((r=t.charCodeAt(o))>55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null;}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128);}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&wm(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i;},writeFloat:function(e){this.realloc(4),mm.write(this.buf,e,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(e){this.realloc(8),mm.write(this.buf,e,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i<t;i++)this.buf[this.pos++]=e[i];},writeRawMessage:function(e,t){this.pos++;var i=this.pos;e(t,this);var r=this.pos-i;r>=128&&wm(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r;},writeMessage:function(e,t,i){this.writeTag(e,_m.Bytes),this.writeRawMessage(t,i);},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,Tm,t);},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,Em,t);},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Sm,t);},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,Mm,t);},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,Am,t);},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Im,t);},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Cm,t);},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,zm,t);},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Pm,t);},writeBytesField:function(e,t){this.writeTag(e,_m.Bytes),this.writeBytes(t);},writeFixed32Field:function(e,t){this.writeTag(e,_m.Fixed32),this.writeFixed32(t);},writeSFixed32Field:function(e,t){this.writeTag(e,_m.Fixed32),this.writeSFixed32(t);},writeFixed64Field:function(e,t){this.writeTag(e,_m.Fixed64),this.writeFixed64(t);},writeSFixed64Field:function(e,t){this.writeTag(e,_m.Fixed64),this.writeSFixed64(t);},writeVarintField:function(e,t){this.writeTag(e,_m.Varint),this.writeVarint(t);},writeSVarintField:function(e,t){this.writeTag(e,_m.Varint),this.writeSVarint(t);},writeStringField:function(e,t){this.writeTag(e,_m.Bytes),this.writeString(t);},writeFloatField:function(e,t){this.writeTag(e,_m.Fixed32),this.writeFloat(t);},writeDoubleField:function(e,t){this.writeTag(e,_m.Fixed64),this.writeDouble(t);},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t));}};var km=d(fm);const Om=["tile","layer","source","sourceLayer","state"];class Bm{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=r,this.properties=e.properties,this.id=n;}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e;}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};void 0!==this.id&&(e.id=this.id);for(const t of Om)void 0!==this[t]&&(e[t]=this[t]);return e}}class Fm{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(e,t,i){const r=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},k(this.stateChanges[e][r],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==r&&(this.deletedStates[e][t]=null);}else if(this.deletedStates[e]&&null===this.deletedStates[e][r]){this.deletedStates[e][r]={};for(const t in this.state[e][r])i[t]||(this.deletedStates[e][r][t]=null);}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][r]&&null===this.deletedStates[e][r][t]&&delete this.deletedStates[e][r][t];}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null;}getState(e,t){const i=String(t),r=k({},(this.state[e]||{})[i],(this.stateChanges[e]||{})[i]);if(null===this.deletedStates[e])return {};if(this.deletedStates[e]){const i=this.deletedStates[e][t];if(null===i)return {};for(const e in i)delete r[e];}return r}initializeTileState(e,t){e.setFeatureState(this.state,t);}coalesceChanges(e,t){const i={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]={}),k(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t;}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else if(this.state[e][i])for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i];}i[e]=i[e]||{},k(i[e],t);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in e)e[r].setFeatureState(i,t);}}class Nm{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[];}getElevation(e,t){const i=this.toIdx(e,t);return {min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function Um(e,t,i,r){let n=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(r[s])<1e-15){if(i[s]<e[s]||i[s]>t[s])return null}else {const a=1/r[s];let l=(e[s]-i[s])*a,c=(t[s]-i[s])*a;if(l>c){const e=l;l=c,c=e;}if(l>n&&(n=l),c<o&&(o=c),n>o)return null}return n}function Vm(e,t,i,r,n,o,s,a,l,c,h){const u=r-e,d=n-t,p=o-i,f=s-e,m=a-t,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,x=h[0]*m-h[1]*f,v=u*g+d*y+p*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-e,T=c[1]-t,E=c[2]-i,M=(w*g+T*y+E*x)*b;if(M<0||M>1)return null;const A=T*p-E*d,S=E*u-w*p,I=w*d-T*u,C=(h[0]*A+h[1]*S+h[2]*I)*b;return C<0||M+C>1?null:(f*A+m*S+_*I)*b}function jm(e,t,i){return (e-t)/(i-t)}function Gm(e,t,i,r,n,o,s,a,l){const c=1<<i,h=o-r,u=s-n,d=(e+1)/c*h+r,p=(t+0)/c*u+n,f=(t+1)/c*u+n;a[0]=(e+0)/c*h+r,a[1]=p,l[0]=d,l[1]=f;}class qm{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const t=function(e){const t=Math.ceil(Math.log2(e.dim/8)),i=[];let r=Math.ceil(Math.pow(2,t));const n=1/r,o=(e,t,i,r,n)=>{const o=r?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;n[0]=e*i,n[1]=a,n[2]=s,n[3]=l;};let s=new Nm(r);const a=[];for(let t=0;t<r*r;t++){o(t%r,Math.floor(t/r),n,!1,a);const i=$m(a[0],a[1],e),l=$m(a[2],a[1],e),c=$m(a[2],a[3],e),h=$m(a[0],a[3],e);s.minimums.push(Math.min(i,l,c,h)),s.maximums.push(Math.max(i,l,c,h)),s.leaves.push(1);}for(i.push(s),r/=2;r>=1;r/=2){const e=i[i.length-1];s=new Nm(r);for(let t=0;t<r*r;t++){o(t%r,Math.floor(t/r),2,!0,a);const i=e.getElevation(a[0],a[1]),n=e.getElevation(a[2],a[1]),l=e.getElevation(a[2],a[3]),c=e.getElevation(a[0],a[3]),h=e.isLeaf(a[0],a[1]),u=e.isLeaf(a[2],a[1]),d=e.isLeaf(a[2],a[3]),p=e.isLeaf(a[0],a[3]),f=Math.min(i.min,n.min,l.min,c.min),m=Math.max(i.max,n.max,l.max,c.max),_=h&&u&&d&&p;s.maximums.push(m),s.minimums.push(f),s.leaves.push(m-f<=5&&_?1:0);}i.push(s);}return i}(this.dem),i=t.length-1,r=t[i];this._addNode(r.minimums[0],r.maximums[0],r.leaves[0]),this._construct(t,0,0,i,0);}raycastRoot(e,t,i,r,n,o,s=1){return Um([e,t,-100],[i,r,this.maximums[0]*s],n,o)}raycast(e,t,i,r,n,o,s=1){if(!this.nodeCount)return null;const a=this.raycastRoot(e,t,i,r,n,o,s);if(null==a)return null;const l=[],c=[],h=[],u=[],d=[{idx:0,t:a,nodex:0,nodey:0,depth:0}];for(;d.length>0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){Gm(f,m,_,e,t,i,r,h,u);const a=1<<_,l=(f+0)/a,c=(f+1)/a,d=(m+0)/a,g=(m+1)/a,y=$m(l,d,this.dem)*s,x=$m(c,d,this.dem)*s,v=$m(c,g,this.dem)*s,b=$m(l,g,this.dem)*s,w=Vm(h[0],h[1],y,u[0],h[1],x,u[0],u[1],v,n,o),T=Vm(u[0],u[1],v,h[0],u[1],b,h[0],h[1],y,n,o),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const e=Du.scaleAndAdd([],n,o,p);if(Zm(y,x,b,v,jm(e[0],h[0],u[0]),jm(e[1],h[1],u[1]))>=e[2])return p}continue}let g=0;for(let d=0;d<this._siblingOffset.length;d++){Gm((f<<1)+this._siblingOffset[d][0],(m<<1)+this._siblingOffset[d][1],_+1,e,t,i,r,h,u),h[2]=-100,u[2]=this.maximums[this.childOffsets[a]+d]*s;const p=Um(h,u,n,o);if(null!=p){const e=p;l[d]=e;let t=!1;for(let i=0;i<g&&!t;i++)e>=l[c[i]]&&(c.splice(i,0,d),t=!0);t||(c[g]=d),g++;}}for(let e=0;e<g;e++){const t=c[e];d.push({idx:this.childOffsets[a]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:_+1});}}return null}_addNode(e,t,i){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,i,r,n){if(1===e[r].isLeaf(t,i))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);const o=r-1,s=e[o];let a=0,l=0;for(let e=0;e<this._siblingOffset.length;e++){const r=2*t+this._siblingOffset[e][0],n=2*i+this._siblingOffset[e][1],o=s.getElevation(r,n),c=s.isLeaf(r,n),h=this._addNode(o.min,o.max,c);c&&(a|=1<<e),l||(l=h);}for(let r=0;r<this._siblingOffset.length;r++)a&1<<r||this._construct(e,2*t+this._siblingOffset[r][0],2*i+this._siblingOffset[r][1],o,l+r);}}function Zm(e,t,i,r,n,o){return Kr(Kr(e,i,o),Kr(t,r,o),n)}function $m(e,t,i){const r=i.dim,n=z(e*r-.5,0,r-1),o=z(t*r-.5,0,r-1),s=Math.floor(n),a=Math.floor(o),l=Math.min(s+1,r-1),c=Math.min(a+1,r-1);return Zm(i.get(s,a),i.get(l,a),i.get(s,c),i.get(l,c),n-s,o-a)}const Wm={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function Hm(e,t,i){return (256*e*256+256*t+i)/10-1e4}function Xm(e,t,i){return 256*e+t+i/256-32768}class Ym{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,i,r=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return H(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const n=this.dim=t.height-2,o=new Uint32Array(t.data.buffer);if(this.pixels=new Uint8Array(t.data.buffer),this.floatView=new Float32Array(t.data.buffer),this.borderReady=r,this._modifiedForSources={},!r){for(let e=0;e<n;e++)o[this._idx(-1,e)]=o[this._idx(0,e)],o[this._idx(n,e)]=o[this._idx(n-1,e)],o[this._idx(e,-1)]=o[this._idx(e,0)],o[this._idx(e,n)]=o[this._idx(e,n-1)];o[this._idx(-1,-1)]=o[this._idx(0,0)],o[this._idx(n,-1)]=o[this._idx(n-1,0)],o[this._idx(-1,n)]=o[this._idx(0,n-1)],o[this._idx(n,n)]=o[this._idx(n-1,n-1)];}const s="terrarium"===i?Xm:Hm;for(let e=0;e<o.length;++e){const t=4*e;this.floatView[e]=s(this.pixels[t],this.pixels[t+1],this.pixels[t+2]);}this._timestamp=dt.now();}_buildQuadTree(){this._tree=new qm(this);}get(e,t,i=!1){i&&(e=z(e,-1,this.dim),t=z(t,-1,this.dim));const r=this._idx(e,t);return this.floatView[r]}set(e,t,i){const r=this._idx(e,t),n=this.floatView[r];return this.floatView[r]=i,i-n}static getUnpackVector(e){return Wm[e]}_idx(e,t){if(e<-1||e>=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return (t+1)*this.stride+(e+1)}static pack(e,t){const i=[0,0,0,0],r=Ym.getUnpackVector(t);let n=Math.floor((e+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new tf({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1;}switch(i){case-1:o=s-1;break;case 1:s=o+1;}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t<s;t++)for(let i=r;i<n;i++){const r=4*this._idx(i,t),n=4*this._idx(i+a,t+l);this.pixels[r+0]=e.pixels[n+0],this.pixels[r+1]=e.pixels[n+1],this.pixels[r+2]=e.pixels[n+2],this.pixels[r+3]=e.pixels[n+3];}}onDeserialize(){this._tree&&(this._tree.dem=this);}}Rs(Ym,"DEMData"),Rs(qm,"DemMinMaxQuadTree",{omit:["dem"]});class Km{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return !1;const i=t.getSource().maxzoom,r=1<<i,n=Math.floor(e.x),o=Math.floor((e.x-n)*r),s=Math.floor(e.y*r),a=this.findDEMTileFor(new qu(i,n,i,o,s));return !(!a||!a.dem)}getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,i=!0){if(this.isUsingMockSource())return null;null==t&&(t=null);const r=this._source();if(!r)return t;if(e.y<0||e.y>1)return t;const n=r.getSource().maxzoom,o=1<<n,s=Math.floor(e.x),a=e.x-s,l=new qu(n,s,n,Math.floor(a*o),Math.floor(e.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return t;const h=c.dem,u=1<<c.tileID.canonical.z,d=(a*u-c.tileID.canonical.x)*h.dim,p=(e.y*u-c.tileID.canonical.y)*h.dim,f=Math.floor(d),m=Math.floor(p);return (i?this.exaggeration():1)*Kr(Kr(h.get(f,m),h.get(f,m+1),p-m),Kr(h.get(f+1,m),h.get(f+1,m+1),p-m),d-f)}getAtTileOffset(e,t,i){const r=1<<e.canonical.z;return this.getAtPointOrZero(new lp(e.wrap+(e.canonical.x+t/cr)/r,(e.canonical.y+i/cr)/r))}getAtTileOffsetFunc(e,t,i,r){return n=>{const o=this.getAtTileOffset(e,n.x,n.y),s=r.upVector(e.canonical,n.x,n.y),a=r.upVectorScale(e.canonical,t,i).metersToTile;return Du.scale(s,s,o*a),s}}getForTilePoints(e,t,i,r){if(this.isUsingMockSource())return !1;const n=Jm.create(this,e,r);return !!n&&(t.forEach((e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],i);})),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,r=t.tileID,n=1<<e.canonical.z-r.canonical.z;let o=e.canonical.x/n-r.canonical.x,s=e.canonical.y/n-r.canonical.y,a=0;for(let t=0;t<e.canonical.z-r.canonical.z&&!i.leaves[a];t++){o*=2,s*=2;const e=2*Math.floor(s)+Math.floor(o);a=i.childOffsets[a]+e,o%=1,s%=1;}return {min:this.exaggeration()*i.minimums[a],max:this.exaggeration()*i.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,i){throw new Error("Pure virtual method called.")}pointCoordinate(e){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}getMinMaxForVisibleTiles(){const e=this.visibleDemTiles;if(0===e.length)return null;let t=!1,i=Number.MAX_VALUE,r=Number.MIN_VALUE;for(const n of e){const e=this.getMinMaxForTile(n.tileID);e&&(i=Math.min(i,e.min),r=Math.max(r,e.max),t=!0);}return t?{min:i,max:r}:null}}class Jm{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i;}static create(e,t,i){const r=i||e.findDEMTileFor(t);if(!r||!r.dem)return;const n=r.dem,o=r.tileID,s=1<<t.canonical.z-o.canonical.z;return new Jm(r,n.dim/cr/s,[(t.canonical.x/s-o.canonical.x)*n.dim,(t.canonical.y/s-o.canonical.y)*n.dim])}tileCoordToPixel(e,t){const i=t*this._scale+this._offset[1],r=Math.floor(e*this._scale+this._offset[0]),n=Math.floor(i);return new y(r,n)}getElevationAt(e,t,i,r){const n=e*this._scale+this._offset[0],o=t*this._scale+this._offset[1],s=Math.floor(n),a=Math.floor(o),l=this._dem;return r=!!r,i?Kr(Kr(l.get(s,a,r),l.get(s,a+1,r),o-a),Kr(l.get(s+1,a,r),l.get(s+1,a+1,r),o-a),n-s):l.get(s,a,r)}getElevationAtPixel(e,t,i){return this._dem.get(e,t,!!i)}getMeterToDEM(e){return (1<<this._demTile.tileID.canonical.z)*Qd(1,e)*this._dem.stride}}class Qm{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Ps(cr,16,0),this.featureIndexArray=new ml,this.promoteId=t;}insert(e,t,i,r,n,o=0){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n,o);const a=this.grid;for(let e=0;e<t.length;e++){const i=t[e],r=[1/0,1/0,-1/0,-1/0];for(let e=0;e<i.length;e++){const t=i[e];r[0]=Math.min(r[0],t.x),r[1]=Math.min(r[1],t.y),r[2]=Math.max(r[2],t.x),r[3]=Math.max(r[3],t.y);}r[0]<cr&&r[1]<cr&&r[2]>=0&&r[3]>=0&&a.insert(s,r[0],r[1],r[2],r[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new cm(new km(this.rawTileData)).layers,this.sourceLayerCoder=new dm(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[];}return this.vtLayers}query(e,t,i,r){this.loadVTLayers();const n=e.params||{},o=Fo(n.filter),s=e.tileResult,a=e.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((e,t,i,r)=>Pp(s.bufferedTilespaceGeometry,e,t,i,r)));c.sort(t_);let h=null;a.elevation&&c.length>0&&(h=Jm.create(a.elevation,this.tileID));const u={};let d;for(let a=0;a<c.length;a++){const l=c[a];if(l===d)continue;d=l;const p=this.featureIndexArray.get(l);let f=null;this.loadMatchingFeature(u,p,o,n.layers,n.availableImages,t,i,r,((t,i,r,n=0)=>(f||(f=_p(t,this.tileID.canonical,e.tileTransform)),i.queryIntersectsFeature(s,t,r,f,this.z,e.transform,e.pixelPosMatrix,h,n))));}return u}loadMatchingFeature(e,t,i,r,n,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=t,p=this.bucketLayerIDs[h];if(r&&!function(e,t){for(let i=0;i<e.length;i++)if(t.indexOf(e[i])>=0)return !0;return !1}(r,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const e=gp(m,!0);if(!i.filter(new oa(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new oa(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let t=0;t<p.length;t++){const i=p[t];if(r&&r.indexOf(i)<0)continue;const h=o[i];if(!h)continue;let u={};void 0!==_&&a&&(u=a.getState(h.sourceLayer||"_geojsonTileLayer",_));const f=k({},s[i]);f.paint=e_(f.paint,h.paint,m,u,n),f.layout=e_(f.layout,h.layout,m,u,n);const g=!l||l(m,h,u,d);if(!g)continue;const y=new Bm(m,this.z,this.x,this.y,_);y.layer=f;let x=e[i];void 0===x&&(x=e[i]=[]),x.push({featureIndex:c,feature:y,intersectionZ:g});}}lookupSymbolFeatures(e,t,i,r,n,o,s,a){const l={};this.loadVTLayers();const c=Fo(n);for(const n of e)this.loadMatchingFeature(l,{bucketIndex:i,sourceLayerIndex:r,featureIndex:n,layoutVertexArrayOffset:0},c,o,s,a,t);return l}loadFeature(e){const{featureIndex:t,sourceLayerIndex:i}=e;this.loadVTLayers();const r=this.sourceLayerCoder.decode(i),n=this.vtFeatures[r];if(n[t])return n[t];const o=this.vtLayers[r].feature(t);return n[t]=o,o}hasLayer(e){for(const t of this.bucketLayerIDs)for(const i of t)if(e===i)return !0;return !1}getId(e,t){let i=e.id;if(this.promoteId){const r="string"==typeof this.promoteId?this.promoteId:this.promoteId[t];null!=r&&(i=e.properties[r]),"boolean"==typeof i&&(i=Number(i));}return i}}function e_(e,t,i,r,n){return q(e,((e,o)=>{const s=t instanceof pa?t.get(o):null;return s&&s.evaluate?s.evaluate(i,r,n):s}))}function t_(e,t){return t-e}Rs(Qm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const i_=Ia([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),r_=Ia([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),n_=Ia([{name:"a_projected_pos",components:4,type:"Float32"}],4);Ia([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const o_=Ia([{name:"a_z_offset",components:1,type:"Float32"}],4),s_=Ia([{name:"a_texb",components:2,type:"Uint16"}]),a_=Ia([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),l_=Ia([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_z_offset",components:1,type:"Float32"}]);Ia([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const c_=Ia([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),h_=Ia([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ia([{name:"triangle",components:3,type:"Uint16"}]),Ia([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),Ia([{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Float32",name:"zOffset"},{type:"Uint8",name:"hasIconTextFit"}]),Ia([{type:"Float32",name:"offsetX"}]),Ia([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var u_=24;const d_=128;function p_(e,t){const{expression:i}=t;if("constant"===i.kind)return {kind:"constant",layoutSize:i.evaluate(new oa(e+1))};if("source"===i.kind)return {kind:"source"};{const{zoomStops:t,interpolationType:r}=i;let n=0;for(;n<t.length&&t[n]<=e;)n++;n=Math.max(0,n-1);let o=n;for(;o<t.length&&t[o]<e+1;)o++;o=Math.min(t.length-1,o);const s=t[n],a=t[o];return "composite"===i.kind?{kind:"composite",minZoom:s,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:s,maxZoom:a,minSize:i.evaluate(new oa(s)),maxSize:i.evaluate(new oa(a)),interpolationType:r}}}function f_(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:n}){return "source"===e.kind?r/d_:"composite"===e.kind?Kr(r/d_,n/d_,i):t}function m_(e,t){let i=0,r=0;if("constant"===e.kind)r=e.layoutSize;else if("source"!==e.kind){const{interpolationType:n,minZoom:o,maxZoom:s}=e,a=n?z(bn.interpolationFactor(n,t,o,s),0,1):0;"camera"===e.kind?r=Kr(e.minSize,e.maxSize,a):i=a;}return {uSizeT:i,uSize:r}}var __=Object.freeze({__proto__:null,SIZE_PACK_FACTOR:d_,evaluateSizeForFeature:f_,evaluateSizeForZoom:m_,getSizeData:p_});function g_(e,t,i){return e.sections.forEach((e=>{e.text=function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return "uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),na.applyArabicShaping&&(e=na.applyArabicShaping(e)),e}(e.text,t,i);})),e}const y_={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function x_(e){return "︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function v_(e){return "︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}const b_=3;function w_(e,t,i){t.glyphs=[],1===e&&i.readMessage(T_,t);}function T_(e,t,i){if(3===e){const{id:e,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(E_,{});t.glyphs.push({id:e,bitmap:new Qp({width:n+2*b_,height:o+2*b_},r),metrics:{width:n,height:o,left:s,top:a,advance:l}});}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint());}function E_(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint());}const M_=b_,A_={horizontal:1,vertical:2,horizontalOnly:3},S_=-17;class I_{constructor(){this.scale=1,this.fontStack="",this.imageName=null;}static forText(e,t){const i=new I_;return i.scale=e||1,i.fontStack=t,i}static forImage(e){const t=new I_;return t.imageName=e,t}}class C_{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null;}static fromFeature(e,t){const i=new C_;for(let r=0;r<e.sections.length;r++){const n=e.sections[r];n.image?i.addImageSection(n):i.addTextSection(n,t);}return i}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCodePoint(e){return this.text.codePointAt(e)}verticalizePunctuation(e){this.text=function(e,t){let i="";for(let r=0;r<e.length;r++){const n=e.charCodeAt(r+1)||null,o=e.charCodeAt(r-1)||null;i+=!t&&(n&&Gs(n)&&!y_[e[r+1]]||o&&Gs(o)&&!y_[e[r-1]])||!y_[e[r]]?e[r]:y_[e[r]];}return i}(this.text,e);}trim(){let e=0;for(let t=0;t<this.text.length&&P_[this.text.charCodeAt(t)];t++)e++;let t=this.text.length;for(let i=this.text.length-1;i>=0&&i>=e&&P_[this.text.charCodeAt(i)];i--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t);}substring(e,t){const i=new C_;return i.text=this.text.substring(e,t),i.sectionIndex=this.sectionIndex.slice(e,t),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((e,t)=>Math.max(e,this.sections[t].scale)),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(I_.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t<e.text.length;++t)this.sectionIndex.push(i);}addImageSection(e){const t=e.image?e.image.namePrimary:"";if(0===t.length)return void H("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCodePoint(i),this.sections.push(I_.forImage(t)),this.sectionIndex.push(this.sections.length-1)):H("Reached maximum number of images 6401");}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function z_(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f){const m=C_.fromFeature(e,n);u===A_.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(e,t,i,r,n,o){if(!e)return [];const s=[],a=function(e,t,i,r,n,o){let s=0;for(let i=0;i<e.length();i++){const a=e.getSection(i);s+=R_(e.getCodePoint(i),a,r,n,t,o);}return s/Math.max(1,Math.ceil(s/i))}(e,t,i,r,n,o),l=e.text.indexOf("​")>=0;let c=0;for(let i=0;i<e.length();i++){const u=e.getSection(i),d=e.getCodePoint(i);if(P_[d]||(c+=R_(d,u,r,n,t,o)),i<e.length()-1){const t=!((h=d)<11904||!(Fs["Bopomofo Extended"](h)||Fs.Bopomofo(h)||Fs["CJK Compatibility Forms"](h)||Fs["CJK Compatibility Ideographs"](h)||Fs["CJK Compatibility"](h)||Fs["CJK Radicals Supplement"](h)||Fs["CJK Strokes"](h)||Fs["CJK Symbols and Punctuation"](h)||Fs["CJK Unified Ideographs Extension A"](h)||Fs["CJK Unified Ideographs"](h)||Fs["Enclosed CJK Letters and Months"](h)||Fs["Halfwidth and Fullwidth Forms"](h)||Fs.Hiragana(h)||Fs["Ideographic Description Characters"](h)||Fs["Kangxi Radicals"](h)||Fs["Katakana Phonetic Extensions"](h)||Fs.Katakana(h)||Fs["Vertical Forms"](h)||Fs["Yi Radicals"](h)||Fs["Yi Syllables"](h)));(D_[d]||t||u.imageName)&&s.push(O_(i+1,c,a,s,k_(d,e.getCodePoint(i+1),t&&l),!1));}}var h;return B_(O_(e.length(),c,a,s,0,!0))}(m,c,o,t,r,p),{processBidirectionalText:y,processStyledBidirectionalText:x}=na;if(y&&1===m.sections.length){const e=y(m.toString(),g);for(const t of e){const e=new C_;e.text=t,e.sections=m.sections;for(let i=0;i<t.length;i++)e.sectionIndex.push(0);_.push(e);}}else if(x){const e=x(m.text,m.sectionIndex,g);for(const t of e){const e=new C_;e.text=t[0],e.sectionIndex=t[1],e.sections=m.sections,_.push(e);}}else _=function(e,t){const i=[],r=e.text;let n=0;for(const r of t)i.push(e.substring(n,r)),n=r;return n<r.length&&i.push(e.substring(n,r.length)),i}(m,g);const v=[],b={positionedLines:v,text:m.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:u,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(e,t,i,r,n,o,s,a,l,c,h,u){let d=0,p=0,f=0;const m="right"===a?1:"left"===a?0:.5;let _=!1;for(const e of n){const i=e.getSections();for(const e of i){if(e.imageName)continue;const i=t[e.fontStack];if(i&&(_=void 0!==i.ascender&&void 0!==i.descender,!_))break}if(!_)break}let g=0;for(const s of n){s.trim();const n=s.getMaxScale(),a=(n-1)*u_,x={positionedGlyphs:[],lineOffset:0};e.positionedLines[g]=x;const v=x.positionedGlyphs;let b=0;if(!s.length()){p+=o,++g;continue}let w=0,T=0;for(let o=0;o<s.length();o++){const a=s.getSection(o),f=s.getSectionIndex(o),m=s.getCodePoint(o);let g=a.scale,x=null,E=null,M=null,A=u_,S=0;const I=!(l===A_.horizontal||!h&&!js(m)||h&&(P_[m]||(y=m,Fs.Arabic(y)||Fs["Arabic Supplement"](y)||Fs["Arabic Extended-A"](y)||Fs["Arabic Presentation Forms-A"](y)||Fs["Arabic Presentation Forms-B"](y))));if(a.imageName){const t=r[a.imageName];if(!t)continue;M=a.imageName,e.iconsInText=e.iconsInText||!0,E=t.paddedRect;const i=t.displaySize;g=g*u_/u,x={width:i[0],height:i[1],left:0,top:-M_,advance:I?i[1]:i[0],localGlyph:!1},S=_?-x.height*g:S_+n*u_-i[1]*g,A=x.advance;const o=(I?i[0]:i[1])*g-u_*n;o>0&&o>b&&(b=o);}else {const e=i[a.fontStack];if(!e)continue;e[m]&&(E=e[m]);const r=t[a.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(x=o.metrics,A=8203!==m?u_:0,_){const e=void 0!==r.ascender?Math.abs(r.ascender):0,t=void 0!==r.descender?Math.abs(r.descender):0,i=(e+t)*g;w<i&&(w=i,T=(e-t)/2*g),S=-e*g;}else S=S_+(n-g)*u_;}I?(e.verticalizable=!0,v.push({glyph:m,imageName:M,x:d,y:p+S,vertical:I,scale:g,localGlyph:x.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:x,rect:E}),d+=A*g+c):(v.push({glyph:m,imageName:M,x:d,y:p+S,vertical:I,scale:g,localGlyph:x.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:x,rect:E}),d+=x.advance*g+c);}0!==v.length&&(f=Math.max(d-c,f),_?N_(v,m,b,T,o*n/2):N_(v,m,b,0,o/2)),d=0;const E=o*n+b;x.lineOffset=Math.max(b,a),p+=E,++g;}var y;const x=p,{horizontalAlign:v,verticalAlign:b}=F_(s);((function(e,t,i,r,n,o){const s=(t-i)*n,a=-o*r;for(const t of e)for(const e of t.positionedGlyphs)e.x+=s,e.y+=a;}))(e.positionedLines,m,v,b,f,x),e.top+=-b*x,e.bottom=e.top+x,e.left+=-v*f,e.right=e.left+f,e.hasBaseline=_;}(b,t,i,r,_,s,a,l,u,c,d,f),!function(e){for(const t of e)if(0!==t.positionedGlyphs.length)return !1;return !0}(v)&&b}const P_={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},D_={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function R_(e,t,i,r,n,o){if(t.imageName){const e=r[t.imageName];return e?e.displaySize[0]*t.scale*u_/o+n:0}{const r=i[t.fontStack],o=r&&r.glyphs[e];return o?o.metrics.advance*t.scale+n:0}}function L_(e,t,i,r){const n=Math.pow(e-t,2);return r?e<t?n/2:2*n:n+Math.abs(i)*i}function k_(e,t,i){let r=0;return 10===e&&(r-=1e4),i&&(r+=150),40!==e&&65288!==e||(r+=50),41!==t&&65289!==t||(r+=50),r}function O_(e,t,i,r,n,o){let s=null,a=L_(t,i,n,o);for(const e of r){const r=L_(t-e.x,i,n,o)+e.badness;r<=a&&(s=e,a=r);}return {index:e,x:t,priorBreak:s,badness:a}}function B_(e){return e?B_(e.priorBreak).concat(e.index):[]}function F_(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0;}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0;}return {horizontalAlign:t,verticalAlign:i}}function N_(e,t,i,r,n){if(!(t||i||r||n))return;const o=e.length-1,s=e[o],a=(s.x+s.metrics.advance*s.scale)*t;for(let t=0;t<=o;t++)e[t].x-=a,e[t].y+=i+r+n;}function U_(e,t,i,r){const{horizontalAlign:n,verticalAlign:o}=F_(r),s=i[0]-e.displaySize[0]*n,a=i[1]-e.displaySize[1]*o;return {imagePrimary:e,imageSecondary:t,top:a,bottom:a+e.displaySize[1],left:s,right:s+e.displaySize[0]}}function V_(e,t,i,r,n,o){const s=e.imagePrimary;let a;if(s.content){const e=s.content,t=s.pixelRatio||1;a=[e[0]/t,e[1]/t,s.displaySize[0]-e[2]/t,s.displaySize[1]-e[3]/t];}const l=t.left*o,c=t.right*o;let h,u,d,p;"width"===i||"both"===i?(p=n[0]+l-r[3],u=n[0]+c+r[1]):(p=n[0]+(l+c-s.displaySize[0])/2,u=p+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return "height"===i||"both"===i?(h=n[1]+f-r[0],d=n[1]+m+r[2]):(h=n[1]+(f+m-s.displaySize[1])/2,d=h+s.displaySize[1]),{imagePrimary:s,imageSecondary:void 0,top:h,right:u,bottom:d,left:p,collisionPadding:a}}class j_ extends y{constructor(e,t,i,r,n){super(e,t),this.angle=r,this.z=i,void 0!==n&&(this.segment=n);}clone(){return new j_(this.x,this.y,this.z,this.angle,this.segment)}}function G_(e,t,i,r,n){if(void 0===t.segment)return !0;let o=t,s=t.segment+1,a=0;for(;a>-i/2;){if(s--,s<0)return !1;a-=e[s].dist(o),o=e[s];}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;a<i/2;){const t=e[s],i=e[s+1];if(!i)return !1;let o=e[s-1].angleTo(t)-t.angleTo(i);for(o=Math.abs((o+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:o}),c+=o;a-l[0].distance>r;)c-=l.shift().angleDelta;if(c>n)return !1;s++,a+=t.dist(i);}return !0}function q_(e){let t=0;for(let i=0;i<e.length-1;i++)t+=e[i].dist(e[i+1]);return t}function Z_(e,t,i){return e?.6*t*i:0}function $_(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function W_(e,t,i,r,n,o){const s=Z_(i,n,o),a=$_(i,r)*o;let l=0;const c=q_(e)/2;for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1],o=r.dist(n);if(l+o>c){const h=(c-l)/o,u=Kr(r.x,n.x,h),d=Kr(r.y,n.y,h),p=new j_(u,d,0,n.angleTo(r),i);return !s||G_(e,p,a,s,t)?p:void 0}l+=o;}}function H_(e,t,i,r,n,o,s,a,l){const c=Z_(r,o,s),h=$_(r,n),u=h*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-u<t/4&&(t=u+t/4),X_(e,d?t/2*a%t:(h/2+2*o)*s*a%t,t,c,i,u,d,!1,l)}function X_(e,t,i,r,n,o,s,a,l){const c=o/2,h=q_(e);let u=0,d=t-i,p=[];for(let t=0;t<e.length-1;t++){const s=e[t],a=e[t+1],f=s.dist(a),m=a.angleTo(s);for(;d+i<u+f;){d+=i;const _=(d-u)/f,g=Kr(s.x,a.x,_),y=Kr(s.y,a.y,_);if(g>=0&&g<l&&y>=0&&y<l&&d-c>=0&&d+c<=h){const i=new j_(g,y,0,m,t);r&&!G_(e,i,o,r,n)||p.push(i);}}u+=f;}return a||p.length||s||(p=X_(e,u/2,i,r,n,o,s,!0,l)),p}function Y_(e,t,i,r,n){const o=[];for(let s=0;s<e.length;s++){const a=e[s];let l;for(let e=0;e<a.length-1;e++){let s=a[e],c=a[e+1];s.x<t&&c.x<t||(s.x<t?s=new y(t,s.y+(t-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x<t&&(c=new y(t,s.y+(t-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y<i&&c.y<i||(s.y<i?s=new y(s.x+(i-s.y)/(c.y-s.y)*(c.x-s.x),i)._round():c.y<i&&(c=new y(s.x+(i-s.y)/(c.y-s.y)*(c.x-s.x),i)._round()),s.x>=r&&c.x>=r||(s.x>=r?s=new y(r,s.y+(r-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=r&&(c=new y(r,s.y+(r-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=n&&c.y>=n||(s.y>=n?s=new y(s.x+(n-s.y)/(c.y-s.y)*(c.x-s.x),n)._round():c.y>=n&&(c=new y(s.x+(n-s.y)/(c.y-s.y)*(c.x-s.x),n)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))));}}return o}function K_(e){let t=0,i=0;for(const r of e)t+=r.w*r.h,i=Math.max(i,r.w);e.sort(((e,t)=>t.h-e.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const t=r.pop();e<r.length&&(r[e]=t);}else t.h===i.h?(i.x+=t.w,i.w-=t.w):t.w===i.w?(i.y+=t.h,i.h-=t.h):(r.push({x:i.x+t.w,y:i.y,w:i.w-t.w,h:t.h}),i.y+=t.h,i.h-=t.h);break}}return {w:n,h:o,fill:t/(n*o)||0}}Rs(j_,"Anchor");const J_=1;class Q_{constructor(e,{pixelRatio:t,version:i,stretchX:r,stretchY:n,content:o}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=n,this.content=o,this.version=i;}get tl(){return [this.paddedRect.x+J_,this.paddedRect.y+J_]}get br(){return [this.paddedRect.x+this.paddedRect.w-J_,this.paddedRect.y+this.paddedRect.h-J_]}get displaySize(){return [(this.paddedRect.w-2*J_)/this.pixelRatio,(this.paddedRect.h-2*J_)/this.pixelRatio]}}class eg{constructor(e,t){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(e,i,n),this.addImages(t,r,n);const{w:o,h:s}=K_(n),a=new ef({width:o||1,height:s||1});for(const t in e){const r=e[t],n=i[t].paddedRect;ef.copy(r.data,a,{x:0,y:0},{x:n.x+J_,y:n.y+J_},r.data);}for(const e in t){const i=t[e],n=r[e].paddedRect,o=n.x+J_,s=n.y+J_,l=i.data.width,c=i.data.height;ef.copy(i.data,a,{x:0,y:0},{x:o,y:s},i.data),ef.copy(i.data,a,{x:0,y:c-1},{x:o,y:s-1},{width:l,height:1}),ef.copy(i.data,a,{x:0,y:0},{x:o,y:s+c},{width:l,height:1}),ef.copy(i.data,a,{x:l-1,y:0},{x:o-1,y:s},{width:1,height:c}),ef.copy(i.data,a,{x:0,y:0},{x:o+l,y:s},{width:1,height:c});}this.image=a,this.iconPositions=i,this.patternPositions=r;}addImages(e,t,i){for(const r in e){const n=e[r],o={x:0,y:0,w:n.data.width+2*J_,h:n.data.height+2*J_};i.push(o),t[r]=new Q_(o,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r);}}patchUpdatedImages(e,t,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((t=>e.hasImage(t,i))),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const r in e.getUpdatedImages(i))this.patchUpdatedImage(this.iconPositions[r],e.getImage(r,i),t),this.patchUpdatedImage(this.patternPositions[r],e.getImage(r,i),t);}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,n]=e.tl;i.update(t.data,void 0,{x:r,y:n});}}Rs(Q_,"ImagePosition"),Rs(eg,"ImageAtlas");const tg=1e20;function ig(e,t,i,r,n,o,s,a,l){for(let c=t;c<t+r;c++)rg(e,i*o+c,o,n,s,a,l);for(let c=i;c<i+n;c++)rg(e,c*o+t,1,r,s,a,l);}function rg(e,t,i,r,n,o,s){o[0]=0,s[0]=-tg,s[1]=tg,n[0]=e[t];for(let a=1,l=0,c=0;a<r;a++){n[a]=e[t+a*i];const r=a*a;do{const e=o[l];c=(n[a]-n[e]+r-e*e)/(a-e)/2;}while(c<=s[l]&&--l>-1);l++,o[l]=a,s[l]=c,s[l+1]=tg;}for(let a=0,l=0;a<r;a++){for(;s[l+1]<a;)l++;const r=o[l],c=a-r;e[t+a*i]=n[r]+c*c;}}const ng=2;class og{constructor(e,t,i){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=i,this.urls={},this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}};}setURL(e,t){this.urls[t]=e;}getGlyphs(e,t,i){const r=[],o=this.urls[t]||n.GLYPHS_URL;for(const t in e)for(const i of e[t])r.push({stack:t,id:i});R(r,(({stack:e,id:t},i)=>{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let n=r.glyphs[t];if(void 0!==n)return void i(null,{stack:e,id:t,glyph:n});if(n=this._tinySDF(r,e,t),n)return r.glyphs[t]=n,void i(null,{stack:e,id:t,glyph:n});const s=Math.floor(t/256);if(256*s>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[s])return void i(null,{stack:e,id:t,glyph:n});let a=r.requests[s];a||(a=r.requests[s]=[],og.loadGlyphRange(e,s,o,this.requestManager,((e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[s]=!0;}for(const i of a)i(e,t);delete r.requests[s];}))),a.push(((r,n)=>{r?i(r):n&&i(null,{stack:e,id:t,glyph:n.glyphs[t]||null});}));}),((e,t)=>{if(e)i(e);else if(t){const e={};for(const{stack:i,id:r,glyph:n}of t)void 0===e[i]&&(e[i]={}),void 0===e[i].glyphs&&(e[i].glyphs={}),e[i].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},e[i].ascender=this.entries[i].ascender,e[i].descender=this.entries[i].descender;i(null,e);}}));}_doesCharSupportLocalGlyph(e){return 0!==this.localGlyphMode&&(2===this.localGlyphMode?!!this.localFontFamily:!!this.localFontFamily&&(Fs["CJK Unified Ideographs"](e)||Fs["Hangul Syllables"](e)||Fs.Hiragana(e)||Fs.Katakana(e)||Fs["CJK Symbols and Punctuation"](e)||Fs["CJK Unified Ideographs Extension A"](e)||Fs["CJK Unified Ideographs Extension B"](e)))}_tinySDF(e,t,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=e.tinySDF;if(!n){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),n=e.tinySDF=new og.TinySDF({fontFamily:r,fontWeight:i,fontSize:24*ng,buffer:3*ng,radius:8*ng}),n.fontWeight=i;}if(this.localGlyphs[n.fontWeight][i])return this.localGlyphs[n.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=n.draw(o);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new Qp({width:a,height:l},s),metrics:{width:c/ng,height:h/ng,left:u/ng,top:d/ng-27,advance:p/ng,localGlyph:!0}}}}og.loadGlyphRange=function(e,t,i,r,n){const o=256*t,s=o+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),ye.Glyphs);Te(a,((e,t)=>{if(e)n(e);else if(t){const e={},i=function(e){return new km(e).readFields(w_,{})}(t);for(const t of i.glyphs)e[t.id]=t;n(null,{glyphs:e,ascender:i.ascender,descender:i.descender});}}));},og.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=i;const a=this.size=e+4*t,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${e}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a);}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const y=f.getImageData(m,m,a,l);g.fill(tg,0,u),_.fill(0,0,u);for(let e=0;e<l;e++)for(let t=0;t<a;t++){const i=y.data[4*(e*a+t)+3]/255;if(0===i)continue;const r=(e+m)*c+t+m;if(1===i)g[r]=0,_[r]=tg;else {const e=.5-i;g[r]=e>0?e*e:0,_[r]=e<0?e*e:0;}}ig(g,0,0,c,h,c,this.f,this.v,this.z),ig(_,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e<u;e++){const t=Math.sqrt(g[e])-Math.sqrt(_[e]);d[e]=Math.round(255-255*(t/this.radius+this.cutoff));}return p}};const sg=J_;function ag(e,t,i,r){const n=[],o=e.imagePrimary,s=o.pixelRatio,a=o.paddedRect.w-2*sg,l=o.paddedRect.h-2*sg,c=e.right-e.left,h=e.bottom-e.top,u=o.stretchX||[[0,a]],d=o.stretchY||[[0,l]],p=(e,t)=>e+t[1]-t[0],f=u.reduce(p,0),m=d.reduce(p,0),_=a-f,g=l-m;let x=0,v=f,b=0,w=m,T=0,E=_,M=0,A=g;if(o.content&&r){const e=o.content;x=lg(u,0,e[0]),b=lg(d,0,e[1]),v=lg(u,e[0],e[2]),w=lg(d,e[1],e[3]),T=e[0]-x,M=e[1]-b,E=e[2]-e[0]-v,A=e[3]-e[1]-w;}const S=(r,n,a,l)=>{const u=hg(r.stretch-x,v,c,e.left),d=ug(r.fixed-T,E,r.stretch,f),p=hg(n.stretch-b,w,h,e.top),_=ug(n.fixed-M,A,n.stretch,m),g=hg(a.stretch-x,v,c,e.left),S=ug(a.fixed-T,E,a.stretch,f),I=hg(l.stretch-b,w,h,e.top),C=ug(l.fixed-M,A,l.stretch,m),z=new y(u,p),P=new y(g,p),D=new y(g,I),R=new y(u,I),L=new y(d/s,_/s),k=new y(S/s,C/s),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),i=[t,-e,e,t];z._matMult(i),P._matMult(i),R._matMult(i),D._matMult(i);}const B=r.stretch+r.fixed,F=a.stretch+a.fixed,N=n.stretch+n.fixed,U=l.stretch+l.fixed,V=e.imageSecondary;return {tl:z,tr:P,bl:R,br:D,texPrimary:{x:o.paddedRect.x+sg+B,y:o.paddedRect.y+sg+N,w:F-B,h:U-N},texSecondary:V?{x:V.paddedRect.x+sg+B,y:V.paddedRect.y+sg+N,w:F-B,h:U-N}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:k,minFontScaleX:E/s/c,minFontScaleY:A/s/h,isSDF:i}};if(r&&(o.stretchX||o.stretchY)){const e=cg(u,_,f),t=cg(d,g,m);for(let i=0;i<e.length-1;i++){const r=e[i],o=e[i+1];for(let e=0;e<t.length-1;e++)n.push(S(r,t[e],o,t[e+1]));}}else n.push(S({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:a+1},{fixed:0,stretch:l+1}));return n}function lg(e,t,i){let r=0;for(const n of e)r+=Math.max(t,Math.min(i,n[1]))-Math.max(t,Math.min(i,n[0]));return r}function cg(e,t,i){const r=[{fixed:-sg,stretch:0}];for(const[t,i]of e){const e=r[r.length-1];r.push({fixed:t-e.stretch,stretch:e.stretch}),r.push({fixed:t-e.stretch,stretch:e.stretch+(i-t)});}return r.push({fixed:t+sg,stretch:i}),r}function hg(e,t,i,r){return e/t*i+r}function ug(e,t,i,r){return e-t*i/r}function dg(e,t,i,r){const n=t+e.positionedLines[r].lineOffset;return 0===r?i+n/2:i+(n+(t+e.positionedLines[r-1].lineOffset))/2}function pg(e,t=1,i=!1){let r=1/0,n=1/0,o=-1/0,s=-1/0;const a=e[0];for(let e=0;e<a.length;e++){const t=a[e];(!e||t.x<r)&&(r=t.x),(!e||t.y<n)&&(n=t.y),(!e||t.x>o)&&(o=t.x),(!e||t.y>s)&&(s=t.y);}const l=Math.min(o-r,s-n);let c=l/2;const h=new lr([],fg);if(0===l)return new y(r,n);for(let t=r;t<o;t+=l)for(let i=n;i<s;i+=l)h.push(new mg(t+c,i+c,c,e));let u=function(e){let t=0,i=0,r=0;const n=e[0];for(let e=0,o=n.length,s=o-1;e<o;s=e++){const o=n[e],a=n[s],l=o.x*a.y-a.x*o.y;i+=(o.x+a.x)*l,r+=(o.y+a.y)*l,t+=3*l;}return new mg(i/t,r/t,0,e)}(e),d=h.length;for(;h.length;){const r=h.pop();(r.d>u.d||!u.d)&&(u=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-u.d<=t||(c=r.h/2,h.push(new mg(r.p.x-c,r.p.y-c,c,e)),h.push(new mg(r.p.x+c,r.p.y-c,c,e)),h.push(new mg(r.p.x-c,r.p.y+c,c,e)),h.push(new mg(r.p.x+c,r.p.y+c,c,e)),d+=4);}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${u.d}`)),u.p}function fg(e,t){return t.max-e.max}class mg{constructor(e,t,i,r){this.p=new y(e,t),this.h=i,this.d=function(e,t){let i=!1,r=1/0;for(let n=0;n<t.length;n++){const o=t[n];for(let t=0,n=o.length,s=n-1;t<n;s=t++){const n=o[t],a=o[s];n.y>e.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,Ip(e,n,a));}}return (i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2;}}const _g=7,gg=Number.POSITIVE_INFINITY,yg=Math.sqrt(2);function xg(e,[t,i]){let r=0,n=0;if(i===gg){t<0&&(t=0);const i=t/yg;switch(e){case"top-right":case"top-left":n=i-_g;break;case"bottom-right":case"bottom-left":n=-i+_g;break;case"bottom":n=-t+_g;break;case"top":n=t-_g;}switch(e){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=t;break;case"right":r=-t;}}else {switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-_g;break;case"bottom-right":case"bottom-left":case"bottom":n=-i+_g;}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t;}}return [r,n]}function vg(e,t,i,r,n,o,s,a,l,c,h){e.createArrays(),e.tilePixelRatio=cr/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const u=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,p={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new oa(t),a),d["text-size"].possiblyEvaluate(new oa(i),a)];}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new oa(t),a),d["icon-size"].possiblyEvaluate(new oa(i),a)];}p.layoutTextSize=d["text-size"].possiblyEvaluate(new oa(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new oa(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new oa(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");let _=!1;for(const t of e.features)if(t.icon&&t.icon.nameSecondary){_=!0;break}for(const o of e.features){const l=u.get("text-font").evaluate(o,{},a).join(","),d=m.evaluate(o,{},a),g=p.layoutTextSize.evaluate(o,{},a),y=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),x=o.text;let v,b=[0,0];if(x){const r=x.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*u_,c=u.get("text-line-height").evaluate(o,{},a)*u_,h=Us(r)?s:0,p=u.get("text-anchor").evaluate(o,{},a),m=u.get("text-variable-anchor");if(!m){const e=u.get("text-radial-offset").evaluate(o,{},a);b=e?xg(p,[e*u_,gg]):u.get("text-offset").evaluate(o,{},a).map((e=>e*u_));}let _=f?"center":u.get("text-justify").evaluate(o,{},a);const v="point"===u.get("symbol-placement"),w=v?u.get("text-max-width").evaluate(o,{},a)*u_:1/0,T=o=>{e.allowVerticalPlacement&&Ns(r)&&(y.vertical=z_(x,t,i,n,l,w,c,p,o,h,b,A_.vertical,!0,g,d));};if(!f&&m){const e="auto"===_?m.map((e=>bg(e))):[_];let r=!1;for(let o=0;o<e.length;o++){const s=e[o];if(!y.horizontal[s])if(r)y.horizontal[s]=y.horizontal[0];else {const e=z_(x,t,i,n,l,w,c,"center",s,h,b,A_.horizontal,!1,g,d);e&&(y.horizontal[s]=e,r=1===e.positionedLines.length);}}T("left");}else {if("auto"===_&&(_=bg(p)),v||u.get("text-writing-mode").indexOf("horizontal")>=0||!Ns(r)){const e=z_(x,t,i,n,l,w,c,p,_,h,b,A_.horizontal,!1,g,d);e&&(y.horizontal[_]=e);}T(v?"left":_);}}let w=!1;if(o.icon&&o.icon.namePrimary){const t=r[o.icon.namePrimary];t&&(v=U_(n[o.icon.namePrimary],o.icon.nameSecondary?n[o.icon.nameSecondary]:void 0,u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),w=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&H("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0));}const T=Ag(y.horizontal)||y.vertical;e.iconsInText||(e.iconsInText=!!T&&T.iconsInText),(T||v)&&wg(e,o,y,v,r,p,g,0,b,w,s,a,c,h,_);}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray);}function bg(e){switch(e){case"right":case"top-right":case"bottom-right":return "right";case"left":case"top-left":case"bottom-left":return "left"}return "center"}function wg(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f){let m=o.textMaxSize.evaluate(t,{},u);void 0===m&&(m=s);const _=e.layers[0].layout,g=_.get("icon-offset").evaluate(t,{},u),y=Ag(i.horizontal)||i.vertical,x="globe"===d.name,v=u_,b=s/v,T=e.tilePixelRatio*m/v,E=(D=e.overscaling,e.zoom>18&&D>2&&(D>>=1),Math.max(cr/(512*D),1)*_.get("symbol-spacing")),M=_.get("text-padding")*e.tilePixelRatio,A=_.get("icon-padding")*e.tilePixelRatio,S=w(_.get("text-max-angle")),I="map"===_.get("text-rotation-alignment")&&"point"!==_.get("symbol-placement"),C="map"===_.get("icon-rotation-alignment")&&"point"!==_.get("symbol-placement"),z=_.get("symbol-placement"),P=E/2;var D;const R=_.get("icon-text-fit").evaluate(t,{},u),L=_.get("icon-text-fit-padding").evaluate(t,{},u),k="none"!==R;let O;!1===e.hasAnyIconTextFit&&k&&(e.hasAnyIconTextFit=!0),r&&k&&(e.allowVerticalPlacement&&i.vertical&&(O=V_(r,i.vertical,R,L,g,b)),y&&(r=V_(r,y,R,L,g,b)));const B=(s,a,m)=>{if(a.x<0||a.x>=cr||a.y<0||a.y>=cr)return;let _=null;if(x){const{x:e,y:t,z:i}=d.projectTilePoint(a.x,a.y,m);_={anchor:new j_(e,t,i,0,void 0),up:d.upVector(m,a.x,a.y)};}!function(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,M,A){const S=e.addToLineVertexArray(t,r);let I,C,z,P,D,R,L,k=0,O=0,B=0,F=0,N=-1,U=-1;const V={};let j=Cl("");const G=i?i.anchor:t,q="none"!==l.layout.get("icon-text-fit").evaluate(v,{},E);let Z=0,$=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[Z,$]=l.layout.get("text-offset").evaluate(v,{},E).map((e=>e*u_)):(Z=l.layout.get("text-radial-offset").evaluate(v,{},E)*u_,$=gg),e.allowVerticalPlacement&&n.vertical){const e=n.vertical;if(f)R=Ig(e),a&&(L=Ig(a));else {const i=l.layout.get("text-rotate").evaluate(v,{},E)+90;z=Sg(c,G,t,h,u,d,e,p,i,m),a&&(P=Sg(c,G,t,h,u,d,a,g,i));}}if(o){const r=l.layout.get("icon-rotate").evaluate(v,{},E),n=ag(o,r,w,q),s=a?ag(a,r,w,q):void 0;C=Sg(c,G,t,h,u,d,o,g,r),k=4*n.length;const p=e.iconSizeData;let f=null;"source"===p.kind?(f=[d_*l.layout.get("icon-size").evaluate(v,{},E)],f[0]>Eg&&H(`${e.layerIds[0]}: Value for "icon-size" is >= ${Tg}. Reduce your "icon-size".`)):"composite"===p.kind&&(f=[d_*b.compositeIconSizes[0].evaluate(v,{},E),d_*b.compositeIconSizes[1].evaluate(v,{},E)],(f[0]>Eg||f[1]>Eg)&&H(`${e.layerIds[0]}: Value for "icon-size" is >= ${Tg}. Reduce your "icon-size".`)),e.addSymbols(e.icon,n,f,x,y,v,!1,i,t,S.lineStartIndex,S.lineLength,-1,T,E,M,A),N=e.icon.placedSymbolArray.length-1,s&&(O=4*s.length,e.addSymbols(e.icon,s,f,x,y,v,A_.vertical,i,t,S.lineStartIndex,S.lineLength,-1,T,E,M,A),U=e.icon.placedSymbolArray.length-1);}for(const r in n.horizontal){const o=n.horizontal[r];I||(j=Cl(o.text),f?D=Ig(o):I=Sg(c,G,t,h,u,d,o,p,l.layout.get("text-rotate").evaluate(v,{},E),m));const a=1===o.positionedLines.length;if(B+=Mg(e,i,t,o,s,l,f,v,m,S,n.vertical?A_.horizontal:A_.horizontalOnly,a?Object.keys(n.horizontal):[r],V,N,b,T,E,M),a)break}n.vertical&&(F+=Mg(e,i,t,n.vertical,s,l,f,v,m,S,A_.vertical,["vertical"],V,U,b,T,E,M));let W=-1;const X=(e,t)=>e?Math.max(e,t):t;W=X(D,W),W=X(R,W),W=X(L,W);const Y=W>-1?1:0;e.glyphOffsetArray.length>=gy.MAX_GLYPHS&&H("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,v.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,G.x,G.y,G.z,V.right>=0?V.right:-1,V.center>=0?V.center:-1,V.left>=0?V.left:-1,V.vertical>=0?V.vertical:-1,N,U,j,void 0!==I?I:e.collisionBoxArray.length,void 0!==I?I+1:e.collisionBoxArray.length,void 0!==z?z:e.collisionBoxArray.length,void 0!==z?z+1:e.collisionBoxArray.length,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,P||e.collisionBoxArray.length,P?P+1:e.collisionBoxArray.length,h,B,F,k,O,Y,0,Z,$,W,0,q?1:0);}(e,a,_,s,i,r,n,O,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,M,I,l,0,A,C,g,t,o,c,h,u,p,f);};if("line"===z)for(const n of Y_(t.geometry,0,0,cr,cr)){const t=H_(n,E,S,i.vertical||y,r,v,T,e.overscaling,cr);for(const i of t)y&&Cg(e,y.text,P,i)||B(n,i,u);}else if("line-center"===z){for(const e of t.geometry)if(e.length>1){const t=W_(e,S,i.vertical||y,r,v,T);t&&B(e,t,u);}}else if("Polygon"===t.type)for(const e of Ff(t.geometry,0)){const t=pg(e,16);B(e[0],new j_(t.x,t.y,0,0,void 0),u);}else if("LineString"===t.type)for(const e of t.geometry)B(e,new j_(e[0].x,e[0].y,0,0,void 0),u);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)B([t],new j_(t.x,t.y,0,0,void 0),u);}const Tg=255,Eg=Tg*d_;function Mg(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const x=function(e,t,i,r,n,o,s,a){const l=[];if(0===t.positionedLines.length)return l;const c=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,h=function(e){const t=e[0],i=e[1],r=t*i;return r>0?[t,-i]:r<0?[-t,i]:0===t?[i,t]:[i,-t]}(i);let u=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)u-=e.lineOffset;const d=t.positionedLines.length,p=u/d;let f=t.top-i[1];for(let e=0;e<d;++e){const r=t.positionedLines[e];f=dg(t,p,f,e);for(const e of r.positionedGlyphs){if(!e.rect)continue;const r=e.rect||{};let o=M_+1,u=!0,d=1,p=0;if(e.imageName){const t=s[e.imageName];if(!t)continue;if(t.sdf){H("SDF images are not supported in formatted text and will be ignored.");continue}u=!1,d=t.pixelRatio,o=J_/d;}const m=(n||a)&&e.vertical,_=e.metrics.advance*e.scale/2,g=e.metrics,x=e.rect;if(null===x)continue;a&&t.verticalizable&&(p=e.imageName?_-e.metrics.width*e.scale/2:0);const v=n?[e.x+_,e.y]:[0,0];let b=[0,0],w=[0,0],T=!1;n||(m?(w=[e.x+_+h[0],e.y+h[1]-p],T=!0):b=[e.x+_+i[0],e.y+i[1]-p]);const E=x.w*e.scale/(d*(e.localGlyph?ng:1)),M=x.h*e.scale/(d*(e.localGlyph?ng:1));let A,S,I,C;if(m){const t=e.y-f,i=new y(-_,_-t),r=-Math.PI/2,n=new y(...w);A=new y(-_+b[0],b[1]),A._rotateAround(r,i)._add(n),A.x+=-t+_,A.y-=(g.left-o)*e.scale;const s=e.imageName?g.advance*e.scale:u_*e.scale,a=String.fromCodePoint(e.glyph);x_(a)?A.x+=(1-o)*e.scale:v_(a)?A.x+=s-g.height*e.scale+(-o-1)*e.scale:A.x+=e.imageName||g.width+2*o===x.w&&g.height+2*o===x.h?(s-M)/2:(s-(g.height+2*o)*e.scale)/2,S=new y(A.x,A.y-E),I=new y(A.x+M,A.y),C=new y(A.x+M,A.y-E);}else {const t=(g.left-o)*e.scale-_+b[0],i=(-g.top-o)*e.scale+b[1],r=t+E,n=i+M;A=new y(t,i),S=new y(r,i),I=new y(t,n),C=new y(r,n);}if(c){let e;e=n?new y(0,0):T?new y(h[0],h[1]):new y(i[0],i[1]),A._rotateAround(c,e),S._rotateAround(c,e),I._rotateAround(c,e),C._rotateAround(c,e);}const z=new y(0,0),P=new y(0,0);l.push({tl:A,tr:S,bl:I,br:C,texPrimary:r,texSecondary:void 0,writingMode:t.writingMode,glyphOffset:v,sectionIndex:e.sectionIndex,isSDF:u,pixelOffsetTL:z,pixelOffsetBR:P,minFontScaleX:0,minFontScaleY:0});}}return l}(0,r,l,o,s,a,n,e.allowVerticalPlacement),v=e.textSizeData;let b=null;"source"===v.kind?(b=[d_*o.layout.get("text-size").evaluate(a,{},_)],b[0]>Eg&&H(`${e.layerIds[0]}: Value for "text-size" is >= ${Tg}. Reduce your "text-size".`)):"composite"===v.kind&&(b=[d_*f.compositeTextSizes[0].evaluate(a,{},_),d_*f.compositeTextSizes[1].evaluate(a,{},_)],(b[0]>Eg||b[1]>Eg)&&H(`${e.layerIds[0]}: Value for "text-size" is >= ${Tg}. Reduce your "text-size".`)),e.addSymbols(e.text,x,b,l,s,a,h,t,i,c.lineStartIndex,c.lineLength,p,m,_,g,!1);for(const t of u)d[t]=e.text.placedSymbolArray.length-1;return 4*x.length}function Ag(e){for(const t in e)return e[t];return null}function Sg(e,t,i,r,n,o,s,a,l,c){let h=s.top,u=s.bottom,d=s.left,p=s.right;const f=s.collisionPadding;if(f&&(d-=f[0],h-=f[1],p+=f[2],u+=f[3]),l){const e=new y(d,h),t=new y(p,h),i=new y(d,u),r=new y(p,u),n=w(l);let o=new y(0,0);c&&(o=new y(c[0],c[1])),e._rotateAround(n,o),t._rotateAround(n,o),i._rotateAround(n,o),r._rotateAround(n,o),d=Math.min(e.x,t.x,i.x,r.x),p=Math.max(e.x,t.x,i.x,r.x),h=Math.min(e.y,t.y,i.y,r.y),u=Math.max(e.y,t.y,i.y,r.y);}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,d,h,p,u,a,r,n,o),e.length-1}function Ig(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function Cg(e,t,i,r){const n=e.compareText;if(t in n){const e=n[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])<i)return !0}else n[t]=[];return n[t].push(r),!1}function zg(e,t){const i=e.fovAboveCenter,r=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,n=(e._camera.position[2]*e.worldSize-r)/Math.cos(e._pitch),o=Math.sin(i)*n/Math.sin(Math.max(Math.PI/2-e._pitch-i,.01)),s=Math.sin(e._pitch)*o+n;return Math.min(1.01*s,n*(1/e._horizonShift))}function Pg(e,t){if(!t.isReprojectedInTileSpace)return {scale:1<<e.z,x:e.x,y:e.y,x2:e.x+1,y2:e.y+1,projection:t};const i=Math.pow(2,-e.z),r=e.x*i,n=(e.x+1)*i,o=e.y*i,s=(e.y+1)*i,a=ep(r),l=ep(n),c=tp(o),h=tp(s),u=t.project(a,c),d=t.project(l,c),p=t.project(l,h),f=t.project(a,h);let m=Math.min(u.x,d.x,p.x,f.x),_=Math.min(u.y,d.y,p.y,f.y),g=Math.max(u.x,d.x,p.x,f.x),y=Math.max(u.y,d.y,p.y,f.y);const x=i/16;function v(e,i,r,n,o,s){const a=(r+o)/2,l=(n+s)/2,c=t.project(ep(a),tp(l)),h=Math.max(0,m-c.x,_-c.y,c.x-g,c.y-y);m=Math.min(m,c.x),g=Math.max(g,c.x),_=Math.min(_,c.y),y=Math.max(y,c.y),h>x&&(v(e,c,r,n,a,l),v(c,i,a,l,o,s));}v(u,d,r,o,n,o),v(d,p,n,o,n,s),v(p,f,n,s,r,s),v(f,u,r,s,r,o),m-=x,_-=x,g+=x,y+=x;const b=1/Math.max(g-m,y-_);return {scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:t}}function Dg(e,t,i,r,n,o,s,a,l){if("globe"===l.name)return yd(e,t,new ju(i,r,n),!1);const c=Pg({z:i,x:r,y:n},l);return new ed([(o+c.x/c.scale)*t,t*(c.y/c.scale),s],[(o+c.x2/c.scale)*t,t*(c.y2/c.scale),a])}function Rg(e,{x:t,y:i},r=0){return new y(((t-r)*e.scale-e.x)*cr,(i*e.scale-e.y)*cr)}function Lg(e,t,i=0){return Du.fromValues(((t.x-i)*e.scale-e.x)*cr,(t.y*e.scale-e.y)*cr,ip(t.z,t.y))}const kg=Au.identity(new Float32Array(16));class Og{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7];}project(e,t){return {x:0,y:0,z:0}}unproject(e,t){return new Wd(0,0)}projectTilePoint(e,t,i){return {x:e,y:t,z:0}}locationPoint(e,t,i=!0){return e._coordinatePoint(e.locationCoordinate(t),i)}pixelsPerMeter(e,t){return Qd(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return zg(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,r){const n=e.horizonLineFromTop(!1),o=new y(t,Math.max(n,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,i){const r=new y(t,i);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.y,0);return [t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return !this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y<i}createInversionMatrix(e,t){return kg}createTileMatrix(e,t,i){let r,n,o;const s=i.canonical,a=Au.identity(new Float64Array(16));if(this.isReprojectedInTileSpace){const l=Pg(s,this);r=1,n=l.x+i.wrap*l.scale,o=l.y,Au.scale(a,a,[r/l.scale,r/l.scale,e.pixelsPerMeter/t]);}else r=t/e.zoomScale(s.z),n=(s.x+Math.pow(2,s.z)*i.wrap)*r,o=s.y*r;return Au.translate(a,a,[n,o,0]),Au.scale(a,a,[r/cr,r/cr,1]),a}upVector(e,t,i){return [0,0,1]}upVectorScale(e,t,i){return {metersToTile:1}}}class Bg extends Og{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[t,i]=this.parallels=e.parallels||[29.5,45.5],r=Math.sin(w(t));this.n=(r+Math.sin(w(i)))/2,this.c=1+r*(2*this.n-r),this.r0=Math.sqrt(this.c)/this.n;}project(e,t){const{n:i,c:r,r0:n}=this,o=w(e-this.center[0]),s=w(t),a=Math.sqrt(r-2*i*Math.sin(s))/i;return {x:a*Math.sin(o*i),y:a*Math.cos(o*i)-n,z:0}}unproject(e,t){const{n:i,c:r,r0:n}=this,o=n+t;let s=Math.atan2(e,Math.abs(o))*Math.sign(o);o*i<0&&(s-=Math.PI*Math.sign(e)*Math.sign(o));const a=w(this.center[0])*i;s=D(s,-Math.PI-a,Math.PI-a);const l=z(T(s/i)+this.center[0],-180,180),c=Math.asin(z((r-(e*e+o*o)*i*i)/(2*i),-1,1)),h=z(T(c),-rp,rp);return new Wd(l,h)}}const Fg=1.340264,Ng=-.081106,Ug=893e-6,Vg=.003796,jg=Math.sqrt(3)/2;class Gg extends Og{project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const i=Math.asin(jg*Math.sin(t)),r=i*i,n=r*r*r;return {x:.5*(e*Math.cos(i)/(jg*(Fg+3*Ng*r+n*(7*Ug+9*Vg*r)))/Math.PI+.5),y:1-.5*(i*(Fg+Ng*r+n*(Ug+Vg*r))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=i*i,n=r*r*r;for(let e,o,s,a=0;a<12&&(o=i*(Fg+Ng*r+n*(Ug+Vg*r))-t,s=Fg+3*Ng*r+n*(7*Ug+9*Vg*r),e=o/s,i=z(i-e,-Math.PI/3,Math.PI/3),r=i*i,n=r*r*r,!(Math.abs(e)<1e-12));++a);const o=jg*e*(Fg+3*Ng*r+n*(7*Ug+9*Vg*r))/Math.cos(i),s=Math.asin(Math.sin(i)/jg),a=z(180*o/Math.PI,-180,180),l=z(180*s/Math.PI,-rp,rp);return new Wd(a,l)}}class qg extends Og{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0;}project(e,t){return {x:.5+e/360,y:.5-t/360,z:0}}unproject(e,t){const i=360*(e-.5),r=z(360*(.5-t),-rp,rp);return new Wd(i,r)}}const Zg=Math.PI/2;function $g(e){return Math.tan((Zg+e)/2)}class Wg extends Og{constructor(e){super(e),this.center=e.center||[0,30];const[t,i]=this.parallels=e.parallels||[30,30];let r=w(t),n=w(i);this.southernCenter=r+n<0,this.southernCenter&&(r=-r,n=-n);const o=Math.cos(r),s=$g(r);this.n=r===n?Math.sin(r):Math.log(o/Math.cos(n))/Math.log($g(n)/s),this.f=o*Math.pow($g(r),this.n)/this.n;}project(e,t){t=w(t),this.southernCenter&&(t=-t),e=w(e-this.center[0]);const i=1e-6,{n:r,f:n}=this;n>0?t<-Zg+i&&(t=-Zg+i):t>Zg-i&&(t=Zg-i);const o=n/Math.pow($g(t),r);let s=o*Math.sin(r*e),a=n-o*Math.cos(r*e);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:i,f:r}=this,n=r-t,o=Math.sign(n),s=Math.sign(i)*Math.sqrt(e*e+n*n);let a=Math.atan2(e,Math.abs(n))*o;n*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=z(T(a/i)+this.center[0],-180,180),c=z(T(2*Math.atan(Math.pow(r/s,1/i))-Zg),-rp,rp);return new Wd(l,this.southernCenter?-c:c)}}class Hg extends Og{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(e,t){return {x:Kd(e),y:Jd(t),z:0}}unproject(e,t){const i=ep(e),r=tp(t);return new Wd(i,r)}}const Xg=w(rp);class Yg extends Og{project(e,t){const i=(t=w(t))*t,r=i*i;return {x:.5*((e=w(e))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=25,n=0,o=i*i;do{o=i*i;const e=o*o;n=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=z(i-n,-Xg,Xg);}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const s=z(T(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=T(i);return new Wd(s,a)}}const Kg=w(rp);class Jg extends Og{project(e,t){t=w(t),e=w(e);const i=Math.cos(t),r=2/Math.PI,n=Math.acos(i*Math.cos(e/2)),o=Math.sin(n)/n,s=.5*(e*r+2*i*Math.sin(e/2)/o)||0,a=.5*(t+Math.sin(t)/o)||0;return {x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,n=25;const o=1e-6;let s=0,a=0;do{const n=Math.cos(r),o=Math.sin(r),l=2*o*n,c=o*o,h=n*n,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(n*u)*Math.sqrt(1/m):0,y=.5*(2*g*n*d+2*i/Math.PI)-e,x=.5*(g*o+r)-t,v=.5*_*(h*f+g*n*u*c)+1/Math.PI,b=_*(p*l/4-g*o*d),w=.125*_*(l*d-g*o*h*p),T=.5*_*(c*u+g*f*n)+.5,E=b*w-T*v;s=(x*b-y*T)/E,a=(y*w-x*v)/E,i=z(i-s,-Math.PI,Math.PI),r=z(r-a,-Kg,Kg);}while((Math.abs(s)>o||Math.abs(a)>o)&&--n>0);return new Wd(T(i),T(r))}}class Qg extends Og{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(w(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(e,t){const{scale:i,cosPhi:r}=this;return {x:w(e)*r*i+.5,y:-Math.sin(w(t))/r*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:r}=this,n=-(t-.5)/i,o=z(T((e-.5)/i)/r,-180,180),s=Math.asin(z(n*r,-1,1)),a=z(T(s),-rp,rp);return new Wd(o,a)}}class ey extends Hg{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5];}projectTilePoint(e,t,i){const r=Td(e,t,i),n=Ad(fd(i));return Du.transformMat4(r,r,n),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t){const i=wd(t.lat,t.lng),r=Du.normalize([],i),n=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude,o=Qd(1,0)*cr*n;Du.scaleAndAdd(i,i,r,o);const s=Au.identity(new Float64Array(16));return Au.multiply(s,e.pixelMatrix,e.globeMatrix),Du.transformMat4(i,i,s),new y(i[0],i[1])}pixelsPerMeter(e,t){return Qd(1,0)*t}pixelSpaceConversion(e,t,i){const r=Qd(1,e)*t,n=Kr(Qd(1,45)*t,r,i);return this.pixelsPerMeter(e,t)/n}createTileMatrix(e,t,i){const r=Sd(fd(i.canonical));return Au.multiply(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:i}=e,r=Ad(fd(t));return Au.rotateY(r,r,w(i.lng)),Au.rotateX(r,r,w(i.lat)),Au.scale(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,i,r){return ud(e,t,i,!0)||new lp(0,0)}pointCoordinate3D(e,t,i){const r=this.pointCoordinate(e,t,i,0);return [r.x,r.y,r.z]}isPointAboveHorizon(e,t){return !ud(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,r=e._centerAltitude*t,n=e._camera,o=e._camera.forward(),s=Du.add([],Du.scale([],o,-i),[0,0,r]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,h=Math.tan(e.fovAboveCenter),u=Du.scale([],n.up(),h),d=Du.scale([],n.right(),h*c),p=Du.normalize([],Du.add([],Du.add([],o,u),d)),f=[];let m;if(new Wu(s,p).closestPointOnSphere(l,a,f)){const t=Du.add([],f,l),i=Du.sub([],t,s);m=Math.cos(e.fovAboveCenter)*Du.length(i);}else {const e=Du.sub([],s,l),t=Du.sub([],l,s);Du.normalize(t,t);const i=Du.length(e)-a;m=Math.sqrt(i*(i+2*a));const r=Math.acos(m/(a+i))-Math.acos(Du.dot(o,t));m*=Math.cos(r);}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=Dd(e.zoom);if(i>0){const r=zg(e,Qd(1,e.center.lat)*e.worldSize),n=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Kr(t,r+n*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){return Td(t,i,e,1)}upVectorScale(e){return {metersToTile:hd(Ed(fd(e)))}}}function ty(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new Hg(e);case"equirectangular":return new qg(e);case"naturalEarth":return new Yg(e);case"equalEarth":return new Gg(e);case"winkelTripel":return new Jg(e);case"albers":return i?new Qg(e):new Bg(e);case"lambertConformalConic":return i?new Qg(e):new Wg(e);case"globe":return new ey(e)}throw new Error(`Invalid projection name: ${e.name}`)}const iy=new ga({"symbol-placement":new fa(Pt.layout_symbol["symbol-placement"]),"symbol-spacing":new fa(Pt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new fa(Pt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ma(Pt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new fa(Pt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new fa(Pt.layout_symbol["symbol-z-elevate"]),"icon-allow-overlap":new fa(Pt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new fa(Pt.layout_symbol["icon-ignore-placement"]),"icon-optional":new fa(Pt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new fa(Pt.layout_symbol["icon-rotation-alignment"]),"icon-size":new ma(Pt.layout_symbol["icon-size"]),"icon-text-fit":new ma(Pt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ma(Pt.layout_symbol["icon-text-fit-padding"]),"icon-image":new ma(Pt.layout_symbol["icon-image"]),"icon-rotate":new ma(Pt.layout_symbol["icon-rotate"]),"icon-padding":new fa(Pt.layout_symbol["icon-padding"]),"icon-keep-upright":new fa(Pt.layout_symbol["icon-keep-upright"]),"icon-offset":new ma(Pt.layout_symbol["icon-offset"]),"icon-anchor":new ma(Pt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new fa(Pt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new fa(Pt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new fa(Pt.layout_symbol["text-rotation-alignment"]),"text-field":new ma(Pt.layout_symbol["text-field"]),"text-font":new ma(Pt.layout_symbol["text-font"]),"text-size":new ma(Pt.layout_symbol["text-size"]),"text-max-width":new ma(Pt.layout_symbol["text-max-width"]),"text-line-height":new ma(Pt.layout_symbol["text-line-height"]),"text-letter-spacing":new ma(Pt.layout_symbol["text-letter-spacing"]),"text-justify":new ma(Pt.layout_symbol["text-justify"]),"text-radial-offset":new ma(Pt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new fa(Pt.layout_symbol["text-variable-anchor"]),"text-anchor":new ma(Pt.layout_symbol["text-anchor"]),"text-max-angle":new fa(Pt.layout_symbol["text-max-angle"]),"text-writing-mode":new fa(Pt.layout_symbol["text-writing-mode"]),"text-rotate":new ma(Pt.layout_symbol["text-rotate"]),"text-padding":new fa(Pt.layout_symbol["text-padding"]),"text-keep-upright":new fa(Pt.layout_symbol["text-keep-upright"]),"text-transform":new ma(Pt.layout_symbol["text-transform"]),"text-offset":new ma(Pt.layout_symbol["text-offset"]),"text-allow-overlap":new fa(Pt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new fa(Pt.layout_symbol["text-ignore-placement"]),"text-optional":new fa(Pt.layout_symbol["text-optional"]),visibility:new fa(Pt.layout_symbol.visibility)});var ry={paint:new ga({"icon-opacity":new ma(Pt.paint_symbol["icon-opacity"]),"icon-emissive-strength":new ma(Pt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ma(Pt.paint_symbol["text-emissive-strength"]),"icon-color":new ma(Pt.paint_symbol["icon-color"]),"icon-halo-color":new ma(Pt.paint_symbol["icon-halo-color"]),"icon-halo-width":new ma(Pt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ma(Pt.paint_symbol["icon-halo-blur"]),"icon-translate":new fa(Pt.paint_symbol["icon-translate"]),"icon-translate-anchor":new fa(Pt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new ma(Pt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ma(Pt.paint_symbol["text-opacity"]),"text-color":new ma(Pt.paint_symbol["text-color"],{runtimeType:Zt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new ma(Pt.paint_symbol["text-halo-color"]),"text-halo-width":new ma(Pt.paint_symbol["text-halo-width"]),"text-halo-blur":new ma(Pt.paint_symbol["text-halo-blur"]),"text-translate":new fa(Pt.paint_symbol["text-translate"]),"text-translate-anchor":new fa(Pt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new fa(Pt.paint_symbol["icon-color-saturation"])}),layout:iy};class ny{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Vt,this.defaultValue=e;}evaluate(e){if(e.formattedSection){const t=this.defaultValue.property.overrides;if(t&&t.hasOverride(e.formattedSection))return t.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}Rs(ny,"FormatSectionOverride",{omit:["defaultValue"]});class oy extends Ta{constructor(e,t){super(e,ry,t);}recalculate(e,t){super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e;}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides();}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||To(o.value)||!n?n:function(e,t){return t.replace(/{([^{}]+)}/g,((t,i)=>i in e?String(e[i]):""))}(t.properties,n)}createBucket(e){return new gy(e)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const e of ry.paint.overridableProperties){if(!oy.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new ny(t),r=new wo(i,t.property.specification);let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new Mo("source",r):new Ao("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new da(t.property,n,t.parameters);}}_handleOverridablePaintPropertyUpdate(e,t,i){return !(!this.layout||t.isDataDriven()||i.isDataDriven())&&oy.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=ry.paint.properties[t];let n=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof pi)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{n||(t instanceof vi&&gi(t.value)===Xt?o(t.value.sections):t instanceof Mi?o(t.sections):t.eachChild(e));},t=i.value;t._styleExpression&&e(t._styleExpression.expression);}return n}getProgramIds(){const e=0!==this.paint.get("icon-opacity").constantOr(1),t=0!==this.paint.get("text-opacity").constantOr(1),i=[];return e&&i.push("symbolIcon"),t&&i.push("symbolSDF"),i}getDefaultProgramParams(e,t){return {config:new Ql(this,t),overrideFog:!1}}}const sy=hm.types,ay=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ly(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=a?Math.min(Eg,Math.round(a[0])):0,f=a?Math.min(Eg,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*n),o,s,(p<<1)+(l?1:0),f,16*c,16*h,256*u,256*d);}function cy(e,t,i){e.emplaceBack(t,i);}function hy(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,s);}function uy(e,t,i,r,n){const o=5*t+2;e.float32[o+0]=i,e.float32[o+1]=r,e.float32[o+2]=n;}function dy(e,t,i,r,n){e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n),e.emplaceBack(t,i,r,n);}function py(e){for(const t of e.sections)if($s(t.text))return !0;return !1}class fy{constructor(e){this.layoutVertexArray=new Na,this.indexArray=new Wa,this.programConfigurations=e,this.segments=new xl,this.dynamicLayoutVertexArray=new ka,this.opacityVertexArray=new Va,this.placedSymbolArray=new cl,this.iconTransitioningVertexArray=new ja,this.globeExtVertexArray=new Ua,this.zOffsetVertexArray=new Ya;}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(e,t,i,r,n){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,i_.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,n_.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,ay,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,s_.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,r_.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||n)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,o_.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e));}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy());}}Rs(fy,"SymbolBuffers");class my{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new xl,this.collisionVertexArray=new $a,this.collisionVertexArrayExt=new ka;}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,a_.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,l_.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}Rs(my,"CollisionBuffers");class _y{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.hasAnyIconTextFit=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=Au.identity([]),this.placementViewportMatrix=Au.identity([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=p_(this.zoom,t["text-size"]),this.iconSizeData=p_(this.zoom,t["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((e=>A_[e])),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=i.get("symbol-z-elevate");}createArrays(){this.text=new fy(new ec(this.layers,this.zoom,(e=>/^text/.test(e)))),this.icon=new fy(new ec(this.layers,this.zoom,(e=>/^icon/.test(e)))),this.glyphOffsetArray=new dl,this.lineVertexArray=new pl,this.symbolInstances=new ul;}calculateGlyphDependencies(e,t,i,r,n){for(let i=0;i<e.length;i++){const o=e.codePointAt(i);if(void 0===o)break;if(t[o]=!0,r&&n&&o<=65535){const r=y_[e.charAt(i)];r&&(t[r.charCodeAt(0)]=!0);}}}populate(e,t,i,r){const n=this.layers[0],o=n.layout,s="globe"===this.projection.name,a=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),h=("constant"!==l.value.kind||l.value.value instanceof pi&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!h&&!u)return;const p=t.iconDependencies,f=t.glyphDependencies,m=t.availableImages,_=new oa(this.zoom);for(const{feature:t,id:l,index:c,sourceLayerIndex:g}of e){const e=n._featureFilter.needGeometry,y=gp(t,e);if(!n._featureFilter.filter(_,y,i))continue;if(e||(y.geometry=_p(t,i,r)),s&&1!==t.type&&i.z<=5){const e=y.geometry,t=.98078528056,r=(e,r)=>{const n=Td(e.x,e.y,i,1),o=Td(r.x,r.y,i,1);return Du.dot(n,o)<t};for(let t=0;t<e.length;t++)e[t]=dp(e[t],r);}let x,v;if(h){const e=n.getValueAndResolveTokens("text-field",y,i,m),t=pi.factory(e);py(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===ia()||this.hasRTLText&&na.isParsed())&&(x=g_(t,n,y));}if(u){const e=n.getValueAndResolveTokens("icon-image",y,i,m);v=e instanceof fi?e:fi.fromString(e);}if(!x&&!v)continue;const b=this.sortFeaturesByKey?d.evaluate(y,{},i):void 0;if(this.features.push({id:l,text:x,icon:v,index:c,sourceLayerIndex:g,geometry:y.geometry,properties:t.properties,type:sy[t.type],sortKey:b}),v&&(p[v.namePrimary]=!0,v.nameSecondary&&(p[v.nameSecondary]=!0)),x){const e=a.evaluate(y,{},i).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(A_.vertical)>=0;for(const i of x.sections)if(i.image)p[i.image.namePrimary]=!0;else {const r=Ns(x.toString()),n=i.fontStack||e,o=f[n]=f[n]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,r);}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},r=[];let n=0;function o(t){r.push(e[t]),n++;}function s(e,t,n){const o=i[e];return delete i[e],i[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function a(e,i,n){const o=t[i];return delete t[i],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return `${e}:${r.x}:${r.y}`}for(let c=0;c<e.length;c++){const h=e[c],u=h.geometry,d=h.text?h.text.toString():null;if(!d){o(c);continue}const p=l(d,u),f=l(d,u,!0);if(p in i&&f in t&&i[p]!==t[f]){const e=a(p,f,u),n=s(p,f,r[e].geometry);delete t[p],delete i[f],i[l(d,r[n].geometry,!0)]=n,r[e].geometry=null;}else p in i?s(p,f,u):f in t?a(p,f,u):(o(c),t[p]=n-1,i[f]=n-1);}return r.filter((e=>e.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((e,t)=>e.sortKey-t.sortKey));}update(e,t,i,r,n){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(e,t,s,i,r,n),this.icon.programConfigurations.updatePaintArrays(e,t,s,i,r,n);}updateZOffset(){const e=(e,t,r)=>{i+=t,i>e.length&&e.resize(i);for(let n=-t;n<0;n++)e.emplace(n+i,r);},t=(e,t,i)=>{r+=t,r>e.length&&e.resize(r);for(let n=-t;n<0;n++)e.emplace(n+r,i);};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,r=0;for(let i=0;i<this.symbolInstances.length;i++){const r=this.symbolInstances.get(i),{numHorizontalGlyphVertices:n,numVerticalGlyphVertices:o,numIconVertices:s}=r,a=r.zOffset,l=s>0;if((n>0||o>0)&&(e(this.text.zOffsetVertexArray,n,a),e(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=r;e>=0&&t(this.icon.zOffsetVertexArray,s,a),i>=0&&t(this.icon.zOffsetVertexArray,r.numVerticalIconVertices,a);}}this.text.zOffsetVertexBuffer&&this.text.zOffsetVertexBuffer.updateData(this.text.zOffsetVertexArray),this.icon.zOffsetVertexBuffer&&this.icon.zOffsetVertexBuffer.updateData(this.icon.zOffsetVertexArray);}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=ty(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:i}of t)this.lineVertexArray.emplaceBack(e,i);return {lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=e.indexArray,g=e.layoutVertexArray,y=e.globeExtVertexArray,x=e.segments.prepareSegment(4*t.length,g,_,this.canOverlap?o.sortKey:void 0),v=this.glyphOffsetArray.length,b=x.vertexLength,w=this.allowVerticalPlacement&&s===A_.vertical?Math.PI/2:0,T=o.text&&o.text.sections;for(let r=0;r<t.length;r++){const{tl:n,tr:s,bl:c,br:h,texPrimary:u,texSecondary:v,pixelOffsetTL:b,pixelOffsetBR:E,minFontScaleX:M,minFontScaleY:A,glyphOffset:S,isSDF:I,sectionIndex:C}=t[r],z=x.vertexLength,P=S[1];if(ly(g,l.x,l.y,n.x,P+n.y,u.x,u.y,i,I,b.x,b.y,M,A),ly(g,l.x,l.y,s.x,P+s.y,u.x+u.w,u.y,i,I,E.x,b.y,M,A),ly(g,l.x,l.y,c.x,P+c.y,u.x,u.y+u.h,i,I,b.x,E.y,M,A),ly(g,l.x,l.y,h.x,P+h.y,u.x+u.w,u.y+u.h,i,I,E.x,E.y,M,A),a){const{x:t,y:i,z:r}=a.anchor,[n,o,s]=a.up;hy(y,t,i,r,n,o,s),hy(y,t,i,r,n,o,s),hy(y,t,i,r,n,o,s),hy(y,t,i,r,n,o,s),dy(e.dynamicLayoutVertexArray,t,i,r,w);}else dy(e.dynamicLayoutVertexArray,l.x,l.y,l.z,w);if(m){const t=v||u;cy(e.iconTransitioningVertexArray,t.x,t.y),cy(e.iconTransitioningVertexArray,t.x+t.w,t.y),cy(e.iconTransitioningVertexArray,t.x,t.y+t.h),cy(e.iconTransitioningVertexArray,t.x+t.w,t.y+t.h);}_.emplaceBack(z,z+1,z+2),_.emplaceBack(z+1,z+2,z+3),x.vertexLength+=4,x.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(S[0]),r!==t.length-1&&C===t[r+1].sectionIndex||e.programConfigurations.populatePaintArrays(g.length,o,o.index,{},d,p,f,T&&T[C]);}const E=a?a.anchor:l;e.placedSymbolArray.emplaceBack(E.x,E.y,E.z,l.x,l.y,v,this.glyphOffsetArray.length-v,b,c,h,l.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],s,0,!1,0,u,0);}_commitLayoutVertex(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,Math.round(s.x),Math.round(s.y));}_addCollisionDebugVertices(e,t,i,r,n,o,s){const a=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),l=a.vertexLength,c=s.tileAnchorX,h=s.tileAnchorY;for(let e=0;e<4;e++)i.collisionVertexArray.emplaceBack(0,0,0,0);this._commitDebugCollisionVertexUpdate(i.collisionVertexArrayExt,t,e.padding,s.zOffset),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,h,new y(e.x1,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,h,new y(e.x2,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,h,new y(e.x2,e.y2)),this._commitLayoutVertex(i.layoutVertexArray,r,n,o,c,h,new y(e.x1,e.y2)),a.vertexLength+=4;const u=i.indexArray;u.emplaceBack(l,l+1),u.emplaceBack(l+1,l+2),u.emplaceBack(l+2,l+3),u.emplaceBack(l+3,l),a.primitiveLength+=4;}_addTextDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceTextSize(e,o,t,s);this._addCollisionDebugVertices(r,n,this.textCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o);}}_addIconDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceIconSize(e,t,o.placedIconSymbolIndex);this._addCollisionDebugVertices(r,n,this.iconCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o);}}generateCollisionDebugBuffers(e,t){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new my(qa,c_.members,ja),this.iconCollisionBox=new my(qa,c_.members,ja);const i=m_(this.iconSizeData,e),r=m_(this.textSizeData,e);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._addTextDebugCollisionBoxes(r,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(r,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o);}}getSymbolInstanceTextSize(e,t,i,r){const n=this.text.placedSymbolArray.get(t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=f_(this.textSizeData,e,n)/u_;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const r=this.icon.placedSymbolArray.get(i),n=f_(this.iconSizeData,e,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,t,i,r){e.emplaceBack(t,-i,-i,r),e.emplaceBack(t,i,-i,r),e.emplaceBack(t,i,i,r),e.emplaceBack(t,-i,i,r);}_updateTextDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceTextSize(e,o,t,s);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,n,r.padding,o.zOffset);}}_updateIconDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceIconSize(e,t,o.placedIconSymbolIndex);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,n,r.padding,o.zOffset);}}updateCollisionDebugBuffers(e,t){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=m_(this.iconSizeData,e),r=m_(this.textSizeData,e);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._updateTextDebugCollisionBoxes(r,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._updateTextDebugCollisionBoxes(r,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._updateIconDebugCollisionBoxes(i,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._updateIconDebugCollisionBoxes(i,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o);}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt);}_deserializeCollisionBoxesForSymbol(e,t,i,r,n,o,s,a,l){const c={};if(t<i){const{x1:i,y1:r,x2:n,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d,featureIndex:p}=e.get(t);c.textBox={x1:i,y1:r,x2:n,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d},c.textFeatureIndex=p;}if(r<n){const{x1:t,y1:i,x2:n,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d,featureIndex:p}=e.get(r);c.verticalTextBox={x1:t,y1:i,x2:n,y2:o,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d},c.verticalTextFeatureIndex=p;}if(o<s){const{x1:t,y1:i,x2:r,y2:n,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d,featureIndex:p}=e.get(o);c.iconBox={x1:t,y1:i,x2:r,y2:n,padding:s,projectedAnchorX:a,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d},c.iconFeatureIndex=p;}if(a<l){const{x1:t,y1:i,x2:r,y2:n,padding:o,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d,featureIndex:p}=e.get(a);c.verticalIconBox={x1:t,y1:i,x2:r,y2:n,padding:o,projectedAnchorX:s,projectedAnchorY:l,projectedAnchorZ:h,tileAnchorX:u,tileAnchorY:d},c.verticalIconFeatureIndex=p;}return c}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex));}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}hasIconTextFit(){return this.hasAnyIconTextFit}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;t<r;t+=4)e.indexArray.emplaceBack(t,t+1,t+2),e.indexArray.emplaceBack(t+1,t+2,t+3);}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const t=Math.sin(e),i=Math.cos(e),r=[],n=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);const s=this.symbolInstances.get(e);r.push(0|Math.round(t*s.tileAnchorX+i*s.tileAnchorY)),n.push(s.featureIndex);}return o.sort(((e,t)=>r[e]-r[t]||n[t]-n[e])),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;e<this.symbolInstances.length;++e)this.symbolInstanceIndexesSortedZOffset.push(e);}return this.zOffsetSortDirty=!1,this.symbolInstanceIndexesSortedZOffset.sort(((e,t)=>this.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset))}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===t?i.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1});}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:r,leftJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=t;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),r>=0&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}Rs(_y,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),_y.MAX_GLYPHS=65535,_y.addDynamicAttributes=dy;var gy=_y;const yy=Ia([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:xy}=yy,vy=Ia([{name:"a_packed",components:4,type:"Float32"}]),{members:by}=vy,wy=hm.types,Ty=Math.cos(Math.PI/180*37.5);class Ey{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((e=>{this.gradients[e.id]={};})),this.layoutVertexArray=new La,this.layoutVertexArray2=new ka,this.indexArray=new Wa,this.programConfigurations=new ec(e.layers,e.zoom),this.segments=new xl,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id));}populate(e,t,i,r){this.hasPattern=Uf("line",this.layers,t);const n=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=gp(t,e);if(!this.layers[0]._featureFilter.filter(new oa(this.zoom),c,i))continue;const h=n?n.evaluate(c,{},i):void 0,u={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:_p(t,i,r),patterns:{},sortKey:h};o.push(u);}n&&o.sort(((e,t)=>e.sortKey-t.sortKey));const{lineAtlas:s,featureIndex:a}=t,l=this.addConstantDashes(s);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:c}=r;if(l&&this.addFeatureDashes(r,s),this.hasPattern){const e=Vf("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e);}else this.addFeature(r,n,o,i,s.positions,t.availableImages,t.brightness);a.insert(e[o].feature,n,o,c,this.index);}}addConstantDashes(e){let t=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)t=!0;else {const t=n.value,i=r.value;if(!i)continue;e.addDash(i,t);}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let s,a;if("constant"===n.kind){if(s=n.value,!s)continue}else s=n.evaluate({zoom:i},e);a="constant"===o.kind?o.value:o.evaluate({zoom:i},e),t.addDash(s,a),e.patterns[r.id]=t.getKey(s,a);}}update(e,t,i,r,n){const o=0!==Object.keys(e).length;o&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(e,t,o?this.stateDependentLayers:this.layers,i,r,n);}addFeatures(e,t,i,r,n,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r,o);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,by)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,xy),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return {start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,r,n,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),c=a.get("line-cap").evaluate(e,{}),h=a.get("line-miter-limit"),u=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,l,c,h,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r,s);}addLine(e,t,i,r,n,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance);}const s="Polygon"===wy[t.type];let a=e.length;for(;a>=2&&e[a-1].equals(e[a-2]);)a--;let l=0;for(;l<a-1&&e[l].equals(e[l+1]);)l++;if(a<(s?3:2))return;"bevel"===i&&(n=1.05);const c=this.overscaling<=16?15*cr/(512*this.overscaling):0,h=this.segments.prepareSegment(10*a,this.layoutVertexArray,this.indexArray);let u,d,p,f,m;this.e1=this.e2=-1,s&&(u=e[a-2],m=e[l].sub(u)._unit()._perp());for(let t=l;t<a;t++){if(p=t===a-1?s?e[l+1]:void 0:e[t+1],p&&e[t].equals(p))continue;m&&(f=m),u&&(d=u),u=e[t],m=p?p.sub(u)._unit()._perp():f,f=f||m;let _=f.add(m);0===_.x&&0===_.y||_._unit();const g=f.x*m.x+f.y*m.y,y=_.x*m.x+_.y*m.y,x=0!==y?1/y:1/0,v=2*Math.sqrt(2-2*y),b=y<Ty&&d&&p,w=f.x*m.y-f.y*m.x>0;if(b&&t>l){const e=u.dist(d);if(e>2*c){const t=u.sub(u.sub(d)._mult(c/e)._round());this.updateDistance(d,t),this.addCurrentVertex(t,f,0,0,h),d=t;}}const T=d&&p;let E=T?i:s?"butt":r;if(T&&"round"===E&&(x<o?E="miter":x<=2&&(E="fakeround")),"miter"===E&&x>n&&(E="bevel"),"bevel"===E&&(x>2&&(E="flipbevel"),x<n&&(E="miter")),d&&this.updateDistance(d,u),"miter"===E)_._mult(x),this.addCurrentVertex(u,_,0,0,h);else if("flipbevel"===E){if(x>100)_=m.mult(-1);else {const e=x*f.add(m).mag()/f.sub(m).mag();_._perp()._mult(e*(w?-1:1));}this.addCurrentVertex(u,_,0,0,h),this.addCurrentVertex(u,_.mult(-1),0,0,h);}else if("bevel"===E||"fakeround"===E){const e=-Math.sqrt(x*x-1),t=w?e:0,i=w?0:e;if(d&&this.addCurrentVertex(u,f,t,i,h),"fakeround"===E){const e=Math.round(180*v/Math.PI/20);for(let t=1;t<e;t++){let i=t/e;if(.5!==i){const e=i-.5;i+=i*e*(i-1)*((1.0904+g*(g*(3.55645-1.43519*g)-3.2452))*e*e+(.848013+g*(.215638*g-1.06021)));}const r=m.sub(f)._mult(i)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(u,r.x,r.y,!1,w,0,h);}}p&&this.addCurrentVertex(u,m,-t,-i,h);}else if("butt"===E)this.addCurrentVertex(u,_,0,0,h);else if("square"===E){const e=d?1:-1;d||this.addCurrentVertex(u,_,e,e,h),this.addCurrentVertex(u,_,0,0,h),d&&this.addCurrentVertex(u,_,e,e,h);}else "round"===E&&(d&&(this.addCurrentVertex(u,f,0,0,h),this.addCurrentVertex(u,f,1,1,h,!0)),p&&(this.addCurrentVertex(u,m,-1,-1,h,!0),this.addCurrentVertex(u,m,0,0,h)));if(b&&t<a-1){const e=u.dist(p);if(e>2*c){const t=u.add(p.sub(u)._mult(c/e)._round());this.updateDistance(u,t),this.addCurrentVertex(t,m,0,0,h),u=t;}}}}addCurrentVertex(e,t,i,r,n,o=!1){const s=t.y*r-t.x,a=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,n),this.addHalfVertex(e,s,a,o,!0,-r,n);}addHalfVertex({x:e,y:t},i,r,n,o,s,a){this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),o?this.e2=l:this.e1=l;}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance;}else this.lineSoFar=this.distance;}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance();}}Rs(Ey,"LineBucket",{omit:["layers","patternFeatures"]});class My{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r);}update(e,i,r){const{width:n,height:o}=e,{context:s}=this,{gl:a}=s,{HTMLImageElement:l,HTMLCanvasElement:c,HTMLVideoElement:h,ImageData:u,ImageBitmap:d}=t;if(a.bindTexture(a.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!i||!1!==i.premultiply)),r||this.size&&this.size[0]===n&&this.size[1]===o){const{x:t,y:i}=r||{x:0,y:0};if(e instanceof l||e instanceof c||e instanceof h||e instanceof u||d&&e instanceof d)a.texSubImage2D(a.TEXTURE_2D,0,t,i,a.RGBA,a.UNSIGNED_BYTE,e);else {let r=this.format,s=a.UNSIGNED_BYTE;this.format===a.R32F&&(r=a.RED,s=a.FLOAT),a.texSubImage2D(a.TEXTURE_2D,0,t,i,n,o,r,s,e.data);}}else if(this.size=[n,o],e instanceof l||e instanceof c||e instanceof h||e instanceof u||d&&e instanceof d){let t=this.format;this.format===a.R8&&(t=a.RED),a.texImage2D(a.TEXTURE_2D,0,this.format,t,a.UNSIGNED_BYTE,e);}else {let t=this.format,i=this.format,r=a.UNSIGNED_BYTE;this.format===a.DEPTH_COMPONENT&&(t=a.DEPTH_COMPONENT16,r=a.UNSIGNED_SHORT),this.format===a.R32F&&(r=a.FLOAT,i=a.RED),a.texImage2D(a.TEXTURE_2D,0,t,n,o,0,i,r,e.data);}this.useMipmap=Boolean(i&&i.useMipmap),this.useMipmap&&a.generateMipmap(a.TEXTURE_2D);}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap?e===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_NEAREST:e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t);}bindExtraParam(e,t,i,r){const{context:n}=this,{gl:o}=n;o.bindTexture(o.TEXTURE_2D,this.texture),t!==this.magFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,this.useMipmap?e===o.NEAREST?o.NEAREST_MIPMAP_NEAREST:o.LINEAR_MIPMAP_NEAREST:e),this.minFilter=e),i!==this.wrapS&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),this.wrapS=i),r!==this.wrapT&&(o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,r),this.wrapT=r);}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null;}}class Ay{constructor(e,t){this.context=e,this.texture=t;}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrapS=t);}}const Sy=32,Iy=33,Cy=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,r=0,n=0,o=0,s=0,a=0;for(1&t?n=o=s=Sy:i=r=a=Sy;(t>>=1)>1;){const e=i+n>>1,l=r+o>>1;1&t?(n=i,o=r,i=s,r=a):(i=n,r=o,n=s,o=a),s=e,a=l;}const l=4*e;Cy[l+0]=i,Cy[l+1]=r,Cy[l+2]=n,Cy[l+3]=o;}const zy=new Uint16Array(2178),Py=new Uint8Array(1089),Dy=new Uint16Array(1089);function Ry(e){return 0===e?-.03125:32===e?.03125:0}var Ly=Ia([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const ky={type:2,extent:cr,loadGeometry:()=>[[new y(0,0),new y(cr+1,0),new y(cr+1,cr+1),new y(0,cr+1),new y(0,0)]]};class Oy{constructor(e,t,i,r,n){this.tileID=e,this.uid=F(),this.uses=0,this.tileSize=t,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection);}registerFadeDuration(e){const t=e+this.timeAdded;t<dt.now()||this.fadeEndTime&&t<this.fadeEndTime||(this.fadeEndTime=t);}wasRequested(){return "errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=Pg(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,t,i){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const i={};if(!t)return i;for(const r of e){const e=r.layerIds.map((e=>t.getLayer(e))).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((t=>e.filter((e=>e.id===t))[0])));for(const t of e)i[t.fqid]=r;}}return i}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof gy){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof gy&&t.hasRTLText){this.hasRTLText=!0,na.isLoading()||na.isLoaded()||"deferred"!==ia()||ra();break}}this.queryPadding=0;for(const e in this.buckets){const i=this.buckets[e],r=t.style.getOwnLayer(e);if(!r)continue;const n=r.queryRadius(i);this.queryPadding=Math.max(this.queryPadding,n);}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas),this._lastUpdatedBrightness=e.brightness;}else this.collisionBoxArray=new al;}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded";}}getBucket(e){return this.buckets[e.fqid]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e);}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new My(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new My(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new My(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0);}prepare(e,t,i){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture,i),!t||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const r=t.style.getBrightness();(this._lastUpdatedBrightness||r)&&(this._lastUpdatedBrightness&&r&&Math.abs(this._lastUpdatedBrightness-r)<.001||(this._lastUpdatedBrightness=r,this.updateBuckets(void 0,t)));}queryRenderedFeatures(e,t,i,r,n,o,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:s,transform:o,params:n,tileTransform:this.tileTransform},e,t,i):{}}querySourceFeatures(e,t){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=t?t.sourceLayer:"",o=r._geojsonTileLayer||r[n];if(!o)return;const s=Fo(t&&t.filter),{z:a,x:l,y:c}=this.tileID.canonical,h={z:a,x:l,y:c};for(let t=0;t<o.length;t++){const r=o.feature(t);if(s.needGeometry){const e=gp(r,!0);if(!s.filter(new oa(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!s.filter(new oa(this.tileID.overscaledZ),r))continue;const u=i.getId(r,n),d=new Bm(r,a,l,c,u);d.tile=h,e.push(d);}}hasData(){return "loaded"===this.state||"reloading"===this.state||"expired"===this.state}bucketsLoaded(){for(const e in this.buckets)if(this.buckets[e].uploadPending())return !1;return !0}patternsLoaded(){return !!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const t=this.expirationTime;if(e.cacheControl){const t=ee(e.cacheControl);t["max-age"]&&(this.expirationTime=Date.now()+1e3*t["max-age"]);}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const e=Date.now();let i=!1;if(this.expirationTime>e)i=!1;else if(t)if(this.expirationTime<t)i=!0;else {const r=this.expirationTime-t;r?this.expirationTime=e+Math.max(r,3e4):i=!0;}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0;}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(e,t){this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData&&0!==Object.keys(e).length&&t&&this.updateBuckets(e,t);}updateBuckets(e,t){if(!this.latestFeatureIndex)return;const i=this.latestFeatureIndex.loadVTLayers(),r=t.style.listImages(),n=t.style.getBrightness();for(const o in this.buckets){if(!t.style.hasLayer(o))continue;const s=this.buckets[o],a=s.layers[0].sourceLayer||"_geojsonTileLayer",l=i[a];let c={};if(e&&(c=e[a],!l||!c||0===Object.keys(c).length))continue;if(s.update(c,l,r,this.imageAtlas&&this.imageAtlas.patternPositions||{},n),s instanceof Ey||s instanceof jf){const e=t.style.getOwnSourceCache(s.layers[0].source);t._terrain&&t._terrain.enabled&&e&&s.programConfigurations.needsUpload&&t._terrain._clearRenderCacheForTile(e.id,this.tileID);}const h=t&&t.style&&t.style.getOwnLayer(o);h&&(this.queryPadding=Math.max(this.queryPadding,h.queryRadius(s)));}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return !this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<dt.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0;}setHoldDuration(e){this.symbolFadeHoldUntil=dt.now()+e;}setTexture(e,t){const i=t.context,r=i.gl;this.texture=this.texture||t.getTileTexture(e.width),this.texture&&this.texture instanceof My?this.texture.update(e,{useMipmap:!0}):(this.texture=new My(i,e,r.RGBA,{useMipmap:!0}),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE));}setDependencies(e,t){const i={};for(const e of t)i[e]=!0;this.dependencies[e]=i;}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const i of t)if(e[i])return !0}return !1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,t){if(!t||"mercator"===t.name||this._tileDebugBuffer)return;const i=_p(ky,this.tileID.canonical,this.tileTransform)[0],r=new za,n=new el;for(let e=0;e<i.length;e++){const{x:t,y:o}=i[e];r.emplaceBack(t,o),n.emplaceBack(e);}n.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(n),this._tileDebugBuffer=e.createVertexBuffer(r,Nu.members),this._tileDebugSegments=xl.simpleSegment(0,0,r.length,n.length);}_makeTileBoundsBuffers(e,t){if(this._tileBoundsBuffer||!t||"mercator"===t.name)return;const i=_p(ky,this.tileID.canonical,this.tileTransform)[0];let r,n;if(this.isRaster){const e=function(e,t){const i=Pg(e,t),r=Math.pow(2,e.z);for(let n=0;n<Iy;n++)for(let o=0;o<Iy;o++){const s=ep((e.x+(o+Ry(o))/Sy)/r),a=tp((e.y+(n+Ry(n))/Sy)/r),l=t.project(s,a),c=n*Iy+o;zy[2*c+0]=Math.round((l.x*i.scale-i.x)*cr),zy[2*c+1]=Math.round((l.y*i.scale-i.y)*cr);}Py.fill(0),Dy.fill(0);for(let e=2045;e>=0;e--){const t=4*e,i=Cy[t+0],r=Cy[t+1],n=Cy[t+2],o=Cy[t+3],s=i+n>>1,a=r+o>>1,l=s+a-r,c=a+i-s,h=r*Iy+i,u=o*Iy+n,d=a*Iy+s,p=Math.hypot((zy[2*h+0]+zy[2*u+0])/2-zy[2*d+0],(zy[2*h+1]+zy[2*u+1])/2-zy[2*d+1])>=16;Py[d]=Py[d]||(p?1:0),e<1022&&(Py[d]=Py[d]||Py[(r+c>>1)*Iy+(i+l>>1)]||Py[(o+c>>1)*Iy+(n+l>>1)]);}const n=new Da,o=new Wa;let s=0;function a(e,t){const i=t*Iy+e;return 0===Dy[i]&&(n.emplaceBack(zy[2*i+0],zy[2*i+1],e*cr/Sy,t*cr/Sy),Dy[i]=++s),Dy[i]-1}function l(e,t,i,r,n,s){const c=e+i>>1,h=t+r>>1;if(Math.abs(e-n)+Math.abs(t-s)>1&&Py[h*Iy+c])l(n,s,e,t,c,h),l(i,r,n,s,c,h);else {const l=a(e,t),c=a(i,r),h=a(n,s);o.emplaceBack(l,c,h);}}return l(0,0,Sy,Sy,Sy,0),l(Sy,Sy,0,0,0,Sy),{vertices:n,indices:o}}(this.tileID.canonical,t);r=e.vertices,n=e.indices;}else {r=new Da,n=new Wa;for(const{x:e,y:t}of i)r.emplaceBack(e,t,0,0);const e=Bf(r.int16,void 0,4);for(let t=0;t<e.length;t+=3)n.emplaceBack(e[t],e[t+1],e[t+2]);}this._tileBoundsBuffer=e.createVertexBuffer(r,Ly.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(n),this._tileBoundsSegments=xl.simpleSegment(0,0,r.length,n.length);}_makeGlobeTileDebugBuffers(e,t){const i=t.projection;if(!i||"globe"!==i.name||t.freezeTileCoverage)return;const r=this.tileID.canonical,n=Ad(_d(r,t)),o=Dd(t.zoom);let s;o>0&&(s=Au.invert(new Float64Array(16),t.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,t,n,s,o),this._makeGlobeTileDebugTextBuffer(e,r,t,n,s,o);}_globePoint(e,t,i,r,n,o,s){let a=Td(e,t,i);if(o){const n=1<<i.z,l=Kd(r.center.lng),c=Jd(r.center.lat),h=(i.x+.5)/n-l;let u=0;h>.5?u=-1:h<-.5&&(u=1);let d=(e/cr+i.x)/n+u,p=(t/cr+i.y)/n;d=(d-l)*r._pixelsPerMercatorPixel+l,p=(p-c)*r._pixelsPerMercatorPixel+c;const f=[d*r.worldSize,p*r.worldSize,0];Du.transformMat4(f,f,o),a=md(a,f,s);}return Du.transformMat4(a,a,n)}_makeGlobeTileDebugBorderBuffer(e,t,i,r,n,o){const s=new za,a=new el,l=new Pa,c=(e,c,h,u,d)=>{const p=(h-e)/(d-1),f=(u-c)/(d-1),m=s.length;for(let h=0;h<d;h++){const u=e+h*p,d=c+h*f;s.emplaceBack(u,d);const _=this._globePoint(u,d,t,i,r,n,o);l.emplaceBack(_[0],_[1],_[2]),a.emplaceBack(m+h);}},h=cr;c(0,0,h,0,16),c(h,0,h,h,16),c(h,h,0,h,16),c(0,h,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(a),this._tileDebugBuffer=e.createVertexBuffer(s,Nu.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(l,Fu.members),this._tileDebugSegments=xl.simpleSegment(0,0,s.length,a.length);}_makeGlobeTileDebugTextBuffer(e,t,i,r,n,o){const s=cr/4,a=new za,l=new Wa,c=new Pa,h=25;l.reserve(32),a.reserve(h),c.reserve(h);const u=(e,t)=>h*e+t;for(let e=0;e<h;e++){const l=e*s;for(let e=0;e<h;e++){const h=e*s;a.emplaceBack(h,l);const u=this._globePoint(h,l,t,i,r,n,o);c.emplaceBack(u[0],u[1],u[2]);}}for(let e=0;e<4;e++)for(let t=0;t<4;t++){const i=u(e,t),r=u(e,t+1),n=u(e+1,t),o=u(e+1,t+1);l.emplaceBack(i,r,n),l.emplaceBack(n,r,o);}this._tileDebugTextIndexBuffer=e.createIndexBuffer(l),this._tileDebugTextBuffer=e.createVertexBuffer(a,Nu.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(c,Fu.members),this._tileDebugTextSegments=xl.simpleSegment(0,0,h,32);}destroy(e=!1){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&(this.imageAtlasTexture.destroy(),delete this.imageAtlasTexture),this.glyphAtlasTexture&&(this.glyphAtlasTexture.destroy(),delete this.glyphAtlasTexture),this.lineAtlasTexture&&(this.lineAtlasTexture.destroy(),delete this.lineAtlasTexture),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),!e&&this.texture&&this.texture instanceof My&&(this.texture.destroy(),delete this.texture),this.hillshadeFBO&&(this.hillshadeFBO.destroy(),delete this.hillshadeFBO),this.dem&&delete this.dem,this.neighboringTiles&&delete this.neighboringTiles,this.demTexture&&(this.demTexture.destroy(),delete this.demTexture),this.latestFeatureIndex=null,this.state="unloaded";}}class By{constructor(e,t){this.max=e,this.onRemove=t,this.reset();}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(e,n);}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e);}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e);}}class Fy{constructor(e,t,i,r){this.id=Fy.uniqueIdxCounter,Fy.uniqueIdxCounter++,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||r||t.destroy();}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(e){this.id=Fy.uniqueIdxCounter,Fy.uniqueIdxCounter++;const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}Fy.uniqueIdxCounter=0;const Ny={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Uy{constructor(e,t,i,r,n,o){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.instanceCount=o,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||n||t.destroy();}bind(){this.context.bindVertexBuffer.set(this.buffer);}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer);}enableAttributes(e,t){for(let i=0;i<this.attributes.length;i++){const r=t.attributes[this.attributes[i].name];void 0!==r&&e.enableVertexAttribArray(r);}}setVertexAttribPointers(e,t,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],o=t.attributes[n.name];void 0!==o&&e.vertexAttribPointer(o,n.components,e[Ny[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0));}}setVertexAttribDivisor(e,t,i){for(let r=0;r<this.attributes.length;r++){const n=t.attributes[this.attributes[r].name];void 0!==n&&this.instanceCount&&this.instanceCount>0&&e.vertexAttribDivisor(n,i);}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}class Vy{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1;}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default);}}class jy extends Vy{getDefault(){return hi.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class Gy extends Vy{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1);}}class qy extends Vy{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1);}}class Zy extends Vy{getDefault(){return [!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class $y extends Vy{getDefault(){return !0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1);}}class Wy extends Vy{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1);}}class Hy extends Vy{getDefault(){return {func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1);}}class Xy extends Vy{getDefault(){const e=this.gl;return [e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1);}}class Yy extends Vy{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1;}}class Ky extends Vy{getDefault(){return [0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1);}}class Jy extends Vy{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1;}}class Qy extends Vy{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1);}}class ex extends Vy{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1;}}class tx extends Vy{getDefault(){const e=this.gl;return [e.ONE,e.ZERO,e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.blendFuncSeparate(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class ix extends Vy{getDefault(){return hi.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class rx extends Vy{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquationSeparate(e,e),this.current=e,this.dirty=!1);}}class nx extends Vy{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1;}}class ox extends Vy{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1);}}class sx extends Vy{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1);}}let ax=class extends Vy{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1);}};class lx extends Vy{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1);}}class cx extends Vy{getDefault(){const e=this.gl;return [0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1);}}class hx extends Vy{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1;}}class ux extends Vy{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class dx extends Vy{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1;}}class px extends Vy{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class fx extends Vy{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class mx extends Vy{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1);}}class _x extends Vy{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1;}}class gx extends Vy{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1;}}class yx extends Vy{getDefault(){return !1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1;}}class xx extends Vy{constructor(e,t){super(e),this.context=e,this.parent=t;}getDefault(){return null}}class vx extends xx{setDirty(){this.dirty=!0;}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class bx extends xx{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1;}}class wx extends xx{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,this.attachment(),t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1;}}class Tx extends bx{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class Ex{constructor(e,t,i,r,n){this.context=e,this.width=t,this.height=i;const o=this.framebuffer=e.gl.createFramebuffer();r&&(this.colorAttachment=new vx(e,o)),n&&(this.depthAttachmentType=n,this.depthAttachment="renderbuffer"===n?new bx(e,o):new wx(e,o));}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.get();t&&e.deleteTexture(t);}if(this.depthAttachment&&this.depthAttachmentType)if("renderbuffer"===this.depthAttachmentType){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t);}else {const t=this.depthAttachment.get();t&&e.deleteTexture(t);}e.deleteFramebuffer(this.framebuffer);}}class Mx{constructor(e,t,i){this.func=e,this.mask=t,this.range=i;}}Mx.ReadOnly=!1,Mx.ReadWrite=!0,Mx.disabled=new Mx(519,Mx.ReadOnly,[0,1]);const Ax=7680;class Sx{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o;}}Sx.disabled=new Sx({func:519,mask:0},0,0,Ax,Ax,Ax);const Ix=771;class Cx{constructor(e,t,i,r){this.blendFunction=e,this.blendColor=t,this.mask=i,this.blendEquation=r;}}Cx.Replace=[1,0,1,0],Cx.disabled=new Cx(Cx.Replace,hi.transparent,[!1,!1,!1,!1]),Cx.unblended=new Cx(Cx.Replace,hi.transparent,[!0,!0,!0,!0]),Cx.alphaBlended=new Cx([1,Ix,1,Ix],hi.transparent,[!0,!0,!0,!0]),Cx.multiply=new Cx([774,0,774,0],hi.transparent,[!0,!0,!0,!0]);const zx=1029,Px=2305;class Dx{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i;}}Dx.disabled=new Dx(!1,zx,Px),Dx.backCCW=new Dx(!0,zx,Px),Dx.backCW=new Dx(!0,zx,2304),Dx.frontCW=new Dx(!0,1028,2304),Dx.frontCCW=new Dx(!0,1028,Px);class Rx{constructor(e,t){this.gl=e,this.clearColor=new jy(this),this.clearDepth=new Gy(this),this.clearStencil=new qy(this),this.colorMask=new Zy(this),this.depthMask=new $y(this),this.stencilMask=new Wy(this),this.stencilFunc=new Hy(this),this.stencilOp=new Xy(this),this.stencilTest=new Yy(this),this.depthRange=new Ky(this),this.depthTest=new Jy(this),this.depthFunc=new Qy(this),this.blend=new ex(this),this.blendFunc=new tx(this),this.blendColor=new ix(this),this.blendEquation=new rx(this),this.cullFace=new nx(this),this.cullFaceSide=new ox(this),this.frontFace=new sx(this),this.program=new ax(this),this.activeTexture=new lx(this),this.viewport=new cx(this),this.bindFramebuffer=new hx(this),this.bindRenderbuffer=new ux(this),this.bindTexture=new dx(this),this.bindVertexBuffer=new px(this),this.bindElementBuffer=new fx(this),this.bindVertexArrayOES=new mx(this),this.pixelStoreUnpack=new _x(this),this.pixelStoreUnpackPremultiplyAlpha=new gx(this),this.pixelStoreUnpackFlipY=new yx(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE);}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault();}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArrayOES.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0;}createIndexBuffer(e,t,i){return new Fy(this,e,t,i)}createVertexBuffer(e,t,i,r,n){return new Uy(this,e,t,i,r,n)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i,r){return new Ex(this,e,t,i,r)}clear({color:e,depth:t,stencil:i,colorMask:r}){const n=this.gl;let o=0;e&&(o|=n.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(r||[!0,!0,!0,!0])),void 0!==t&&(o|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(o|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),n.clear(o);}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace));}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1);}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1);}setColorMode(e){x(e.blendFunction,Cx.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor),e.blendEquation?this.blendEquation.set(e.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(e.mask);}unbindVAO(){this.bindVertexArrayOES.set(null);}}class Lx extends zt{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,t.on("data",(e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform));})),t.on("error",(()=>{this._sourceErrored=!0;})),this._source=t,this._tiles={},this._cache=new By(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Fm,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType;}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize;}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;for(const e in this._tiles){const t=this._tiles[e];if("errored"!==t.state&&("loaded"!==t.state||!t.bucketsLoaded()))return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform);}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,e.isExtraShadowCaster=this._shadowCasterTiles[e.tileID.key],this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,(()=>{}))}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,(()=>{}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope);}}getIds(){return L(this._tiles).map((e=>e.tileID)).sort(kx).map((e=>e.key))}getRenderableIds(e,t){const i=[];for(const r in this._tiles)this._isIdRenderable(+r,e,t)&&i.push(this._tiles[r]);return e?i.sort(((e,t)=>{const i=e.tileID,r=t.tileID,n=new y(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new y(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||o.y-n.y||o.x-n.x})).map((e=>e.tileID.key)):i.map((e=>e.tileID)).sort(kx).map((e=>e.key))}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return !!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())&&(i||!this._shadowCasterTiles[e])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading");}}_reloadTile(e,t){const i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)));}_tileLoaded(e,t,i,r){if(r)if(e.state="errored",404!==r.status)this._source.fire(new Ct(r,{tile:e}));else {if(!(e.tileID.key in this._loadedParentTiles))return void this._source.fire(new It("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id}));if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id);}else this.update(this.transform);}else e.timeAdded=dt.now(),"expired"===i&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new It("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}));}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r<t.length;r++){const n=t[r];if(e.neighboringTiles&&e.neighboringTiles[n]){const t=this.getTileByID(n);i(e,t),i(t,e);}}function i(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x;const r=t.tileID.canonical.y-e.tileID.canonical.y,n=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)));}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(s=e);}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){r[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const i=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,n=Math.floor(i*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s);}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r;}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e]);}}update(e,t,i,r){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let n;if(this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new qu(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(n=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(n=n.filter((e=>this._source.hasTile(e))))):n=[],n.length>0&&this.castsShadows&&r&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!Ox(this._source.type)){const o=e.coveringZoomLevel({tileSize:t||this._source.tileSize,roundZoom:this._source.roundZoom&&!i}),s=Math.min(o,this._source.maxzoom),a=e.extendTileCoverForShadows(n,r,s);for(const e of a)this._shadowCasterTiles[e.key]=!0,n.push(e);}const o=this._updateRetainedTiles(n);if(Ox(this._source.type)&&0!==n.length){const e={},t={},i=Object.keys(o);for(const r of i){const i=o[r],n=this._tiles[r];if(!n||n.fadeEndTime&&n.fadeEndTime<=dt.now())continue;const s=this.findLoadedParent(i,Math.max(i.overscaledZ-Lx.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),e[s.tileID.key]=s.tileID),t[r]=i;}const r=n[n.length-1].overscaledZ;for(const e in this._tiles){const i=this._tiles[e];if(o[e]||!i.hasData())continue;let n=i.tileID;for(;n.overscaledZ>r;){n=n.scaledTo(n.overscaledZ-1);const r=this._tiles[n.key];if(r&&r.hasData()&&t[n.key]){o[e]=i.tileID;break}}}for(const t in e)o[t]||(this._coveredTiles[t]=!0,o[t]=e[t]);}for(const e in o)this._tiles[e].clearFadeHold();const s=function(e,t){const i=[];for(const r in e)r in t||i.push(r);return i}(this._tiles,o);for(const e of s){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e);}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate();}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e);}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const i={},r=e.reduce(((e,t)=>Math.min(e,t.overscaledZ)),1/0),n=e[0].overscaledZ,o=Math.max(n-Lx.maxOverzooming,this._source.minzoom),s=Math.max(n+Lx.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||r<this._source.maxzoom&&(a[i.key]=i);}this._retainLoadedChildren(a,r,s,t);for(const r of e){let e=this._tiles[r.key];if(e.hasData())continue;if(r.canonical.z>=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else {const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let s=r.overscaledZ-1;s>=o;--s){const o=r.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=e;}for(const e of t)this._loadedParentTiles[e]=i;}}_addTile(e){let t=this._tiles[e.key];if(t)return !0!==t.isExtraShadowCaster||!!this._shadowCasterTiles[e.key]||this._reloadTile(e.key,"reloading"),t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const i=Boolean(t);if(!i){const i=this.map?this.map.painter:null;t=new Oy(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,i,this._isRaster),this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state));}return t?(t.uses++,this._tiles[e.key]=t,i||this._source.fire(new It("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout((()=>{this._reloadTile(e,"expired"),delete this._timers[e];}),i));}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))));}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id);}tilesIn(e,t,i){const r=[],n=this.transform;if(!n)return r;const o="globe"===n.projection.name,s=Kd(n.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(z(s,...Bx(e,-1))-s),Math.abs(z(s,...Bx(e,1))-s)];c=[0,2*t.indexOf(Math.min(...t))-1];}else {const t=[Math.abs(z(s,...Bx(e,-1))-s),Math.abs(z(s,...Bx(e,0))-s),Math.abs(z(s,...Bx(e,1))-s)];c=[t.indexOf(Math.min(...t))-1];}}else c=[0];for(const i of c){const o=e.containsTile(l,n,t,i);o&&r.push(o);}}return r}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const i=this.getRenderableIds(e,t).map((e=>this._tiles[e].tileID)),r="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=r?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,r=this.transform._camera.forward(),n={};for(const e of t){const t=1/(1<<e.canonical.z);n[e.key]=((e.canonical.x+.5)*t+e.wrap-i[0])*r[0]+((e.canonical.y+.5)*t-i[1])*r[1]-i[2]*r[2];}return t.sort(((e,t)=>n[e.key]-n[t.key])),t}hasTransition(){if(this._source.hasTransition())return !0;if(Ox(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=dt.now())return !0}return !1}setFeatureState(e,t,i){this._state.updateState(e=e||"_geojsonTileLayer",t,i);}removeFeatureState(e,t,i){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,i);}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i);}reloadTilesForDependencies(e,t){for(const i in this._tiles)this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(e,t)));}_preloadTiles(e,t){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(e,t));};return void this._source.on("data",i)}const i=new Map,r=Array.isArray(e)?e:[e],n=this.map.painter.terrain,o=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)i.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1);}R(Array.from(i.values()),((e,t)=>{const i=new Oy(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i);}));}),t);}}function kx(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Ox(e){return "raster"===e||"image"===e||"video"===e||"custom"===e}function Bx(e,t){const i=1<<e.z;return [e.x/i+t,(e.x+1)/i+t]}Lx.maxOverzooming=10,Lx.maxUnderzooming=3;const Fx=Ia([{name:"a_pos_3f",components:3,type:"Float32"}]),Nx=Ia([{name:"a_color_3f",components:3,type:"Float32"}]),Ux=Ia([{name:"a_color_4f",components:4,type:"Float32"}]),Vx=Ia([{name:"a_uv_2f",components:2,type:"Float32"}]),jx=Ia([{name:"a_normal_3f",components:3,type:"Float32"}]),Gx=Ia([{name:"a_normal_matrix0",components:4,type:"Float32"},{name:"a_normal_matrix1",components:4,type:"Float32"},{name:"a_normal_matrix2",components:4,type:"Float32"},{name:"a_normal_matrix3",components:4,type:"Float32"}]),qx=Ia([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);class Zx{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r;}interpolate(e,t,i){return null!=t.top&&null!=e.top&&(this.top=Kr(e.top,t.top,i)),null!=t.bottom&&null!=e.bottom&&(this.bottom=Kr(e.bottom,t.bottom,i)),null!=t.left&&null!=e.left&&(this.left=Kr(e.left,t.left,i)),null!=t.right&&null!=e.right&&(this.right=Kr(e.right,t.right,i)),this}getCenter(e,t){const i=z((this.left+e-this.right)/2,0,e),r=z((this.top+t-this.bottom)/2,0,t);return new y(i,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Zx(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function $x(e,t){const i=ne(e,3);Au.fromQuat(e,t),oe(e,3,i);}function Wx(e,t){const i=Iu.identity([]);return Iu.rotateZ(i,i,-t),Iu.rotateX(i,i,-e),i}function Hx(e,t){const i=[e[0],e[1],0],r=[t[0],t[1],0];if(Du.length(i)>=1e-15){const e=Du.normalize([],i);Du.scale(r,e,Du.dot(r,e)),t[0]=r[0],t[1]=r[1];}const n=Du.cross([],t,e);if(Du.len(n)<1e-15)return null;const o=Math.atan2(-n[1],n[0]);return Wx(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),o)}class Xx{constructor(e,t){this.position=e,this.orientation=t;}get position(){return this._position}set position(e){if(e){const t=e instanceof lp?e:new lp(e[0],e[1],e[2]);this._renderWorldCopies&&(t.x=D(t.x,0,1)),this._position=t;}else this._position=null;}lookAtPoint(e,t){if(this.orientation=null,!this.position)return;const i=this.position,r=this._elevation?this._elevation.getAtPointOrZero(lp.fromLngLat(e)):0,n=lp.fromLngLat(e,r),o=[n.x-i.x,n.y-i.y,n.z-i.z];t||(t=[0,0,1]),t[2]=Math.abs(t[2]),this.orientation=Hx(o,t);}setPitchBearing(e,t){this.orientation=Wx(w(e),w(-t));}}class Yx{constructor(e,t){this._transform=Au.identity([]),this.orientation=t,this.position=e;}get mercatorPosition(){const e=this.position;return new lp(e[0],e[1],e[2])}get position(){const e=ne(this._transform,3);return [e[0],e[1],e[2]]}set position(e){var t;e&&oe(this._transform,3,[(t=e)[0],t[1],t[2],1]);}get orientation(){return this._orientation}set orientation(e){this._orientation=e||Iu.identity([]),e&&$x(this._transform,this._orientation);}getPitchBearing(){const e=this.forward(),t=this.right();return {bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Wx(e,t),$x(this._transform,this._orientation);}forward(){const e=ne(this._transform,2);return [-e[0],-e[1],-e[2]]}up(){const e=ne(this._transform,1);return [-e[0],-e[1],-e[2]]}right(){const e=ne(this._transform,0);return [e[0],e[1],e[2]]}getCameraToWorld(e,t){const i=new Float64Array(16);return Au.invert(i,this.getWorldToCamera(e,t)),i}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(e,t,i){const r=this.position;Du.scale(r,r,-e);const n=new Float64Array(16);return Au.fromScaling(n,[i,i,i]),Au.translate(n,n,r),n[10]*=t,n}getWorldToCamera(e,t){const i=new Float64Array(16),r=new Float64Array(4),n=this.position;return Iu.conjugate(r,this._orientation),Du.scale(n,n,-e),Au.fromQuat(i,r),Au.translate(i,i,n),i[1]*=-1,i[5]*=-1,i[9]*=-1,i[13]*=-1,i[8]*=t,i[9]*=t,i[10]*=t,i[11]*=t,i}getCameraToClipPerspective(e,t,i,r){const n=new Float64Array(16);return Au.perspective(n,e,t,i,r),n}getCameraToClipOrthographic(e,t,i,r,n,o){const s=new Float64Array(16);return Au.ortho(s,e,t,i,r,n,o),s}getDistanceToElevation(e,t=!1){const i=0===e?0:Qd(e,t?tp(this.position[1]):this.position[1]),r=this.forward();return (i-this.position[2])/r[2]}clone(){return new Yx([...this.position],[...this.orientation])}}function Kx(e,t){const i=Qx(e.projection,e.zoom,e.width,e.height),r=function(e,t,i,r,n){const o=new Wd(i.lng-180*ev,i.lat),s=new Wd(i.lng+180*ev,i.lat),a=e.project(o.lng,o.lat),l=e.project(s.lng,s.lat),c=-Math.atan2(l.y-a.y,l.x-a.x),h=lp.fromLngLat(i);h.y=z(h.y,-1+ev,1-ev);const u=h.toLngLat(),d=e.project(u.lng,u.lat),p=lp.fromLngLat(u);p.x+=ev;const f=p.toLngLat(),m=e.project(f.lng,f.lat),_=iv(m.x-d.x,m.y-d.y,c),g=lp.fromLngLat(u);g.y+=ev;const y=g.toLngLat(),x=e.project(y.lng,y.lat),v=iv(x.x-d.x,x.y-d.y,c),b=Math.abs(_.x)/Math.abs(v.y),w=Au.identity([]);Au.rotateZ(w,w,-c*(1-(n?0:r)));const T=Au.identity([]);return Au.scale(T,T,[1,1-(1-b)*r,1]),T[4]=-v.x/v.y*r,Au.rotateZ(T,T,c),Au.multiply(T,w,T),T}(e.projection,0,e.center,i,t),n=Jx(e);return Au.scale(r,r,[n,n,1]),r}function Jx(e){const t=e.projection,i=Qx(e.projection,e.zoom,e.width,e.height),r=tv(t,e.center),n=tv(t,Wd.convert(t.center));return Math.pow(2,r*i+(1-i)*n)}function Qx(e,t,i,r,n=1/0){const o=e.range;if(!o)return 0;const s=Math.min(n,Math.max(i,r)),a=Math.log(s/1024)/Math.LN2;return P(o[0]+a,o[1]+a,t)}const ev=1/4e4;function tv(e,t){const i=z(t.lat,-rp,rp),r=new Wd(t.lng-180*ev,i),n=new Wd(t.lng+180*ev,i),o=e.project(r.lng,i),s=e.project(n.lng,i),a=lp.fromLngLat(r),l=lp.fromLngLat(n),c=s.x-o.x,h=s.y-o.y,u=l.x-a.x,d=l.y-a.y,p=Math.sqrt((u*u+d*d)/(c*c+h*h));return Math.log(p)/Math.LN2}function iv(e,t,i){const r=Math.cos(i),n=Math.sin(i);return {x:e*r-t*n,y:e*n+t*r}}function rv(e,t,i){return t*(cr/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}const nv={unknown:0,flipRequired:1,flipNotRequired:2},ov=Math.tan(85*Math.PI/180);function sv(e,t,i,r,n,o,s){const a=Au.create();if(i)if("globe"===o.name){const e=function(e,t){const{x:i,y:r}=e.point,n=zd(i,r,e.worldSize/e._pixelsPerMercatorPixel,0,0);return Au.multiply(n,n,Sd(fd(t)))}(n,t);Au.multiply(a,a,e);}else {const e=bu.invert([],s);a[0]=e[0],a[1]=e[1],a[4]=e[2],a[5]=e[3],r||Au.rotateZ(a,a,n.angle);}else Au.multiply(a,n.labelPlaneMatrix,e);return a}function av(e,t,i,r,n,o,s){const a=sv(e,t,i,r,n,o,s);return "globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function lv(e,t,i,r,n,o,s){if(i){if("globe"===o.name){const a=sv(e,t,i,r,n,o,s);return Au.invert(a,a),Au.multiply(a,e,a),a}{const t=Au.clone(e),i=Au.identity([]);return i[0]=s[0],i[1]=s[1],i[4]=s[2],i[5]=s[3],Au.multiply(t,t,i),r||Au.rotateZ(t,t,-n.angle),t}}return n.glCoordMatrix}function cv(e,t,i,r){const n=[e,t,i,1];i?yu.transformMat4(n,n,r):vv(n,n,r);const o=n[3];return n[0]/=o,n[1]/=o,n[2]/=o,n}function hv(e,t){return Math.min(.5+e/t*.5,1.5)}function uv(e,t){const i=e[0]/e[3],r=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&r>=-t[1]&&r<=t[1]}function dv(e,t,i,r,n,o,s,a,l,c){const h=i.transform,u=r?e.textSizeData:e.iconSizeData,d=m_(u,i.transform.zoom),p="globe"===h.projection.name,f=[256/i.width*2+1,256/i.height*2+1],m=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;m.clear();let _=null;p&&(_=r?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const g=e.lineVertexArray,x=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let b,w=!1;for(let r=0;r<x.length;r++){const p=x.get(r),{numGlyphs:T,writingMode:E}=p;if(E!==A_.vertical||w||b===A_.horizontal||(w=!0),b=E,(p.hidden||E===A_.vertical)&&!w){xv(T,m);continue}w=!1;const M=new y(p.tileAnchorX,p.tileAnchorY);let{x:A,y:S,z:I}=h.projection.projectTilePoint(M.x,M.y,c.canonical);if(l){const[e,t,i]=l(M);A+=e,S+=t,I+=i;}const C=[A,S,I,1];if(yu.transformMat4(C,C,t),!uv(C,f)){xv(T,m);continue}const z=C[3],P=hv(i.transform.getCameraToCenterDistance(h.projection),z),D=f_(u,d,p),R=s?D/P:D*P,L=cv(A,S,I,n);if(L[3]<=0){xv(T,m);continue}let k={};const O=s?null:l,B=mv(p,R,!1,a,t,n,o,e.glyphOffsetArray,g,m,_,L,M,k,v,O,h.projection,c,s);w=B.useVertical,O&&B.needsFlipping&&(k={}),(B.notEnoughRoom||w||B.needsFlipping&&mv(p,R,!0,a,t,n,o,e.glyphOffsetArray,g,m,_,L,M,k,v,O,h.projection,c,s).notEnoughRoom)&&xv(T,m);}r?(e.text.dynamicLayoutVertexBuffer.updateData(m),_&&e.text.globeExtVertexBuffer&&e.text.globeExtVertexBuffer.updateData(_)):(e.icon.dynamicLayoutVertexBuffer.updateData(m),_&&e.icon.globeExtVertexBuffer&&e.icon.globeExtVertexBuffer.updateData(_));}function pv(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const{lineStartIndex:_,glyphStartIndex:g,segment:y}=a,x=g+a.numGlyphs,v=_+a.lineLength,b=t.getoffsetX(g),w=t.getoffsetX(x-1),T=yv(e*b,i,r,n,o,s,y,_,v,l,c,h,u,d,!0,p,f,m);if(!T)return null;const E=yv(e*w,i,r,n,o,s,y,_,v,l,c,h,u,d,!0,p,f,m);return E?{first:T,last:E}:null}function fv(e,t,i,r){return e===A_.horizontal&&Math.abs(r)>Math.abs(i)?{useVertical:!0}:e===A_.vertical?r>0?{needsFlipping:!0}:null:t!==nv.unknown&&function(e,t){return 0===e||Math.abs(t/e)>ov}(i,r)?t===nv.flipRequired?{needsFlipping:!0}:null:i<0?{needsFlipping:!0}:null}function mv(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,x){const v=t/24,b=e.lineOffsetX*v,w=e.lineOffsetY*v,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:M,segment:A,writingMode:S,flipState:I}=e,C=T+e.lineLength,z=e=>{if(h){const[t,i,r]=e.up,n=c.length;uy(h,n+0,t,i,r),uy(h,n+1,t,i,r),uy(h,n+2,t,i,r),uy(h,n+3,t,i,r);}const[t,i,r]=e.point;dy(c,t,i,r,e.angle);};if(M>1){const t=pv(v,a,b,w,i,u,d,e,l,o,p,m,!1,_,g,x);if(!t)return {notEnoughRoom:!0};if(r&&!i){let[i,r,n]=t.first.point,[o,a,l]=t.last.point;[i,r]=cv(i,r,n,s),[o,a]=cv(o,a,l,s);const c=fv(S,I,(o-i)*f,a-r);if(e.flipState=c&&c.needsFlipping?nv.flipRequired:nv.flipNotRequired,c)return c}z(t.first);for(let e=E+1;e<E+M-1;e++){const t=yv(v*a.getoffsetX(e),b,w,i,u,d,A,T,C,l,o,p,m,!1,!1,_,g,x);if(!t)return c.length-=4*(e-E),{notEnoughRoom:!0};z(t);}z(t.last);}else {if(r&&!i){const t=cv(d.x,d.y,0,n),i=T+A+1,r=new y(l.getx(i),l.gety(i)),o=cv(r.x,r.y,0,n),s=o[3]>0?o:gv(d,r,t,1,n,void 0,_,g.canonical),a=fv(S,I,(s[0]-t[0])*f,s[1]-t[1]);if(e.flipState=a&&a.needsFlipping?nv.flipRequired:nv.flipNotRequired,a)return a}const t=yv(v*a.getoffsetX(E),b,w,i,u,d,A,T,C,l,o,p,m,!1,!1,_,g,x);if(!t)return {notEnoughRoom:!0};z(t);}return {}}function _v(e,t,i,r,n){const{x:o,y:s,z:a}=r.projectTilePoint(e.x,e.y,t);if(!n)return cv(o,s,a,i);const[l,c,h]=n(e);return cv(o+l,s+c,a+h,i)}function gv(e,t,i,r,n,o,s,a){const l=_v(e.sub(t)._unit()._add(e),a,n,s,o);return Du.sub(l,i,l),Du.normalize(l,l),Du.scaleAndAdd(l,i,l,r)}function yv(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const x=r?e-t:e+t;let v=x>0?1:-1,b=0;r&&(v*=-1,b=Math.PI),v<0&&(b+=Math.PI);let w=a+s+(v>0?0:1)|0,T=n,E=n,M=0,A=0;const S=Math.abs(x),I=[],C=[];let z=o,P=z;const D=()=>gv(P,z,E,S-M+1,h,d,m,_.canonical);for(;M+A<=S;){if(w+=v,w<a||w>=l)return null;if(E=T,P=z,I.push(E),p&&C.push(P),z=new y(c.getx(w),c.gety(w)),T=u[w],!T){const e=_v(z,_.canonical,h,m,d);T=e[3]>0?u[w]=e:D();}M+=A,A=Du.distance(E,T);}f&&d&&(u[w]&&(T=D(),A=Du.distance(E,T)),u[w]=T);const R=(S-M)/A,L=z.sub(P)._mult(R)._add(P),k=Du.sub([],T,E),O=Du.scaleAndAdd([],E,k,R);let B=[0,0,1],F=k[0],N=k[1];if(g&&(B=m.upVector(_.canonical,L.x,L.y),0!==B[0]||0!==B[1]||1!==B[2])){const e=[B[2],0,-B[0]],t=Du.cross([],B,e);Du.normalize(e,e),Du.normalize(t,t),F=Du.dot(k,e),N=Du.dot(k,t);}if(i){const e=Du.cross([],B,k);Du.normalize(e,e),Du.scaleAndAdd(O,O,e,i*v);}const U=b+Math.atan2(N,F);return I.push(O),p&&C.push(L),{point:O,angle:U,path:I,tilePath:C,up:B}}function xv(e,t){const i=t.length,r=i+4*e;t.resize(r),t.float32.fill(-1/0,4*i,4*r);}function vv(e,t,i){const r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e[3]=i[3]*r+i[7]*n+i[15],e}const bv=(e,t,i)=>(1-i)*e+i*t,wv=e=>e*e*e*e*e;class Tv{constructor(e,t,i,r,n,o,s){this.tileSize=512,this._renderWorldCopies=void 0===n||n,this._minZoom=e||0,this._maxZoom=t||22,this._minPitch=null==i?0:i,this._maxPitch=null==r?60:r,this.setProjection(o),this.setMaxBounds(s),this.width=0,this.height=0,this._center=new Wd(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Zx,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Yx,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1;}clone(){const e=new Tv(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get isOrthographic(){return "globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices());}get depthOcclusionForSymbolsAndCircles(){return "globe"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(t),this._calcMatrices();}getProjection(){return O(this.projection,["name","center","parallels"])}setProjection(e){this.projectionOptions=e||{name:"mercator"};const t=this.projection?this.getProjection():void 0;this.projection=ty(this.projectionOptions);const i=!x(t,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=ty({name:"mercator"});const t=e!==this.projection.name;return t&&this._calcMatrices(),t}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e));}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e));}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e));}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e));}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return Qd(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new y(this.width,this.height)}get bearing(){return D(this.rotation,-180,180)}set bearing(e){this.rotation=e;}get rotation(){return -this.angle/Math.PI*180}set rotation(e){const t=-e*Math.PI/180;this.angle!==t&&(this._unmodified=!1,this.angle=t,this._calcMatrices(),this.rotationMatrix=bu.create(),bu.rotate(this.rotationMatrix,this.rotationMatrix,this.angle));}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const t=z(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==t&&(this._unmodified=!1,this._pitch=t,this._calcMatrices());}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=w(e),this._calcMatrices());}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={};}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices());}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom;}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom();}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize));}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,t=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],i=this.horizonLineFromTop();let r=0,n=0;for(let o=0;o<t.length;o++){const s=new y(t[o][0]*this.width,i+t[o][1]*(this.height-i)),a=e.pointCoordinate(s);if(!a)continue;const l=1/Math.hypot(a[0]-this._camera.position[0],a[1]-this._camera.position[1]);r+=a[3]*l,n+=l;}return 0===n?NaN:r/n}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices());}_updateZoomFromElevation(){if(null==this._seaLevelZoom||!this._elevation)return;const e=this._seaLevelZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*t,r=this._mercatorZfromZoom(e),n=this._mercatorZfromZoom(this._maxZoom),o=Math.max(r-i,n);this._setZoom(this._zoomFromMercatorZ(o));}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices());}computeZoomRelativeTo(e){const t=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,e.toAltitude()));let i;i=e.z<this._camera.position[2]?[t.x,t.y,t.z]:[e.x,e.y,e.z];const r=Du.length(Du.sub([],this._camera.position,i));return z(this._zoomFromMercatorZ(r),this._minZoom,this._maxZoom)}setFreeCameraOptions(e){if(!this.height)return;if(!e.position&&!e.orientation)return;this._updateCameraState();let t=!1;if(e.orientation&&!Iu.exactEquals(e.orientation,this._camera.orientation)&&(t=this._setCameraOrientation(e.orientation)),e.position){const i=[e.position.x,e.position.y,e.position.z];Du.exactEquals(i,this._camera.position)||(this._setCameraPosition(i),t=!0);}t&&(this._updateStateFromCamera(),this.recenterOnTerrain());}getFreeCameraOptions(){this._updateCameraState();const e=this._camera.position,t=new Xx;return t.position=new lp(e[0],e[1],e[2]),t.orientation=this._camera.orientation,t._elevation=this.elevation,t._renderWorldCopies=this.renderWorldCopies,t}_setCameraOrientation(e){if(!Iu.length(e))return !1;Iu.normalize(e,e);const t=Du.transformQuat([],[0,0,-1],e),i=Du.transformQuat([],[0,-1,0],e);if(i[2]<0)return !1;const r=Hx(t,i);return !!r&&(this._camera.orientation=r,!0)}_setCameraPosition(e){const t=this.zoomScale(this.minZoom)*this.tileSize,i=this.zoomScale(this.maxZoom)*this.tileSize,r=this.cameraToCenterDistance;e[2]=z(e[2],r/i,r/t),this._camera.position=e;}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices();}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(e){const t=[new Gu(0,e)];if(this.renderWorldCopies){const i=this.pointCoordinate(new y(0,0)),r=this.pointCoordinate(new y(this.width,0)),n=this.pointCoordinate(new y(this.width,this.height)),o=this.pointCoordinate(new y(0,this.height)),s=Math.floor(Math.min(i.x,r.x,n.x,o.x)),a=Math.floor(Math.max(i.x,r.x,n.x,o.x)),l=1;for(let i=s-l;i<=a+l;i++)0!==i&&t.push(new Gu(i,e));}return t}isLODDisabled(e){return (!e||this.pitch<=60)&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace}extendTileCoverForShadows(e,t,i){let r=[];if(0===t[0]&&0===t[1])return r;for(const i of e){const e=i.canonical,n=i.overscaledZ,o=i.wrap,s=1<<e.z,a=e.x+1<s,l=e.x>0,c=e.y+1<s,h=e.y>0,u=i.wrap-(l?0:1),d=i.wrap+(a?0:1),p=l?e.x-1:s-1,f=a?e.x+1:0;t[0]<0?(r.push(new qu(n,d,e.z,f,e.y)),t[1]<0&&c&&(r.push(new qu(n,o,e.z,e.x,e.y+1)),r.push(new qu(n,d,e.z,f,e.y+1))),t[1]>0&&h&&(r.push(new qu(n,o,e.z,e.x,e.y-1)),r.push(new qu(n,d,e.z,f,e.y-1)))):t[0]>0?(r.push(new qu(n,u,e.z,p,e.y)),t[1]<0&&c&&(r.push(new qu(n,o,e.z,e.x,e.y+1)),r.push(new qu(n,u,e.z,p,e.y+1))),t[1]>0&&h&&(r.push(new qu(n,o,e.z,e.x,e.y-1)),r.push(new qu(n,u,e.z,p,e.y-1)))):t[1]<0&&c?r.push(new qu(n,o,e.z,e.x,e.y+1)):h&&r.push(new qu(n,o,e.z,e.x,e.y-1));}if(r.length>1){r.sort(((e,t)=>e.overscaledZ-t.overscaledZ||e.wrap-t.wrap||e.canonical.z-t.canonical.z||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y));let e=0,t=0;for(;t<r.length;)r[t].equals(r[e])?++t:r[++e]=r[t++];r.length=e+1;}const n=[];for(const e of r)r.some((t=>e.isChildOf(t)))||n.push(e);return r=n.filter((t=>!e.some((e=>!!(t.overscaledZ<i&&e.isChildOf(t))||t.equals(e)||t.isChildOf(e))))),r}coveringTiles(e){let t=this.coveringZoomLevel(e);const i=t,r=this.elevation&&this.elevation.exaggeration(),n=r&&!e.isTerrainDEM,o="mercator"===this.projection.name;if(void 0!==e.minzoom&&t<e.minzoom)return [];void 0!==e.maxzoom&&t>e.maxzoom&&(t=e.maxzoom);const s=this.locationCoordinate(this.center),a=this.center.lat,l=1<<t,c=[l*s.x,l*s.y,0],h="globe"===this.projection.name,u=!h,d=Qu.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,u),p=h?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),f=l*Qd(1,this.center.lat),m=this._camera.position[2]/Qd(1,this.center.lat),_=[l*p.x,l*p.y,m*(u?1:f)],g=h||r,y=this.cameraToCenterDistance/e.tileSize*(e.roundZoom?1:.502),x=this.isLODDisabled(!0)?t:0;let v;if(this._elevation&&e.isTerrainDEM)v=1e4*this._elevation.exaggeration();else if(this._elevation){const e=this._elevation.getMinMaxForVisibleTiles();v=e?e.max:this._centerAltitude;}else v=this._centerAltitude;const b=e.isTerrainDEM?-v:this._elevation?this._elevation.getMinElevationBelowMSL():0,w=this.projection.isReprojectedInTileSpace?Jx(this):1,T=e=>{const t=1/4e4,i=new lp(e.x+t,e.y,e.z),r=new lp(e.x,e.y+t,e.z),n=e.toLngLat(),o=i.toLngLat(),s=r.toLngLat(),a=this.locationCoordinate(n),l=this.locationCoordinate(o),c=this.locationCoordinate(s),h=Math.hypot(l.x-a.x,l.y-a.y),u=Math.hypot(c.x-a.x,c.y-a.y);return Math.sqrt(h*u)*w/t},M=e=>{const t=v,i=b;return {aabb:Dg(this,l,0,0,0,e,i,t,this.projection),zoom:0,x:0,y:0,minZ:i,maxZ:t,wrap:e,fullyVisible:!1}},A=[];let S=[];const I=t,C=e.reparseOverscaled?i:t,z=e=>e*e,P=z((m-this._centerAltitude)*f),D=e=>{if(!this._elevation||!e.tileID||!o)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=R(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude));},R=e=>{if(e.zoom<x)return !0;if(e.zoom===I)return !1;if(null!=e.shouldSplit)return e.shouldSplit;const t=e.aabb.distanceX(_),r=e.aabb.distanceY(_);let o=P,s=1;if(h){o=z(e.aabb.distanceZ(_));const t=Math.pow(2,e.zoom),i=tp((e.y+1)/t),r=tp(e.y/t),n=Math.min(Math.max(a,i),r),l=Yd(n)/Yd(a);if(s=n===a?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,l/this._mercatorScaleRatio),this.zoom<=td&&e.zoom===I-1&&l>=.9)return !0}else if(n&&(o=z(e.aabb.distanceZ(_)*f)),this.projection.isReprojectedInTileSpace&&i<=5){const t=Math.pow(2,e.zoom),i=T(new lp((e.x+.5)/t,(e.y+.5)/t));s=i>.85?1:i;}const l=t*t+r*r+o,c=z((1<<I-e.zoom)*y*s*((e,t)=>{if(t*z(.707)<e)return 1;const i=Math.sqrt(t/e);return i/(1.4144271570014144+(Math.pow(1.1,i-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(o,P),l));return l<c};if(this.renderWorldCopies)for(let e=1;e<=3;e++)A.push(M(-e)),A.push(M(e));for(A.push(M(0));A.length>0;){const i=A.pop(),r=i.x,s=i.y;let a=i.fullyVisible;const u=()=>"globe"===this.projection.name&&(0===i.y||i.y===(1<<i.zoom)-1);if(!a){let e=g?i.aabb.intersects(d):i.aabb.intersectsFlat(d);if(0===e&&u()){const t=new ju(i.zoom,r,s);e=yd(this,l,t,!0).intersects(d);}if(0===e)continue;a=2===e;}if(i.zoom!==I&&R(i))for(let e=0;e<4;e++){const t=(r<<1)+e%2,c=(s<<1)+(e>>1),u={aabb:o?i.aabb.quadrant(e):Dg(this,l,i.zoom+1,t,c,i.wrap,i.minZ,i.maxZ,this.projection),zoom:i.zoom+1,x:t,y:c,wrap:i.wrap,fullyVisible:a,tileID:void 0,shouldSplit:void 0,minZ:i.minZ,maxZ:i.maxZ};n&&!h&&(u.tileID=new qu(i.zoom+1===I?C:i.zoom+1,i.wrap,i.zoom+1,t,c),D(u)),A.push(u);}else {const n=i.zoom===I?C:i.zoom;if(e.minzoom&&e.minzoom>n)continue;if(!a){let e=g?i.aabb.intersectsPrecise(d):i.aabb.intersectsPreciseFlat(d);if(0===e&&u()){const t=new ju(i.zoom,r,s);e=yd(this,l,t,!0).intersectsPrecise(d);}if(0===e)continue}const o=c[0]-(.5+r+(i.wrap<<i.zoom))*(1<<t-i.zoom),h=c[1]-.5-s,p=i.tileID?i.tileID:new qu(n,i.wrap,i.zoom,r,s);S.push({tileID:p,distanceSq:o*o+h*h});}}if(this.fogCullDistSq){const t=this.fogCullDistSq,i=this.horizonLineFromTop();S=S.filter((r=>{const n=[0,0,0,1],o=[cr,cr,0,1],s=this.calculateFogTileMatrix(r.tileID.toUnwrapped());yu.transformMat4(n,n,s),yu.transformMat4(o,o,s);const a=function(e,t,i){let r=0;for(let i=0;i<2;++i){const n=0;e[i]>n&&(r+=(e[i]-n)*(e[i]-n)),t[i]<n&&(r+=(n-t[i])*(n-t[i]));}return r}(yu.min([],n,o),yu.max([],n,o));if(0===a)return !0;let l=!1;const c=this._elevation;if(c&&a>t&&0!==i){const t=this.calculateProjMatrix(r.tileID.toUnwrapped());let n;e.isTerrainDEM||(n=c.getMinMaxForTile(r.tileID)),n||(n={min:b,max:v});const o=function(e){const t=Math.round((e+45+360)%360/90)%4;return E[t]}(this.rotation),s=[o[0]*cr,o[1]*cr,n.max];Du.transformMat4(s,s,t),l=(1-s[1])*this.height*.5<i;}return a<t||l}));}return S.sort(((e,t)=>e.distanceSq-t.distanceSq)).map((e=>e.tileID))}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices();}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){const t=z(e.lat,-rp,rp),i=this.projection.project(e.lng,t);return new y(i.x*this.worldSize,i.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/Qd(1,this.center.lat)/this.worldSize}setLocationAtPoint(e,t){let i,r;const n=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;i=(t.x-n.x)/e,r=(t.y-n.y)/e;}else {const e=this.pointCoordinate(t),o=this.pointCoordinate(n);i=e.x-o.x,r=e.y-o.y;}const o=this.locationCoordinate(e);this.setLocation(new lp(o.x-i,o.y-r));}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap());}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(e,t){const i=t?Qd(t,e.lat):void 0,r=this.projection.project(e.lng,e.lat);return new lp(r.x,r.y,i)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(e,t){const i=null!=t?t:this._centerAltitude,r=[e.x,e.y,0,1],n=[e.x,e.y,1,1];yu.transformMat4(r,r,this.pixelMatrixInverse),yu.transformMat4(n,n,this.pixelMatrixInverse);const o=n[3];yu.scale(r,r,1/r[3]),yu.scale(n,n,1/o);const s=r[2],a=n[2];return {p0:r,p1:n,t:s===a?0:(i-s)/(a-s)}}screenPointToMercatorRay(e){const t=[e.x,e.y,0,1],i=[e.x,e.y,1,1];return yu.transformMat4(t,t,this.pixelMatrixInverse),yu.transformMat4(i,i,this.pixelMatrixInverse),yu.scale(t,t,1/t[3]),yu.scale(i,i,1/i[3]),t[2]=Qd(t[2],this._center.lat)*this.worldSize,i[2]=Qd(i[2],this._center.lat)*this.worldSize,yu.scale(t,t,1/this.worldSize),yu.scale(i,i,1/this.worldSize),new Wu([t[0],t[1],t[2]],Du.normalize([],Du.sub([],i,t)))}rayIntersectionCoordinate(e){const{p0:t,p1:i,t:r}=e,n=Qd(t[2],this._center.lat),o=Qd(i[2],this._center.lat);return new lp(Kr(t[0],i[0],r)/this.worldSize,Kr(t[1],i[1],r)/this.worldSize,Kr(n,o,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let t=this.projection.pointCoordinate3D(this,e.x,e.y);if(t)return new lp(t[0],t[1],t[2]);let i=0,r=this.horizonLineFromTop();if(e.y>r)return this.pointCoordinate(e);const n=.02*r,o=e.clone();for(let e=0;e<10&&r-i>n;e++){o.y=Kr(i,r,.66);const e=this.projection.pointCoordinate3D(this,o.x,o.y);e?(r=o.y,t=e):i=o.y;}return t?new lp(t[0],t[1],t[2]):this.pointCoordinate(e)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(e){if(e.y<0||e.y>this.height||e.x<0||e.x>this.width)return !1;if(this.elevation||this.zoom>=id)return !this.isPointAboveHorizon(e);const t=this.pointCoordinate(e);return t.y>=0&&t.y<=1}_coordinatePoint(e,t){const i=t&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,r=[e.x*this.worldSize,e.y*this.worldSize,i+e.toAltitude(),1];return yu.transformMat4(r,r,this.pixelMatrix),r[3]>0?new y(r[0]/r[3],r[1]/r[3]):new y(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:e,left:t}=this._edgeInsets,i=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,n=this.pointLocation3D(new y(t,e)),o=this.pointLocation3D(new y(r,e)),s=this.pointLocation3D(new y(r,i)),a=this.pointLocation3D(new y(t,i));let l=Math.min(n.lng,o.lng,s.lng,a.lng),c=Math.max(n.lng,o.lng,s.lng,a.lng),h=Math.min(n.lat,o.lat,s.lat,a.lat),u=Math.max(n.lat,o.lat,s.lat,a.lat);const d=Math.pow(2,-this.zoom)/16*270,p="globe"===this.projection.name?1:4,f=(e,t,i,r,n)=>{const o=(e+i)/2,s=(t+r)/2,a=new y(o,s),{lng:m,lat:_}=this.pointLocation3D(a),g=Math.max(0,l-m,h-_,m-c,_-u);l=Math.min(l,m),c=Math.max(c,m),h=Math.min(h,_),u=Math.max(u,_),(n<p||g>d)&&(f(e,t,o,s,n+1),f(o,s,i,r,n+1));};if(f(t,e,r,e,1),f(r,e,r,i,1),f(r,i,t,i,1),f(t,i,t,e,1),"globe"===this.projection.name){const[e,t]=function(e){const t=Au.identity(new Float64Array(16));Au.multiply(t,e.pixelMatrix,e.globeMatrix);const i=[0,ad,0],r=[0,ld,0];return Du.transformMat4(i,i,t),Du.transformMat4(r,r,t),[i[0]>0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!Nd(e,new Wd(e.center.lat,90)),r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!Nd(e,new Wd(e.center.lat,-90))]}(this);e?(u=90,c=180,l=-180):t&&(h=-90,c=180,l=-180);}return new sc(new Wd(l,h),new Wd(c,u))}_getBoundsRectangular(e,t){const{top:i,left:r}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,o=this.width-this._edgeInsets.right,s=new y(r,i),a=new y(o,i),l=new y(o,n),c=new y(r,n);let h=this.pointCoordinate(s,e),u=this.pointCoordinate(a,e);const d=this.pointCoordinate(l,t),p=this.pointCoordinate(c,t),f=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&u.y>=0?h=new lp((1-p.y)/f(p,h)+p.x,1):h.y<0&&u.y<=1&&(h=new lp(-p.y/f(p,h)+p.x,0)),u.y>1&&h.y>=0?u=new lp((1-d.y)/f(d,u)+d.x,1):u.y<0&&h.y<=1&&(u=new lp(-d.y/f(d,u)+d.x,0)),(new sc).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(d))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0]);}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return "mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-rp,this.maxLat=rp,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=Kd(this.minLng)*this.tileSize,this.worldMaxX=Kd(this.maxLng)*this.tileSize,this.worldMinY=Jd(this.maxLat)*this.tileSize,this.worldMaxY=Jd(this.minLat)*this.tileSize,this._constrain();}calculatePosMatrix(e,t){return this.projection.createTileMatrix(this,t,e)}calculateDistanceTileData(e){const t=e.key,i=this._distanceTileDataCache;if(i[t])return i[t];const r=e.canonical,n=1/this.height,o=this.cameraWorldSize,s=o/this.zoomScale(r.z),a=(r.x+Math.pow(2,r.z)*e.wrap)*s,l=r.y*s,c=this.point;c.x*=o/this.worldSize,c.y*=o/this.worldSize;const h=this.angle,u=Math.sin(-h),d=-Math.cos(-h);return i[t]={bearing:[u,d],center:[(c.x-a)*n,(c.y-l)*n],scale:s/cr*n},i[t]}calculateFogTileMatrix(e){const t=e.key,i=this._fogTileMatrixCache;if(i[t])return i[t];const r=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,e);return Au.multiply(r,this.worldToFogMatrix,r),i[t]=new Float32Array(r),i[t]}calculateProjMatrix(e,t=!1,i=!1){const r=e.key;let n;if(n=i?this._expandedProjMatrixCache:t?this._alignedProjMatrixCache:this._projMatrixCache,n[r])return n[r];const o=this.calculatePosMatrix(e,this.worldSize);let s;return s=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:i?this.expandedFarZProjMatrix:t?this.alignedProjMatrix:this.projMatrix,Au.multiply(o,s,o),n[r]=new Float32Array(o),n[r]}calculatePixelsToTileUnitsMatrix(e){const t=e.tileID.key,i=this._pixelsToTileUnitsCache;if(i[t])return i[t];const r=function(e,t){const{scale:i}=e.tileTransform,r=i*cr/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return bu.scale(new Float32Array(4),t.inverseAdjustmentMatrix,[r,r])}(e,this);return i[t]=r,i[t]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if("globe"===this.projection.name){const e=1/this.worldSize,t=Au.fromScaling([],[e,e,e]);return Au.multiply(t,t,this.globeMatrix),t}}recenterOnTerrain(){if(!this._elevation||"globe"===this.projection.name)return;const e=this._elevation;this._updateCameraState();const t=Qd(1,this._center.lat)*this.worldSize,i=this._computeCameraPosition(t),r=this._camera.forward(),n=Qd(1,this._center.lat);i[2]/=n,r[2]/=n,Du.normalize(r,r);const o=e.raycast(i,r,e.exaggeration());if(o){const e=Du.scaleAndAdd([],i,r,o),t=new lp(e[0],e[1],Qd(e[2],tp(e[1]))),s=(t.z+Du.length([t.x-i[0],t.y-i[1],t.z-i[2]*n]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(s),this._centerAltitude=t.toAltitude(),this._center=this.coordinateLocation(t),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices();}}_constrainCamera(e=!1){if(!this._elevation)return;const t=this._elevation,i=Qd(1,this._center.lat)*this.worldSize,r=this._computeCameraPosition(i),n=t.getAtPointOrZero(new lp(...r)),o=this.pixelsPerMeter/this.worldSize*n,s=this._minimumHeightOverTerrain(),a=r[2]-o;if(a<=s)if(a<0||e){const e=this.locationCoordinate(this._center,this._centerAltitude),t=[r[0],r[1],e.z-r[2]],i=Du.length(t);t[2]-=(s-a)/this._pixelsPerMercatorPixel;const n=Du.length(t);if(0===n)return;Du.scale(t,t,i/n*this._pixelsPerMercatorPixel),this._camera.position=[r[0],r[1],e.z*this._pixelsPerMercatorPixel-t[2]],this._updateStateFromCamera();}else this._isCameraConstrained=!0;}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e="globe"===this.projection.name||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||e){const t=this.center;return t.lat=z(t.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!e)&&(t.lng=z(t.lng,this.minLng,this.maxLng)),this.center=t,void(this._constraining=!1)}const t=this._unmodified,{x:i,y:r}=this.point;let n=0,o=i,s=r;const a=this.width/2,l=this.height/2,c=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(r-l<c&&(s=c+l),r+l>h&&(s=h-l),h-c<this.height&&(n=Math.max(n,this.height/(h-c)),s=(h+c)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,r=this.worldSize/2-(e+t)/2;o=(i+r+this.worldSize)%this.worldSize-r,o-a<e&&(o=e+a),o+a>t&&(o=t-a),t-e<this.width&&(n=Math.max(n,this.width/(t-e)),o=(t+e)/2);}o===i&&s===r||(this.center=this.unproject(new y(o,s))),n&&(this.zoom+=this.scaleZoom(n)),this._constrainCamera(),this._unmodified=t,this._constraining=!1;}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,t="globe"===this.projection.name,i=this.pixelsPerMeter;"globe"===this.projection.name&&(this._mercatorScaleRatio=Qd(1,this.center.lat)/Qd(1,45));const r=Qx(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,r),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const n="meters"===this.projection.zAxisUnit?i:1,o=this._camera.getWorldToCamera(this.worldSize,n);let s;const a=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);if(a[8]=2*-e.x/this.width,a[9]=2*e.y/this.height,this.isOrthographic){let t=.5*this.height/Math.tan(this._fov/2)*1*Math.tan(.5*this._fov),i=t*this.aspect,r=-i,n=-t;i-=e.x,r-=e.x,t+=e.y,n+=e.y,s=this._camera.getCameraToClipOrthographic(r,i,n,t,this._nearZ,this._farZ),((e,t,i,r)=>{for(let n=0;n<16;n++)e[n]=bv(t[n],i[n],r);})(s,s,a,wv(this.pitch>=15?1:this.pitch/15));}else s=a;const l=Au.mul([],a,o);let c=Au.mul([],s,o);if(this.projection.isReprojectedInTileSpace){const e=this.locationCoordinate(this.center),t=Au.identity([]);Au.translate(t,t,[e.x*this.worldSize,e.y*this.worldSize,0]),Au.multiply(t,t,Kx(this)),Au.translate(t,t,[-e.x*this.worldSize,-e.y*this.worldSize,0]),Au.multiply(c,c,t),Au.multiply(l,l,t),this.inverseAdjustmentMatrix=function(e){const t=Kx(e,!0);return bu.invert([],[t[0],t[1],t[4],t[5]])}(this);}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=Au.scale([],c,[this.worldSize,this.worldSize,this.worldSize/n,1]),this.projMatrix=c,this.invProjMatrix=Au.invert(new Float64Array(16),this.projMatrix),t){const t=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);t[8]=2*-e.x/this.width,t[9]=2*e.y/this.height,this.expandedFarZProjMatrix=Au.mul([],t,o);}else this.expandedFarZProjMatrix=this.projMatrix;const h=Au.invert([],s);this.frustumCorners=Hu.fromInvProjectionMatrix(h,this.horizonLineFromTop(),this.height),this.cameraFrustum=Qu.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!t);const u=new Float32Array(16);Au.identity(u),Au.scale(u,u,[1,-1,1]),Au.rotateX(u,u,this._pitch),Au.rotateZ(u,u,this.angle);const d=Au.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=Au.clone(d);const p=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;d[8]=2*-e.x/this.width,d[9]=2*(e.y+p)/this.height,this.skyboxMatrix=Au.multiply(u,d,u);const f=this.point,m=f.x,_=f.y,g=this.width%2/2,y=this.height%2/2,x=Math.cos(this.angle),v=Math.sin(this.angle),b=m-Math.round(m)+x*g+v*y,w=_-Math.round(_)+x*y+v*g,T=new Float64Array(c);if(Au.translate(T,T,[b>.5?b-1:b,w>.5?w-1:w,0]),this.alignedProjMatrix=T,c=Au.create(),Au.scale(c,c,[this.width/2,-this.height/2,1]),Au.translate(c,c,[1,-1,0]),this.labelPlaneMatrix=c,c=Au.create(),Au.scale(c,c,[1,-1,1]),Au.translate(c,c,[-1,-1,0]),Au.scale(c,c,[2/this.width,2/this.height,1]),this.glCoordMatrix=c,this.pixelMatrix=Au.multiply(new Float64Array(16),this.labelPlaneMatrix,l),this._calcFogMatrices(),this._distanceTileDataCache={},c=Au.invert(new Float64Array(16),this.pixelMatrix),!c)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=c,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=function(e){const{x:t,y:i}=e.point,{lng:r,lat:n}=e._center;return zd(t,i,e.worldSize,r,n)}(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=Du.transformMat4(e,e,o),this.globeRadius=this.worldSize/2/Math.PI-1;}else this.globeMatrix=c;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={};}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSizeForFog,t=this.cameraPixelsPerMeter,i=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,n=[e,e,t];Du.scale(n,n,r),Du.scale(i,i,-1),Du.multiply(i,i,n);const o=Au.create();Au.translate(o,o,i),Au.scale(o,o,n),this.mercatorFogMatrix=o,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,t,r);}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return [r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,e/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition());}_translateCameraConstrained(e){const t=this._maxCameraBoundsDistance()*Math.cos(this._pitch),i=this._camera.position[2],r=e[2];let n=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(n=Math.min((t-i)/r,1)),this._camera.position=Du.scaleAndAdd([],this._camera.position,e,n),this._updateStateFromCamera();}_updateStateFromCamera(){const e=this._camera.position,t=this._camera.forward(),{pitch:i,bearing:r}=this._camera.getPitchBearing(),n=Qd(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,o=this._mercatorZfromZoom(this._maxZoom)*Math.cos(w(this._maxPitch)),s=Math.max((e[2]-n)/Math.cos(i),o),a=this._zoomFromMercatorZ(s);Du.scaleAndAdd(e,e,t,s),this._pitch=z(i,w(this.minPitch),w(this.maxPitch)),this.angle=D(r,-Math.PI,Math.PI),this._setZoom(z(a,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new lp(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices();}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(e){let t=0,i=id,r=0,n=1/0;for(;i-t>1e-6&&i>t;){const o=t+.5*(i-t),s=this.tileSize*Math.pow(2,o),a=this.getCameraToCenterDistance(this.projection,o,s),l=this.scaleZoom(a/(e*this.tileSize)),c=Math.abs(o-l);c<n&&(n=c,r=o),o<l?t=o:i=o;}return r}_terrainEnabled(){return !(!this._elevation||!this.projection.supportsTerrain&&(H("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(e,t){const i=Math.min(e.x,t.x),r=Math.max(e.x,t.x),n=Math.min(e.y,t.y),o=Math.max(e.y,t.y);if(n<this.horizonLineFromTop(!1))return !0;if("mercator"!==this.projection.name)return !1;const s=[new y(i,n),new y(r,o),new y(i,o),new y(r,n)],a=this.renderWorldCopies?-3:0,l=this.renderWorldCopies?4:1;for(const e of s){const t=this.pointRayIntersection(e);if(t.t<0)return !0;const i=this.rayIntersectionCoordinate(t);if(i.x<a||i.y<0||i.x>l||i.y>1)return !0}return !1}isHorizonVisible(){return this.pitch+T(this.fovAboveCenter)>88||this.anyCornerOffEdge(new y(0,0),new y(this.width,this.height))}zoomDeltaToMovement(e,t){const i=Du.length(Du.sub([],this._camera.position,e)),r=this._zoomFromMercatorZ(i)+t;return i-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const e=function([e,t,i],r){const n=[e,t,i,1];yu.transformMat4(n,n,r);const o=n[3]=Math.max(n[3],1e-6);return n[0]/=o,n[1]/=o,n[2]/=o,n}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new y(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new y(0,e))}}getCameraToCenterDistance(e,t=this.zoom,i=this.worldSize){const r=Qx(e,t,this.width,this.height,1024),n=e.pixelSpaceConversion(this.center.lat,i,r);let o=.5/Math.tan(.5*this._fov)*this.height*n;return this.isOrthographic&&(o=bv(1,o,wv(this.pitch>=15?1:this.pitch/15))),o}getWorldToCameraMatrix(){const e=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return "globe"===this.projection.name&&Au.multiply(e,e,this.globeMatrix),e}getFrustum(e){return Qu.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,e,"meters"===this.projection.zAxisUnit)}}function Ev(e,t,i){Au.identity(e),Au.rotateZ(e,e,w(t[2])),Au.rotateX(e,e,w(t[0])),Au.rotateY(e,e,w(t[1])),Au.scale(e,e,i),Au.multiply(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1]);}function Mv(e,t,i,r,n,o,s,a){const l=[i[0]-t[0],i[1]-t[1],0],c=[r[0]-t[0],r[1]-t[1],0];if(Du.length(l)<1e-12||Du.length(c)<1e-12)return Iu.identity(e);const h=Du.cross([],l,c);Du.normalize(h,h),Du.subtract(c,r,t),l[2]=(o-n)*a,c[2]=(s-n)*a;const u=l;return Du.cross(u,l,c),Du.normalize(u,u),Iu.rotationTo(e,h,u)}function Av(e,t,i=!1){const r=Dd(t.zoom),n=function(e,t,i){const r=t.worldSize,n=[e[12],e[13],e[14]],o=tp(n[1]/r),s=ep(n[0]/r),a=Au.identity([]),l=Qd(1,o)*r,c=Qd(1,0)*r*op(o,t.zoom),h=1/Id(r);let u=c*h;if(i){const e=Qx(t.projection,t.zoom,t.width,t.height,1024);u=h*t.projection.pixelSpaceConversion(t.center.lat,r,e);}const d=wd(o,s);Du.add(d,d,Du.scale([],Du.normalize([],d),l*u*n[2]));const p=function(e){const t=[e[0],e[1],e[2]];let i=[0,1,0];const r=Du.cross([],i,t);return Du.cross(i,t,r),0===Du.squaredLength(i)&&(i=[0,1,0],Du.cross(r,t,i)),Du.normalize(r,r),Du.normalize(i,i),Du.normalize(t,t),[r[0],r[1],r[2],0,i[0],i[1],i[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(d);Au.scale(a,a,[u,u,u*l]),Au.translate(a,a,[-n[0],-n[1],-n[2]]);const f=Au.multiply([],t.globeMatrix,p);return Au.multiply(f,f,a),Au.multiply(f,f,e),f}(e,t,i);if(r>0){const i=function(e,t){const i=t.worldSize,r=Qd(1,0)*i*op(t.center.lat,t.zoom)/Id(i),n=Qd(1,t.center.lat)*i,o=Au.identity([]);return Au.rotateY(o,o,w(t.center.lng)),Au.rotateX(o,o,w(t.center.lat)),Au.translate(o,o,[0,0,rd]),Au.scale(o,o,[r,r,r*n]),Au.translate(o,o,[t.point.x-.5*i,t.point.y-.5*i,0]),Au.multiply(o,o,e),Au.multiply(o,t.globeMatrix,o)}(e,t);return function(e,t,i){const r=(e,t,i)=>{const r=Du.length(e),n=Du.length(t),o=md(e,t,i);return Du.scale(o,o,1/Du.length(o)*Kr(r,n,i))},n=r([e[0],e[1],e[2]],[t[0],t[1],t[2]],i),o=r([e[4],e[5],e[6]],[t[4],t[5],t[6]],i),s=r([e[8],e[9],e[10]],[t[8],t[9],t[10]],i),a=md([e[12],e[13],e[14]],[t[12],t[13],t[14]],i);return [n[0],n[1],n[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(n,i,r)}return n}const Sv=64,Iv=[1,1,1];class Cv{constructor(e,t,i,r){this.id=e,this.position=null!=t?new Wd(t[0],t[1]):new Wd(0,0),this.orientation=null!=i?i:[0,0,0],this.nodes=r,this.uploaded=!1,this.aabb=new ed([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[];}_applyTransformations(e,t){if(Au.multiply(e.matrix,t,e.matrix),e.meshes)for(const t of e.meshes){const i=ed.applyTransform(t.aabb,e.matrix);this.aabb.encapsulate(i);}if(e.children)for(const t of e.children)this._applyTransformations(t,e.matrix);}computeBoundsAndApplyParent(){const e=Au.identity([]);for(const t of this.nodes)this._applyTransformations(t,e);}_positionModelOnTerrain(e,t){const i=e.elevation;if(!i)return 0;const r=ed.projectAabbCorners(this.aabb,this.matrix),n=Qd(1,this.position.lat)*e.worldSize,o=function(e,t){const i=[0,0,1],r=[{corners:[0,1,3,2],dotProductWithUp:0},{corners:[1,5,2,6],dotProductWithUp:0},{corners:[0,4,1,5],dotProductWithUp:0},{corners:[2,6,3,7],dotProductWithUp:0},{corners:[4,7,5,6],dotProductWithUp:0},{corners:[0,3,4,7],dotProductWithUp:0}];for(const n of r){const r=e[n.corners[0]],o=e[n.corners[1]],s=e[n.corners[2]],a=[o[0]-r[0],o[1]-r[1],t*(o[2]-r[2])],l=Du.cross(a,a,[s[0]-r[0],s[1]-r[1],t*(s[2]-r[2])]);Du.normalize(l,l),n.dotProductWithUp=Du.dot(l,i);}return r.sort(((e,t)=>e.dotProductWithUp-t.dotProductWithUp)),r[0].corners}(r,n),s=r[o[0]],a=r[o[1]],l=r[o[2]],c=r[o[3]],h=i.getAtPointOrZero(new lp(s[0]/e.worldSize,s[1]/e.worldSize),0),u=i.getAtPointOrZero(new lp(a[0]/e.worldSize,a[1]/e.worldSize),0),d=i.getAtPointOrZero(new lp(l[0]/e.worldSize,l[1]/e.worldSize),0),p=i.getAtPointOrZero(new lp(c[0]/e.worldSize,c[1]/e.worldSize),0),f=(h+p)/2,m=(u+d)/2;return f>m?u<d?Mv(t,a,c,s,u,p,h,n):Mv(t,l,s,c,d,h,p,n):h<p?Mv(t,s,a,l,h,u,d,n):Mv(t,c,l,a,p,d,u,n),Math.max(f,m)}computeModelMatrix(e,t,i,r,n,o,s=!1){const a=e.transform,l=a.zoom,c=a.project(this.position),h=op(this.position.lat,l),u=1/h;Au.identity(this.matrix),Au.translate(this.matrix,this.matrix,[c.x+r[0]*u,c.y+r[1]*u,r[2]]);let d=1,p=1;const f=a.worldSize;if(s){if("mercator"===a.projection.name){let e=0;a.elevation&&(e=a.elevation.getAtPointOrZero(new lp(c.x/f,c.y/f),0));const t=yu.transformMat4([],[c.x,c.y,e,1],a.projMatrix)[3]/a.cameraToCenterDistance;d=t,p=t*op(a.center.lat,l);}else if("globe"===a.projection.name){const e=Av(this.matrix,a),t=Au.multiply([],a.projMatrix,e),i=[0,0,0,1];yu.transformMat4(i,i,t);const r=i[3]/a.cameraToCenterDistance,n=Dd(l),o=a.projection.pixelsPerMeter(this.position.lat,f)*op(this.position.lat,l),s=a.projection.pixelsPerMeter(a.center.lat,f)*op(a.center.lat,l);d=r/Kr(o,np(a.center.lat),n),p=r*h/o,d*=s,p*=s;}}else d=u;Au.scale(this.matrix,this.matrix,[d,d,p]);const m=[...this.matrix],_=this.orientation,g=[];if(Ev(g,[_[0]+t[0],_[1]+t[1],_[2]+t[2]],i),Au.multiply(this.matrix,m,g),n&&a.elevation){let e=0;const t=[];if(o&&a.elevation){e=this._positionModelOnTerrain(a,t);const i=Au.fromQuat([],t),r=Au.multiply([],i,g);Au.multiply(this.matrix,m,r);}else e=a.elevation.getAtPointOrZero(new lp(c.x/f,c.y/f),0);0!==e&&(this.matrix[14]+=e);}}upload(e){if(!this.uploaded){for(const t of this.nodes)Dv(t,e);for(const e of this.nodes)Rv(e);this.uploaded=!0;}}destroy(){for(const e of this.nodes)Lv(e);}}function zv(e,t,i=!1){e.uploaded||(e.gfxTexture=new My(t,e.image,i?t.gl.R8:t.gl.RGBA,{useMipmap:e.sampler.minFilter>=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null);}function Pv(e,t,i){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Fx.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,jx.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,Vx.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Nx:Ux).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,qx.members,!0)),e.segments=xl.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const r=e.material;r.pbrMetallicRoughness.baseColorTexture&&zv(r.pbrMetallicRoughness.baseColorTexture,t),r.pbrMetallicRoughness.metallicRoughnessTexture&&zv(r.pbrMetallicRoughness.metallicRoughnessTexture,t),r.normalTexture&&zv(r.normalTexture,t),r.occlusionTexture&&zv(r.occlusionTexture,t,i),r.emissionTexture&&zv(r.emissionTexture,t);}function Dv(e,t,i){if(e.meshes)for(const r of e.meshes)Pv(r,t,i);if(e.children)for(const r of e.children)Dv(r,t,i);}function Rv(e){if(e.meshes)for(const t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(const t of e.children)Rv(t);}function Lv(e){if(e.meshes)for(const i of e.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((t=i.material).pbrMetallicRoughness.baseColorTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture&&t.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),t.pbrMetallicRoughness.metallicRoughnessTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&t.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),t.normalTexture&&t.normalTexture.gfxTexture&&t.normalTexture.gfxTexture.destroy(),t.emissionTexture&&t.emissionTexture.gfxTexture&&t.emissionTexture.gfxTexture.destroy(),t.occlusionTexture&&t.occlusionTexture.gfxTexture&&t.occlusionTexture.gfxTexture.destroy()));var t;if(e.children)for(const t of e.children)Lv(t);}class kv{constructor(e,t){this.feature=e,this.instancedDataOffset=t,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0];}}class Ov{constructor(){this.instancedDataArray=new rl,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={};}}class Bv{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.projection=e.projection,this.index=e.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0};}populate(e,t,i,r){this.tileToMeter=ap(i);const n=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=gp(o,n);if(!this.layers[0]._featureFilter.filter(new oa(this.zoom),e,i))continue;const c={id:s,sourceLayerIndex:l,index:a,geometry:n?e.geometry:_p(o,i,r),properties:o.properties,type:o.type,patterns:{}},h=this.addFeature(c,c.geometry,e);h&&t.featureIndex.insert(o,c.geometry,a,l,this.index,this.instancesPerModel[h].instancedDataArray.length);}this.lookup=null;}update(e,t,i,r){for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t in e)i.idToFeaturesIndex.hasOwnProperty(t)&&this.evaluate(i.features[i.idToFeaturesIndex[t]],e[t],i,!0);}this.maxHeight=0;}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return !1;let e=!1;for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t of i.features){const r=this.layers[0],n=t.feature,o=this.canonical,s=r.paint.get("model-rotation").evaluate(n,{},o),a=r.paint.get("model-scale").evaluate(n,{},o),l=r.paint.get("model-translation").evaluate(n,{},o);Du.exactEquals(t.rotation,s)&&Du.exactEquals(t.scale,a)&&Du.exactEquals(t.translation,l)||(this.evaluate(t,t.featureStates,i,!0),e=!0);}}return e}isEmpty(){for(const e in this.instancesPerModel)if(0!==this.instancesPerModel[e].instancedDataArray.length)return !1;return !0}uploadPending(){return !this.uploaded}upload(e){if(!this.uploaded)for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];i.instancedDataArray.length<0||0===i.instancedDataArray.length||(i.instancedDataBuffer?i.instancedDataBuffer.updateData(i.instancedDataArray):i.instancedDataBuffer=e.createVertexBuffer(i.instancedDataArray,Gx.members,!0,void 0,this.instanceCount));}this.uploaded=!0;}destroy(){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy();}}addFeature(e,t,i){const r=this.layers[0],n=r.layout.get("model-id").evaluate(i,{},this.canonical);if(!n)return H(`modelId is not evaluated for layer ${r.id} and it is not going to get rendered.`),n;this.instancesPerModel[n]||(this.instancesPerModel[n]=new Ov);const o=this.instancesPerModel[n],s=o.instancedDataArray,a=new kv(i,s.length);for(const e of t)for(const t of e){if(t.x<0||t.x>=cr||t.y<0||t.y>=cr)continue;const e=(this.lookupDim-1)/cr,i=this.lookupDim*(t.y*e|0)+t.x*e|0;if(this.lookup){if(0!==this.lookup[i])continue;this.lookup[i]=1;}this.instanceCount++;const r=s.length;s.resize(r+1),o.instancesEvaluatedElevation.push(0),s.float32[16*r]=t.x,s.float32[16*r+1]=t.y;}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(e.id&&(o.idToFeaturesIndex[e.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),n}evaluate(e,t,i,r){const n=this.layers[0],o=e.feature,s=this.canonical,a=e.rotation=n.paint.get("model-rotation").evaluate(o,t,s),l=e.scale=n.paint.get("model-scale").evaluate(o,t,s),c=e.translation=n.paint.get("model-translation").evaluate(o,t,s),h=n.paint.get("model-color").evaluate(o,t,s);h.a=n.paint.get("model-color-mix-intensity").evaluate(o,t,s);const u=[];this.maxVerticalOffset<c[2]&&(this.maxVerticalOffset=c[2]),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),Ev(u,a,l);const d=Math.round(100*h.a)+h.b/1.05;for(let t=0;t<e.instancedDataCount;++t){const n=e.instancedDataOffset+t,o=16*n,a=i.instancedDataArray.float32;let l=0;r&&(l=a[o+6]-i.instancesEvaluatedElevation[n]);const p=0|a[o+1];a[o]=(0|a[o])+h.r/1.05,a[o+1]=p+h.g/1.05,a[o+2]=d,a[o+3]=1/(s.z>10?this.tileToMeter:ap(s,p)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=u[0],a[o+8]=u[1],a[o+9]=u[2],a[o+10]=u[4],a[o+11]=u[5],a[o+12]=u[6],a[o+13]=u[8],a[o+14]=u[9],a[o+15]=u[10],i.instancesEvaluatedElevation[n]=c[2];}}}Rs(Bv,"ModelBucket",{omit:["layers"]}),Rs(Ov,"PerModelAttributes"),Rs(kv,"ModelFeature");const Fv=new ga({visibility:new fa(Pt.layout_model.visibility),"model-id":new ma(Pt.layout_model["model-id"])});var Nv={paint:new ga({"model-opacity":new fa(Pt.paint_model["model-opacity"]),"model-rotation":new ma(Pt.paint_model["model-rotation"]),"model-scale":new ma(Pt.paint_model["model-scale"]),"model-translation":new ma(Pt.paint_model["model-translation"]),"model-color":new ma(Pt.paint_model["model-color"]),"model-color-mix-intensity":new ma(Pt.paint_model["model-color-mix-intensity"]),"model-type":new fa(Pt.paint_model["model-type"]),"model-cast-shadows":new fa(Pt.paint_model["model-cast-shadows"]),"model-receive-shadows":new fa(Pt.paint_model["model-receive-shadows"]),"model-ambient-occlusion-intensity":new fa(Pt.paint_model["model-ambient-occlusion-intensity"]),"model-emissive-strength":new ma(Pt.paint_model["model-emissive-strength"]),"model-roughness":new ma(Pt.paint_model["model-roughness"]),"model-height-based-emissive-strength-multiplier":new ma(Pt.paint_model["model-height-based-emissive-strength-multiplier"]),"model-cutoff-fade-range":new fa(Pt.paint_model["model-cutoff-fade-range"])}),layout:Fv};const Uv=new Float32Array(262144),Vv=new Uint8Array(262144);function jv(e){let t=0;if(e.meshes)for(const i of e.meshes)t=Math.max(t,i.aabb.max[2]);if(e.children)for(const i of e.children)t=Math.max(t,jv(i));return t}const Gv=["","wall","door","roof","window","lamp","logo"];class qv{constructor(e){this.node=e,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:"Point",id:e.id,geometry:[],properties:{height:jv(e)}};}}class Zv{constructor(e,t,i,r){this.nodes=e,this.id=t,this.modelTraits|=1,this.uploaded=!1,this.hasPattern=!1,i&&(this.modelTraits|=4),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=r,this.dirty=!0,this.needsUpload=!1;}update(){console.log("Update 3D model bucket");}populate(){console.log("populate 3D model bucket");}uploadPending(){return !this.uploaded||this.needsUpload}upload(e){if(!this.needsUpload)return;const t=this.getNodesInfo();for(const i of t){const t=i.node;this.uploaded?this.updatePbrBuffer(t):Dv(t,e,!0);}for(const e of t)Rv(e.node);this.uploaded=!0,this.needsUpload=!1;}updatePbrBuffer(e){let t=!1;if(!e.meshes)return t;for(const i of e.meshes)i.pbrBuffer&&(i.pbrBuffer.updateData(i.featureArray),t=!0);return t}needsReEvaluation(e,t,i){const r=e.transform.projectionOptions,n=e.style.getBrightness(),o=this.brightness!==n;return !!(!this.uploaded||this.dirty||r.name!==this.projection.name||$v(i.paint.get("model-color").value,o)||$v(i.paint.get("model-color-mix-intensity").value,o)||$v(i.paint.get("model-roughness").value,o)||$v(i.paint.get("model-emissive-strength").value,o)||$v(i.paint.get("model-height-based-emissive-strength-multiplier").value,o))&&(this.projection=r,this.brightness=n,!0)}evaluateScale(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const i=this.getNodesInfo(),r=this.id.canonical;for(const e of i){const i=e.feature;e.evaluatedScale=t.paint.get("model-scale").evaluate(i,{},r);}}evaluate(e){const t=this.getNodesInfo();for(const i of t){if(!i.node.meshes)continue;const t=i.feature,r=i.node.meshes&&i.node.meshes[0].featureData,n=i.evaluatedColor[2],o=i.evaluatedRMEA[2],s=this.id.canonical;if(i.hasTranslucentParts=!1,r){for(let r=0;r<Gv.length;r++){const n=Gv[r];n.length&&(t.properties.part=n);const o=e.paint.get("model-color").evaluate(t,{},s),a=e.paint.get("model-color-mix-intensity").evaluate(t,{},s);i.evaluatedColor[r]=[o.r,o.g,o.b,a],i.evaluatedRMEA[r][0]=e.paint.get("model-roughness").evaluate(t,{},s),i.evaluatedRMEA[r][2]=e.paint.get("model-emissive-strength").evaluate(t,{},s),i.evaluatedRMEA[r][3]=o.a,i.emissionHeightBasedParams[r]=e.paint.get("model-height-based-emissive-strength-multiplier").evaluate(t,{},s),!i.hasTranslucentParts&&o.a<1&&(i.hasTranslucentParts=!0);}delete t.properties.part,Hv(i,n!==i.evaluatedColor[2]||o!==i.evaluatedRMEA[2]);}i.evaluatedScale=e.paint.get("model-scale").evaluate(t,{},s),this.updatePbrBuffer(i.node)||(this.needsUpload=!0);}this.dirty=!1;}elevationUpdate(e,t,i,r){const n=e.findDEMTileFor(i);if(n&&(n.tileID.canonical!==this.terrainTile||t!==this.terrainExaggeration)){if(n.dem&&n.tileID.overscaledZ!==this.elevationReadFromZ){this.elevationReadFromZ=n.tileID.overscaledZ;const t=Jm.create(e,i,n);if(!t)return;4&this.modelTraits&&this.updateDEM(e,t,i,r);for(const e of this.getNodesInfo()){const i=e.node;if(!i.footprint||!i.footprint.vertices||!i.footprint.vertices.length)continue;const r=i.footprint.vertices;let n=t.getElevationAt(r[0].x,r[0].y,!0,!0);for(let e=1;e<r.length;e++)n=Math.min(n,t.getElevationAt(r[e].x,r[e].y,!0,!0));i.elevation=n;}}this.terrainTile=n.tileID.canonical,this.terrainExaggeration=t;}}updateDEM(e,t,i,r){let n=t._dem._modifiedForSources[r];if(void 0===n&&(t._dem._modifiedForSources[r]=[],n=t._dem._modifiedForSources[r]),n.includes(i.canonical))return;const o=t._dem.dim;n.push(i.canonical);let s=!1;for(const e of this.getNodesInfo()){const i=e.node;if(!i.footprint||!i.footprint.grid)continue;const r=i.footprint.grid,n=t.tileCoordToPixel(r.min.x,r.min.y),a=t.tileCoordToPixel(r.max.x,r.max.y),l=Math.min(Math.min(o-a.y,n.x),Math.min(n.y,o-a.x));if(l<0)continue;const c=z(l,2,5);let h=Math.max(0,n.x-c),u=Math.max(0,n.y-c),d=Math.min(a.x+c,o-1),p=Math.min(a.y+c,o-1);for(let e=u;e<=p;++e)for(let t=h;t<=d;++t)Vv[e*o+t]=255;let f=0,m=0;for(let e=0;e<r.cellsY;++e)for(let i=0;i<r.cellsX;++i){if(!r.cells[e*r.cellsX+i])continue;const n=t.tileCoordToPixel(r.min.x+i/r.xScale,r.min.y+e/r.yScale),s=t.tileCoordToPixel(r.min.x+(i+1)/r.xScale,r.min.y+(e+1)/r.yScale);for(let e=n.y;e<=Math.min(s.y+1,o-1);++e)for(let i=n.x;i<=Math.min(s.x+1,o-1);++i)255===Vv[e*o+i]&&(Vv[e*o+i]=0,f+=t.getElevationAtPixel(i,e),m++);}const _=f/m;h=Math.max(1,n.x-c),u=Math.max(1,n.y-c),d=Math.min(a.x+c,o-2),p=Math.min(a.y+c,o-2),s=!0;for(let e=u;e<=p;++e)for(let i=h;i<=d;++i)0===Vv[e*o+i]&&(Uv[e*o+i]=t._dem.set(i,e,_));for(let e=1;e<c;++e){h=Math.max(1,n.x-e),u=Math.max(1,n.y-e),d=Math.min(a.x+e,o-2),p=Math.min(a.y+e,o-2);for(let i=u;i<=p;++i)for(let r=h;r<=d;++r){const n=i*o+r;if(255===Vv[n]){let s=0,a=0,l=-1,h=-1;for(let t=-1;t<=1;++t)for(let n=-1;n<=1;++n){const c=(i+t)*o+r+n;if(Vv[c]>=e)continue;const u=Uv[c],d=Math.abs(u);d>a&&(s=u,a=d,l=n,h=t);}if(a>.1){const o=1-(e+.5*Math.abs(l*h))/c;let a=t._dem.get(r,i)+s*o;const u=t._dem.get(r+l,i+h),d=t._dem.get(r-l,i-h,!0);(a-u)*(a-d)>0&&(a=(u+d)/2),Uv[n]=t._dem.set(r,i,a),Vv[n]=e;}}}}}s&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=dt.now());}getNodesInfo(){if(!this.nodesInfo){this.nodesInfo=[];for(const e of this.nodes)this.nodesInfo.push(new qv(e));this.freeNodes();}return this.nodesInfo}freeNodes(){if(this.nodes){for(const e of this.nodes)Lv(e);this.nodes.splice(0,this.nodes.length);}}destroy(){this.freeNodes();const e=this.getNodesInfo();for(const t of e)Rv(t.node),Lv(t.node);}isEmpty(){return !this.nodes.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped()),r=this.getNodesInfo();for(let e=0;e<this.nodesInfo.length;e++){const t=r[e].node;r[e].hiddenByReplacement=!!t.footprint&&!i.find((e=>e.footprint===t.footprint));}}getHeightAtTileCoord(e,t){const i=this.getNodesInfo(),r=[];for(let n=0;n<this.nodesInfo.length;n++){const o=i[n],s=o.node.meshes[0];if(e<s.aabb.min[0]||t<s.aabb.min[1]||e>s.aabb.max[0]||t>s.aabb.max[1])continue;const a=(e-s.aabb.min[0])/(s.aabb.max[0]-s.aabb.min[0])*Sv|0,l=Math.min(63,(t-s.aabb.min[1])/(s.aabb.max[1]-s.aabb.min[1])*Sv|0)*Sv+Math.min(63,a);if(!(s.heightmap[l]<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return {height:s.heightmap[l],maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new y(e,t),new y(e,t),r),r.length>0)return {height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function $v(e,t){return !e.isLightConstant&&t}function Wv(e,t,i,r,n,o,s,a){let l=(61440&t|(61440&t)>>4)>>8,c=(3840&t|(3840&t)>>4)>>4,h=240&t|(240&t)>>4;i[3]>0&&(l=Kr(l,255*i[0],i[3]),c=Kr(c,255*i[1],i[3]),h=Kr(h,255*i[2],i[3]));const u=l<<8|c,d=h<<8|Math.floor(255*r[3]),p=function(e){const t=z(e,0,2);return Math.min(Math.round(.5*t*255),255)}(r[2])<<8|15*r[0]<<4|15*r[1],f=z(n[0],0,1),m=z(n[1],0,1),_=z(n[2],0,1),g=z(n[3],0,1);let y,x,v,b;if(f!==m&&s!==o&&m!==f){const e=s-o;x=1/(e*(m-f)),v=-(o+e*f)/(e*(m-f));const t=z(n[4],-1,1);b=Math.pow(10,t),y=255*_<<8|255*g;}else y=65535,x=0,v=1,b=1;if(e.emplaceBack(u,d,p,y,x,v,b),a){const e=a.length;a.clear();for(let t=0;t<e;t++)a.emplaceBack(u,d,p,y,x,v,b);}}function Hv(e,t){const i=e.node;let r=0;for(const n of i.meshes){if(i.lights&&i.lightMeshIndex===r)continue;if(!n.featureData)continue;n.featureArray=new nl,n.featureArray.reserve(n.featureData.length);let o=t;for(const t of n.featureData){let r;const s=65535&t,a=(15&s)<8?15&s:0,l=t>>16&65535,c=e.evaluatedRMEA[a],h=e.evaluatedColor[a],u=e.emissionHeightBasedParams[a];if(o&&2===a&&i.lights&&(r=new nl,r.resize(10*i.lights.length)),Wv(n.featureArray,l,h,c,u,n.aabb.min[2],n.aabb.max[2],r),r&&o){o=!1;const e=i.meshes[i.lightMeshIndex];e.featureArray=r,e.featureArray._trim();}}n.featureArray._trim(),r++;}}Rs(Zv,"Tiled3dModelBucket",{omit:["layers"]}),Rs(qv,"Tiled3dModelFeature");class Xv{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[];}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[];}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e){const t=Qv(new y(0,0),new y(cr,cr),e),i=[];for(const r of this._activeRegions){if(r.hiddenByOverlap)continue;if(!Jv(t,r))continue;const n=eb(r.min,r.max,e);i.push({min:n.min,max:n.max,sourceId:this._sourceIds[r.priority],footprint:r.footprint,footprintTileId:r.tileId});}return i}setSources(e){this._setSources(e.map((e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const i of e.cache.getVisibleCoordinates()){const r=e.cache.getTile(i).buckets[e.layer];if(r)for(const e of r.getNodesInfo()){const r=e.node;r.footprint&&t.push({footprint:r.footprint,id:i.toUnwrapped()});}}return t}}))));}_addSource(e){const t=e.getFootprints();if(0!==t.length){for(const e of t){if(!e.footprint)continue;const t=Qv(e.footprint.min,e.footprint.max,e.id);this._activeRegions.push({min:t.min,max:t.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:e.id,footprint:e.footprint});}this._sourceIds.push(e.getSourceId());}}_computeReplacement(){this._activeRegions.sort(((e,t)=>e.priority-t.priority||Yv(e.min,t.min)||Yv(e.max,t.max)));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0,i=0;for(;!e&&t!==this._activeRegions.length;){const r=this._activeRegions[t],n=this._prevRegions[i];e=r.priority!==n.priority||!Kv(r,n),++t,++i;}}if(e){++this._updateTime;const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const i=t[e].priority;for(;e<t.length&&t[e].priority===i;)++e;return e};if(this._sourceIds.length>1){let t=0,i=e(t);for(;t!==i;){let r=t;const n=t;for(;r!==i;){const e=this._activeRegions[r];e.hiddenByOverlap=!1;for(let t=0;t<n;t++){const i=this._activeRegions[t];if(!i.hiddenByOverlap&&Jv(e,i)&&(e.hiddenByOverlap=ib(e.footprint,e.tileId,i.footprint,i.tileId),e.hiddenByOverlap))break}++r;}t=i,i=e(t);}}}}_setSources(e){[this._prevRegions,this._activeRegions]=[this._activeRegions,[]],this._sourceIds=[];for(let t=e.length-1;t>=0;t--)this._addSource(e[t]);this._computeReplacement();}}function Yv(e,t){return e.x-t.x||e.y-t.y}function Kv(e,t){return 0===Yv(e.min,t.min)&&0===Yv(e.max,t.max)}function Jv(e,t){return !(e.min.x>t.max.x||e.max.x<t.min.x||e.min.y>t.max.y||e.max.y<t.min.y)}function Qv(e,t,i){const r=1/cr,n=1/(1<<i.canonical.z),o=(t.x*r+i.canonical.x)*n+i.wrap,s=(t.y*r+i.canonical.y)*n;return {min:new y((e.x*r+i.canonical.x)*n+i.wrap,(e.y*r+i.canonical.y)*n),max:new y(o,s)}}function eb(e,t,i){const r=1<<i.canonical.z,n=((t.x-i.wrap)*r-i.canonical.x)*cr,o=(t.y*r-i.canonical.y)*cr;return {min:new y(((e.x-i.wrap)*r-i.canonical.x)*cr,(e.y*r-i.canonical.y)*cr),max:new y(n,o)}}function tb(e,t,i,r,n,o,s){const a=e.indices,l=e.vertices,c=[];for(let h=r;h<r+n;h+=3){const r=t[i[h+0]+o],n=t[i[h+1]+o],u=t[i[h+2]+o],d=Math.min(r.x,n.x,u.x),p=Math.max(r.x,n.x,u.x),f=Math.min(r.y,n.y,u.y),m=Math.max(r.y,n.y,u.y);c.length=0,e.grid.query(new y(d,f),new y(p,m),c);for(let e=0;e<c.length;e++){const t=c[e];if(Lp(l[a[3*t+0]],l[a[3*t+1]],l[a[3*t+2]],r,n,u,s))return !0}}return !1}function ib(e,t,i,r){if(!e||!i)return !1;let n=e.vertices;if(!t.canonical.equals(r.canonical)||t.wrap!==r.wrap){if(i.vertices.length<e.vertices.length)return ib(i,r,e,t);const o=t.canonical,s=r.canonical,a=Math.pow(2,s.z-o.z);n=e.vertices.map((e=>new y(e.x*o.x*cr*a-s.x*cr,e.y*o.y*cr*a-s.y*cr)));}return tb(i,n,e.indices,0,e.indices.length,0,0)}const rb=hm.types,nb=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius"],ob=["fill-extrusion-flood-light-ground-radius"],sb=Math.pow(2,13),ab=Math.pow(2,15)-1,lb=new y(0,1),cb=2147483648;function hb(e,t,i,r,n,o,s,a){e.emplaceBack((t<<1)+s,(i<<1)+o,(Math.floor(r*sb)<<1)+n,Math.round(a));}function ub(e,t,i,r,n,o){e.emplaceBack(t.x,t.y,(i.x<<1)+r,(i.y<<1)+n,o);}function db(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r);}class pb{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0;}}class fb{constructor(){this.centroidXY=new y(0,0),this.vertexArrayOffset=0,this.vertexCount=0,this.groundVertexArrayOffset=0,this.groundVertexCount=0,this.flags=0,this.footprintSegIdx=-1,this.footprintSegLen=0,this.polygonSegIdx=-1,this.polygonSegLen=0,this.min=new y(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new y(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0;}span(){return new y(this.max.x-this.min.x,this.max.y-this.min.y)}}class mb{constructor(){this.acc=new y(0,0),this.accCount=0,this.centroidDataIndex=0;}startRing(e,t){e.min.x===Number.MAX_VALUE&&(e.min.x=e.max.x=t.x,e.min.y=e.max.y=t.y);}appendEdge(e,t,i){this.accCount++,this.acc._add(t);let r=!!this.borders;t.x<e.min.x?(e.min.x=t.x,r=!0):t.x>e.max.x&&(e.max.x=t.x,r=!0),t.y<e.min.y?(e.min.y=t.y,r=!0):t.y>e.max.y&&(e.max.y=t.y,r=!0),((0===t.x||t.x===cr)&&t.x===i.x)!=((0===t.y||t.y===cr)&&t.y===i.y)&&this.processBorderOverlap(t,i),r&&this.checkBorderIntersection(t,i);}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,Kr(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>cr!=e.x>cr&&this.addBorderIntersection(1,Kr(t.y,e.y,(cr-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Kr(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>cr!=e.y>cr&&this.addBorderIntersection(3,Kr(t.x,e.x,(cr-t.y)/(e.y-t.y)));}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[e];t<i[0]&&(i[0]=t),t>i[1]&&(i[1]=t);}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y);}else {const i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x);}}centroid(){return 0===this.accCount?new y(0,0):new y(Math.floor(Math.max(0,this.acc.x)/this.accCount),Math.floor(Math.max(0,this.acc.y)/this.accCount))}intersectsCount(){return this.borders?this.borders.reduce(((e,t)=>e+ +(t[0]!==Number.MAX_VALUE)),0):0}}function _b(e,t){const i=e.add(t)._unit(),r=z(e.x*i.x+e.y*i.y,-1,1);var n,o,s;return n=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(n)))/4*ab*((o=e).x*(s=t).y-o.y*s.x<0?-1:1)}const gb=[e=>e.x<0,e=>e.x>cr,e=>e.y<0,e=>e.y>cr];function yb(e,t,i,r){const n=[4];if(0===r)return n;i._mult(r);const o=e.sub(i),s=t.sub(i),a=[e,t,o,s];for(let e=0;e<4;e++)for(const t of a)if(gb[e](t)){n.push(e);break}return n}class xb{constructor(e){this.vertexArray=new Ra,this.indexArray=new Wa,this.programConfigurations=new ec(e.layers,e.zoom,(e=>ob.includes(e))),this._segments=new xl,this.hiddenByLandmarkVertexArray=new ol,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new xl;}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,i,r=!1){const n=e.length;if(n>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*n,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;o!==this._segments.get().length-1&&(o++,this._segmentToGroundQuads[o]=[],this._segmentToRegionTriCounts[o]=[0,0,0,0,0]);{const t=e[0],i=e[1];a=_b(t.sub(e[n-1])._perp()._unit(),i.sub(t)._perp()._unit());}for(let l=0;l<n;l++){const c=l===n-1?0:l+1,h=e[l],u=e[c],d=e[c===n-1?0:c+1],p=u.sub(h)._perp()._unit(),f=_b(p,d.sub(u)._perp()._unit()),m=a,_=f;if(Eb(h,u,t)||r&&Mb(h,t)&&Mb(u,t)){a=f;continue}const g=s.vertexLength;ub(this.vertexArray,h,u,1,1,m),ub(this.vertexArray,h,u,1,0,m),ub(this.vertexArray,h,u,0,1,_),ub(this.vertexArray,h,u,0,0,_),s.vertexLength+=4;const y=yb(h,u,p,i);for(const e of y)this._segmentToGroundQuads[o].push({id:g,region:e}),this._segmentToRegionTriCounts[o][e]+=2,s.primitiveLength+=2;a=f;}}}prepareBorderSegments(){if(!this.hasData())return;const e=this._segments.get(),t=e.length;for(let e=0;e<t;e++)this._segmentToGroundQuads[e].sort(((e,t)=>e.region-t.region));for(let i=0;i<t;i++){const t=this._segmentToGroundQuads[i],r=e[i],n=this._segmentToRegionTriCounts[i];n.reduce(((e,t)=>e+t),0);let o=0;for(let e=0;e<=4;e++){const t=n[e];if(0!==t){let i=this.regionSegments[e];i||(i=this.regionSegments[e]=new xl);const n={vertexOffset:r.vertexOffset,primitiveOffset:r.primitiveOffset+o,vertexLength:r.vertexLength,primitiveLength:t};i.get().push(n);}o+=t;}for(let e=0;e<t.length;e++){const i=t[e].id;this.indexArray.emplaceBack(i,i+1,i+3),this.indexArray.emplaceBack(i,i+3,i+2);}}this._segmentToGroundQuads=null,this._segmentToRegionTriCounts=null,this._segments.destroy(),this._segments=null;}addPaintPropertiesData(e,t,i,r,n,o){this.hasData()&&this.programConfigurations.populatePaintArrays(this.vertexArray.length,e,t,i,r,n,o);}upload(e){this.hasData()&&(this.vertexBuffer=e.createVertexBuffer(this.vertexArray,$f.members),this.indexBuffer=e.createIndexBuffer(this.indexArray));}uploadPaintProperties(e){this.hasData()&&this.programConfigurations.upload(e);}update(e,t,i,r,n,o){this.hasData()&&this.programConfigurations.updatePaintArrays(e,t,i,r,n,o);}updateHiddenByLandmark(e){if(!this.hasData())return;const t=e.groundVertexCount+e.groundVertexArrayOffset;if(0===e.groundVertexCount)return;const i=e.flags&cb?1:0;for(let r=e.groundVertexArrayOffset;r<t;++r)this.hiddenByLandmarkVertexArray.emplace(r,i);this._needsHiddenByLandmarkUpdate=!0;}uploadHiddenByLandmark(e){this.hasData()&&this._needsHiddenByLandmarkUpdate&&(!this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexArray.length>0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Hf.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1);}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let e=0;e<=4;e++){const t=this.regionSegments[e];t&&t.destroy();}}}}class vb{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((e=>e.fqid)),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Wa,this.footprintVertices=new za,this.footprintSegments=[],this.layoutVertexArray=new Da,this.centroidVertexArray=new _l,this.indexArray=new Wa,this.programConfigurations=new ec(e.layers,e.zoom,(e=>nb.includes(e))),this.segments=new xl,this.stateDependentLayerIds=this.layers.filter((e=>e.isStateDependent())).map((e=>e.id)),this.groundEffect=new xb(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[];}populate(e,t,i,r){this.features=[],this.hasPattern=Uf("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=ap(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:n,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=gp(n,e);if(!this.layers[0]._featureFilter.filter(new oa(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:_p(n,i,r),properties:n.properties,type:n.type,patterns:{}},h=this.layoutVertexArray.length;this.hasPattern?this.features.push(Vf("fill-extrusion",this.layers,c,this.zoom,t)):this.addFeature(c,c.geometry,s,i,{},t.availableImages,r,t.brightness),t.featureIndex.insert(n,c.geometry,s,a,this.index,h);}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0;}addFeatures(e,t,i,r,n,o){for(const e of this.features){const{geometry:s}=e;this.addFeature(e,s,e.index,t,i,r,n,o);}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles();}update(e,t,i,r,n){const o=0!==Object.keys(e).length;if(o&&!this.stateDependentLayers.length)return;const s=o?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(e,t,s,i,r,n),this.groundEffect.update(e,t,s,i,r,n);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Yf),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Xf.members,!0)),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0;}uploadCentroid(e){this.groundEffect.uploadHiddenByLandmark(e),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Wf.members,!0):this.centroidVertexBuffer&&this.centroidVertexBuffer.updateData(this.centroidVertexArray),this.needsCentroidUpdate=!1);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.groundEffect.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}addFeature(e,t,i,r,n,o,s,a){const l=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(e,{})/this.tileToMeter,c=[new y(0,0),new y(cr,cr)],h=s.projection,u="globe"===h.name,d="Polygon"===rb[e.type],p=new mb;p.centroidDataIndex=this.centroidData.length;const f=new fb,m=this.layers[0].paint.get("fill-extrusion-base").evaluate(e,{},r)<=0,_=this.layers[0].paint.get("fill-extrusion-height").evaluate(e,{},r);f.height=_,f.vertexArrayOffset=this.layoutVertexArray.length,f.groundVertexArrayOffset=this.groundEffect.vertexArray.length,u&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Fa);const g=Ff(t,500);for(let e=g.length-1;e>=0;e--){const t=g[e];(0===t.length||(x=t[0]).every((e=>e.x<=0))||x.every((e=>e.x>=cr))||x.every((e=>e.y<=0))||x.every((e=>e.y>=cr)))&&g.splice(e,1);}var x;let v;if(u)v=Cb(g,c,r);else {v=[];for(const e of g)v.push({polygon:e,bounds:c});}const b=d?this.edgeRadius:0,w=b>0&&this.zoom<17,T=(e,t)=>{if(0===e.length)return !1;const i=e[e.length-1];return t.x===i.x&&t.y===i.y};for(const{polygon:e,bounds:t}of v){let i=0,n=0;for(const t of e)d&&!t[0].equals(t[t.length-1])&&t.push(t[0]),n+=d?t.length-1:t.length;const o=this.segments.prepareSegment((d?5:4)*n,this.layoutVertexArray,this.indexArray);f.footprintSegIdx<0&&(f.footprintSegIdx=this.footprintSegments.length),f.polygonSegIdx<0&&(f.polygonSegIdx=this.polygonSegments.length);const s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},a=new pb;if(a.vertexOffset=this.footprintVertices.length,a.indexOffset=3*this.footprintIndices.length,a.ringIndices=[],d){const n=[],s=[];i=o.vertexLength;for(let i=0;i<e.length;i++){const c=e[i];c.length&&0!==i&&s.push(n.length/2);const d=[];let p,f;p=c[1].sub(c[0])._perp()._unit(),a.ringIndices.push(c.length-1);for(let e=1;e<c.length;e++){const t=c[e],i=c[e===c.length-1?1:e+1],s=t.clone();if(b){f=i.sub(t)._perp()._unit();const e=p.add(f)._unit(),r=b*Math.min(4,1/(p.x*e.x+p.y*e.y));s.x+=r*e.x,s.y+=r*e.y,s.x=Math.round(s.x),s.y=Math.round(s.y),p=f;}!m||0!==b&&!w||T(d,s)||d.push(s),hb(this.layoutVertexArray,s.x,s.y,0,0,1,1,0),o.vertexLength++,this.footprintVertices.emplaceBack(t.x,t.y),n.push(t.x,t.y),u&&db(this.layoutVertexExtArray,h.projectTilePoint(s.x,s.y,r),h.upVector(r,s.x,s.y));}m&&(0===b||w)&&(0!==d.length&&T(d,d[0])&&d.pop(),this.groundEffect.addData(d,t,l));}const c=Bf(n,s);for(let e=0;e<c.length;e+=3)this.footprintIndices.emplaceBack(a.vertexOffset+c[e+0],a.vertexOffset+c[e+1],a.vertexOffset+c[e+2]),this.indexArray.emplaceBack(i+c[e],i+c[e+2],i+c[e+1]),o.primitiveLength++;a.indexCount+=c.length,a.vertexCount+=this.footprintVertices.length-a.vertexOffset;}for(let n=0;n<e.length;n++){const s=e[n];p.startRing(f,s[0]);let a=s.length>4&&Ab(s[s.length-2],s[0],s[1]),c=b?wb(s[s.length-2],s[0],s[1],b):0;const _=[];let g,y,x;y=s[1].sub(s[0])._perp()._unit();let v=!0;for(let e=1,n=0;e<s.length;e++){let l=s[e-1],d=s[e];const w=s[e===s.length-1?1:e+1];if(p.appendEdge(f,d,l),Eb(d,l,t)){b&&(y=w.sub(d)._perp()._unit(),v=!v);continue}const E=d.sub(l)._perp(),M=E.x/(Math.abs(E.x)+Math.abs(E.y)),A=E.y>0?1:0,S=l.dist(d);if(n+S>32768&&(n=0),b){x=w.sub(d)._perp()._unit();let e=Tb(l,d,w,bb(y,x),b);isNaN(e)&&(e=0);const t=d.sub(l)._unit();l=l.add(t.mult(c))._round(),d=d.add(t.mult(-e))._round(),c=e,y=x,m&&this.zoom>=17&&(T(_,l)||_.push(l),T(_,d)||_.push(d));}const I=o.vertexLength,C=s.length>4&&Ab(l,d,w);let z=Sb(n,a,v);if(hb(this.layoutVertexArray,l.x,l.y,M,A,0,0,z),hb(this.layoutVertexArray,l.x,l.y,M,A,0,1,z),n+=S,z=Sb(n,C,!v),a=C,hb(this.layoutVertexArray,d.x,d.y,M,A,0,0,z),hb(this.layoutVertexArray,d.x,d.y,M,A,0,1,z),o.vertexLength+=4,this.indexArray.emplaceBack(I+0,I+1,I+2),this.indexArray.emplaceBack(I+1,I+3,I+2),o.primitiveLength+=2,b){const r=i+(1===e?s.length-2:e-2),n=1===e?i:r+1;if(this.indexArray.emplaceBack(I+1,r,I+3),this.indexArray.emplaceBack(r,n,I+3),o.primitiveLength+=2,void 0===g&&(g=I),!Eb(w,s[e],t)){const t=e===s.length-1?g:o.vertexLength;this.indexArray.emplaceBack(I+2,I+3,t),this.indexArray.emplaceBack(I+3,t+1,t),this.indexArray.emplaceBack(I+3,n,t+1),o.primitiveLength+=3;}v=!v;}if(u){const e=this.layoutVertexExtArray,t=h.projectTilePoint(l.x,l.y,r),i=h.projectTilePoint(d.x,d.y,r),n=h.upVector(r,l.x,l.y),o=h.upVector(r,d.x,d.y);db(e,t,n),db(e,t,n),db(e,i,o),db(e,i,o);}}d&&(i+=s.length-1),m&&b&&this.zoom>=17&&(0!==_.length&&T(_,_[0])&&_.pop(),this.groundEffect.addData(_,t,l,b>0));}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++f.footprintSegLen,++f.polygonSegLen;}if(f.vertexCount=this.layoutVertexArray.length-f.vertexArrayOffset,f.groundVertexCount=this.groundEffect.vertexArray.length-f.groundVertexArrayOffset,0!==f.vertexCount){if(f.centroidXY=p.borders?lb:this.encodeCentroid(p,f),this.centroidData.push(f),p.borders){this.featuresOnBorder.push(p);const e=this.featuresOnBorder.length-1;for(let t=0;t<p.borders.length;t++)p.borders[t][0]!==Number.MAX_VALUE&&this.borderFeatureIndices[t].push(e);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r,a),this.groundEffect.addPaintPropertiesData(e,i,n,o,r,a),this.maxHeight=Math.max(this.maxHeight,_);}}sortBorders(){for(let e=0;e<this.borderFeatureIndices.length;e++)this.borderFeatureIndices[e].sort(((t,i)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0]));}splitToSubtiles(){const e=[];for(let t=0;t<this.centroidData.length;t++){const i=this.centroidData[t],r=+(i.min.y+i.max.y>cr),n=2*r+(+(i.min.x+i.max.x>cr)^r);for(let r=0;r<i.polygonSegLen;r++){const o=i.polygonSegIdx+r;e.push({centroidIdx:t,subtile:n,polygonSegmentIdx:o,triangleSegmentIdx:this.polygonSegments[o].triangleSegIdx});}}const t=new Wa;e.sort(((e,t)=>e.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx));let i=0,r=0,n=0;for(const t of e){if(t.triangleSegmentIdx!==i)break;n++;}const o=e.length;for(;r!==e.length;){i=e[r].triangleSegmentIdx;let s=0,a=r,l=r;for(let t=a;t<n&&e[t].subtile===s;t++)l++;for(;a!==n;){const r=e[a];s=r.subtile;const o=this.centroidData[r.centroidIdx].min.clone(),c=this.centroidData[r.centroidIdx].max.clone(),h={vertexOffset:this.segments.segments[i].vertexOffset,primitiveOffset:t.length,vertexLength:this.segments.segments[i].vertexLength,primitiveLength:0,sortKey:void 0,vaos:{}};for(let i=a;i<l;i++){const r=e[i],n=this.polygonSegments[r.polygonSegmentIdx],s=this.centroidData[r.centroidIdx].min,a=this.centroidData[r.centroidIdx].max,l=this.indexArray.uint16;for(let e=n.triangleArrayOffset;e<n.triangleArrayOffset+n.triangleCount;e++)t.emplaceBack(l[3*e],l[3*e+1],l[3*e+2]);h.primitiveLength+=n.triangleCount,o.x=Math.min(o.x,s.x),o.y=Math.min(o.y,s.y),c.x=Math.max(c.x,a.x),c.y=Math.max(c.y,a.y);}h.primitiveLength>0&&this.triangleSubSegments.push({segment:h,min:o,max:c}),a=l;for(let t=a;t<n&&e[t].subtile===e[a].subtile;t++)l++;}r=n;for(let t=r;t<o&&e[t].triangleSegmentIdx===e[r].triangleSegmentIdx;t++)n++;}t._trim(),this.indexArray=t;}getVisibleSegments(e,t,i){let r=0,n=0;const o=1<<e.canonical.z;if(t){const i=t.getMinMaxForTile(e);i&&(r=i.min,n=i.max);}n+=this.maxHeight;const s=e.toUnwrapped();let a;const l=[s.canonical.x/o+s.wrap,s.canonical.y/o],c=[(s.canonical.x+1)/o+s.wrap,(s.canonical.y+1)/o],h=new xl,u=(e,t,i)=>[e[0]*(1-i[0])+t[0]*i[0],e[1]*(1-i[1])+t[1]*i[1]],d=[],p=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/cr,d[1]=e.min.y/cr,p[0]=e.max.x/cr,p[1]=e.max.y/cr;const t=u(l,c,d),o=u(l,c,p);if(0===new ed([t[0],t[1],r],[o[0],o[1],n]).intersectsPrecise(i)){a&&(h.segments.push(a),a=void 0);continue}const s=e.segment;a&&a.vertexOffset!==s.vertexOffset&&(h.segments.push(a),a=void 0),a?(a.vertexLength+=s.vertexLength,a.primitiveLength+=s.primitiveLength):a={vertexOffset:s.vertexOffset,primitiveLength:s.primitiveLength,vertexLength:s.vertexLength,primitiveOffset:s.primitiveOffset,sortKey:void 0,vaos:{}};}return a&&h.segments.push(a),h}encodeCentroid(e,t){const i=e.centroid(),r=t.span(),n=Math.min(7,Math.round(r.x*this.tileToMeter/10)),o=Math.min(7,Math.round(r.y*this.tileToMeter/10));return new y(z(i.x,1,cr-1)<<3|n,z(i.y,1,cr-1)<<3|o)}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=cb,t.centroidXY.x=0,t.centroidXY.y=0,this.writeCentroidToBuffer(t);}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,i=e.vertexCount+e.vertexArrayOffset,r=e.flags&cb?lb:e.centroidXY,n=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==r.y||n!==r.x){for(let e=t;e<i;++e)this.centroidVertexArray.emplace(e,r.x,r.y);this.needsCentroidUpdate=!0;}}createCentroidsBuffer(){this.centroidVertexArray.resize(this.layoutVertexArray.length),this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const e of this.centroidData)this.writeCentroidToBuffer(e);}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped());if(function(e,t){if(e.length!==t.length)return !1;for(let i=0;i<e.length;i++)if(e[i].sourceId!==t[i].sourceId||!Kv(e[i],t[i]))return !1;return !0}(this.activeReplacements,i))return;if(this.activeReplacements=i,0===this.centroidVertexArray.length)this.createCentroidsBuffer();else for(const e of this.centroidData)e.flags&=2147483647;const r=[];for(const t of this.activeReplacements){const i=Math.pow(2,t.footprintTileId.canonical.z-e.canonical.z);for(const n of this.centroidData)if(!(n.flags&cb||t.min.x>n.max.x||n.min.x>t.max.x||t.min.y>n.max.y||n.min.y>t.max.y))for(let o=0;o<n.footprintSegLen;o++){const s=this.footprintSegments[n.footprintSegIdx+o];if(r.length=0,zb(this.footprintVertices,s.vertexOffset,s.vertexCount,t.footprintTileId.canonical,e.canonical,r),tb(t.footprint,r,this.footprintIndices.uint16,s.indexOffset,s.indexCount,-s.vertexOffset,-i)){n.flags|=cb;break}}}for(const e of this.centroidData)this.writeCentroidToBuffer(e);this.borderDoneWithNeighborZ=[-1,-1,-1,-1];}footprintContainsPoint(e,t,i){let r=!1;for(let n=0;n<i.footprintSegLen;n++){const o=this.footprintSegments[i.footprintSegIdx+n];let s=0;for(const i of o.ringIndices){for(let n=s,a=i+s-1;n<i+s;a=n++){const i=this.footprintVertices.int16[2*(n+o.vertexOffset)+0],s=this.footprintVertices.int16[2*(n+o.vertexOffset)+1],l=this.footprintVertices.int16[2*(a+o.vertexOffset)+1];s>t!=l>t&&e<(this.footprintVertices.int16[2*(a+o.vertexOffset)+0]-i)*(t-s)/(l-s)+i&&(r=!r);}s=i;}}return r}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,r=!0;const n=4*(e+cr)*cr+(t+cr);if(this.partLookup.hasOwnProperty(n)){const e=this.partLookup[n];return e?{height:e.height,hidden:!!(e.flags&cb)}:void 0}for(const o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||this.footprintContainsPoint(e,t,o)&&o&&o.height>i&&(i=o.height,this.partLookup[n]=o,r=!!(o.flags&cb));if(i!==Number.NEGATIVE_INFINITY)return {height:i,hidden:r};this.partLookup[n]=void 0;}}function bb(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function wb(e,t,i,r){const n=t.sub(e)._perp()._unit(),o=i.sub(t)._perp()._unit();return Tb(e,t,i,bb(n,o),r)}function Tb(e,t,i,r,n){const o=Math.sqrt(1-r*r);return Math.min(e.dist(t)/3,t.dist(i)/3,n*o/r)}function Eb(e,t,i){return e.x<i[0].x&&t.x<i[0].x||e.x>i[1].x&&t.x>i[1].x||e.y<i[0].y&&t.y<i[0].y||e.y>i[1].y&&t.y>i[1].y}function Mb(e,t){return e.x<t[0].x||e.x>t[1].x||e.y<t[0].y||e.y>t[1].y}function Ab(e,t,i){if(e.x<0||e.x>=cr||t.x<0||t.x>=cr||i.x<0||i.x>=cr)return !1;const r=i.sub(t),n=r.perp(),o=e.sub(t);return (r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&n.x*o.x+n.y*o.y<0}function Sb(e,t,i){const r=t?2|e:-3&e;return i?1|r:-2&r}function Ib(){const e=Math.PI/32,t=Math.tan(e),i=qd;return i*Math.sqrt(1+2*t*t)-i}function Cb(e,t,i){const r=1<<i.z,n=ep(i.x/r),o=ep((i.x+1)/r),s=tp(i.y/r),a=tp((i.y+1)/r);return function(e,t,i,r,n=0,o){const s=[];if(!e.length||!i||!r)return s;const a=(e,t)=>{for(const i of e)s.push({polygon:i,bounds:t});},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(r)),h=l-c,u=[];for(let e=0;e<Math.abs(h);e++)u.push(h>0?0:1);for(let e=0;e<Math.min(l,c);e++)u.push(0),u.push(1);let d=e;if(d=um(d,t[0].y-n,t[1].y+n,1),d=um(d,t[0].x-n,t[1].x+n,0),!d.length)return s;const p=[];for(u.length?p.push({polygons:d,bounds:t,depth:0}):a(d,t);p.length;){const e=p.pop(),t=e.depth,i=u[t],r=e.bounds[0],s=e.bounds[1],l=0===i?r.x:r.y,c=0===i?s.x:s.y,h=o?o(i,l,c):.5*(l+c),d=um(e.polygons,l-n,h+n,i),f=um(e.polygons,h-n,c+n,i);if(d.length){const e=[r,new y(0===i?h:s.x,1===i?h:s.y)];u.length>t+1?p.push({polygons:d,bounds:e,depth:t+1}):a(d,e);}if(f.length){const e=[new y(0===i?h:r.x,1===i?h:r.y),s];u.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):a(f,e);}}return s}(e,t,Math.ceil((o-n)/11.25),Math.ceil((s-a)/11.25),1,((e,t,n)=>{if(0===e)return .5*(t+n);{const e=tp((i.y+t/cr)/r);return (Jd(.5*(tp((i.y+n/cr)/r)+e))*r-i.y)*cr}}))}function zb(e,t,i,r,n,o){const s=Math.pow(2,r.z-n.z);for(let a=0;a<i;a++){let i=e.int16[2*(a+t)+0],l=e.int16[2*(a+t)+1];i=(i+n.x*cr)*s-r.x*cr,l=(l+n.y*cr)*s-r.y*cr,o.push(new y(i,l));}}Rs(vb,"FillExtrusionBucket",{omit:["layers","features"]}),Rs(fb,"PartData"),Rs(pb,"FootprintSegment"),Rs(mb,"BorderCentroidData"),Rs(xb,"GroundEffect");const Pb=new ga({visibility:new fa(Pt["layout_fill-extrusion"].visibility),"fill-extrusion-edge-radius":new fa(Pt["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var Db={paint:new ga({"fill-extrusion-opacity":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new ma(Pt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new ma(Pt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new ma(Pt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new ma(Pt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-ambient-occlusion-wall-radius":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-wall-radius"]),"fill-extrusion-ambient-occlusion-ground-radius":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-radius"]),"fill-extrusion-ambient-occlusion-ground-attenuation":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-ground-attenuation"]),"fill-extrusion-flood-light-color":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-flood-light-color"]),"fill-extrusion-flood-light-intensity":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-flood-light-intensity"]),"fill-extrusion-flood-light-wall-radius":new ma(Pt["paint_fill-extrusion"]["fill-extrusion-flood-light-wall-radius"]),"fill-extrusion-flood-light-ground-radius":new ma(Pt["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-radius"]),"fill-extrusion-flood-light-ground-attenuation":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-flood-light-ground-attenuation"]),"fill-extrusion-vertical-scale":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-vertical-scale"]),"fill-extrusion-rounded-roof":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-rounded-roof"]),"fill-extrusion-cutoff-fade-range":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-cutoff-fade-range"]),"fill-extrusion-emissive-strength":new fa(Pt["paint_fill-extrusion"]["fill-extrusion-emissive-strength"])}),layout:Pb};class Rb extends y{constructor(e,t,i){super(e,t),this.z=i;}}function Lb(e,t){return e.x*t.x+e.y*t.y}function kb(e,t){if(1===e.length){let i=0;const r=t[i++];let n;for(;!n||r.equals(n);)if(n=t[i++],!n)return 1/0;for(;i<t.length;i++){const o=t[i],s=e[0],a=n.sub(r),l=o.sub(r),c=s.sub(r),h=Lb(a,a),u=Lb(a,l),d=Lb(l,l),p=Lb(c,a),f=Lb(c,l),m=h*d-u*u,_=(d*p-u*f)/m,g=(h*f-u*p)/m,y=r.z*(1-_-g)+n.z*_+o.z*g;if(isFinite(y))return y}return 1/0}{let e=1/0;for(const i of t)e=Math.min(e,i.z);return e}}function Ob(e,t,i,r,n,o,s,a){const l=s*n.getElevationAt(e,t,!0,!0),c=0!==o[0],h=c?0===o[1]?s*(o[0]/7-450):s*function(e,t,i){const r=Math.floor(t[0]/8),n=Math.floor(t[1]/8),o=10*(t[0]-8*r),s=10*(t[1]-8*n),a=e.getElevationAt(r,n,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),h=Math.floor(.5*(s*l-1)),u=e.tileCoordToPixel(r,n),d=2*c+1,p=2*h+1,f=function(e,t,i,r,n){return [e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+n,i,!0),e.getElevationAtPixel(t,i+n,!0),e.getElevationAtPixel(t+r,i+n,!0)]}(e,u.x-c,u.y-h,d,p),m=Math.abs(f[0]-f[1]),_=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),y=Math.min(.25,.5*l*(m+_)/d),x=Math.min(.25,.5*l*g/p);return a+Math.max(y*o,x*s)}(n,o,a):l;return {base:l+(0===i)?-1:i,top:c?Math.max(h+r,l+i+2):l+r}}const Bb=new ga({"line-cap":new ma(Pt.layout_line["line-cap"]),"line-join":new ma(Pt.layout_line["line-join"]),"line-miter-limit":new fa(Pt.layout_line["line-miter-limit"]),"line-round-limit":new fa(Pt.layout_line["line-round-limit"]),"line-sort-key":new ma(Pt.layout_line["line-sort-key"]),visibility:new fa(Pt.layout_line.visibility)});var Fb={paint:new ga({"line-opacity":new ma(Pt.paint_line["line-opacity"]),"line-color":new ma(Pt.paint_line["line-color"]),"line-translate":new fa(Pt.paint_line["line-translate"]),"line-translate-anchor":new fa(Pt.paint_line["line-translate-anchor"]),"line-width":new ma(Pt.paint_line["line-width"]),"line-gap-width":new ma(Pt.paint_line["line-gap-width"]),"line-offset":new ma(Pt.paint_line["line-offset"]),"line-blur":new ma(Pt.paint_line["line-blur"]),"line-dasharray":new ma(Pt.paint_line["line-dasharray"]),"line-pattern":new ma(Pt.paint_line["line-pattern"]),"line-gradient":new _a(Pt.paint_line["line-gradient"]),"line-trim-offset":new fa(Pt.paint_line["line-trim-offset"]),"line-emissive-strength":new fa(Pt.paint_line["line-emissive-strength"]),"line-border-width":new ma(Pt.paint_line["line-border-width"]),"line-border-color":new ma(Pt.paint_line["line-border-color"])}),layout:Bb};const Nb=(e,t,i,r,n,o,s)=>{const a=e.transform,l=a.calculatePixelsToTileUnitsMatrix(t);return {u_matrix:jb(e,t,i,r),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:qb(i)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Vb(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:s,u_emissive_strength:i.paint.get("line-emissive-strength")}},Ub=(e,t,i,r,n)=>{const o=e.transform;return {u_matrix:jb(e,t,i,r),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:o.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:n,u_image:0,u_tile_units_to_pixels:Vb(t,o),u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Vb(e,t){return 1/rv(e,1,t.tileZoom)}function jb(e,t,i,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Gb=e=>{const t=[];qb(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");return 0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER"),t};function qb(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const Zb=new class extends ma{possiblyEvaluate(e,t){return t=new oa(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=k({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}(Fb.paint.properties["line-width"].specification);function $b(e,t){return t>0?t+2*e:e}Zb.useIntegerZoom=!0;const Wb=new ga({visibility:new fa(Pt.layout_background.visibility)});var Hb={paint:new ga({"background-color":new fa(Pt.paint_background["background-color"]),"background-pattern":new fa(Pt.paint_background["background-pattern"]),"background-opacity":new fa(Pt.paint_background["background-opacity"]),"background-emissive-strength":new fa(Pt.paint_background["background-emissive-strength"])}),layout:Wb};const Xb=new ga({visibility:new fa(Pt.layout_raster.visibility)});var Yb={paint:new ga({"raster-opacity":new fa(Pt.paint_raster["raster-opacity"]),"raster-color":new _a(Pt.paint_raster["raster-color"]),"raster-color-mix":new fa(Pt.paint_raster["raster-color-mix"]),"raster-color-range":new fa(Pt.paint_raster["raster-color-range"]),"raster-hue-rotate":new fa(Pt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new fa(Pt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new fa(Pt.paint_raster["raster-brightness-max"]),"raster-saturation":new fa(Pt.paint_raster["raster-saturation"]),"raster-contrast":new fa(Pt.paint_raster["raster-contrast"]),"raster-resampling":new fa(Pt.paint_raster["raster-resampling"]),"raster-fade-duration":new fa(Pt.paint_raster["raster-fade-duration"]),"raster-emissive-strength":new fa(Pt.paint_raster["raster-emissive-strength"]),"raster-array-band":new fa(Pt.paint_raster["raster-array-band"]),"raster-elevation":new fa(Pt.paint_raster["raster-elevation"])}),layout:Xb};function Kb(e,t,i,r,n,o,s,a){const l=[e,i,n,t,r,o,1,1,1],c=[s,a,1],h=Eu.adjoint([],l),[u,d,p]=Du.transformMat3(c,c,Eu.transpose(h,h));return Eu.multiply(l,[u,0,0,0,d,0,0,0,p],l)}class Jb extends zt{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.onNorthPole=!1,this.onSouthPole=!1,this.setEventedParent(r),this.options=t,this._dirty=!1;}load(e,i){if(this._loaded=i||!1,this.fire(new It("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Ie(this.map._requestManager.transformRequest(this.url,ye.Image),((i,r)=>{if(this._imageRequest=null,this._loaded=!0,i)this.fire(new Ct(i));else if(r){const{HTMLImageElement:i}=t;this.image=r instanceof i?dt.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading();}}));}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Ay(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new It("data",{dataType:"source",sourceDataType:"metadata"})));}onAdd(e){this.map=e,this.load();}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Ay||this.texture.destroy();}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],i=e[0][1];for(const r of e)r[1]>i&&(i=r[1]),r[1]<t&&(t=r[1]);const r=(i+t)/2;if(r>rp?this.onNorthPole=!0:r<-rp&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(lp.fromLngLat);this.tileID=function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);const o=Math.max(r-t,n-i),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);return new ju(s,Math.floor((t+r)/2*a),Math.floor((i+n)/2*a))}(t),this.minzoom=this.maxzoom=this.tileID.z;}return this.fire(new It("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0;}_prepareData(e){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture);}if(this._boundsArray)return;const t=Pg(this.tileID,this.map.transform.projection),[i,r,n,o]=this.coordinates.map((e=>{const i=t.projection.project(e[0],e[1]);return Rg(t,i)._round()}));this.perspectiveTransform=function(e,t,i,r,n,o,s,a,l,c){const h=Kb(0,0,e,0,0,t,e,t),u=Kb(i,r,n,o,s,a,l,c);return Eu.multiply(u,Eu.adjoint(h,h),u),[u[6]/u[8]*e/cr,u[7]/u[8]*t/cr]}(this.width,this.height,i.x,i.y,r.x,r.y,o.x,o.y,n.x,n.y);const s=this._boundsArray=new Da;s.emplaceBack(i.x,i.y,0,0),s.emplaceBack(r.x,r.y,cr,0),s.emplaceBack(o.x,o.y,0,cr),s.emplaceBack(n.x,n.y,cr,cr),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(s,Ly.members),this.boundsSegments=xl.simpleSegment(0,0,4,2);}prepare(){const e=0!==Object.keys(this.tiles).length;if(this.tileID&&!e)return;const t=this.map.painter.context,i=t.gl;!this._dirty||this.texture instanceof Ay||(this.texture?this.texture.update(this.image):(this.texture=new My(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._dirty=!1),e&&this._prepareData(t);}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null));}serialize(){return {type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}}class Qb extends Ta{constructor(e){super(e,{}),this.implementation=e,e.slot&&(this.slot=e.slot);}is3D(){return "3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isLayerDraped(e){return void 0!==this.implementation.renderToTile}shouldRedrape(){return !!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl);}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl);}}const ew=new ga({visibility:new fa(Pt.layout_sky.visibility)});var tw={paint:new ga({"sky-type":new fa(Pt.paint_sky["sky-type"]),"sky-atmosphere-sun":new fa(Pt.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new fa(Pt.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new fa(Pt.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new fa(Pt.paint_sky["sky-gradient-radius"]),"sky-gradient":new _a(Pt.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new fa(Pt.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new fa(Pt.paint_sky["sky-atmosphere-color"]),"sky-opacity":new fa(Pt.paint_sky["sky-opacity"])}),layout:ew};function iw(e,t,i){const r=[0,0,1],n=Iu.identity([]);return Iu.rotateY(n,n,i?-w(e)+Math.PI:w(e)),Iu.rotateX(n,n,-w(t)),Du.transformQuat(r,r,n),Du.normalize(r,r)}var rw={paint:new ga({})};const nw={circle:class extends Ta{constructor(e,t){super(e,Up,t);}createBucket(e){return new vp(e)}queryRadius(e){const t=e;return kp("circle-radius",this,t)+kp("circle-stroke-width",this,t)+Op(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,i,r,n,o,s,a){const l=Fp(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i);return qp(e,r,o,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return ["circle"]}getDefaultProgramParams(e,t){const i=Gp(this);return {config:new Ql(this,t),defines:i,overrideFog:!1}}},heatmap:class extends Ta{createBucket(e){return new Xp(e)}constructor(e,t){super(e,nf,t),this._updateColorRamp();}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp();}_updateColorRamp(){this.colorRamp=of({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null;}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null);}queryRadius(e){return kp("heatmap-radius",this,e)}queryIntersectsFeature(e,t,i,r,n,o,s,a){const l=this.paint.get("heatmap-radius").evaluate(t,i);return qp(e,r,o,s,a,!0,!0,new y(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return ["heatmap","heatmapTexture"]}getDefaultProgramParams(e,t){return "heatmap"===e?{config:new Ql(this,t),overrideFog:!1}:{}}},hillshade:class extends Ta{constructor(e,t){super(e,af,t);}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return ["hillshade","hillshadePrepare"]}getDefaultProgramParams(e,t){return {overrideFog:!1}}},fill:class extends Ta{constructor(e,t){super(e,qf,t);}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),i=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getDefaultProgramParams(e,t){return {config:new Ql(this,t),overrideFog:!1}}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"]);}createBucket(e){return new jf(e)}queryRadius(){return Op(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,i,r,n,o){return !e.queryGeometry.isAboveHorizon&&Tp(Bp(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),r)}isTileClipped(){return !0}},"fill-extrusion":class extends Ta{constructor(e,t){super(e,Db,t),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0};}createBucket(e){return new vb(e)}queryRadius(){return Op(this.paint.get("fill-extrusion-translate"))}is3D(){return !0}hasShadowPass(){return !0}cutoffRange(){return this.paint.get("fill-extrusion-cutoff-fade-range")}canCastShadows(){return !0}getProgramIds(){return [this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}queryIntersectsFeature(e,t,i,r,n,o,s,a,l){const c=Fp(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),h=this.paint.get("fill-extrusion-height").evaluate(t,i),u=this.paint.get("fill-extrusion-base").evaluate(t,i),d=[0,0],p=a&&o.elevation,f=o.elevation?o.elevation.exaggeration():1,m=e.tile.getBucket(this);if(p&&m instanceof vb){const e=m.centroidVertexArray,t=l+1;t<e.length&&(d[0]=e.geta_centroid_pos0(t),d[1]=e.geta_centroid_pos1(t));}if(0===d[0]&&1===d[1])return !1;"globe"===o.projection.name&&(r=Cb([r],[new y(0,0),new y(cr,cr)],e.tileID.canonical).map((e=>e.polygon)).flat());const _=p?a:null,[g,x]=function(e,t,i,r,n,o,s,a,l,c,h){return "globe"===e.projection.name?function(e,t,i,r,n,o,s,a,l,c,h){const u=[],d=[],p=e.projection.upVectorScale(h,e.center.lat,e.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],_=(e,t,i,r)=>{e[0]=t,e[1]=i,e[2]=r,e[3]=1;},g=Ib();i>0&&(i+=g),r+=g;for(const g of t){const t=[],y=[];for(const u of g){const d=u.x+n.x,g=u.y+n.y,x=e.projection.projectTilePoint(d,g,h),v=e.projection.upVector(h,u.x,u.y);let b=i,w=r;if(s){const e=Ob(d,g,i,r,s,a,l,c);b+=e.base,w+=e.top;}0!==i?_(f,x.x+v[0]*p*b,x.y+v[1]*p*b,x.z+v[2]*p*b):_(f,x.x,x.y,x.z),_(m,x.x+v[0]*p*w,x.y+v[1]*p*w,x.z+v[2]*p*w),Du.transformMat4(f,f,o),Du.transformMat4(m,m,o),t.push(new Rb(f[0],f[1],f[2])),y.push(new Rb(m[0],m[1],m[2]));}u.push(t),d.push(y);}return [u,d]}(e,t,i,r,n,o,s,a,l,c,h):s?function(e,t,i,r,n,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of e){const e=[],p=[];for(const c of d){const h=c.x+r.x,d=c.y+r.y,f=Ob(h,d,t,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,yu.transformMat4(u,u,n),u[3]=Math.max(u[3],1e-5);const m=new Rb(u[0]/u[3],u[1]/u[3],u[2]/u[3]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,yu.transformMat4(u,u,n),u[3]=Math.max(u[3],1e-5);const _=new Rb(u[0]/u[3],u[1]/u[3],u[2]/u[3]);e.push(m),p.push(_);}c.push(e),h.push(p);}return [c,h]}(t,i,r,n,o,s,a,l,c):function(e,t,i,r,n){const o=[],s=[],a=n[8]*t,l=n[9]*t,c=n[10]*t,h=n[11]*t,u=n[8]*i,d=n[9]*i,p=n[10]*i,f=n[11]*i;for(const t of e){const e=[],i=[];for(const o of t){const t=o.x+r.x,s=o.y+r.y,m=n[0]*t+n[4]*s+n[12],_=n[1]*t+n[5]*s+n[13],g=n[2]*t+n[6]*s+n[14],y=n[3]*t+n[7]*s+n[15],x=m+a,v=_+l,b=g+c,w=Math.max(y+h,1e-5),T=m+u,E=_+d,M=g+p,A=Math.max(y+f,1e-5);e.push(new Rb(x/w,v/w,b/w)),i.push(new Rb(T/A,E/A,M/A));}o.push(e),s.push(i);}return [o,s]}(t,i,r,n,o)}(o,r,u,h,c,s,_,d,f,o.center.lat,e.tileID.canonical),v=e.queryGeometry;return function(e,t,i){let r=1/0;Tp(i,t)&&(r=kb(i,t[0]));for(let n=0;n<t.length;n++){const o=t[n],s=e[n];for(let e=0;e<o.length-1;e++){const t=o[e],n=[t,o[e+1],s[e+1],s[e],t];bp(i,n)&&(r=Math.min(r,kb(i,n)));}}return r!==1/0&&r}(g,x,v.isPointQuery()?v.screenBounds:v.screenGeometry)}},line:class extends Ta{constructor(e,t){super(e,Fb,t),this.gradientVersion=0;}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Yr,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER;}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Zb.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e);}createBucket(e){return new Ey(e)}getProgramIds(){return [this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(e,t){const i=Gb(this);return {config:new Ql(this,t),defines:i,overrideFog:!1}}queryRadius(e){const t=e,i=$b(kp("line-width",this,t),kp("line-gap-width",this,t)),r=kp("line-offset",this,t);return i/2+Math.abs(r)+Op(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,r,n,o){if(e.queryGeometry.isAboveHorizon)return !1;const s=Bp(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),a=e.pixelToTileUnitsFactor/2*$b(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),l=this.paint.get("line-offset").evaluate(t,i);return l&&(r=function(e,t){const i=[],r=new y(0,0);for(let n=0;n<e.length;n++){const o=e[n],s=[];for(let e=0;e<o.length;e++){const i=o[e],n=o[e+1],a=0===e?r:i.sub(o[e-1])._unit()._perp(),l=e===o.length-1?r:n.sub(i)._unit()._perp(),c=a._add(l)._unit();c._mult(1/(c.x*l.x+c.y*l.y)),s.push(c._mult(t)._add(i));}i.push(s);}return i}(r,l*e.pixelToTileUnitsFactor)),function(e,t,i){for(let r=0;r<t.length;r++){const n=t[r];if(e.length>=3)for(let t=0;t<n.length;t++)if(zp(e,n[t]))return !0;if(Ep(e,n,i))return !0}return !1}(s,r,a)}isTileClipped(){return !0}},symbol:oy,background:class extends Ta{constructor(e,t){super(e,Hb,t);}getProgramIds(){return [this.paint.get("background-pattern")?"backgroundPattern":"background"]}getDefaultProgramParams(e,t){return {overrideFog:!1}}},raster:class extends Ta{constructor(e,t){super(e,Yb,t),this._updateColorRamp();}getProgramIds(){return ["raster"]}hasColorMap(){return !!this._transitionablePaint._values["raster-color"].value.value}isLayerDraped(e){return !(e&&e._source instanceof Jb)||!e._source.onNorthPole&&!e._source.onSouthPole&&0===this.paint.get("raster-elevation")}_handleSpecialPaintPropertyUpdate(e){"raster-color"!==e&&"raster-color-range"!==e||this._updateColorRamp();}_updateColorRamp(){if(!this.hasColorMap())return;const e=this._transitionablePaint._values["raster-color"].value.expression,[t,i]=this._transitionablePaint._values["raster-color-range"].value.expression.evaluate({zoom:0});this.colorRamp=of({expression:e,evaluationKey:"rasterValue",image:this.colorRamp,clips:[{start:t,end:i}],resolution:256}),this.colorRampTexture=null;}},sky:class extends Ta{constructor(e,t){super(e,tw,t),this._updateColorRamp();}_handleSpecialPaintPropertyUpdate(e){"sky-gradient"===e?this._updateColorRamp():"sky-atmosphere-sun"!==e&&"sky-atmosphere-halo-color"!==e&&"sky-atmosphere-color"!==e&&"sky-atmosphere-sun-intensity"!==e||(this._skyboxInvalidated=!0);}_updateColorRamp(){this.colorRamp=of({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null);}needsSkyboxCapture(e){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return !0;if(!this.paint.get("sky-atmosphere-sun")){const t=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return !1}getCenter(e,t){if("atmosphere"===this.paint.get("sky-type")){const i=this.paint.get("sky-atmosphere-sun"),r=!i,n=e.style.light,o=n.properties.get("position");return r&&"viewport"===n.properties.get("anchor")&&H("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),r?iw(o.azimuthal,90-o.polar,t):iw(i[0],90-i[1],t)}const i=this.paint.get("sky-gradient-center");return iw(i[0],90-i[1],t)}isSky(){return !0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position");}hasOffscreenPass(){return !0}getProgramIds(){const e=this.paint.get("sky-type");return "atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}},slot:class extends Ta{constructor(e,t){super(e,rw);}},model:class extends Ta{constructor(e,t){super(e,Nv,t);}createBucket(e){return new Bv(e)}getProgramIds(){return ["model"]}is3D(){return !0}hasShadowPass(){return !0}canCastShadows(){return !0}hasLightBeamPass(){return !0}cutoffRange(){return this.paint.get("model-cutoff-fade-range")}queryRadius(){return 0}queryIntersectsFeature(){return !1}_handleOverridablePaintPropertyUpdate(e,t,i){return !(!this.layout||t.isDataDriven()||i.isDataDriven()||"model-color"!==e&&"model-color-mix-intensity"!==e&&"model-rotation"!==e&&"model-scale"!==e&&"model-translation"!==e&&"model-emissive-strength"!==e)}_isPropertyZoomDependent(e){const t=this._transitionablePaint._values[e];return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof Ao}isZoomDependent(){return this._isPropertyZoomDependent("model-scale")||this._isPropertyZoomDependent("model-rotation")||this._isPropertyZoomDependent("model-translation")}}};function ow(e,t){return "custom"===e.type?new Qb(e):new nw[e.type](e,t)}function sw(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class aw extends zt{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0;}createScope(e){this.images[e]={},this.loaded[e]=!1,this.updatedImages[e]={},this.patterns[e]={},this.callbackDispatchedThisFrame[e]={},this.atlasImage[e]=new ef({width:1,height:1});}isLoaded(){for(const e in this.loaded)if(!this.loaded[e])return !1;return !0}setLoaded(e,t){if(this.loaded[t]!==e&&(this.loaded[t]=e,e)){for(const{ids:e,callback:i}of this.requestors)this._notify(e,t,i);this.requestors=[];}}hasImage(e,t){return !!this.getImage(e,t)}getImage(e,t){return this.images[t][e]}addImage(e,t,i){this._validate(e,i)&&(this.images[t][e]=i);}_validate(e,t){let i=!0;return this._validateStretch(t.stretchX,t.data&&t.data.width)||(this.fire(new Ct(new Error(`Image "${e}" has invalid "stretchX" value`))),i=!1),this._validateStretch(t.stretchY,t.data&&t.data.height)||(this.fire(new Ct(new Error(`Image "${e}" has invalid "stretchY" value`))),i=!1),this._validateContent(t.content,t)||(this.fire(new Ct(new Error(`Image "${e}" has invalid "content" value`))),i=!1),i}_validateStretch(e,t){if(!e)return !0;let i=0;for(const r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return !1;i=r[1];}return !0}_validateContent(e,t){return !(e&&(4!==e.length||e[0]<0||t.data.width<e[0]||e[1]<0||t.data.height<e[1]||e[2]<0||t.data.width<e[2]||e[3]<0||t.data.height<e[3]||e[2]<e[0]||e[3]<e[1]))}updateImage(e,t,i){i.version=this.images[t][e].version+1,this.images[t][e]=i,this.updatedImages[t][e]=!0;}removeImage(e,t){const i=this.images[t][e];delete this.images[t][e],delete this.patterns[t][e],i.userImage&&i.userImage.onRemove&&i.userImage.onRemove();}listImages(e){return Object.keys(this.images[e])}getImages(e,t,i){let r=!0;const n=!!this.loaded[t];if(!n)for(const i of e)this.images[t][i]||(r=!1);n||r?this._notify(e,t,i):this.requestors.push({ids:e,scope:t,callback:i});}getUpdatedImages(e){return this.updatedImages[e]}_notify(e,t,i){const r={};for(const i of e){this.images[t][i]||this.fire(new It("styleimagemissing",{id:i}));const e=this.images[t][i];e?r[i]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:H(`Image "${i}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`);}i(null,r);}getPixelSize(e){const{width:t,height:i}=this.atlasImage[e];return {width:t,height:i}}getPattern(e,t){const i=this.patterns[t][e],r=this.getImage(e,t);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else {const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},n=new Q_(i,r);this.patterns[t][e]={bin:i,position:n};}return this._updatePatternAtlas(t),this.patterns[t][e].position}bind(e,t){const i=e.gl;let r=this.atlasTexture[t];r?this.dirty&&(r.update(this.atlasImage[t]),this.dirty=!1):(r=new My(e,this.atlasImage[t],i.RGBA),this.atlasTexture[t]=r),r.bind(i.LINEAR,i.CLAMP_TO_EDGE);}_updatePatternAtlas(e){const t=[];for(const i in this.patterns[e])t.push(this.patterns[e][i].bin);const{w:i,h:r}=K_(t),n=this.atlasImage[e];n.resize({width:i||1,height:r||1});for(const t in this.patterns[e]){const{bin:i}=this.patterns[e][t],r=i.x+1,o=i.y+1,s=this.images[e][t].data,a=s.width,l=s.height;ef.copy(s,n,{x:0,y:0},{x:r,y:o},{width:a,height:l}),ef.copy(s,n,{x:0,y:l-1},{x:r,y:o-1},{width:a,height:1}),ef.copy(s,n,{x:0,y:0},{x:r,y:o+l},{width:a,height:1}),ef.copy(s,n,{x:a-1,y:0},{x:r-1,y:o},{width:1,height:l}),ef.copy(s,n,{x:0,y:0},{x:r+a,y:o},{width:1,height:l});}this.dirty=!0;}beginFrame(){for(const e in this.images)this.callbackDispatchedThisFrame[e]={};}dispatchRenderCallbacks(e,t){for(const i of e){if(this.callbackDispatchedThisFrame[t][i])continue;this.callbackDispatchedThisFrame[t][i]=!0;const e=this.images[t][i];sw(e)&&this.updateImage(i,t,e);}}}const lw=new ga({anchor:new fa(Pt.light.anchor),position:new class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return K(e.expression.evaluate(t))}interpolate(e,t,i){return {x:Kr(e.x,t.x,i),y:Kr(e.y,t.y,i),z:Kr(e.z,t.z,i),azimuthal:Kr(e.azimuthal,t.azimuthal,i),polar:Kr(e.polar,t.polar,i)}}}(Pt.light.position),color:new fa(Pt.light.color),intensity:new fa(Pt.light.intensity)});class cw extends zt{constructor(e,t="flat"){super(),this._transitionable=new la(lw),this.setLight(e,t),this._transitioning=this._transitionable.untransitioned();}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(gs,e,i)||(this._transitionable.setTransitionOrValue(e),this.id=t);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(e,t,i){return (!i||!1!==i.validate)&&Ss(this,e.call(ms,k({value:t,style:{glyphs:!0,sprite:!0},styleSpec:Pt})))}}const hw=new ga({source:new fa(Pt.terrain.source),exaggeration:new fa(Pt.terrain.exaggeration)});let uw=class extends zt{constructor(e,t,i,r){super(),this.scope=i,this._transitionable=new la(hw,r),this._transitionable.setTransitionOrValue(e,r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=t;}get(){return this._transitionable.serialize()}set(e,t){this._transitionable.setTransitionOrValue(e,t);}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}getExaggeration(e){return this._transitioning.possiblyEvaluate(new oa(e)).get("exaggeration")}isZoomDependent(){const e=this._transitionable._values.exaggeration;return null!=e&&null!=e.value&&null!=e.value.expression&&e.value.expression instanceof Ao}};const dw=45,pw=65,fw=.05;function mw(e,t,i,r){const n=P(dw,pw,i),[o,s]=_w(e,r);let a=1-Math.min(1,Math.exp((t-o)/(s-o)*-6));return a*=a*a,a=Math.min(1,1.00747*a),a*n*e.alpha}function _w(e,t){const i=.5/Math.tan(.5*t);return [e.range[0]+i,e.range[1]+i]}function gw(e,t,i,r,n){const o=Du.transformMat4([],[t,i,r],n.mercatorFogMatrix);return mw(e,Du.length(o),n.pitch,n._fov)}function yw(e,t,i,r,n,o,s){const a=[[i,r,0],[n,r,0],[n,o,0],[i,o,0]];let l=Number.MAX_VALUE,c=-Number.MAX_VALUE;for(const e of a){const i=Du.transformMat4([],e,t),r=Du.length(i);l=Math.min(l,r),c=Math.max(c,r);}return [mw(e,l,s.pitch,s._fov),mw(e,c,s.pitch,s._fov)]}const xw=new ga({range:new fa(Pt.fog.range),color:new fa(Pt.fog.color),"high-color":new fa(Pt.fog["high-color"]),"space-color":new fa(Pt.fog["space-color"]),"horizon-blend":new fa(Pt.fog["horizon-blend"]),"star-intensity":new fa(Pt.fog["star-intensity"]),"vertical-range":new fa(Pt.fog["vertical-range"])});class vw extends zt{constructor(e,t){super(),this._transitionable=new la(xw),this.set(e),this._transitioning=this._transitionable.untransitioned(),this._transform=t;}get state(){const e=this._transform,t="globe"===e.projection.name,i=Dd(e.zoom),r=this.properties.get("range"),n=[.5,3];return {range:t?[Kr(n[0],r[0],i),Kr(n[1],r[1],i)]:r,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t={}){if(this._validate(vs,e,t))return;const i=k({},e);for(const e of Object.keys(Pt.fog))void 0===i[e]&&(i[e]=Pt.fog[e].default);this._transitionable.setTransitionOrValue(i);}getOpacity(e){if(!this._transform.projection.supportsFog)return 0;const t=this.properties&&this.properties.get("color")||1;return ("globe"===this._transform.projection.name?1:P(dw,pw,e))*t.a}getOpacityAtLatLng(e,t){return this._transform.projection.supportsFog?function(e,t,i){const r=lp.fromLngLat(t),n=i.elevation?i.elevation.getAtPointOrZero(r):0;return gw(e,r.x,r.y,n,i)}(this.state,e,t):0}getOpacityForTile(e){if(!this._transform.projection.supportsFog)return [1,1];const t=this._transform.calculateFogTileMatrix(e.toUnwrapped());return yw(this.state,t,0,0,cr,cr,this._transform)}getOpacityForBounds(e,t,i,r,n){return this._transform.projection.supportsFog?yw(this.state,e,t,i,r,n,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?_w(this.state,e):[0,1]}isVisibleOnFrustum(e){if(!this._transform.projection.supportsFog)return !1;const t=[4,5,6,7];for(const i of t){const t=e.points[i];let r;if(t[2]>=0)r=t;else {const n=e.points[i-4];r=Jr(n,t,n[2]/(n[2]-t[2]));}if(gw(this.state,r[0],r[1],0,this._transform)>=fw)return !0}return !1}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}_validate(e,t,i){return (!i||!1!==i.validate)&&Ss(this,e.call(ms,k({value:t,style:{glyphs:!0,sprite:!0},styleSpec:Pt})))}}class bw{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback();}),0));}remove(){this._channel=void 0,this._callback=()=>{};}}class ww{constructor(){this.tasks={},this.taskQueue=[],j(["process"],this),this.invoker=new bw(this.process),this.nextId=0;}add(e,t){const i=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i}(t);if(0===r){Q();try{e();}finally{}return {cancel:()=>{}}}return this.tasks[i]={fn:e,metadata:t,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i];}}}process(){Q();try{if(this.taskQueue=this.taskQueue.filter((e=>!!this.tasks[e])),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn();}finally{}}pick(){let e=null,t=1/0;for(let i=0;i<this.taskQueue.length;i++){const r=this.tasks[this.taskQueue[i]];r.priority<t&&(t=r.priority,e=i);}if(null===e)return null;const i=this.taskQueue[e];return this.taskQueue.splice(e,1),i}remove(){this.invoker.remove();}}class Tw{constructor(e,t,i){this.target=e,this.parent=t,this.mapId=i,this.callbacks={},this.cancelCallbacks={},j(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.scheduler=new ww;}send(e,t,i,r,n=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[s]=i);const a=new Set;return this.target.postMessage({id:s,type:e,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:Os(t,a)},a),{cancel:()=>{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId});}}}receive(e){const t=e.data,i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if("<cancel>"===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel();}else if(t.mustQueue||Q()){const e=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,t)),e&&e.metadata||{type:"message"});}else this.processTask(i,t);}processTask(e,t){if("<response>"===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(Bs(t.error)):i(null,Bs(t.data)));}else {const i=new Set,r=t.hasCallback?(t,r)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:t?Os(t):null,data:Os(r,i)},i);}:e=>{},n=Bs(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,n,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],n.source,n.scope)[e[1]](n,r);}else r(new Error(`Could not find function ${t.type}`));}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1);}}class Ew{constructor(e,t){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=F();const i=this.workerPool.acquire(this.id);for(let e=0;e<i.length;e++){const r=new Ew.Actor(i[e],t,this.id);r.name=`Worker ${e}`,this.actors.push(r);}this.ready=!1,this.broadcast("checkIfReady",null,(()=>{this.ready=!0;}));}broadcast(e,t,i){R(this.actors,((i,r)=>{i.send(e,t,r);}),i=i||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((e=>{e.remove();})),this.actors=[],this.workerPool.release(this.id);}}Ew.Actor=Tw;class Mw extends zt{constructor(e,t,i,r){super(),this.scope=i,this._options=e,this.properties=new pa(t),this._transitionable=new la(t,new Map(r)),this._transitionable.setTransitionOrValue(e.properties),this._transitioning=this._transitionable.untransitioned();}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(e));}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning);}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e);}get(){return this._options.properties=this._transitionable.serialize(),this._options}set(e,t){this._options=e,this._transitionable.setTransitionOrValue(e.properties,t);}shadowsEnabled(){return !!this.properties&&!0===this.properties.get("cast-shadows")}}const Aw=new ga({color:new fa(Pt.properties_light_ambient.color),intensity:new fa(Pt.properties_light_ambient.intensity)}),Sw=new ga({direction:new class{constructor(e){this.specification=e;}possiblyEvaluate(e,t){return function([e,t]){const i=K([1,e,t]);return {x:i.x,y:i.y,z:i.z}}(e.expression.evaluate(t))}interpolate(e,t,i){return {x:Kr(e.x,t.x,i),y:Kr(e.y,t.y,i),z:Kr(e.z,t.z,i)}}}(Pt.properties_light_directional.direction),color:new fa(Pt.properties_light_directional.color),intensity:new fa(Pt.properties_light_directional.intensity),"cast-shadows":new fa(Pt.properties_light_directional["cast-shadows"]),"shadow-intensity":new fa(Pt.properties_light_directional["shadow-intensity"])});class Iw{constructor(e,t,i,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r);}static createFromScreenPoints(e,t){let i,r;if(e instanceof y||"number"==typeof e[0]){const n=y.convert(e);i=[n],r=t.isPointAboveHorizon(n);}else {const n=y.convert(e[0]),o=y.convert(e[1]);i=[n,o],r=S(n,o).every((e=>t.isPointAboveHorizon(e)));}return new Iw(i,t.getCameraPoint(),r,t)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return S(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const t=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new y(1,1)):this.screenBounds[1],r=S(t,i,0,!1);return this.cameraPoint.y>i.y&&(this.cameraPoint.x>t.x&&this.cameraPoint.x<i.x?r.splice(3,0,this.cameraPoint):this.cameraPoint.x>=i.x?r[2]=this.cameraPoint:this.cameraPoint.x<=t.x&&(r[3]=this.cameraPoint)),function(e,t){const i=[];for(let r=0;r<e.length;r++){const n=D(r-1,-1,e.length-1),o=D(r+1,-1,e.length-1),s=e[r],a=e[o],l=e[n].sub(s).unit(),c=a.sub(s).unit(),h=c.angleWithSep(l.x,l.y),u=l.add(c).unit().mult(-1*t/Math.sin(h/2));i.push(s.add(u));}return i}(r,e)}bufferedCameraGeometryGlobe(e){const t=this.screenBounds[0],i=1===this.screenBounds.length?this.screenBounds[0].add(new y(1,1)):this.screenBounds[1],r=S(t,i,e),n=this.cameraPoint.clone();switch(3*((n.y>t.y)+(n.y>i.y))+((n.x>t.x)+(n.x>i.x))){case 0:r[0]=n,r[4]=n.clone();break;case 1:r.splice(1,0,n);break;case 2:r[1]=n;break;case 3:r.splice(4,0,n);break;case 5:r.splice(2,0,n);break;case 6:r[3]=n;break;case 7:r.splice(3,0,n);break;case 8:r[2]=n;}return r}containsTile(e,t,i,r=0){const n=e.queryPadding/t._pixelsPerMercatorPixel+1,o=i?this._bufferedCameraMercator(n,t):this._bufferedScreenMercator(n,t);let s=e.tileID.wrap+(o.unwrapped?r:0);const a=o.polygon.map((t=>Rg(e.tileTransform,t,s)));if(!Pp(a,0,0,cr,cr))return;s=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const l=this.screenGeometryMercator.polygon.map((t=>Lg(e.tileTransform,t,s))),c=l.map((e=>new y(e[0],e[1]))),h=t.getFreeCameraOptions().position||new lp(0,0,0),u=Lg(e.tileTransform,h,s),d=l.map((e=>{const t=Du.sub(e,e,u);return Du.normalize(t,t),new Wu(u,t)})),p=rv(e,1,t.zoom)*t._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:c,tilespaceRays:d,bufferedTilespaceGeometry:a,bufferedTilespaceBounds:(f=A(a),f.min.x=z(f.min.x,0,cr),f.min.y=z(f.min.y,0,cr),f.max.x=z(f.max.x,0,cr),f.max.y=z(f.max.y,0,cr),f),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:p};var f;}_bufferedScreenMercator(e,t){const i=Pw(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(e,t){const i=Pw(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=r,r}}_projectAndResample(e,t){const i=function(e,t){const i=Au.multiply([],t.pixelMatrix,t.globeMatrix),r=[0,-rd,0,1],n=[0,rd,0,1],o=[0,0,0,1];yu.transformMat4(r,r,i),yu.transformMat4(n,n,i),yu.transformMat4(o,o,i);const s=new y(r[0]/r[3],r[1]/r[3]),a=new y(n[0]/n[3],n[1]/n[3]),l=zp(e,s)&&r[3]<o[3],c=zp(e,a)&&n[3]<o[3];if(!l&&!c)return null;const h=function(e,t,i){for(let r=1;r<e.length;r++){const n=zw(t.pointCoordinate3D(e[r-1]).x),o=zw(t.pointCoordinate3D(e[r]).x);if(i<0){if(n<o)return {idx:r,t:-n/(o-1-n)}}else if(o<n)return {idx:r,t:(1-n)/(o+1-n)}}return null}(e,t,l?-1:1);if(!h)return null;const{idx:u,t:d}=h;let p=u>1?Cw(e.slice(0,u),t):[],f=u<e.length?Cw(e.slice(u),t):[];p=p.map((e=>new y(zw(e.x),e.y))),f=f.map((e=>new y(zw(e.x),e.y)));const m=[...p];0===m.length&&m.push(f[f.length-1]);const _=Kr(m[m.length-1].y,(0===f.length?p[0]:f[0]).y,d);let g;return g=l?[new y(0,_),new y(0,0),new y(1,0),new y(1,_)]:[new y(1,_),new y(1,1),new y(0,1),new y(0,_)],m.push(...g),0===f.length?m.push(p[0]):m.push(...f),{polygon:m.map((e=>new lp(e.x,e.y))),unwrapped:!1}}(e,t);if(i)return i;const r=function(e,t){let i=!1,r=-1/0,n=0;for(let t=0;t<e.length-1;t++)e[t].x>r&&(r=e[t].x,n=t);for(let t=0;t<e.length-1;t++){const r=(n+t)%(e.length-1),o=e[r],s=e[r+1];Math.abs(o.x-s.x)>.5&&(o.x<s.x?(o.x+=1,0===r&&(e[e.length-1].x+=1)):(s.x+=1,r+1===e.length-1&&(e[0].x+=1)),i=!0);}const o=Kd(t.center.lng);return i&&o<Math.abs(o-1)&&e.forEach((e=>{e.x-=1;})),{polygon:e,unwrapped:i}}(Cw(e,t).map((e=>new y(zw(e.x),e.y))),t);return {polygon:r.polygon.map((e=>new lp(e.x,e.y))),unwrapped:r.unwrapped}}}function Cw(e,t){return hp(e,(e=>{const i=t.pointCoordinate3D(e);e.x=i.x,e.y=i.y;}),1/256)}function zw(e){return e<0?1+e%1:e%1}function Pw(e){return 100*e|0}function Dw(e,t,i,r,n){const o=function(i,r){if(i)return n(i);if(r){e.url&&r.tiles&&e.tiles&&delete e.tiles;const i=O(k(r,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(i.vectorLayers=r.vector_layers,i.vectorLayerIds=i.vectorLayers.map((e=>e.id))),i.tiles=t.canonicalizeTileset(i,e.url),n(null,i);}};return e.url?we(t.transformRequest(t.normalizeSourceURL(e.url,null,i,r),ye.Source),o):dt.frame((()=>o(null,e)))}class Rw{constructor(e,t,i){this.bounds=sc.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const t=Math.pow(2,e.z),i=Math.floor(Kd(this.bounds.getWest())*t),r=Math.floor(Jd(this.bounds.getNorth())*t),n=Math.ceil(Kd(this.bounds.getEast())*t),o=Math.ceil(Jd(this.bounds.getSouth())*t);return e.x>=i&&e.x<n&&e.y>=r&&e.y<o}}class Lw{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new Qp({width:e,height:t}),this.positions={},this.uploaded=!1;}getDash(e,t){const i=this.getKey(e,t);return this.positions[i]}trim(){const e=this.width,t=this.height=U(this.nextRow);this.image.resize({width:e,height:t});}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,i){const r=[];let n=e.length%2==1?-e[e.length-1]*i:0,o=e[0]*i,s=!0;r.push({left:n,right:o,isDash:s,zeroLength:0===e[0]});let a=e[0];for(let t=1;t<e.length;t++){s=!s;const l=e[t];n=a*i,a+=l,o=a*i,r.push({left:n,right:o,isDash:s,zeroLength:0===l});}return r}addRoundDash(e,t,i){const r=t/2;for(let t=-i;t<=i;t++){const n=this.width*(this.nextRow+i+t);let o=0,s=e[o];for(let a=0;a<this.width;a++){a/s.right>1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e);}else u=r-Math.sqrt(h*h+d*d);this.image.data[n+a]=Math.max(0,Math.min(255,u+128));}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1));}const i=e[0],r=e[e.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,s=e[o];for(let i=0;i<this.width;i++){i/s.right>1&&(s=e[++o]);const r=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(r,a);this.image.data[n+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+t+128));}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const r="round"===t,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return H("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;t<e.length;t++)e[t]<0&&(H("Negative value is found in line dasharray, replacing values with 0"),e[t]=0),s+=e[t];if(0!==s){const i=this.width/s,o=this.getDashRanges(e,this.width,i);r?this.addRoundDash(o,i,n):this.addRegularDash(o,"square"===t?.5*i:0);}const a=this.nextRow+n;this.nextRow+=o;const l={tl:[a,n],br:[s,0]};return this.positions[i]=l,l}}Rs(Lw,"LineAtlas");const kw=1*ng;class Ow{constructor(e){const t={},i=[];for(const r in e){const n=e[r],o=t[r]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const r=t.metrics.localGlyph?kw:1,s={x:0,y:0,w:t.bitmap.width+2*r,h:t.bitmap.height+2*r};i.push(s),o[e]=s;}}const{w:r,h:n}=K_(i),o=new Qp({width:r||1,height:n||1});for(const i in e){const r=e[i];for(const e in r.glyphs){const n=r.glyphs[+e];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const s=t[i][e],a=n.metrics.localGlyph?kw:1;Qp.copy(n.bitmap,o,{x:0,y:0},{x:s.x+a,y:s.y+a},n.bitmap);}}this.image=o,this.positions=t;}}Rs(Ow,"GlyphAtlas");class Bw{constructor(e){this.tileID=new qu(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.scope=e.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.promoteId=e.promoteId,this.isSymbolTile=e.isSymbolTile,this.tileTransform=Pg(e.tileID.canonical,e.projection),this.projection=e.projection,this.brightness=e.brightness,this.extraShadowCaster=!!e.extraShadowCaster;}parse(e,t,i,r,n){this.status="parsing",this.data=e,this.collisionBoxArray=new al;const o=new dm(Object.keys(e.layers).sort()),s=new Qm(this.tileID,this.promoteId);s.bucketLayerIDs=[];const a={},l=new Lw(256,256),c={featureIndex:s,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:i,brightness:this.brightness},h=t.familiesBySource[this.source];for(const t in h){const r=e.layers[t];if(!r)continue;let n=!1,l=!1,u=!1;for(const e of h[t])"symbol"===e[0].type?n=!0:l=!0,e[0].is3D()&&"model"!==e[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!n)continue;if(!1===this.isSymbolTile&&!l)continue;1===r.version&&H(`Vector tile source "${this.source}" layer "${t}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const d=o.encode(t),p=[];for(let e=0;e<r.length;e++){const i=r.feature(e),n=s.getId(i,t);p.push({feature:i,id:n,index:e,sourceLayerIndex:d});}for(const e of h[t]){const t=e[0];(!this.extraShadowCaster||t.is3D()&&"model"!==t.type)&&(void 0!==this.isSymbolTile&&"symbol"===t.type!==this.isSymbolTile||t.minzoom&&this.zoom<Math.floor(t.minzoom)||t.maxzoom&&this.zoom>=t.maxzoom||"none"!==t.visibility&&(Fw(e,this.zoom,c.brightness,i),(a[t.id]=t.createBucket({index:s.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:d,sourceID:this.source,projection:this.projection.spec})).populate(p,c,this.tileID.canonical,this.tileTransform),s.bucketLayerIDs.push(e.map((e=>e.id)))));}}let u,d,p,f;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},_=()=>{if(u)return this.status="done",n(u);if(this.extraShadowCaster)this.status="done",n(null,{buckets:L(a).filter((e=>!e.isEmpty())),featureIndex:s,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:c.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(d&&p&&f){const e=new Ow(d),t=new eg(p,f);for(const r in a){const n=a[r];n instanceof gy?(Fw(n.layers,this.zoom,c.brightness,i),vg(n,d,e.positions,p,t.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):n.hasPattern&&(n instanceof Ey||n instanceof jf||n instanceof vb)&&(Fw(n.layers,this.zoom,c.brightness,i),n.addFeatures(c,this.tileID.canonical,t.patternPositions,i,this.tileTransform,this.brightness));}this.status="done",n(null,{buckets:L(a).filter((e=>!e.isEmpty())),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:l,imageAtlas:t,brightness:c.brightness});}};if(!this.extraShadowCaster){const e=q(c.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(e).length?r.send("getGlyphs",{uid:this.uid,stacks:e,scope:this.scope},((e,t)=>{u||(u=e,d=t,_());}),void 0,!1,m):d={};const t=Object.keys(c.iconDependencies);t.length?r.send("getImages",{icons:t,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},((e,t)=>{u||(u=e,p=t,_());}),void 0,!1,m):p={};const i=Object.keys(c.patternDependencies);i.length?r.send("getImages",{icons:i,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},((e,t)=>{u||(u=e,f=t,_());}),void 0,!1,m):f={};}_();}}function Fw(e,t,i,r){const n=new oa(t,{brightness:i});for(const t of e)t.recalculate(n,r);}class Nw{constructor(e){this.entries={},this.scheduler=e;}request(e,t,i,r){const n=this.entries[e]=this.entries[e]||{callbacks:[]};if(n.result){const[e,i]=n.result;return this.scheduler?this.scheduler.add((()=>{r(e,i);}),t):r(e,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i(((i,r)=>{n.result=[i,r];for(const e of n.callbacks)this.scheduler?this.scheduler.add((()=>{e(i,r);}),t):e(i,r);setTimeout((()=>delete this.entries[e]),3e3);}))),()=>{n.result||(n.callbacks=n.callbacks.filter((e=>e!==r)),n.callbacks.length||(n.cancel(),delete this.entries[e]));}}}function Uw(e,t,i){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},(t=>{const r=Te(e.request,((e,r,n,o)=>{e?t(e):r&&t(null,{vectorTile:i?void 0:new cm(new km(r)),rawData:r,cacheControl:n,expires:o});}));return ()=>{r.cancel(),t();}}),t)}class Vw extends zt{constructor(e,t,i,r){if(super(),this.id=e,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,k(this,O(t,["url","scheme","tileSize","promoteId"])),this._options=k({type:"vector"},t),this._collectResourceTiming=!!t.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r),this._tileWorkers={},this._deduped=new Nw;}load(e){this._loaded=!1,this.fire(new It("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map._worldview;this._tileJSONRequest=Dw(this._options,this.map._requestManager,t,i,((r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${t}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new Ct(r))):n&&(k(this,n),n.bounds&&(this.tileBounds=new Rw(n.bounds,this.minzoom,this.maxzoom)),Ge(n.tiles,this.map._requestManager._customAccessToken),this.fire(new It("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new It("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r);}));}loaded(){return this._loaded}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const e=va(this.id,this.scope);this.load((()=>this.map.style.clearSource(e)));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest();}serialize(){return k({},this._options)}loadTile(e,t){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(i,ye.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:dt.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:e.isExtraShadowCaster};if(r.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=t:e.request=e.actor.send("reloadTile",r,n.bind(this));else if(e.actor=this._tileWorkers[i]=this._tileWorkers[i]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",r,n.bind(this),void 0,!0);else {const t=Uw.call({deduped:this._deduped},r,((t,i)=>{t||!i?n.call(this,t):(r.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},e.actor&&e.actor.send("loadTile",r,n.bind(this),void 0,!0));}),!0);e.request={cancel:t};}function n(i,r){return delete e.request,e.aborted?t(null):i&&404!==i.status?t(i):(r&&r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&e.setExpiryData(r),e.loadVectorData(r,this.map.painter),ge(this.dispatcher),t(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope});}unloadTile(e){e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}hasTransition(){return !1}afterUpdate(){this._tileWorkers={};}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}class jw extends zt{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=k({type:"raster"},t),k(this,O(t,["url","scheme","tileSize"]));}load(e){this._loaded=!1,this.fire(new It("dataloading",{dataType:"source"})),this._tileJSONRequest=Dw(this._options,this.map._requestManager,null,null,((t,i)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new Ct(t)):i&&(k(this,i),i.bounds&&(this.tileBounds=new Rw(i.bounds,this.minzoom,this.maxzoom)),Ge(i.tiles),this.fire(new It("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new It("data",{dataType:"source",sourceDataType:"content"}))),e&&e(t);}));}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}reload(){this.cancelTileJSONRequest();const e=va(this.id,this.scope);this.load((()=>this.map.style.clearSource(e)));}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest();}serialize(){return k({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const i=dt.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),i,this.tileSize);e.request=Ie(this.map._requestManager.transformRequest(r,ye.Tile),((i,r,n,o)=>(delete e.request,e.aborted?(e.state="unloaded",t(null)):i?(e.state="errored",t(i)):r?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:n,expires:o}),e.setTexture(r,this.map.painter),e.state="loaded",ge(this.dispatcher),void t(null)):t(null))));}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t();}unloadTile(e,t){e.texture&&e.texture instanceof My?(e.destroy(!0),e.texture&&e.texture instanceof My&&this.map.painter.saveTileTexture(e.texture)):e.destroy(),t();}hasTransition(){return !1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}}function Gw(){return null!=xI.workerClass?new xI.workerClass:new t.Worker(xI.workerUrl)}const qw="mapboxgl_preloaded_worker_pool";class Zw{constructor(){this.active={};}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<Zw.workerCount;)this.workers.push(new Gw);return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],this.workers&&0===this.numActive()&&(this.workers.forEach((e=>{e.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[qw]}numActive(){return Object.keys(this.active).length}}let $w;function Ww(){return $w||($w=new Zw),$w}Zw.workerCount=2;let Hw,Xw,Yw,Kw=null;function Jw(){return Q()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:Xw||n.DRACO_URL}const Qw=5123,eT=5126,tT={5120:Int8Array,5121:Uint8Array,5122:Int16Array,[Qw]:Uint16Array,5125:Uint32Array,[eT]:Float32Array},iT={5120:"DT_INT8",5121:"DT_UINT8",5122:"DT_INT16",[Qw]:"DT_UINT16",5125:"DT_UINT32",[eT]:"DT_FLOAT32"},rT={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function nT(e,t,i){const r=i.json.bufferViews.length,n=i.buffers.length;t.bufferView=r,i.json.bufferViews[r]={buffer:n,byteLength:e.byteLength},i.buffers[n]=e;}const oT="KHR_draco_mesh_compression";function sT(e,t){const i=e.extensions&&e.extensions[oT];if(!i)return;const r=new Yw.Decoder,n=uT(t,i.bufferView),o=new Yw.Mesh;if(!r.DecodeArrayToMesh(n,n.byteLength,o))throw new Error("Failed to decode Draco mesh");const s=t.json.accessors[e.indices],a=tT[s.componentType],l=s.count*a.BYTES_PER_ELEMENT,c=Yw._malloc(l);a===Uint16Array?r.GetTrianglesUInt16Array(o,l,c):r.GetTrianglesUInt32Array(o,l,c),nT(Yw.memory.buffer.slice(c,c+l),s,t),Yw._free(c);for(const n of Object.keys(i.attributes)){const s=r.GetAttributeByUniqueId(o,i.attributes[n]),a=t.json.accessors[e.attributes[n]],l=iT[a.componentType],c=a.count*rT[a.type]*tT[a.componentType].BYTES_PER_ELEMENT,h=Yw._malloc(c);r.GetAttributeDataArrayForAllPoints(o,s,Yw[l],c,h),nT(Yw.memory.buffer.slice(h,h+c),a,t),Yw._free(h);}r.destroy(),o.destroy(),delete e.extensions[oT];}const aT=1179937895,lT=new TextDecoder("utf8");function cT(e,t){return new URL(e,t).href}function hT(e,t,i,r){return fetch(cT(e.uri,r)).then((e=>e.arrayBuffer())).then((e=>{t.buffers[i]=e;}))}function uT(e,t){const i=e.json.bufferViews[t];return new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function dT(e,i,r,n){if(e.uri){const o=cT(e.uri,n);return fetch(o).then((e=>e.blob())).then((e=>t.createImageBitmap(e))).then((e=>{i.images[r]=e;}))}if(void 0!==e.bufferView){const n=uT(i,e.bufferView),o=new t.Blob([n],{type:e.mimeType});return t.createImageBitmap(o).then((e=>{i.images[r]=e;}))}}function pT(e,t=0,i){const r={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===aT){const i=new Uint32Array(e,t);let n=2;const o=(i[n++]>>2)-3,s=i[n++]>>2;if(n++,r.json=JSON.parse(lT.decode(i.subarray(n,n+s))),n+=s,n<o){const o=i[n++];n++;const s=t+(n<<2);r.buffers[0]=e.slice(s,s+o);}}else r.json=JSON.parse(lT.decode(new Uint8Array(e,t)));const{buffers:n,images:o,meshes:s,extensionsUsed:a}=r.json;let l=Promise.resolve();if(n){const e=[];for(let t=0;t<n.length;t++){const o=n[t];o.uri?e.push(hT(o,r,t,i)):r.buffers[t]||(r.buffers[t]=null);}l=Promise.all(e);}return l.then((()=>{const e=[],t=a&&a.includes(oT);if(t&&e.push(function(){if(!Yw)return Hw||(Hw=function(e){let t,i=null;function r(){t=new Uint8Array(i.buffer);}function n(){throw new Error("Unexpected Draco error.")}const o={a:{a:n,d:function(e,i,r){return t.copyWithin(e,i,i+r)},c:function(e){const n=t.length,o=Math.max(e>>>0,Math.ceil(1.2*n)),s=Math.ceil((o-n)/65536);try{return i.grow(s),r(),!0}catch(e){return !1}},b:n}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,o)))).then((e=>{const{Rb:n,Qb:o,P:s,T:a,X:l,Ja:c,La:h,Qa:u,Va:d,Wa:p,eb:f,jb:m,f:_,e:g,yb:y,zb:x,Ab:v,Bb:b,Db:w,Gb:T}=e.instance.exports;i=g;const E=(()=>{let e=0,i=0,r=0,s=0;return a=>{r&&(n(s),n(e),i+=r,r=e=0),e||(i+=128,e=o(i));const l=a.length+7&-8;let c=e;l>=i&&(r=l,c=s=o(l));for(let e=0;e<a.length;e++)t[c+e]=a[e];return c}})();return r(),_(),{memory:g,_free:n,_malloc:o,Mesh:class{constructor(){this.ptr=s();}destroy(){a(this.ptr);}},Decoder:class{constructor(){this.ptr=c();}destroy(){m(this.ptr);}DecodeArrayToMesh(e,t,i){const r=E(e),n=h(this.ptr,r,t,i.ptr);return !!l(n)}GetAttributeByUniqueId(e,t){return {ptr:u(this.ptr,e.ptr,t)}}GetTrianglesUInt16Array(e,t,i){d(this.ptr,e.ptr,t,i);}GetTrianglesUInt32Array(e,t,i){p(this.ptr,e.ptr,t,i);}GetAttributeDataArrayForAllPoints(e,t,i,r,n){f(this.ptr,e.ptr,t.ptr,i,r,n);}},DT_INT8:y(),DT_UINT8:x(),DT_INT16:v(),DT_UINT16:b(),DT_UINT32:w(),DT_FLOAT32:T()}}))}(fetch(Jw())),Hw.then((e=>{Yw=e,Hw=void 0;})))}()),o)for(let t=0;t<o.length;t++)e.push(dT(o[t],r,t,i));return (e.length?Promise.all(e):Promise.resolve()).then((()=>{if(t&&s)for(const{primitives:e}of s)for(const t of e)sT(t,r);return r}))}))}function fT(e){return fetch(e).then((e=>e.arrayBuffer())).then((t=>pT(t,0,e)))}class mT{constructor(e,t,i){if(this.triangleCount=t.length/3,this.min=new y(0,0),this.max=new y(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length||0===i)return;const r=e.map((e=>e.x)),n=e.map((e=>e.y));this.min=new y(Math.min(...r),Math.min(...n)),this.max=new y(Math.max(...r),Math.max(...n));const o=this.max.sub(this.min);o.x=Math.max(o.x,1),o.y=Math.max(o.y,1);const s=Math.max(o.x,o.y)/i;this.cellsX=Math.max(1,Math.ceil(o.x/s)),this.cellsY=Math.max(1,Math.ceil(o.y/s)),this.xScale=1/s,this.yScale=1/s;const a=[];for(let i=0;i<this.triangleCount;i++){const r=e[t[3*i+0]].sub(this.min),n=e[t[3*i+1]].sub(this.min),o=e[t[3*i+2]].sub(this.min),l=_T(Math.floor(Math.min(r.x,n.x,o.x)),this.xScale,this.cellsX),c=_T(Math.floor(Math.max(r.x,n.x,o.x)),this.xScale,this.cellsX),h=_T(Math.floor(Math.min(r.y,n.y,o.y)),this.yScale,this.cellsY),u=_T(Math.floor(Math.max(r.y,n.y,o.y)),this.yScale,this.cellsY),d=new y(0,0),p=new y(0,0),f=new y(0,0),m=new y(0,0);for(let e=h;e<=u;++e){d.y=p.y=e*s,f.y=m.y=(e+1)*s;for(let t=l;t<=c;++t)d.x=f.x=t*s,p.x=m.x=(t+1)*s,(Lp(r,n,o,d,p,m)||Lp(r,n,o,d,m,f))&&a.push({cellIdx:e*this.cellsX+t,triIdx:i});}}if(0===a.length)return;a.sort(((e,t)=>e.cellIdx-t.cellIdx||e.triIdx-t.triIdx));let l=0;for(;l<a.length;){const e=a[l].cellIdx,t={start:this.payload.length,len:0};for(;l<a.length&&a[l].cellIdx===e;)++t.len,this.payload.push(a[l++].triIdx);this.cells[e]=t;}}query(e,t,i){if(0===this.triangleCount||0===this.cells.length)return;if(e.x>this.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this.lookup||(this.lookup=new Uint8Array(Math.ceil(this.triangleCount/8)));for(let e=0;e<this.lookup.length;e++)this.lookup[e]=0;const r=_T(e.x-this.min.x,this.xScale,this.cellsX),n=_T(t.x-this.min.x,this.xScale,this.cellsX),o=_T(e.y-this.min.y,this.yScale,this.cellsY),s=_T(t.y-this.min.y,this.yScale,this.cellsY);for(let e=o;e<=s;e++)for(let t=r;t<=n;t++){const r=this.cells[e*this.cellsX+t];if(r)for(let e=0;e<r.len;e++){const t=this.payload[r.start+e],n=Math.floor(t/8),o=1<<t%8;if(!(this.lookup[n]&o)&&(this.lookup[n]|=o,i.push(t),i.length===this.triangleCount))return}}}}function _T(e,t,i){return Math.max(0,Math.min(i-1,Math.floor(e*t)))}function gT(e,t){const i=e.json.bufferViews[t.bufferView];return new(0,tT[t.componentType])(e.buffers[i.buffer],(t.byteOffset||0)+(i.byteOffset||0),t.count*rT[t.type])}function yT(e,t,i){const r=e.indices,n=e.attributes,o={};o.indexArray=new Wa;const s=t.json.accessors[r],a=s.count/3;o.indexArray.reserve(a);const l=gT(t,s);for(let e=0;e<a;e++)o.indexArray.emplaceBack(l[3*e],l[3*e+1],l[3*e+2]);o.indexArray._trim(),o.vertexArray=new tl;const c=t.json.accessors[n.POSITION];o.vertexArray.reserve(c.count);const h=gT(t,c);for(let e=0;e<c.count;e++)o.vertexArray.emplaceBack(h[3*e],h[3*e+1],h[3*e+2]);if(o.vertexArray._trim(),o.aabb=new ed(c.min,c.max),o.centroid=function(e,t){const i=[0,0,0],r=e.length;if(r>0){for(let n=0;n<r;n++){const r=3*e[n];i[0]+=t[r],i[1]+=t[r+1],i[2]+=t[r+2];}i[0]/=r,i[1]/=r,i[2]/=r;}return i}(l,h),void 0!==n.COLOR_0){const e=t.json.accessors[n.COLOR_0],i=rT[e.type];if(e.componentType===eT){o.colorArray=3===i?new tl:new ka,o.colorArray.reserve(e.count);const r=gT(t,e);if(3===i)for(let t=0;t<e.count;t++)o.colorArray.emplaceBack(r[3*t],r[3*t+1],r[3*t+2]);else for(let t=0;t<e.count;t++)o.colorArray.emplaceBack(r[4*t],r[4*t+1],r[4*t+2],r[4*t+3]);o.colorArray._trim();}else if(e.componentType===Qw&&4===i){o.colorArray=new ka,o.colorArray.resize(e.count);const i=gT(t,e),r=1/65535,n=o.colorArray.float32;for(let e=0;e<4*i.length;++e)n[e]=i[e]*r;}else H(`glTF color buffer parsing for accessor ${JSON.stringify(e)} is not supported`);}if(void 0!==n.NORMAL){o.normalArray=new tl;const e=t.json.accessors[n.NORMAL];o.normalArray.reserve(e.count);const i=gT(t,e);for(let t=0;t<e.count;t++)o.normalArray.emplaceBack(i[3*t],i[3*t+1],i[3*t+2]);o.normalArray._trim();}if(void 0!==n.TEXCOORD_0&&i.length>0){o.texcoordArray=new il;const e=t.json.accessors[n.TEXCOORD_0];o.texcoordArray.reserve(e.count);const i=gT(t,e);for(let t=0;t<e.count;t++)o.texcoordArray.emplaceBack(i[2*t],i[2*t+1]);o.texcoordArray._trim();}const u=e.material;return o.material=function(e,t){const{emissiveFactor:i=[0,0,0],alphaMode:r="OPAQUE",alphaCutoff:n=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l}=e,{baseColorFactor:c=[1,1,1,1],metallicFactor:h=1,roughnessFactor:u=1,baseColorTexture:d,metallicRoughnessTexture:p}=e.pbrMetallicRoughness||{};return {pbrMetallicRoughness:{baseColorFactor:new hi(...c),metallicFactor:h,roughnessFactor:u,baseColorTexture:d?t[d.index]:void 0,metallicRoughnessTexture:p?t[p.index]:void 0},doubleSided:l,emissiveFactor:i,alphaMode:r,alphaCutoff:n,normalTexture:o?t[o.index]:void 0,occlusionTexture:s?t[s.index]:void 0,emissionTexture:a?t[a.index]:void 0,defined:void 0===e.defined}}(void 0!==u?t.json.materials[u]:{defined:!1},i),void 0!==n._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(gT(t,t.json.accessors[n._FEATURE_RGBA4444]).buffer)),o}function xT(e,t,i){const{matrix:r,rotation:n,translation:o,scale:s,mesh:a,extras:l,children:c}=e,h={};if(h.matrix=r||Au.fromRotationTranslationScale([],n||[0,0,0,1],o||[0,0,0],s||[1,1,1]),void 0!==a){h.meshes=i[a];const e=h.anchor=[0,0];for(const t of h.meshes){const{min:i,max:r}=t.aabb;e[0]+=i[0]+r[0],e[1]+=i[1]+r[1];}e[0]=Math.floor(e[0]/h.meshes.length/2),e[1]=Math.floor(e[1]/h.meshes.length/2);}if(l&&(l.id&&(h.id=l.id),l.lights&&(h.lights=function(e){if(!e.length)return [];const t=function(e){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.codePointAt(e);return i}(e),i=[],r=t.length/24,n=new Uint16Array(t.buffer),o=new Float32Array(t.buffer);for(let e=0;e<r;e++){const t=n[2*e*6]/30,r=n[2*e*6+1]/30,s=n[2*e*6+10]/100,a=o[6*e+1],l=o[6*e+2],c=o[6*e+3],h=o[6*e+4],u=c-a,d=h-l,p=Math.hypot(u,d);i.push({pos:[a+.5*u,l+.5*d,r],normal:[d/p,-u/p,0],width:p,height:t,depth:s,points:[a,l,c,h]});}return i}(l.lights))),c){const e=[];for(const r of c)e.push(xT(t.json.nodes[r],t,i));h.children=e;}return h}function vT(e){if(0===e.vertices.length||0===e.indices.length)return null;const[t,i]=[e.vertices[0].clone(),e.vertices[0].clone()];for(let r=1;r<e.vertices.length;++r){const n=e.vertices[r];t.x=Math.min(t.x,n.x),t.y=Math.min(t.y,n.y),i.x=Math.max(i.x,n.x),i.y=Math.max(i.y,n.y);}const r=Math.ceil(Math.max(i.x-t.x,i.y-t.y)/256),n=Math.max(8,r),o=new mT(e.vertices,e.indices,n);return {vertices:e.vertices,indices:e.indices,grid:o,min:t,max:i}}function bT(e){if(!e.extras||!e.extras.ground)return null;const t=e.extras.ground;if(!t||!Array.isArray(t)||0===t.length)return null;const i=t[0];if(!i||!Array.isArray(i)||0===i.length)return null;const r=[];for(const e of i){if(!Array.isArray(e)||2!==e.length)continue;const t=e[0],i=e[1];"number"==typeof t&&"number"==typeof i&&r.push(new y(t,i));}if(r.length<3)return null;r.length>1&&r[r.length-1].equals(r[0])&&r.pop();let n=0;for(let e=0;e<r.length;e++){const t=r[e],i=r[(e+1)%r.length],o=r[(e+2)%r.length];n+=(t.x-i.x)*(o.y-i.y)-(o.x-i.x)*(t.y-i.y);}n>0&&r.reverse();const o=Bf(r.flatMap((e=>[e.x,e.y])),[]);return 0===o.length?null:{vertices:r,indices:o}}function wT(e){const t=[],i=[];let r=0;for(const n of e){r=t.length;const e=n.vertexArray.float32,o=n.indexArray.uint16;for(let i=0;i<n.vertexArray.length;i++)t.push(new y(e[3*i+0],e[3*i+1]));for(let e=0;e<3*n.indexArray.length;e++)i.push(o[e]+r);}if(i.length%3!=0)return null;for(let e=0;e<i.length;e+=3){const r=t[i[e+0]],n=t[i[e+1]],o=t[i[e+2]];(r.x-n.x)*(o.y-n.y)-(o.x-n.x)*(r.y-n.y)>0&&([i[e+1],i[e+2]]=[i[e+2],i[e+1]]);}return {vertices:t,indices:i}}function TT(e){const i=function(e,i){const r=[],n=t.WebGL2RenderingContext;if(e.json.textures)for(const t of e.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==t.sampler&&Object.assign(o,e.json.samplers[t.sampler]),r.push({image:i[t.source],sampler:o,uploaded:!1});}return r}(e,e.images),r=function(e,t){const i=[];for(const r of e.json.meshes){const n=[];for(const i of r.primitives)n.push(yT(i,e,t));i.push(n);}return i}(e,i),{scenes:n,scene:o,nodes:s}=e.json,a=n?n[o||0].nodes:s,l=[];for(const t of a)l.push(xT(s[t],e,r));return function(e,t,i){const r={},n=new Set;for(let o=0;o<e.length;o++){const e=i[t[o]];if(!e.extras)continue;const s=e.extras["mapbox:footprint:version"],a=e.extras["mapbox:footprint:id"];(s||a)&&n.add(o),"1.0.0"===s&&a&&(r[a]=o);}for(let o=0;o<e.length;o++){if(n.has(o))continue;const s=e[o],a=i[t[o]];if(!a.extras)continue;let l=null;s.id in r&&(l=wT(e[r[s.id]].meshes)),l||(l=bT(a)),l&&(s.footprint=vT(l));}if(n.size>0){const t=Array.from(n.values()).sort(((e,t)=>e-t));for(let i=t.length-1;i>=0;i--)e.splice(t[i],1);}}(l,a,e.json.nodes),l}function ET(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,i=e.aabb.min[0]-1,r=e.aabb.min[1]-1,n=Sv/(e.aabb.max[0]-i+2),o=Sv/(e.aabb.max[1]-r+2);for(let s=0;s<t.length;s+=3){const a=t[s+2],l=(t[s+0]-i)*n|0,c=(t[s+1]-r)*o|0;a>e.heightmap[c*Sv+l]&&(e.heightmap[c*Sv+l]=a);}}function MT(e,t){const i={};i.indexArray=new Wa,i.indexArray.reserve(4*e.length),i.vertexArray=new tl,i.vertexArray.reserve(10*e.length),i.colorArray=new ka,i.vertexArray.reserve(10*e.length);let r=0;for(const n of e){const e=Math.min(10,Math.max(4,1.3*n.height))*t,o=[-n.normal[1],n.normal[0],0],s=Math.min(.29,.1*n.width/n.depth),a=n.width-2*n.depth*t*(s+.01),l=Du.scaleAndAdd([],n.pos,o,a/2),c=Du.scaleAndAdd([],n.pos,o,-a/2),h=[l[0],l[1],l[2]+n.height],u=[c[0],c[1],c[2]+n.height],d=Du.scaleAndAdd([],n.normal,o,s);Du.scale(d,d,e);const p=Du.scaleAndAdd([],n.normal,o,-s);Du.scale(p,p,e),Du.add(d,l,d),Du.add(p,c,p),l[2]+=.1,c[2]+=.1,i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(h[0],h[1],h[2]),i.vertexArray.emplaceBack(u[0],u[1],u[2]),i.vertexArray.emplaceBack(l[0],l[1],l[2]),i.vertexArray.emplaceBack(c[0],c[1],c[2]),i.vertexArray.emplaceBack(d[0],d[1],d[2]),i.vertexArray.emplaceBack(p[0],p[1],p[2]);const f=a/e/2;i.colorArray.emplaceBack(-f-s,-1,f,.8),i.colorArray.emplaceBack(f+s,-1,f,.8),i.colorArray.emplaceBack(-f,0,f,1.3),i.colorArray.emplaceBack(f,0,f,1.3),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(f+s,-.8,f,.7),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(0,0,f,1.3),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.colorArray.emplaceBack(f+s,-1.2,f,.8),i.indexArray.emplaceBack(6+r,4+r,8+r),i.indexArray.emplaceBack(7+r,9+r,5+r),i.indexArray.emplaceBack(0+r,1+r,2+r),i.indexArray.emplaceBack(1+r,3+r,2+r),r+=10;}const n={defined:!0,emissiveFactor:[0,0,0]},o={};return o.baseColorFactor=hi.white,n.pbrMetallicRoughness=o,i.material=n,i.aabb=new ed([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}Rs(mT,"TriangleGridIndex");const AT={vector:Vw,raster:jw,"raster-dem":class extends jw{constructor(e,t,i,r){super(e,t,i,r),this.type="raster-dem",this.maxzoom=22,this._options=k({type:"raster-dem"},t),this.encoding=t.encoding||"mapbox";}loadTile(e,i){const r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function n(t,r){t&&(e.state="errored",i(t)),r&&(e.dem=r,e.dem.onDeserialize(),e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0,e.state="loaded",i(null));}e.request=Ie(this.map._requestManager.transformRequest(r,ye.Tile),function(r,o,s,a){if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(r)e.state="errored",i(r);else if(o){this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:s,expires:a});const i=t.ImageBitmap&&o instanceof t.ImageBitmap&&ut(),r=1-(o.width-((l=o.width)<=1?1:Math.pow(2,Math.floor(Math.log(l)/Math.LN2))))/2;r<1||e.neighboringTiles||(e.neighboringTiles=this._getNeighboringTiles(e.tileID));const c=i?o:dt.getImageData(o,r),h={uid:e.uid,coord:e.tileID,source:this.id,scope:this.scope,rawImageData:c,encoding:this.encoding,padding:r};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",h,n.bind(this),void 0,!0));}var l;}.bind(this));}_getNeighboringTiles(e){const t=e.canonical,i=Math.pow(2,t.z),r=(t.x-1+i)%i,n=0===t.x?e.wrap-1:e.wrap,o=(t.x+1+i)%i,s=t.x+1===i?e.wrap+1:e.wrap,a={};return a[new qu(e.overscaledZ,n,t.z,r,t.y).key]={backfilled:!1},a[new qu(e.overscaledZ,s,t.z,o,t.y).key]={backfilled:!1},t.y>0&&(a[new qu(e.overscaledZ,n,t.z,r,t.y-1).key]={backfilled:!1},a[new qu(e.overscaledZ,e.wrap,t.z,t.x,t.y-1).key]={backfilled:!1},a[new qu(e.overscaledZ,s,t.z,o,t.y-1).key]={backfilled:!1}),t.y+1<i&&(a[new qu(e.overscaledZ,n,t.z,r,t.y+1).key]={backfilled:!1},a[new qu(e.overscaledZ,e.wrap,t.z,t.x,t.y+1).key]={backfilled:!1},a[new qu(e.overscaledZ,s,t.z,o,t.y+1).key]={backfilled:!1}),a}},geojson:class extends zt{constructor(e,t,i,r){super(),this.id=e,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=i.getActor(),this.setEventedParent(r),this._data=t.data,this._options=k({},t),this._collectResourceTiming=t.collectResourceTiming,void 0!==t.maxzoom&&(this.maxzoom=t.maxzoom),t.type&&(this.type=t.type),t.attribution&&(this.attribution=t.attribution),this.promoteId=t.promoteId;const n=cr/this.tileSize;this.workerOptions=k({source:this.id,scope:this.scope,cluster:t.cluster||!1,geojsonVtOptions:{buffer:(void 0!==t.buffer?t.buffer:128)*n,tolerance:(void 0!==t.tolerance?t.tolerance:.375)*n,extent:cr,maxZoom:this.maxzoom,lineMetrics:t.lineMetrics||!1,generateId:t.generateId||!1},superclusterOptions:{maxZoom:void 0!==t.clusterMaxZoom?t.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,t.clusterMinPoints||2),extent:cr,radius:(void 0!==t.clusterRadius?t.clusterRadius:50)*n,log:!1,generateId:t.generateId||!1},clusterProperties:t.clusterProperties,filter:t.filter},t.workerOptions);}onAdd(e){this.map=e,this.setData(this._data);}setData(e){return this._data=e,this._updateWorkerData(),this}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id,scope:this.scope},t),this}getClusterLeaves(e,t,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,scope:this.scope,clusterId:e,limit:t,offset:i},r),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new It("dataloading",{dataType:"source"})),this._loaded=!1;const e=k({},this.workerOptions);e.scope=this.scope;const t=this._data;"string"==typeof t?(e.request=this.map._requestManager.transformRequest(dt.resolveURL(t),ye.Source),e.request.collectResourceTiming=this._collectResourceTiming):e.data=JSON.stringify(t),this._pendingLoad=this.actor.send(`${this.type}.loadData`,e,((e,t)=>{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new Ct(e));else {const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&t&&t.resourceTiming&&t.resourceTiming[this.id]&&(e.resourceTiming=t.resourceTiming[this.id]),this.fire(new It("data",e)),this._metadataFired=!0;}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1);}));}loaded(){return this._loaded}loadTile(e,t){const i=e.actor?"reloadTile":"loadTile";e.actor=this.actor;const r={type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,scope:this.scope,pixelRatio:dt.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0};e.request=this.actor.send(i,r,((r,n)=>(delete e.request,e.destroy(),e.aborted?t(null):r?t(r):(e.loadVectorData(n,this.map.painter,"reloadTile"===i),t(null)))),void 0,"loadTile"===i);}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0;}unloadTile(e){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy();}onRemove(){this._pendingLoad&&this._pendingLoad.cancel();}serialize(){return k({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}},video:class extends Jb{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t;}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,ye.Source).url);!function(e,i){const r=t.document.createElement("video");r.muted=!0,r.onloadstart=function(){i(null,r);};for(let i=0;i<e.length;i++){const n=t.document.createElement("source");Ee(e[i])||(r.crossOrigin="Anonymous"),n.src=e[i],r.appendChild(n);}}(this.urls,((e,t)=>{this._loaded=!0,e?this.fire(new Ct(e)):t&&(this.video=t,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading());}));}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(e){if(this.video){const t=this.video.seekable;e<t.start(0)||e>t.end(0)?this.fire(new Ct(new Dt(`sources.${this.id}`,null,`Playback for this video can be set only between the ${t.start(0)} and ${t.end(0)}-second mark.`))):this.video.currentTime=e;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,t=e.gl;this.texture?this.video.paused||(this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,this.video)):(this.texture=new My(e,this.video,t.RGBA),this.texture.bind(t.LINEAR,t.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e);}serialize(){return {type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Jb,model:class extends zt{constructor(e,t,i,r){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t;}load(){const e=[];for(const t in this._options.models){const i=this._options.models[t],r=fT(this.map._requestManager.transformRequest(i.uri,ye.Model).url).then((e=>{if(!e)return;const r=TT(e),n=new Cv(t,i.position,i.orientation,r);n.computeBoundsAndApplyParent(),this.models.push(n);})).catch((e=>{this.fire(new Ct(new Error(`Could not load model ${t} from ${i.uri}: ${e.message}`)));}));e.push(r);}return Promise.allSettled(e).then((()=>{this._loaded=!0,this.fire(new It("data",{dataType:"source",sourceDataType:"metadata"}));})).catch((e=>{this.fire(new Ct(new Error(`Could not load models: ${e.message}`)));}))}onAdd(e){this.map=e,this.load();}hasTransition(){return !1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return {type:"model"}}},"batched-model":class extends zt{constructor(e,t,i,r){super(),this.type="batched-model",this.id=e,this.tileSize=512,this._options=t,this.tiles=this._options.tiles,this.maxzoom=t.maxzoom||19,this.minzoom=t.minzoom||0,this.roundZoom=!0,this.usedInConflation=!0,this.dispatcher=i,this.reparseOverscaled=!1,this.scheme="xyz",this._loaded=!1,this.setEventedParent(r);}onAdd(e){this.map=e,this.load();}load(e){this._loaded=!1,this.fire(new It("dataloading",{dataType:"source"}));const t=Array.isArray(this.map._language)?this.map._language.join():this.map._language,i=this.map._worldview;this._tileJSONRequest=Dw(this._options,this.map._requestManager,t,i,((r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(t&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${t}`),i&&2!==i.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${i}`),this.fire(new Ct(r))):n&&(k(this,n),n.bounds&&(this.tileBounds=new Rw(n.bounds,this.minzoom,this.maxzoom)),Ge(n.tiles,this.map._requestManager._customAccessToken),this.fire(new It("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new It("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r);}));}hasTransition(){return !1}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(e,t){const i=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(i,ye.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:e.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0};if(e.actor&&"expired"!==e.state)if("loading"===e.state)e.reloadCallback=t;else {if(e.buckets){const t=Object.values(e.buckets);for(const e of t)e.dirty=!0;return void(e.state="loaded")}e.request=e.actor.send("reloadTile",r,n.bind(this));}else e.actor=this.dispatcher.getActor(),e.request=e.actor.send("loadTile",r,n.bind(this),void 0,!0);function n(i,r){return e.aborted?t(null):i&&404!==i.status?t(i):(r&&(r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&e.setExpiryData(r),e.buckets={...e.buckets,...r.buckets}),e.state="loaded",void t(null))}}serialize(){return k({},this._options)}},canvas:class extends Jb{constructor(e,i,r,n){super(e,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>"number"!=typeof e))))||this.fire(new Ct(new Dt(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new Ct(new Dt(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new Ct(new Dt(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof t.HTMLCanvasElement||this.fire(new Ct(new Dt(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new Ct(new Dt(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof t.HTMLCanvasElement?this.options.canvas:t.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new Ct(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const t=this.map.painter.context;this.texture?!e&&!this._playing||this.texture instanceof Ay||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new My(t,this.canvas,t.gl.RGBA,{premultiply:!0}),this._prepareData(t);}serialize(){return {type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}},custom:class extends zt{constructor(e,t,i,r){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=i,this._implementation=t,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new Ct(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new Ct(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Rw(this._implementation.bounds,this.minzoom,this.maxzoom)),t.update=this._update.bind(this),t.clearTiles=this._clearTiles.bind(this),t.coveringTiles=this._coveringTiles.bind(this),k(this,O(t,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]));}serialize(){return O(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new It("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new It("data",{dataType:"source",sourceDataType:"content"}));}loaded(){return this._loaded}onAdd(e){this._map=e,this._loaded=!1,this.fire(new It("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),this.load();}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e);}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:r})}return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,i){const{x:r,y:n,z:o}=e.tileID.canonical,s=new t.AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:r,y:n,z:o},{signal:s.signal})).then(function(r){return delete e.request,e.aborted?(e.state="unloaded",i(null)):void 0===r?(e.state="errored",i(null)):null===r?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",i(null)):function(e){return e instanceof t.ImageData||e instanceof t.HTMLCanvasElement||e instanceof t.ImageBitmap||e instanceof t.HTMLImageElement}(r)?(this.loadTileData(e,r),e.state="loaded",void i(null)):(e.state="errored",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((t=>{20!==t.code&&(e.state="errored",i(t));})),e.request.cancel=()=>s.abort();}loadTileData(e,t){e.setTexture(t,this._map.painter);}unloadTile(e,t){if(e.texture&&e.texture instanceof My?(e.destroy(!0),e.texture&&e.texture instanceof My&&this._map.painter.saveTileTexture(e.texture)):e.destroy(),this._implementation.unloadTile){const{x:t,y:i,z:r}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:i,z:r});}t();}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t();}hasTransition(){return !1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_clearTiles(){const e=va(this.id,this.scope);this._map.style.clearSource(e);}_update(){this.fire(new It("data",{dataType:"source",sourceDataType:"content"}));}}},ST=function(e,t,i,r){const n=new AT[t.type](e,t,i,r);if(n.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${n.id}`);return j(["load","abort","unload","serialize","prepare"],n),n};function IT(e,t){const i=Au.identity([]);return Au.scale(i,i,[.5*e.width,.5*-e.height,1]),Au.translate(i,i,[1,-1,0]),Au.multiply(i,i,e.calculateProjMatrix(t.toUnwrapped())),Float32Array.from(i)}function CT(e,t,i,r,n,o,s,a=!1){const l=e.tilesIn(r,s,a);l.sort(PT);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r,n,o,IT(e.transform,r.tile.tileID),a)});const h=function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in e){const r=e[i],n=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of r)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e));}}return t}(c);for(const t in h)h[t].forEach((t=>{const i=t.feature,r=i.layer;r&&"background"!==r.type&&"sky"!==r.type&&"slot"!==r.type&&(i.source=r.source,r["source-layer"]&&(i.sourceLayer=r["source-layer"]),i.state=void 0!==i.id?e.getFeatureState(r["source-layer"],i.id):{});}));return h}function zT(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],n={};for(let e=0;e<i.length;e++){const o=i[e],s=o.tileID.canonical.key;n[s]||(n[s]=!0,o.querySourceFeatures(r,t));}return r}function PT(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}class DT{constructor(e){this.style=e;}processLayersChanged(){this.layers=[];for(const e in this.style._mergedLayers){const t=this.style._mergedLayers[e];if("fill-extrusion"===t.type)this.layers.push(t);else if("model"===t.type){const e=this.style.getLayerSource(t);e&&"batched-model"===e.type&&this.layers.push(t);}}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(let e=0;e<this.layers.length;++e){const i=this.layers[e],r=this.style.getLayerSourceCache(i);let n=1;"fill-extrusion"===i.type&&(n=i.paint.get("fill-extrusion-opacity")>0?i.paint.get("fill-extrusion-vertical-scale"):0);let o=r?r.getTile(t):null;if(!o&&r&&t.canonical.z>r.getSource().minzoom){let e=t.scaledTo(Math.min(r.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=r.getSource().minzoom&&(o=r.getTile(e),!o&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1);}this.currentBuildingBuckets.push({bucket:o?o.getBucket(i):null,tileID:o?o.tileID:t,verticalScale:n});}e.hasAnyZOffset=!1;let i=!1;for(let r=0;r<e.symbolInstances.length;r++){const n=e.symbolInstances.get(r),o=n.zOffset,s=this._getHeightAtTileOffset(t,n.tileAnchorX,n.tileAnchorY);n.zOffset=-1!==s?s:o,i||o===n.zOffset||(i=!0),e.hasAnyZOffset||0===n.zOffset||(e.hasAnyZOffset=!0);}i&&(e.zOffsetBuffersNeedUpload=!0,e.zOffsetSortDirty=!0);}_mapCoordToOverlappingTile(e,t,i,r){let n=t,o=i;if(e.canonical.z!==r.canonical.z){const s=r.canonical,a=1/(1<<e.canonical.z-s.z);n=(t+e.canonical.x*cr)*a-s.x*cr|0,o=(i+e.canonical.y*cr)*a-s.y*cr|0;}return {tileX:n,tileY:o}}_getHeightAtTileOffset(e,t,i){let r;for(let n=0;n<this.layers.length;++n){if("fill-extrusion"!==this.layers[n].type)continue;const{bucket:o,tileID:s,verticalScale:a}=this.currentBuildingBuckets[n];if(!o)continue;const{tileX:l,tileY:c}=this._mapCoordToOverlappingTile(e,t,i,s),h=o.getHeightAtTileCoord(l,c);if(h&&void 0!==h.height){if(!h.hidden)return h.height*a;r=h.height;}}for(let n=0;n<this.layers.length;++n){if("model"!==this.layers[n].type)continue;const{bucket:o,tileID:s}=this.currentBuildingBuckets[n];if(!o)continue;const{tileX:a,tileY:l}=this._mapCoordToOverlappingTile(e,t,i,s),c=o.getHeightAtTileCoord(a,l);if(c&&!c.hidden)return void 0===c.height&&void 0!==r?Math.min(c.maxHeight,r)*c.verticalScale:(c.height||0)*c.verticalScale}return -1}}var RT=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function LT(e,t){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return RT.forEach((e=>{e in t&&(i[e]=t[e]);})),i}function kT(e){e=e.slice();const t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=LT(e[i],t[e[i].ref]));return e}const OT={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setSlot:"setSlot",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setCamera:"setCamera",setLights:"setLights",setProjection:"setProjection",addImport:"addImport",removeImport:"removeImport",setImportUrl:"setImportUrl",setImportData:"setImportData",setImportConfig:"setImportConfig"};function BT(e,t,i){i.push({command:OT.addSource,args:[e,t[e]]});}function FT(e,t,i){t.push({command:OT.removeSource,args:[e]}),i[e]=!0;}function NT(e,t,i,r){FT(e,i,r),BT(e,t,i);}function UT(e,t,i){let r;for(r in e[i])if(e[i].hasOwnProperty(r)&&"data"!==r&&!x(e[i][r],t[i][r]))return !1;for(r in t[i])if(t[i].hasOwnProperty(r)&&"data"!==r&&!x(e[i][r],t[i][r]))return !1;return !0}function VT(e,t,i,r,n,o){let s;for(s in t=t||{},e=e||{})e.hasOwnProperty(s)&&(x(e[s],t[s])||i.push({command:o,args:[r,s,t[s],n]}));for(s in t)t.hasOwnProperty(s)&&!e.hasOwnProperty(s)&&(x(e[s],t[s])||i.push({command:o,args:[r,s,t[s],n]}));}function jT(e){return e.id}function GT(e,t){return e[t.id]=t,e}class qT{constructor(e,t){this.reset(e,t);}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding;}lerp(e){if(1===this.points.length)return this.points[0];e=z(e,0,1);let t=1,i=this._distances[t];const r=e*this.paddedLength+this.padding;for(;i<r&&t<this._distances.length;)i=this._distances[++t];const n=t-1,o=this._distances[n],s=i-o,a=s>0?(r-o)/s:0;return this.points[n].mult(1-a).add(this.points[t].mult(a))}}class ZT{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;e<this.xCellCount*this.yCellCount;e++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0;}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n);}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r);}_insertBoxCell(e,t,i,r,n,o){this.boxCells[n].push(o);}_insertCircleCell(e,t,i,r,n,o){this.circleCells[n].push(o);}_query(e,t,i,r,n,o){if(i<0||e>this.width||r<0||t>this.height)return !n&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return !0;for(let e=0;e<this.boxKeys.length;e++)s.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],i=this.circles[3*e+1],r=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-r,y1:i-r,x2:t+r,y2:i+r});}return o?s.filter(o):s}return this._forEachCell(e,t,i,r,this._queryCell,s,{hitTest:n,seenUids:{box:{},circle:{}}},o),n?s.length>0:s}_queryCircle(e,t,i,r,n){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return !r&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(e,t,i,r,n){return this._query(e,t,i,r,!1,n)}hitTest(e,t,i,r,n){return this._query(e,t,i,r,!0,n)}hitTestCircle(e,t,i,r){return this._queryCircle(e,t,i,!0,r)}_queryCell(e,t,i,r,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=n[c+2]&&t<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[h]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[h],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]});}}}const h=this.circleCells[n];if(null!==h){const n=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(n[h],n[h+1],n[h+2],e,t,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=n[h],t=n[h+1],i=n[h+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i});}}}}}_queryCellCircle(e,t,i,r,n,o,s,a){const l=s.circle,c=s.seenUids,h=this.boxCells[n];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const u=this.circleCells[n];if(null!==u){const e=this.circles;for(const t of u)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,i,r,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(n.call(this,e,t,i,r,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,n,o){const s=r-e,a=n-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(e-(r+a));if(l>a+i)return !1;const c=(s-n)/2,h=Math.abs(t-(n+c));if(h>c+i)return !1;if(l<=a||h<=c)return !0;const u=l-a,d=h-c;return u*u+d*d<=i*i}}const $T=100;class WT{constructor(e,t,i=new ZT(e.width+200,e.height+200,25),r=new ZT(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+$T,this.screenBottomBoundary=e.height+$T,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t;}placeCollisionBox(e,t,i,r,n,o,s,a){let l=i.projectedAnchorX,c=i.projectedAnchorY,h=i.projectedAnchorZ;const u=i.elevation,d=i.tileID,p=e.getProjection();if(u&&d){const[e,t,r]=p.upVector(d.canonical,i.tileAnchorX,i.tileAnchorY),n=p.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*u*n,c+=t*u*n,h+=r*u*n;}const f=this.projectAndGetPerspectiveRatio(s,l,c,h,i.tileID,"globe"===p.name||!!u||this.transform.pitch>0,p),m=o*f.perspectiveRatio,_=(i.x1*t+r.x-i.padding)*m+f.point.x,g=(i.y1*t+r.y-i.padding)*m+f.point.y,y=(i.x2*t+r.x+i.padding)*m+f.point.x,x=(i.y2*t+r.y+i.padding)*m+f.point.y,v=f.perspectiveRatio<=.55||f.occluded;return !this.isInsideGrid(_,g,y,x)||!n&&this.grid.hitTest(_,g,y,x,a)||v?{box:[],offscreen:!1,occluded:f.occluded}:{box:[_,g,y,x],offscreen:this.isOffscreen(_,g,y,x),occluded:!1}}placeCollisionCircles(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f){const m=[],_=this.transform.elevation,g=e.getProjection(),x=_?_.getAtTileOffsetFunc(f,this.transform.center.lat,this.transform.worldSize,g):null,v=new y(i.tileAnchorX,i.tileAnchorY);let{x:b,y:w,z:T}=g.projectTilePoint(v.x,v.y,f.canonical);if(x){const[e,t,i]=x(v);b+=e,w+=t,T+=i;}const E="globe"===g.name,M=this.projectAndGetPerspectiveRatio(s,b,w,T,f,E||!!_||this.transform.pitch>0,g),{perspectiveRatio:A}=M,S=(h?o/A:o*A)/u_,I=cv(b,w,T,a),C=M.signedDistanceFromCamera>0?pv(S,n,i.lineOffsetX*S,i.lineOffsetY*S,!1,I,v,i,r,a,{},_&&!h?x:null,h&&!!_,g,f,h):null;let z=!1,P=!1,D=!0;if(C&&!M.occluded){const e=.5*d*A+p,i=new y(-100,-100),r=new y(this.screenRightBoundary,this.screenBottomBoundary),n=new qT,{first:o,last:s}=C,a=o.path.length;let h=[];for(let e=a-1;e>=1;e--)h.push(o.path[e]);for(let e=1;e<s.path.length;e++)h.push(s.path[e]);const f=2.5*e;l&&(h=h.map((([e,t,i],r)=>(x&&!E&&(i=x(r<a-1?o.tilePath[a-1-r]:s.tilePath[r-a+2])[2]),cv(e,t,i,l)))),h.some((e=>e[3]<=0))&&(h=[]));let _=[];if(h.length>0){let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const i of h)e=Math.min(e,i[0]),n=Math.min(n,i[1]),t=Math.max(t,i[0]),o=Math.max(o,i[1]);t>=i.x&&e<=r.x&&o>=i.y&&n<=r.y&&(_=[h.map((e=>new y(e[0],e[1])))],(e<i.x||t>r.x||n<i.y||o>r.y)&&(_=Y_(_,i.x,i.y,r.x,r.y)));}for(const i of _){n.reset(i,.25*e);let r=0;r=n.length<=.5*e?1:Math.ceil(n.paddedLength/f)+1;for(let i=0;i<r;i++){const o=i/Math.max(r-1,1),s=n.lerp(o),a=s.x+$T,l=s.y+$T;m.push(a,l,e,0);const h=a-e,d=l-e,p=a+e,f=l+e;if(D=D&&this.isOffscreen(h,d,p,f),P=P||this.isInsideGrid(h,d,p,f),!t&&this.grid.hitTestCircle(a,l,e,u)&&(z=!0,!c))return {circles:[],offscreen:!1,collisionDetected:z,occluded:!1}}}}return {circles:!c&&z||!P?[]:m,offscreen:D,collisionDetected:z,occluded:M.occluded}}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return {};const t=[];let i=1/0,r=1/0,n=-1/0,o=-1/0;for(const s of e){const e=new y(s.x+$T,s.y+$T);i=Math.min(i,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y),t.push(e);}const s=this.grid.query(i,r,n,o).concat(this.ignoredGrid.query(i,r,n,o)),a={},l={};for(const e of s){const i=e.key;void 0===a[i.bucketInstanceId]&&(a[i.bucketInstanceId]={}),a[i.bucketInstanceId][i.featureIndex]||bp(t,[new y(e.x1,e.y1),new y(e.x2,e.y1),new y(e.x2,e.y2),new y(e.x1,e.y2)])&&(a[i.bucketInstanceId][i.featureIndex]=!0,void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]=[]),l[i.bucketInstanceId].push(i.featureIndex));}return l}insertCollisionBox(e,t,i,r,n){(t?this.ignoredGrid:this.grid).insert({bucketInstanceId:i,featureIndex:r,collisionGroupID:n},e[0],e[1],e[2],e[3]);}insertCollisionCircles(e,t,i,r,n){const o=t?this.ignoredGrid:this.grid,s={bucketInstanceId:i,featureIndex:r,collisionGroupID:n};for(let t=0;t<e.length;t+=4)o.insertCircle(s,e[t],e[t+1],e[t+2]);}projectAndGetPerspectiveRatio(e,t,i,r,n,o,s){const a=[t,i,r,1];let l=!1;if(r||this.transform.pitch>0){if(yu.transformMat4(a,a,e),this.fogState&&n&&"globe"!==s.name){const e=function(e,t,i,r,n,o){const s=o.calculateFogTileMatrix(n),a=[t,i,r];return Du.transformMat4(a,a,s),mw(e,Du.length(a),o.pitch,o._fov)}(this.fogState,t,i,r,n.toUnwrapped(),this.transform);l=e>.9;}}else vv(a,a,e);const c=a[3];return {point:new y((a[0]/c+1)/2*this.transform.width+$T,(-a[1]/c+1)/2*this.transform.height+$T),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(s)/c*.5,1.5),signedDistanceFromCamera:c,occluded:o&&a[2]>c||l}}isOffscreen(e,t,i,r){return i<$T||e>=this.screenRightBoundary||r<$T||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const e=Au.identity([]);return Au.translate(e,e,[-100,-100,0]),e}}function HT(e,t,i){const r=t.createTileMatrix(e,e.worldSize,i.toUnwrapped());return Au.multiply(new Float32Array(16),e.projMatrix,r)}function XT(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const r=i.clone();return r.setProjection(t.projection),HT(r,t.getProjection(),e)}function YT(e,t,i){return t.name===i.projection.name?e.projMatrix:HT(i,t,e)}class KT{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i;}isHidden(){return 0===this.opacity&&!this.placed}}class JT{constructor(e,t,i,r,n,o=!1){this.text=new KT(e?e.text:null,t,i,n),this.icon=new KT(e?e.icon:null,t,r,n),this.clipped=o;}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class QT{constructor(e,t,i,r=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=r;}}class eE{constructor(){this.invProjMatrix=Au.create(),this.viewportMatrix=Au.create(),this.circles=[];}}class tE{constructor(e,t,i,r,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n;}}class iE{constructor(e){this.crossSourceCollisions=e,this.maxGroupID=0,this.collisionGroups={};}get(e){if(this.crossSourceCollisions)return {ID:0,predicate:null};if(!this.collisionGroups[e]){const t=++this.maxGroupID;this.collisionGroups[e]={ID:t,predicate:e=>e.collisionGroupID===t};}return this.collisionGroups[e]}}function rE(e,t,i,r,n){const{horizontalAlign:o,verticalAlign:s}=F_(e),a=-(o-.5)*t,l=-(s-.5)*i,c=xg(e,r);return new y(a+c[0]*n,l+c[1]*n)}function nE(e,t,i,r,n){const o=new y(e,t);return i&&o._rotate(r?n:-n),o}class oE{constructor(e,t,i,r,n,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new WT(this.transform,n),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new iE(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={};}getBucketParts(e,t,i,r){const n=i.getBucket(t),o=i.latestFeatureIndex;if(!n||!o||t.fqid!==n.layerIds[0])return;const s=n.layers[0].layout,a=i.collisionBoxArray,l=Math.pow(2,this.transform.zoom-i.tileID.overscaledZ),c=i.tileSize/cr,h=i.tileID.toUnwrapped();this.transform.setProjection(n.projection);const u=(d=i.tileID,p=n.getProjection(),f=this.transform,p.name===this.projection?f.calculateProjMatrix(d.toUnwrapped()):HT(f,p,d));var d,p,f;const m="map"===s.get("text-pitch-alignment"),_="map"===s.get("text-rotation-alignment");t.compileFilter();const g=t.dynamicFilter(),y=t.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(i),v=av(u,i.tileID.canonical,m,_,this.transform,n.getProjection(),x);let b=null;if(m){const e=lv(u,i.tileID.canonical,m,_,this.transform,n.getProjection(),x);b=Au.multiply([],this.transform.labelPlaneMatrix,e);}let w=null;g&&i.latestFeatureIndex&&(w={unwrappedTileID:h,dynamicFilter:g,dynamicFilterNeedsFeature:y,featureIndex:i.latestFeatureIndex}),this.retainedQueryData[n.bucketInstanceId]=new tE(n.bucketInstanceId,o,n.sourceLayerIndex,n.index,i.tileID);const T={bucket:n,layout:s,posMatrix:u,textLabelPlaneMatrix:v,labelToScreenMatrix:b,clippingData:w,scale:l,textPixelRatio:c,holdingForFade:i.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:m_(n.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:m_(n.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(r)for(const t of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:T});}else e.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:T});}attemptAnchorPlacement(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const{textOffset0:y,textOffset1:x,crossTileID:v}=u,b=[y,x],w=rE(e,i,r,b,n),T=this.collisionIndex.placeCollisionBox(p,n,t,nE(w.x,w.y,o,s,this.transform.angle),h,a,l,c.predicate);if(m){const e=p.getSymbolInstanceIconSize(g,this.transform.zoom,u.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(p,e,m,nE(w.x,w.y,o,s,this.transform.angle),h,a,l,c.predicate).box.length)return}if(T.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[v]&&this.prevPlacement.placements[v]&&this.prevPlacement.placements[v].text&&(t=this.prevPlacement.variableOffsets[v].anchor),this.variableOffsets[v]={textOffset:b,width:i,height:r,anchor:e,textScale:n,prevAnchor:t},this.markUsedJustification(p,e,u,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,u),this.placedOrientations[v]=f),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(e,t,i,r){const{bucket:n,layout:o,posMatrix:s,textLabelPlaneMatrix:a,labelToScreenMatrix:l,clippingData:c,textPixelRatio:h,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:p,partiallyEvaluatedIconSize:f,collisionGroup:m}=e.parameters,_=o.get("text-optional"),g=o.get("icon-optional"),x=o.get("text-allow-overlap"),v=o.get("icon-allow-overlap"),b="map"===o.get("text-rotation-alignment"),w="map"===o.get("text-pitch-alignment"),T="viewport-y"===o.get("symbol-z-order"),E=o.get("symbol-z-elevate");this.transform.setProjection(n.projection);let M=x&&(v||!n.hasIconData()||g),A=v&&(x||!n.hasTextData()||_);!n.collisionArrays&&d&&n.deserializeCollisionBoxes(d),i&&r&&n.updateCollisionDebugBuffers(this.transform.zoom,d);const S=(e,r,d)=>{const{crossTileID:T,numVerticalGlyphVertices:E}=e;if(c){const i={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(c.dynamicFilterNeedsFeature){const t=this.retainedQueryData[n.bucketInstanceId];r=c.featureIndex.loadFeature({featureIndex:e.featureIndex,bucketIndex:t.bucketIndex,sourceLayerIndex:t.sourceLayerIndex,layoutVertexArrayOffset:0});}if(!(0,c.dynamicFilter)(i,r,this.retainedQueryData[n.bucketInstanceId].tileID.canonical,new y(e.tileAnchorX,e.tileAnchorY),this.transform.calculateDistanceTileData(c.unwrappedTileID)))return this.placements[T]=new QT(!1,!1,!1,!0),void t.add(T)}if(t.has(T))return;if(u)return void(this.placements[T]=new QT(!1,!1,!1));let S=!1,I=!1,C=!0,z=!1,P=!1,D=null,R={box:null,offscreen:null,occluded:null},L={box:null,offscreen:null,occluded:null},k=null,O=null,B=null,F=0,N=0,U=0;d.textFeatureIndex?F=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(F=e.featureIndex),d.verticalTextFeatureIndex&&(N=d.verticalTextFeatureIndex);const V=t=>{t.tileID=this.retainedQueryData[n.bucketInstanceId].tileID;const i=this.transform.elevation;t.elevation=e.zOffset+(i?i.getAtTileOffset(t.tileID,t.tileAnchorX,t.tileAnchorY):0);},j=d.textBox;if(j){V(j);const t=t=>{let i=A_.horizontal;if(n.allowVerticalPlacement&&!t&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[T];t&&(this.placedOrientations[T]=t,i=t,this.markUsedOrientation(n,i,e));}return i},i=(e,t)=>{if(n.allowVerticalPlacement&&E>0&&d.verticalTextBox){for(const i of n.writingModes)if(i===A_.vertical?(R=t(),L=R):R=e(),R&&R.box&&R.box.length)break}else R=e();};if(o.get("text-variable-anchor")){let a=o.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[T]){const e=this.prevPlacement.variableOffsets[T];a.indexOf(e.anchor)>0&&(a=a.filter((t=>t!==e.anchor)),a.unshift(e.anchor));}const l=(t,i,o)=>{const l=n.getSymbolInstanceTextSize(p,e,this.transform.zoom,r),c=(t.x2-t.x1)*l+2*t.padding,u=(t.y2-t.y1)*l+2*t.padding,d=e.hasIconTextFit&&!v?i:null;d&&V(d);let _={box:[],offscreen:!1,occluded:!1};const g=x?2*a.length:a.length;for(let i=0;i<g;++i){const g=this.attemptAnchorPlacement(a[i%a.length],t,c,u,l,b,w,h,s,m,i>=a.length,e,r,n,o,d,p,f);if(g&&(_=g.placedGlyphBoxes,_&&_.box&&_.box.length)){S=!0,D=g.shift;break}}return _};i((()=>l(j,d.iconBox,A_.horizontal)),(()=>{const e=d.verticalTextBox;return e&&V(e),n.allowVerticalPlacement&&!(R&&R.box&&R.box.length)&&E>0&&e?l(e,d.verticalIconBox,A_.vertical):{box:null,offscreen:null,occluded:null}})),R&&(S=R.box,C=R.offscreen,z=R.occluded);const c=t(!(!R||!R.box));if(!S&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[T];t&&(this.variableOffsets[T]=t,this.markUsedJustification(n,t.anchor,e,c));}}else {const o=(t,i)=>{const o=n.getSymbolInstanceTextSize(p,e,this.transform.zoom,r),a=this.collisionIndex.placeCollisionBox(n,o,t,new y(0,0),x,h,s,m.predicate);return a&&a.box&&a.box.length&&(this.markUsedOrientation(n,i,e),this.placedOrientations[T]=i),a};i((()=>o(j,A_.horizontal)),(()=>{const e=d.verticalTextBox;return n.allowVerticalPlacement&&E>0&&e?(V(e),o(e,A_.vertical)):{box:null,offscreen:null,occluded:null}})),t(!!(R&&R.box&&R.box.length));}}if(k=R,S=k&&k.box&&k.box.length>0,C=k&&k.offscreen,z=k&&k.occluded,e.useRuntimeCollisionCircles){const t=n.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex),r=f_(n.textSizeData,p,t),c=o.get("text-padding");O=this.collisionIndex.placeCollisionCircles(n,x,t,n.lineVertexArray,n.glyphOffsetArray,r,s,a,l,i,w,m.predicate,e.collisionCircleDiameter*r/u_,c,this.retainedQueryData[n.bucketInstanceId].tileID),S=x||O.circles.length>0&&!O.collisionDetected,C=C&&O.offscreen,z=O.occluded;}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const t=t=>{V(t);const i=e.hasIconTextFit&&D?nE(D.x,D.y,b,w,this.transform.angle):new y(0,0),r=n.getSymbolInstanceIconSize(f,this.transform.zoom,e.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(n,r,t,i,v,h,s,m.predicate)};L&&L.box&&L.box.length&&d.verticalIconBox?(B=t(d.verticalIconBox),I=B.box.length>0):(B=t(d.iconBox),I=B.box.length>0),C=C&&B.offscreen,P=B.occluded;}const G=_||0===e.numHorizontalGlyphVertices&&0===E,q=g||0===e.numIconVertices;if(G||q?q?G||(I=I&&S):S=I&&S:I=S=I&&S,S&&k&&k.box&&this.collisionIndex.insertCollisionBox(k.box,o.get("text-ignore-placement"),n.bucketInstanceId,L&&L.box&&N?N:F,m.ID),I&&B&&this.collisionIndex.insertCollisionBox(B.box,o.get("icon-ignore-placement"),n.bucketInstanceId,U,m.ID),O&&(S&&this.collisionIndex.insertCollisionCircles(O.circles,o.get("text-ignore-placement"),n.bucketInstanceId,F,m.ID),i)){const e=n.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new eE);for(let e=0;e<O.circles.length;e+=4)t.circles.push(O.circles[e+0]),t.circles.push(O.circles[e+1]),t.circles.push(O.circles[e+2]),t.circles.push(O.collisionDetected?1:0);}const Z="globe"!==n.projection.name;M=M&&(Z||!z),A=A&&(Z||!P),this.placements[T]=new QT(S||M,I||A,C||n.justReloaded),t.add(T);};if(E&&this.buildingIndex&&(this.buildingIndex.updateZOffset(n,this.retainedQueryData[n.bucketInstanceId].tileID),n.updateZOffset()),T){const e=n.getSortedSymbolIndexes(this.transform.angle);for(let t=e.length-1;t>=0;--t){const i=e[t];S(n.symbolInstances.get(i),i,n.collisionArrays[i]);}n.hasAnyZOffset&&H(`${n.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`);}else if(n.hasAnyZOffset){const e=n.getSortedIndexesByZOffset();for(let t=0;t<e.length;++t){const i=e[t];S(n.symbolInstances.get(i),i,n.collisionArrays[i]);}}else for(let t=e.symbolInstanceStart;t<e.symbolInstanceEnd;t++)S(n.symbolInstances.get(t),t,n.collisionArrays[t]);if(i&&n.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[n.bucketInstanceId];Au.invert(e.invProjMatrix,s),e.viewportMatrix=this.collisionIndex.getViewportMatrix();}n.justReloaded=!1;}markUsedJustification(e,t,i,r){const{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:a,crossTileID:l}=i,c=bg(t),h=r===A_.vertical?a:"left"===c?n:"center"===c?o:"right"===c?s:-1;n>=0&&(e.text.placedSymbolArray.get(n).crossTileID=h>=0&&n!==h?0:l),o>=0&&(e.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:l),s>=0&&(e.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:l),a>=0&&(e.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:l);}markUsedOrientation(e,t,i){const r=t===A_.horizontal||t===A_.horizontalOnly?t:0,n=t===A_.vertical?t:0,{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:l}=i,c=e.text.placedSymbolArray;o>=0&&(c.get(o).placedOrientation=r),s>=0&&(c.get(s).placedOrientation=r),a>=0&&(c.get(a).placedOrientation=r),l>=0&&(c.get(l).placedOrientation=n);}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new JT(o,r,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new JT(null,r,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon);}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new JT(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,i=i||t.text.placed||t.icon.placed);}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t){const i=new Set;for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,i,r.collisionBoxArray),t.layers[0].layout.get("symbol-z-elevate")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,r.tileID),t.updateZOffset()));}}updateBucketOpacities(e,t,i){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const r=e.layers[0].layout,n=!!e.layers[0].dynamicFilter(),o=new JT(null,0,!1,!1,!0),s=r.get("text-allow-overlap"),a=r.get("icon-allow-overlap"),l=r.get("text-variable-anchor"),c="map"===r.get("text-rotation-alignment"),h="map"===r.get("text-pitch-alignment"),u=new JT(null,0,s&&(a||!e.hasIconData()||r.get("icon-optional")),a&&(s||!e.hasTextData()||r.get("text-optional")),!0);!e.collisionArrays&&i&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(i);const d=(e,t,i)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(i);};let p=0;for(let i=0;i<e.symbolInstances.length;i++){const r=e.symbolInstances.get(i),{numHorizontalGlyphVertices:s,numVerticalGlyphVertices:a,crossTileID:f,numIconVertices:m}=r,_=t.has(f);let g=this.opacities[f];_?g=o:g||(g=u,this.opacities[f]=g),t.add(f);const x=s>0||a>0,v=m>0,b=this.placedOrientations[f],w=b===A_.vertical,T=b===A_.horizontal||b===A_.horizontalOnly;if(!x&&!v||g.isHidden()||p++,x){const t=fE(g.text);d(e.text,s,w?mE:t),d(e.text,a,T?mE:t);const i=g.text.isHidden(),{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=r,h=e.text.placedSymbolArray,u=i||w?1:0;n>=0&&(h.get(n).hidden=u),o>=0&&(h.get(o).hidden=u),l>=0&&(h.get(l).hidden=u),c>=0&&(h.get(c).hidden=i||T?1:0);const p=this.variableOffsets[f];p&&this.markUsedJustification(e,p.anchor,r,b);const m=this.placedOrientations[f];m&&(this.markUsedJustification(e,"left",r,m),this.markUsedOrientation(e,m,r));}if(v){const t=fE(g.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:n}=r,o=e.icon.placedSymbolArray,s=g.icon.isHidden()?1:0;i>=0&&(d(e.icon,m,w?mE:t),o.get(i).hidden=s),n>=0&&(d(e.icon,r.numVerticalIconVertices,T?mE:t),o.get(n).hidden=s);}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const t=e.collisionArrays[i];if(t){let i=new y(0,0),o=!0;if(t.textBox||t.verticalTextBox){if(l){const e=this.variableOffsets[f];e?(i=rE(e.anchor,e.width,e.height,e.textOffset,e.textScale),c&&i._rotate(h?this.transform.angle:-this.transform.angle)):o=!1;}n&&(o=!g.clipped),t.textBox&&sE(e.textCollisionBox.collisionVertexArray,g.text.placed,!o||w,i.x,i.y),t.verticalTextBox&&sE(e.textCollisionBox.collisionVertexArray,g.text.placed,!o||T,i.x,i.y);}const s=o&&Boolean(!T&&t.verticalIconBox);t.iconBox&&sE(e.iconCollisionBox.collisionVertexArray,g.icon.placed,s,r.hasIconTextFit?i.x:0,r.hasIconTextFit?i.y:0),t.verticalIconBox&&sE(e.iconCollisionBox.collisionVertexArray,g.icon.placed,!s,r.hasIconTextFit?i.x:0,r.hasIconTextFit?i.y:0);}}}if(e.fullyClipped=0===p,e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId];}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0;}}function sE(e,t,i,r,n){e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0);}const aE=Math.pow(2,25),lE=Math.pow(2,24),cE=Math.pow(2,17),hE=Math.pow(2,16),uE=Math.pow(2,9),dE=Math.pow(2,8),pE=Math.pow(2,1);function fE(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,i=Math.floor(127*e.opacity);return i*aE+t*lE+i*cE+t*hE+i*uE+t*dE+i*pE+t}const mE=0;class _E{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[];}continuePlacement(e,t,i,r,n){const o=this._bucketParts;for(;this._currentTileIndex<e.length;)if(t.getBucketParts(o,r,e[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return !0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort(((e,t)=>e.sortKey-t.sortKey)));this._currentPartIndex<o.length;){const e=o[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,i,0===e.symbolInstanceStart),this._currentPartIndex++,n())return !0}return !1}}class gE{constructor(e,t,i,r,n,o,s,a,l){this.placement=new oE(e,n,o,s,a,l),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=r,this._done=!1;}isDone(){return this._done}continuePlacement(e,t,i,r){const n=dt.now(),o=()=>{const e=dt.now()-n;return !this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const n=t[e[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if("symbol"===n.type&&(!n.minzoom||n.minzoom<=s)&&(!n.maxzoom||n.maxzoom>s)){const e=n,t=e.layout.get("symbol-z-elevate"),s=this._inProgressLayer=this._inProgressLayer||new _E(e),a=va(n.source,n.scope);if(s.continuePlacement(t?r[a]:i[a],this.placement,this._showCollisionBoxes,n,o))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const yE=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class xE{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=yE[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new xE(s,o,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=yE.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e);}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return vE(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u<=s){for(let s=u;s<=h;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=r&&l.push(n[s]);}continue}const d=u+h>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=r&&l.push(n[d]),(0===c?e<=p:t<=f)&&(a.push(u),a.push(d-1),a.push(1-c)),(0===c?i>=p:r>=f)&&(a.push(d+1),a.push(h),a.push(1-c));}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,s=[0,r.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,h=s.pop()||0,u=s.pop()||0;if(h-u<=o){for(let i=u;i<=h;i++)EE(n[2*i],n[2*i+1],e,t)<=l&&a.push(r[i]);continue}const d=u+h>>1,p=n[2*d],f=n[2*d+1];EE(p,f,e,t)<=l&&a.push(r[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(u),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(h),s.push(1-c));}return a}}function vE(e,t,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;bE(e,t,s,r,n,o),vE(e,t,i,r,s-1,1-o),vE(e,t,i,s+1,n,1-o);}function bE(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);bE(e,t,i,Math.max(r,Math.floor(i-a*c/s+h)),Math.min(n,Math.floor(i+(s-a)*c/s+h)),o);}const s=t[2*i+o];let a=r,l=n;for(wE(e,t,r,i),t[2*n+o]>s&&wE(e,t,r,n);a<l;){for(wE(e,t,a,l),a++,l--;t[2*a+o]<s;)a++;for(;t[2*l+o]>s;)l--;}t[2*r+o]===s?wE(e,t,r,l):(l++,wE(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1);}}function wE(e,t,i,r){TE(e,i,r),TE(t,2*i,2*r),TE(t,2*i+1,2*r+1);}function TE(e,t,i){const r=e[t];e[t]=e[i],e[i]=r;}function EE(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}const ME=512/cr/2;class AE{constructor(e,t,i){this.tileID=e,this.bucketInstanceId=i,this.index=new xE(t.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=e.canonical.x*cr,n=e.canonical.y*cr;for(let e=0;e<t.length;e++){const{key:i,crossTileID:o,tileAnchorX:s,tileAnchorY:a}=t.get(e),l=Math.floor((r+s)*ME),c=Math.floor((n+a)*ME);this.index.add(l,c),this.keys.push(i),this.crossTileIDs.push(o);}this.index.finish();}findMatches(e,t,i){const r=this.tileID.canonical.z<t.canonical.z?1:Math.pow(2,this.tileID.canonical.z-t.canonical.z),n=ME/Math.pow(2,t.canonical.z-this.tileID.canonical.z),o=t.canonical.x*cr,s=t.canonical.y*cr;for(let t=0;t<e.length;t++){const a=e.get(t);if(a.crossTileID)continue;const{key:l,tileAnchorX:c,tileAnchorY:h}=a,u=Math.floor((o+c)*n),d=Math.floor((s+h)*n),p=this.index.range(u-r,d-r,u+r,d+r);for(const e of p){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!i.has(t)){i.add(t),a.crossTileID=t;break}}}}}class SE{constructor(){this.maxCrossTileID=0;}generate(){return ++this.maxCrossTileID}}class IE{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0;}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const n=i[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n;}this.indexes[e]=r;}this.lng=e;}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return !1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key]);}for(let e=0;e<t.symbolInstances.length;e++)t.symbolInstances.get(e).crossTileID=0;this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]=new Set);const r=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r);}else {const o=n[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,r);}}for(let e=0;e<t.symbolInstances.length;e++){const n=t.symbolInstances.get(e);n.crossTileID||(n.crossTileID=i.generate(),r.add(n.crossTileID));}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new AE(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i of t.crossTileIDs)this.usedCrossTileIDs[e].delete(i);}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)e[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],t=!0);}return t}}class CE{constructor(){this.layerIndexes={},this.crossTileIDs=new SE,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={};}addLayer(e,t,i,r){let n=this.layerIndexes[e.fqid];void 0===n&&(n=this.layerIndexes[e.fqid]=new IE);let o=!1;const s={};"globe"!==r.name&&n.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);t&&e.fqid===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(i.tileID,t,this.crossTileIDs)&&(o=!0),s[t.bucketInstanceId]=!0);}return n.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(e){const t={};e.forEach((e=>{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}var zE="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#ifdef RENDER_CUTOFF\nfloat cutoff_opacity(vec4 cutoff_params,float depth) {float near=cutoff_params.x;float far=cutoff_params.y;float cutoffStart=cutoff_params.z;float cutoffEnd=cutoff_params.w-0.0001;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",PE="in highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;out highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",DE="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(dd,0)).r;float bl=texture(u_dem,pos+vec2(0,dd)).r;float br=texture(u_dem,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture(u_dem_prev,pos).r;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=texture(u_dem_prev,pos).r;float tr=texture(u_dem_prev,pos+vec2(dd,0)).r;float bl=texture(u_dem_prev,pos+vec2(0,dd)).r;float br=texture(u_dem_prev,pos+vec2(dd,dd)).r;return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture(u_depth,uv-df.xz)),unpack_depth(texture(u_depth,uv+df.xz)),unpack_depth(texture(u_depth,uv-df.zy)),unpack_depth(texture(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",RE="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;out vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",LE="highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {\n#ifdef FOG_DITHERING\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\n#else\nreturn color;\n#endif\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",kE="#ifdef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);vec4 _raTexLinearCoord(vec2 texCoord,vec2 texResolution,out vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return (texCoord.xxyy+vec2(1.5,0.5).xyxy)/texResolution.xxyy;}vec2 _raTexLinearMix(vec2 fxy,vec4 colorMix,float colorOffset,vec4 t00,vec4 t10,vec4 t01,vec4 t11) {vec2 c00=t00==NODATA ? vec2(0) : vec2(colorOffset+dot(t00,colorMix),1);vec2 c10=t10==NODATA ? vec2(0) : vec2(colorOffset+dot(t10,colorMix),1);vec2 c01=t01==NODATA ? vec2(0) : vec2(colorOffset+dot(t01,colorMix),1);vec2 c11=t11==NODATA ? vec2(0) : vec2(colorOffset+dot(t11,colorMix),1);return mix(mix(c01,c11,fxy.x),mix(c00,c10,fxy.x),fxy.y);}vec2 raTexture2D_image0_linear(vec2 texCoord,vec2 texResolution,vec4 colorMix,float colorOffset) {vec2 fxy;vec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texture(u_image0,c.yz),texture(u_image0,c.xz),texture(u_image0,c.yw),texture(u_image0,c.xw)\n);}vec2 raTexture2D_image1_linear(vec2 texCoord,vec2 texResolution,vec4 colorMix,float colorOffset) {vec2 fxy;vec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texture(u_image1,c.yz),texture(u_image1,c.xz),texture(u_image1,c.yw),texture(u_image1,c.xw)\n);}vec2 raTexture2D_image0_nearest(vec2 texCoord,vec2 texResolution,vec4 colorMix,float colorOffset) {vec4 t=texture(u_image0,texCoord);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(vec2 texCoord,vec2 texResolution,vec4 colorMix,float colorOffset) {vec4 t=texture(u_image1,texCoord);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",OE="#ifdef RENDER_SHADOWS\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\n#endif//RENDER_SHADOWS",BE="#ifdef RENDER_SHADOWS\n#ifdef DEPTH_TEXTURE\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\n#else\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\n#endif\nuniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_1,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_1,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\n#ifdef DEPTH_TEXTURE\nshadow_depth=texture(u_shadowmap_0,uv).r;\n#else\nshadow_depth=unpack_depth(texture(u_shadowmap_0,uv))*0.5+0.5;\n#endif\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\n#ifdef NATIVE\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\n#else\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\n);\n#endif\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\n#ifdef SHADOWS_SINGLE_CASCADE\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\n#else\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\n#endif\n}highp float calculate_shadow_bias(float NDotL) {\n#ifdef NORMAL_OFFSET\nreturn 0.5*u_shadow_bias.x;\n#else\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\n#endif\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_unbiased(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=0.0;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}float shadow_occlusion(float ndotl,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float bias=calculate_shadow_bias(ndotl);return shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);}\n#endif";const FE=[];qE(zE,FE);const NE={"_prelude_fog.vertex.glsl":RE,"_prelude_terrain.vertex.glsl":DE,"_prelude_shadow.vertex.glsl":OE,"_prelude_fog.fragment.glsl":LE,"_prelude_shadow.fragment.glsl":BE,"_prelude_lighting.glsl":"\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec3 u_lighting_ambient_color;uniform mediump vec3 u_lighting_directional_dir;uniform mediump vec3 u_lighting_directional_color;uniform mediump vec3 u_ground_radiance;float calculate_ambient_directional_factor(vec3 normal) {float NdotL=dot(normal,u_lighting_directional_dir);const float factor_reduction_max=0.3;float dir_luminance=dot(u_lighting_directional_color,vec3(0.2126,0.7152,0.0722));float directional_factor_min=1.0-factor_reduction_max*min(dir_luminance,1.0);float ambient_directional_factor=mix(directional_factor_min,1.0,min((NdotL+1.0),1.0));const float vertical_factor_min=0.92;float vertical_factor=mix(vertical_factor_min,1.0,normal.z*0.5+0.5);return vertical_factor*ambient_directional_factor;}vec3 linearProduct(vec3 srgbIn,vec3 k) {return srgbIn*pow(k,vec3(1./2.2));}vec3 apply_lighting(vec3 color,vec3 normal,float dir_factor) {float ambient_directional_factor=calculate_ambient_directional_factor(normal);vec3 ambient_contrib=ambient_directional_factor*u_lighting_ambient_color;vec3 directional_contrib=u_lighting_directional_color*dir_factor;return linearProduct(color,ambient_contrib+directional_contrib);}vec4 apply_lighting(vec4 color,vec3 normal,float dir_factor) {return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting(vec3 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return apply_lighting(color.rgb,normal,dir_factor);}vec4 apply_lighting(vec4 color,vec3 normal) {float dir_factor=max(dot(normal,u_lighting_directional_dir),0.0);return vec4(apply_lighting(color.rgb,normal,dir_factor),color.a);}vec3 apply_lighting_ground(vec3 color) {return color*u_ground_radiance;}vec4 apply_lighting_ground(vec4 color) {return vec4(apply_lighting_ground(color.rgb),color.a);}float calculate_NdotL(vec3 normal) {const float ext=0.70710678118;return (clamp(dot(normal,u_lighting_directional_dir),-ext,1.0)+ext)/(1.0+ext);}vec4 apply_lighting_with_emission_ground(vec4 color,float emissive_strength) {return mix(apply_lighting_ground(color),color,emissive_strength);}vec3 compute_flood_lighting(vec3 flood_light_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=flood_light_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);float occlusion_ramp=smoothstep(0.0,0.2,1.0-occlusion);return mix(fully_occluded_color,flood_light_color,occlusion_ramp);}vec3 compute_emissive_draped(vec3 unlit_color,float fully_occluded_factor,float occlusion,vec3 ground_shadow_factor) {vec3 fully_occluded_color=unlit_color*mix(ground_shadow_factor,vec3(1.0),fully_occluded_factor);return mix(fully_occluded_color,unlit_color,1.0-occlusion);}\n#endif//LIGHTING_3D_MODE","_prelude_raster_array.glsl":kE},UE={};ZE("",DE),ZE(LE,RE),ZE(BE,OE),ZE(kE,"");const VE=ZE("\nout vec4 glFragColor;highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\n#ifdef INDICATOR_CUTOUT\nuniform vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color) {\n#ifdef INDICATOR_CUTOUT\nfloat holeMinOpacity=u_indicator_cutout_params.x;float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\n#else\nreturn color;\n#endif\n}\n#ifdef DEBUG_WIREFRAME\n#define HANDLE_WIREFRAME_DEBUG \\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\ngl_FragDepth=gl_FragCoord.z-0.0001;\n#else\n#define HANDLE_WIREFRAME_DEBUG\n#endif\n#ifdef RENDER_CUTOFF\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\n#endif","\n#define EXTENT 8192.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}\n#ifdef RENDER_CUTOFF\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\n#endif\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}"),jE=zE;var GE={background:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting_with_emission_ground(u_color,u_emissive_strength);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),backgroundPattern:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),circle:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\nglFragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nout vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}'),clippingMask:ZE("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:ZE('#include "_prelude_fog.fragment.glsl"\nuniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nout vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),heatmapTexture:ZE("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));glFragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(0.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}","in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:ZE("in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",'#include "_prelude_terrain.vertex.glsl"\nin vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in float a_size_scale;in vec2 a_padding;in float a_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;out float v_placed;out float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(a_z_offset+elevation(a_anchor_pos)),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'),collisionCircle:ZE("in float v_radius;in vec2 v_extrude;in float v_perspective_ratio;in float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);glFragColor=color*alpha*opacity_t;}","in vec2 a_pos_2f;in float a_radius;in vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;out float v_radius;out vec2 v_extrude;out float v_perspective_ratio;out float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:ZE("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}",'#include "_prelude_terrain.vertex.glsl"\nin vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;\n#endif\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}'),fill:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutline:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;out vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;in vec2 v_pos;in vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;out vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;in vec2 v_pos;uniform float u_emissive_strength;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nin vec4 v_color;in vec4 v_flat;\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth;\n#endif\nuniform lowp float u_opacity;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec2 v_ao;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nin vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nin highp vec3 v_normal;\n#endif\nuniform vec3 u_flood_light_color;uniform highp float u_vertical_scale;uniform float u_flood_light_intensity;uniform vec3 u_ground_shadow_factor;\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nin float v_flood_radius;in float v_has_floodlight;\n#endif\nuniform float u_emissive_strength;in float v_height;void main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nvec3 normal=normalize(v_normal);\n#endif\nfloat z;vec4 color=v_color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);\n#ifdef LIGHTING_3D_MODE\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#else\ncolor=mix(v_color,v_roof_color,z);\n#endif\n#endif\nfloat h=max(0.0,v_height);float ao_shade=1.0;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\n#else\ncolor.rgb*=ao_shade;\n#endif\n#else\ncolor.rgb*=ao_shade;\n#endif\n#endif\n#ifdef LIGHTING_3D_MODE\nfloat flood_radiance=0.0;\n#ifdef FLOOD_LIGHT\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef FLOOD_LIGHT\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,v_depth);vec3 litColor=apply_lighting(color.rgb,normal,(1.0-u_shadow_intensity*occlusion)*ndotl);vec3 floodLitColor=compute_flood_lighting(u_flood_light_color*u_opacity,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=mix(litColor,floodLitColor,flood_radiance);\n#else\nfloat shadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,normal,shadowed_lighting_factor);\n#endif\n#else\ncolor.rgb=apply_lighting(color.rgb,normal);\n#ifdef FLOOD_LIGHT\ncolor.rgb=mix(color.rgb,u_flood_light_color*u_opacity,flood_radiance);\n#endif\n#endif\ncolor.rgb=mix(color.rgb,v_flat.rgb,u_emissive_strength);color*=u_opacity;\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\n#endif\n#ifdef RENDER_CUTOFF\ncolor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#include "_prelude_lighting.glsl"\n#ifdef RENDER_CUTOFF\ninvariant gl_Position;\n#endif\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nuniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;out float v_depth;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nout vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nout highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec2 v_ao;\n#endif\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\nout float v_flood_radius;out float v_has_floodlight;\n#endif\nout float v_height;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define highp float flood_light_wall_radius\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize highp float flood_light_wall_radius\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\nv_normal=normal;\n#endif\nbase=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);h=h-ele;v_height=h;\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(normal);shd_pos0+=offset*shadow_normal_offset_multiplier0();shd_pos1+=offset*shadow_normal_offset_multiplier1();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shd_pos0,1);v_pos_light_view_1=u_light_matrix_1*vec4(shd_pos1,1);v_depth=gl_Position.w;\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifndef LIGHTING_3D_MODE\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);if (normal.y !=0.0) {float r=0.84;r=mix(0.7,0.98,1.0-u_lightintensity);NdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#endif\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec2(mix(concave,-concave,start),y_ground);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\n#ifdef FLOOD_LIGHT\nfloat is_wall=1.0-float(t > 0.0 && top_up_ny.y > 0.0);v_has_floodlight=float(flood_light_wall_radius > 0.0 && is_wall > 0.0);v_flood_radius=flood_light_wall_radius*u_vertical_scale;\n#endif\nv_color=vec4(color.rgb,1.0);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),1.0);\n#else\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#endif\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),fillExtrusionDepth:ZE("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\nout highp float v_depth;void main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nvec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base);pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;in vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nin vec3 v_normal;\n#endif\nin vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_lighting.glsl"\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nout vec2 v_pos;out vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;out vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nout vec3 v_normal;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define mediump vec4 pattern\n#pragma mapbox: define highp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_normal=normal;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}'),groundShadow:ZE('#include "_prelude_shadow.fragment.glsl"\nprecision highp float;uniform vec3 u_ground_shadow_factor;in vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);vec3 shadow=mix(u_ground_shadow_factor,vec3(1.0),light);\n#ifdef RENDER_CUTOFF\nshadow=mix(vec3(1.0),shadow,cutoff_opacity(u_cutoff_params,v_depth));\n#endif\n#ifdef FOG\nshadow=mix(shadow,vec3(1.0),v_fog_opacity);\n#endif\n#ifdef INDICATOR_CUTOUT\nshadow=mix(shadow,vec3(1.0),1.0-applyCutout(vec4(1.0)).r);\n#endif\nglFragColor=vec4(shadow,1.0);}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;in vec2 a_pos;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0.0,1.0);v_pos_light_view_0=u_light_matrix_0*vec4(a_pos,0.0,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(a_pos,0.0,1.0);v_depth=gl_Position.w;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:ZE("uniform highp float u_ao_pass;uniform highp float u_opacity;uniform highp float u_flood_light_intensity;uniform highp vec3 u_flood_light_color;uniform highp float u_attenuation;uniform sampler2D u_fb;uniform float u_fb_size;\n#ifdef SDF_SUBPASS\nin highp vec2 v_pos;in highp vec4 v_line_segment;in highp float v_flood_light_radius_tile;in highp vec2 v_ao;float line_df(highp vec2 a,highp vec2 b,highp vec2 p) {highp vec2 ba=b-a;highp vec2 pa=p-a;highp float r=clamp(dot(pa,ba)/dot(ba,ba),0.0,1.0);return length(pa-r*ba);}\n#ifdef FOG\nin highp float v_fog;\n#endif\n#endif\nvoid main() {\n#ifdef CLEAR_SUBPASS\nvec4 color=vec4(1.0);\n#ifdef CLEAR_FROM_TEXTURE\ncolor=texture(u_fb,gl_FragCoord.xy/vec2(u_fb_size));\n#endif\nglFragColor=color;\n#else\n#ifdef SDF_SUBPASS\nhighp float d=line_df(v_line_segment.xy,v_line_segment.zw,v_pos);highp float effect_radius=mix(v_flood_light_radius_tile,v_ao.y,u_ao_pass);d/=effect_radius;d=min(d,1.0);d=1.0-pow(1.0-d,u_attenuation);highp float effect_intensity=mix(u_flood_light_intensity,v_ao.x,u_ao_pass);highp float fog=1.0;\n#ifdef FOG\nfog=v_fog;\n#endif\n#ifdef RENDER_CUTOFF\nfog*=v_cutoff_opacity;\n#endif\nglFragColor=vec4(vec3(0.0),mix(1.0,d,effect_intensity*u_opacity*fog));\n#else\nvec4 color=mix(vec4(u_flood_light_color,1.0),vec4(vec3(0.0),1.0),u_ao_pass);\n#ifdef OVERDRAW_INSPECTOR\ncolor=vec4(1.0);\n#endif\nglFragColor=color;HANDLE_WIREFRAME_DEBUG;\n#endif\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float a_hidden_by_landmark;\n#ifdef SDF_SUBPASS\nout highp vec2 v_pos;out highp vec4 v_line_segment;out highp float v_flood_light_radius_tile;out highp vec2 v_ao;\n#ifdef FOG\nout highp float v_fog;\n#endif\n#endif\nuniform highp float u_flood_light_intensity;uniform highp mat4 u_matrix;uniform highp float u_ao_pass;uniform highp float u_meter_to_tile;uniform highp float u_edge_radius;uniform highp vec2 u_ao;\n#pragma mapbox: define highp float flood_light_ground_radius\nconst float TANGENT_CUTOFF=4.0;const float NORM=32767.0;void main() {\n#pragma mapbox: initialize highp float flood_light_ground_radius\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;\n#ifdef FORCE_ABS_FL_GROUND_RADIUS\nfl_ground_radius=abs(flood_light_ground_radius);\n#endif\nfloat flood_radius_tile=fl_ground_radius*u_meter_to_tile;vec2 v=normalize(q-p);float ao_radius=u_ao.y/3.5;float effect_radius=mix(flood_radius_tile,ao_radius,u_ao_pass)+u_edge_radius;float angular_offset_factor=a_angular_offset_factor/NORM*TANGENT_CUTOFF;float angular_offset=angular_offset_factor*effect_radius;float top=1.0-start_bottom.y;float side=(0.5-start_bottom.x)*2.0;vec2 extrusion_parallel=v*side*mix(1.0,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=perp*effect_radius*top;vec3 pos=vec3(mix(q,p,start_bottom.x),0.0);pos.xy+=extrusion_parallel+extrusion_perp;\n#ifdef SDF_SUBPASS\nv_pos=pos.xy;v_line_segment=vec4(p,q)+perp.xyxy*u_edge_radius;v_flood_light_radius_tile=flood_radius_tile;v_ao=vec2(u_ao.x,ao_radius);\n#ifdef FOG\nv_fog_pos=fog_position(pos);v_fog=1.0-fog(v_fog_pos);\n#endif\n#endif\nfloat hidden_by_landmark=0.0;\n#ifdef HAS_CENTROID\nhidden_by_landmark=a_hidden_by_landmark;\n#endif\nfloat isFloodlit=float(fl_ground_radius > 0.0 && u_flood_light_intensity > 0.0);float hidden=mix(1.0-isFloodlit,isFloodlit,u_ao_pass);hidden+=hidden_by_landmark;gl_Position=mix(u_matrix*vec4(pos,1.0),AWAY,float(hidden > 0.0));\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n}'),hillshadePrepare:ZE("precision highp float;uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;uniform float u_emissive_strength;void main() {vec4 pixel=texture(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);glFragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\nglFragColor=apply_lighting_with_emission_ground(glFragColor,u_emissive_strength);\n#endif\n#ifdef FOG\nglFragColor=fog_dither(fog_apply_premultiplied(glFragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),line:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trimmed=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}\n#endif\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) { \nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color.rgb=mix(border_color.rgb*border_color.a*trimmed,out_color.rgb,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nin float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),linePattern:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture(u_image,pos);\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_ground(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color);\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}'),raster:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_raster_array.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;uniform float u_emissive_strength;\n#ifndef RASTER_ARRAY\nuniform sampler2D u_image0;uniform sampler2D u_image1;\n#endif\n#ifdef RASTER_COLOR\nuniform sampler2D u_color_ramp;uniform highp vec4 u_colorization_mix;uniform highp float u_colorization_offset;uniform vec2 u_texture_res;\n#endif\nvoid main() {vec4 color0,color1,color;vec2 value;\n#ifdef RASTER_COLOR\n#ifdef RASTER_ARRAY\n#ifdef RASTER_ARRAY_LINEAR\nvalue=mix(\nraTexture2D_image0_linear(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_linear(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#else\nvalue=mix(\nraTexture2D_image0_nearest(v_pos0,u_texture_res,u_colorization_mix,u_colorization_offset),raTexture2D_image1_nearest(v_pos1,u_texture_res,u_colorization_mix,u_colorization_offset),u_fade_t\n);\n#endif\nif (value.y > 0.0) value.x/=value.y;\n#else\ncolor=mix(texture(u_image0,v_pos0),texture(u_image1,v_pos1),u_fade_t);value=vec2(u_colorization_offset+dot(color.rgb,u_colorization_mix.rgb),color.a);\n#endif\ncolor=texture(u_color_ramp,vec2(value.x,0.5));if (color.a > 0.0) color.rgb/=color.a;color.a*=value.y;\n#else\ncolor0=texture(u_image0,v_pos0);color1=texture(u_image1,v_pos1);if (color0.a > 0.0) color0.rgb/=color0.a;if (color1.a > 0.0) color1.rgb/=color1.a;color=mix(color0,color1,u_fade_t);\n#endif\ncolor.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),u_emissive_strength).rgb;\n#endif\n#ifdef FOG\nhighp float fog_limit_high_meters=1000000.0;highp float fog_limit_low_meters=600000.0;float fog_limit=1.0-smoothstep(fog_limit_low_meters,fog_limit_high_meters,u_raster_elevation);out_color=fog_dither(fog_apply(out_color,v_fog_pos,fog_limit));\n#endif\nglFragColor=vec4(out_color*color.a,color.a);\n#ifdef RENDER_CUTOFF\nglFragColor=glFragColor*cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform mat3 u_grid_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;uniform vec2 u_texture_offset;uniform float u_raster_elevation;uniform vec4 u_tl_br;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#elif defined(PROJECTION_GLOBE_VIEW)\nin vec2 a_pos;\n#else\nin vec2 a_pos;in vec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;void main() {vec2 uv;\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);vec2 globe_tl=vec2(u_tl_br.x,u_tl_br.y);vec2 globe_br=vec2(u_tl_br.z,u_tl_br.w);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=1.0-((mercatorY-globe_br.y)/(globe_tl.y-globe_br.y));float mercatorX=mercatorXfromLng(latLng[1]);float uvX=(mercatorX-globe_br.x)/(globe_tl.x-globe_br.x);vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);uv=vec2(uvX,uvY);globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,u_raster_elevation,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);gl_Position=u_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\nuv=a_texture_pos/8192.0;\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;v_pos0=u_texture_offset.x+u_texture_offset.y*v_pos0;v_pos1=u_texture_offset.x+u_texture_offset.y*v_pos1;\n#ifdef RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),symbolIcon:ZE('#include "_prelude_lighting.glsl"\nuniform sampler2D u_texture;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\nin float v_fade_opacity;in vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nuniform mediump float u_icon_saturation;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nlowp float alpha=opacity*v_fade_opacity;vec4 out_color;\n#ifdef ICON_TRANSITION\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b)*alpha;\n#else\nout_color=texture(u_texture,v_tex_a)*alpha;\n#endif\n#ifdef SATURATION\nvec3 luma=vec3(dot(out_color.rgb,vec3(0.2126,0.7152,0.0722)));out_color.rgb=mix(luma,out_color.rgb,u_icon_saturation);\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 a_texb;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nv_tex_a=a_tex/u_texsize;\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\nv_fade_opacity=out_fade_opacity;}'),symbolSDF:ZE('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\nuniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;in float v_draw_halo;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout float v_draw_halo;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,out_fade_opacity);}'),symbolTextAndIcon:ZE('#include "_prelude_lighting.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_halo;in float v_draw_halo;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nout float v_draw_halo;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nfloat out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\n#endif\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,out_fade_opacity,is_sdf);}'),terrainRaster:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in vec2 v_pos0;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth;\n#endif\nuniform vec3 u_ground_shadow_factor;void main() {vec4 image_color=texture(u_image0,v_pos0);vec4 color;\n#ifdef LIGHTING_3D_MODE\nconst vec3 normal=vec3(0.0,0.0,1.0);\n#ifdef RENDER_SHADOWS\nfloat cutoffOpacity=1.0;\n#ifdef RENDER_CUTOFF\ncutoffOpacity=cutoff_opacity(u_cutoff_params,v_depth);\n#endif\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nvec3 unlit_base=image_color.rgb*(1.0-image_color.a);vec3 emissive_base=image_color.rgb*image_color.a;float ndotl=u_shadow_direction.z;float occlusion=ndotl < 0.0 ? 1.0 : shadow_occlusion(v_pos_light_view_0,v_pos_light_view_1,v_depth,0.0);ndotl=max(0.0,ndotl);vec3 lit=apply_lighting(unlit_base,normal,mix(1.0,(1.0-(u_shadow_intensity*occlusion))*ndotl,cutoffOpacity));vec3 emissive=compute_emissive_draped(emissive_base,1.0-u_shadow_intensity,occlusion,u_ground_shadow_factor);color.rgb=lit+emissive;color.a=1.0;\n#else\nfloat lighting_factor=shadowed_light_factor_normal_unbiased(normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color=apply_lighting(image_color,normal,mix(1.0,lighting_factor,cutoffOpacity));\n#endif\n#else\nfloat lighting_factor=u_lighting_directional_dir.z;color=apply_lighting(image_color,normal,lighting_factor);\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor.rgb=mix(color.rgb,image_color.rgb,image_color.a);color.a=1.0;\n#endif\n#endif\n#else\ncolor=image_color;\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_skirt_height;in vec2 a_pos;out vec2 v_pos0;\n#ifdef FOG\nout float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth;\n#endif\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;\n#endif\n}'),terrainDepth:ZE("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;out float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:ZE('#include "_prelude_fog.fragment.glsl"\nin lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',PE),skyboxGradient:ZE('#include "_prelude_fog.fragment.glsl"\nin highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',PE),skyboxCapture:ZE("\nin highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;precision highp float;\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;glFragColor=vec4(color,1.0);}","in highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;out highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\nraster=apply_lighting_with_emission_ground(raster,raster.a);color=vec4(raster.rgb*antialias,antialias);\n#else\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\n#endif\n#else\ncolor=texture(u_image0,v_pos0);\n#ifdef LIGHTING_3D_MODE\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\ncolor=apply_lighting_with_emission_ground(color,color.a);color.a=1.0;\n#else\ncolor=apply_lighting_ground(color);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\nglFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;\n#endif\nout vec2 v_pos0;void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);globe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}'),globeAtmosphere:ZE('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {\n#ifdef ALPHA_PASS\nglFragColor=vec4(0,0,0,0);return;\n#else\n#ifdef NATIVE\nglFragColor=vec4(1,1,1,1);\n#else\nglFragColor=vec4(0,0,0,1);\n#endif\nreturn;\n#endif\n}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;\n#ifdef ALPHA_PASS\nfloat a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a);\n#else\nvec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;\n#ifndef NATIVE\nc=dither(c,gl_FragCoord.xy+u_temporal_offset);\n#endif\nglFragColor=vec4(c*t,t);\n#endif\n}',"in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}"),model:ZE('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\n#ifdef RENDER_SHADOWS\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#ifdef HAS_ATTRIBUTE_a_pbr\nin lowp vec4 v_roughness_metallic_emissive_alpha;in mediump vec4 v_height_based_emission_params;\n#endif\n#ifdef HAS_TEXTURE_u_baseColorTexture\nuniform sampler2D u_baseColorTexture;uniform bool u_baseTextureIsAlpha;uniform bool u_alphaMask;uniform float u_alphaCutoff;\n#endif\n#ifdef HAS_TEXTURE_u_metallicRoughnessTexture\nuniform sampler2D u_metallicRoughnessTexture;\n#endif\n#ifdef HAS_TEXTURE_u_occlusionTexture\nuniform sampler2D u_occlusionTexture;uniform float u_aoIntensity;\n#endif\n#ifdef HAS_TEXTURE_u_normalTexture\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef HAS_TEXTURE_u_emissionTexture\nuniform sampler2D u_emissionTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform sampler2D u_depthTexture;uniform vec2 u_inv_depth_size;bool isOccluded() {vec2 coord=gl_FragCoord.xy*u_inv_depth_size;highp float depth=unpack_depth(texture(u_depthTexture,coord));return v_depth > depth+0.0005;}\n#endif\n#define saturate(_x) clamp(_x,0.,1.)\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}float calculate_NdotL(vec3 normal,vec3 lightDir) {const float ext=0.70710678118;return (clamp(dot(normal,lightDir),-ext,1.0)+ext)/(1.0+ext);}vec3 getDiffuseShadedColor(vec3 albedo,vec3 normal,vec3 lightDir,vec3 lightColor)\n{\n#ifdef LIGHTING_3D_MODE\nvec3 transformed_normal=vec3(-normal.xy,normal.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=saturate(dot(transformed_normal,u_lighting_directional_dir));\n#endif\nreturn apply_lighting(albedo,transformed_normal,lighting_factor);\n#else\nvec3 n=normal;float colorvalue=((albedo.x*0.2126)+(albedo.y*0.7152))+(albedo.z*0.0722);vec3 c=vec3(0.03,0.03,0.03);float directional=clamp(dot(n,vec3(lightDir)),0.0,1.0);directional=mix(1.0-u_lightintensity,max((1.0-colorvalue)+u_lightintensity,1.0),directional);vec3 c3=c+clamp((albedo*directional)*lightColor,mix(vec3(0.0),vec3(0.3),vec3(1.0)-lightColor),vec3(1.0));return c3;\n#endif\n}vec4 getBaseColor() {vec4 albedo=u_baseColorFactor;\n#ifdef HAS_ATTRIBUTE_a_color_3f\nalbedo*=vec4(color_3f,1.0);\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#else\n#ifdef HAS_ATTRIBUTE_a_color_4f\nalbedo*=color_4f;\n#endif\n#endif\n#if defined (HAS_TEXTURE_u_baseColorTexture) && defined (HAS_ATTRIBUTE_a_uv_2f)\nvec4 texColor=texture(u_baseColorTexture,uv_2f);if(u_alphaMask) {if (texColor.w < u_alphaCutoff) {discard;}}\n#ifdef UNPREMULT_TEXTURE_IN_SHADER\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=1.0;\n#endif\ntexColor.rgb=sRGBToLinear(texColor.rgb);if(u_baseTextureIsAlpha) {if (texColor.w < 0.5) {discard;}albedo*=mix(vec4(texColor.rgb,texColor.a),vec4(texColor.a),float(u_baseTextureIsAlpha));} else {albedo*=texColor;}\n#endif\nreturn vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);}highp mat3 cotangentFrame(highp vec3 N,highp vec3 p,highp vec2 uv ) {\n#ifdef HAS_TEXTURE_u_normalTexture\nhighp vec3 dp1=vec3(dFdx(p.x),dFdx(p.y),dFdx(p.z));highp vec3 dp2=vec3(dFdy(p.x),dFdy(p.y),dFdy(p.z));highp vec2 duv1=vec2(dFdx(uv.x),dFdx(uv.y));highp vec2 duv2=vec2(dFdy(uv.x),dFdy(uv.y));highp vec3 dp2perp=cross( dp2,N );highp vec3 dp1perp=cross( N,dp1 );highp vec3 T=dp2perp*duv1.x+dp1perp*duv2.x;highp vec3 B=dp2perp*duv1.y+dp1perp*duv2.y;highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\n#else\nreturn mat3(1.0);\n#endif\n}highp vec3 getNormal(){highp vec3 n;\n#ifdef HAS_ATTRIBUTE_a_normal_3f\nn=normalize(normal_3f);\n#else\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));n=normalize(cross(fdx,fdy))*-1.0;\n#endif\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\n#endif\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\n#ifdef HAS_ATTRIBUTE_a_pbr\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\n#endif\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\n#endif\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\n{\n#ifdef LIGHTING_3D_MODE\nreturn mat.diffuseColor;\n#else\nreturn mat.diffuseColor/PI;\n#endif\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\n{vec3 env_light=vec3(0.65,0.65,0.65);\n#ifdef LIGHTING_3D_MODE\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\n#endif\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\n#ifdef RENDER_SHADOWS\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nlighting_factor=NdotL;\n#endif\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\n#if !defined(LIGHTING_3D_MODE)\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\n#endif\ncolor*=intensityFactor;return color;}void main() {\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nif (isOccluded()) {discard;}\n#endif\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\n#endif\nvec4 finalColor;\n#ifdef DIFFUSE_SHADED\nvec3 N=getNormal();vec3 diffuse=getDiffuseShadedColor(getBaseColor().rgb,N,lightDir,lightColor);\n#ifdef HAS_TEXTURE_u_occlusionTexture\nfloat ao=(texture(u_occlusionTexture,uv_2f).r-1.0)*u_aoIntensity+1.0;diffuse*=ao;\n#endif\nfinalColor=vec4(diffuse,1.0)*u_opacity;\n#else\nMaterial mat=getPBRMaterial();vec3 color=computeLightContribution(mat,lightDir,lightColor);float ao=1.0;\n#if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nao=(texture(u_occlusionTexture,uv_2f).x-1.0)*u_aoIntensity+1.0;color*=ao;\n#endif\nvec4 emissive=u_emissiveFactor;\n#if defined(HAS_TEXTURE_u_emissionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\nemissive.rgb*=sRGBToLinear(texture(u_emissionTexture,uv_2f).rgb);\n#endif\ncolor+=emissive.rgb;float opacity=mat.baseColor.w*u_opacity;\n#ifdef HAS_ATTRIBUTE_a_pbr\nfloat resEmission=v_roughness_metallic_emissive_alpha.z;resEmission*=v_height_based_emission_params.z+v_height_based_emission_params.w*pow(clamp(v_height_based_emission_params.x,0.0,1.0),v_height_based_emission_params.y);color=mix(color,v_color_mix.rgb,min(1.0,resEmission));\n#ifdef HAS_ATTRIBUTE_a_color_4f\nfloat distance=length(vec2(1.3*max(0.0,abs(color_4f.x)-color_4f.z),color_4f.y));distance+= mix(0.5,0.0,clamp(resEmission-1.0,0.0,1.0));opacity*=v_roughness_metallic_emissive_alpha.w*saturate(1.0-distance*distance);\n#endif\n#endif\nvec3 unlitColor=mat.baseColor.rgb*ao+emissive.rgb;color=mix(color,unlitColor,u_emissive_strength);color=linearTosRGB(color);color*=opacity;finalColor=vec4(color,opacity);\n#endif\n#ifdef FOG\nfinalColor=fog_dither(fog_apply_premultiplied(finalColor,v_fog_pos,v_position_height.w));\n#endif\n#ifdef RENDER_CUTOFF\nfinalColor*=v_cutoff_opacity;\n#endif\n#ifdef INDICATOR_CUTOUT\nfinalColor=applyCutout(finalColor);\n#endif\nglFragColor=finalColor;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec3 a_pos_3f;\n#pragma mapbox: define-attribute highp vec3 normal_3f\n#pragma mapbox: define-attribute highp vec2 uv_2f\n#pragma mapbox: define-attribute highp vec3 color_3f\n#pragma mapbox: define-attribute highp vec4 color_4f\n#pragma mapbox: define-attribute-vertex-shader-only highp vec4 pbr\n#pragma mapbox: define-attribute-vertex-shader-only highp vec3 heightBasedEmissiveStrength\nuniform mat4 u_matrix;uniform mat4 u_lighting_matrix;uniform vec3 u_camera_pos;uniform vec4 u_color_mix;\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_normal_matrix;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth_shadows;\n#endif\nout vec4 v_position_height;out lowp vec4 v_color_mix;\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nout highp float v_depth;\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\n#endif\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\n#pragma mapbox: initialize-attribute highp vec3 color_3f\n#pragma mapbox: initialize-attribute highp vec4 color_4f\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\nhighp mat4 normal_matrix;\n#ifdef INSTANCED_ARRAYS\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\nnormal_matrix=u_normal_matrix;\n#endif\nvec3 local_pos;mat3 rs;\n#ifdef MODEL_POSITION_ON_GPU\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float color_mix=pos_a.z/100.0;v_color_mix=vec4(sRGBToLinear(rgb),color_mix);float meter_to_tile=normal_matrix[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);rs[0].x=normal_matrix[1].w;rs[0].yz=normal_matrix[2].xy;rs[1].xy=normal_matrix[2].zw;rs[1].z=normal_matrix[3].x;rs[2].xyz=normal_matrix[3].yzw;vec4 pos_node=u_lighting_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;local_pos=pos.xyz;gl_Position=u_matrix*pos;pos.z*=meter_to_tile;v_position_height.xyz=pos.xyz-u_camera_pos;\n#else\nlocal_pos=a_pos_3f;gl_Position=u_matrix*vec4(a_pos_3f,1);v_position_height.xyz=vec3(u_lighting_matrix*vec4(a_pos_3f,1));v_color_mix=vec4(sRGBToLinear(u_color_mix.rgb),u_color_mix.a);\n#endif\nv_position_height.w=a_pos_3f.z;\n#ifdef HAS_ATTRIBUTE_a_pbr\nvec4 albedo_c=decode_color(pbr.xy);vec2 e_r_m=unpack_float(pbr.z);vec2 r_m= unpack_float(e_r_m.y*16.0);r_m.r=r_m.r*16.0;v_color_mix=vec4(albedo_c.rgb,1.0);v_roughness_metallic_emissive_alpha=vec4(vec3(r_m,e_r_m.x)/255.0,albedo_c.a);v_roughness_metallic_emissive_alpha.z*=2.0;float heightBasedRelativeIntepolation=a_pos_3f.z*heightBasedEmissiveStrength.x+heightBasedEmissiveStrength.y;v_height_based_emission_params.x=heightBasedRelativeIntepolation;v_height_based_emission_params.y=heightBasedEmissiveStrength.z;vec2 emissionMultiplierValues=unpack_float(pbr.w)/256.0;v_height_based_emission_params.z=emissionMultiplierValues.x;v_height_based_emission_params.w=emissionMultiplierValues.y-emissionMultiplierValues.x;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(local_pos);\n#endif\n#ifdef RENDER_CUTOFF\nv_cutoff_opacity=cutoff_opacity(u_cutoff_params,gl_Position.z);\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nfloat x_squared_scale=dot(rs[0],rs[0]);float y_squared_scale=dot(rs[1],rs[1]);float z_squared_scale=dot(rs[2],rs[2]);vec3 squared_scale=vec3(x_squared_scale,y_squared_scale,z_squared_scale);normal_3f=rs*((u_lighting_matrix*vec4(normal_3f,0.0)).xyz/squared_scale);normal_3f=normalize(normal_3f);\n#else\nnormal_3f=vec3(normal_matrix*vec4(normal_3f,0));\n#endif\n#endif\n#ifdef HAS_ATTRIBUTE_a_pbr\n#ifdef HAS_ATTRIBUTE_a_color_4f\nv_roughness_metallic_emissive_alpha.w=clamp(color_4f.a*v_roughness_metallic_emissive_alpha.w*(v_roughness_metallic_emissive_alpha.z-1.0),0.0,1.0);\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=local_pos;\n#ifdef NORMAL_OFFSET\n#ifdef HAS_ATTRIBUTE_a_normal_3f\n#ifdef MODEL_POSITION_ON_GPU\nvec3 offset=shadow_normal_offset(vec3(-normal_3f.xy,normal_3f.z));shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normalize(normal_3f));shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1);v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:ZE("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;\n#ifdef MODEL_POSITION_ON_GPU\n#ifdef INSTANCED_ARRAYS\nin vec4 a_normal_matrix0;in vec4 a_normal_matrix1;in vec4 a_normal_matrix2;in vec4 a_normal_matrix3;\n#else\nuniform highp mat4 u_instance;\n#endif\nuniform highp mat4 u_node_matrix;\n#endif\nvoid main() {\n#ifdef MODEL_POSITION_ON_GPU\nhighp mat4 instance;\n#ifdef INSTANCED_ARRAYS\ninstance=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\n#else\ninstance=u_instance;\n#endif\nvec3 pos_color=instance[0].xyz;vec4 translate=instance[1];vec3 pos_a=floor(pos_color);float meter_to_tile=instance[0].w;vec4 pos=vec4(pos_a.xy,translate.z,1.0);mat3 rs;rs[0].x=instance[1].w;rs[0].yz=instance[2].xy;rs[1].xy=instance[2].zw;rs[1].z=instance[3].x;rs[2].xyz=instance[3].yzw;vec4 pos_node=u_node_matrix*vec4(a_pos_3f,1.0);vec3 rotated_pos_node=rs*pos_node.xyz;vec3 pos_model_tile=(rotated_pos_node+vec3(translate.xy,0.0))*vec3(meter_to_tile,meter_to_tile,1.0);pos.xyz+=pos_model_tile;gl_Position=u_matrix*pos;\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:ZE("in highp vec2 v_uv;in mediump float v_intensity;float shapeCircle(in vec2 uv)\n{float beginFade=0.6;float lengthFromCenter=length(v_uv);return 1.0-clamp((lengthFromCenter-beginFade)/(1.0-beginFade),0.0,1.0);}void main() {float alpha=shapeCircle(v_uv);vec3 color=vec3(1.0,1.0,1.0);alpha*=v_intensity;glFragColor=vec4(color*alpha,alpha);HANDLE_WIREFRAME_DEBUG;}","\nin vec3 a_pos_3f;in vec2 a_uv;in float a_size_scale;in float a_fade_opacity;uniform mat4 u_matrix;uniform vec3 u_up;uniform vec3 u_right;uniform float u_intensity_multiplier;out highp vec2 v_uv;out mediump float v_intensity;void main() {v_uv=a_uv;v_intensity=a_fade_opacity*u_intensity_multiplier;vec3 pos=a_pos_3f;pos+=a_uv.x*u_right*a_size_scale;pos+=a_uv.y*u_up*a_size_scale;gl_Position=u_matrix*vec4(pos,1.0);}")};function qE(e,t){const i=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of i)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const i=e.split(" ");for(const e of i)t.includes(e)||t.push(e);}}function ZE(e,t){const i=/#include\s+"([^"]+)"/g,r=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g;let n=t.match(/(attribute(\S*)|(^\s*|;)in) (highp |mediump |lowp )?([\w]+) ([\w]+)/gm);n&&(n=n.map((e=>{const t=e.split(" ");return t[t.length-1]})),n=[...new Set(n)]);const o={},s=[],a=[];e=e.replace(i,((e,t)=>(a.push(t),""))),t=t.replace(i,((e,t)=>(s.push(t),"")));let l=[...FE];qE(e,l),qE(t,l);for(const e of [...s,...a])NE[e]||console.error(`Undefined include: ${e}`),UE[e]||(UE[e]=[],qE(NE[e],UE[e])),l=[...l,...UE[e]];return {fragmentSource:e=e.replace(r,((e,t,i,r,n)=>(o[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${i} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?"":void 0))),vertexSource:t=t.replace(r,((e,t,i,r,n)=>{const s="float"===r?"vec2":r,a=n.match(/color/)?"color":s;return "define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\nin ${i} ${r} a_${n};\n#endif\n`:o[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${s} a_${n};\nout ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize"===t?"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n in ${i} ${r} a_${n};\n out ${i} ${r} ${n};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${n} = a_${n};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"define-instanced"===t?"mat4"===a?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${n}0;\nin vec4 a_${n}1;\nin vec4 a_${n}2;\nin vec4 a_${n}3;\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${n}\n ${i} ${r} ${n} = a_${n};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${a}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:n,usedDefines:l,vertexIncludes:s,fragmentIncludes:a}}class $E{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null;}bind(e,t,i,r,n,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e<r.length;e++)this.boundPaintVertexBuffers[e]!==r[e]&&(l=!0);let c=this.boundDynamicVertexBuffers.length!==s.length;for(let e=0;!c&&e<s.length;e++)this.boundDynamicVertexBuffers[e]!==s[e]&&(c=!0);if(!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||l||c||this.boundIndexBuffer!==n||this.boundVertexOffset!==o)this.freshBind(t,i,r,n,o,s,a);else {e.bindVertexArrayOES.set(this.vao);for(const i of s)i&&(i.bind(),a&&i.instanceCount&&i.setVertexAttribDivisor(e.gl,t,a));n&&n.dynamicDraw&&n.bind();}}freshBind(e,t,i,r,n,o,s){const a=e.numAttributes,l=this.context,c=l.gl;this.vao&&this.destroy(),this.vao=l.gl.createVertexArray(),l.bindVertexArrayOES.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffers=o,t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(const t of i)t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n);for(const t of o)t&&(t.enableAttributes(c,e),t.bind(),t.setVertexAttribPointers(c,e,n),s&&t.instanceCount&&t.setVertexAttribDivisor(c,e,s));r&&r.bind(),l.currentNumAttributes=a;}destroy(){this.vao&&(this.context.gl.deleteVertexArray(this.vao),this.vao=null);}}function WE(e,t){const i=Math.pow(2,t.canonical.z),r=t.canonical.y;return [new lp(0,r/i).toLngLat().lat,new lp(0,(r+1)/i).toLngLat().lat]}function HE(e,t,i,r,n,o,s){const a=e.context,l=a.gl,c=i.hillshadeFBO;if(!c)return;e.prepareDrawTile();const h=e.isTileAffectedByFog(t),u=e.getOrCreateProgram("hillshade",{overrideFog:h});a.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment.get());const d=((e,t,i,r)=>{const n=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),s=i.paint.get("hillshade-accent-color"),a=i.paint.get("hillshade-emissive-strength");let l=w(i.paint.get("hillshade-illumination-direction"));if("viewport"===i.paint.get("hillshade-illumination-anchor"))l-=e.transform.angle;else if(e.style&&e.style.enable3dLights()&&e.style.directionalLight){const t=e.style.directionalLight.properties.get("direction");l=w(J(t.x,t.y,t.z)[1]);}const c=!e.options.moving;return {u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),c),u_image:0,u_latrange:WE(0,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),l],u_shadow:n,u_highlight:o,u_emissive_strength:a,u_accent:s}})(e,i,r,e.terrain?t.projMatrix:null);e.uploadCommonUniforms(a,u,t.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=e.getTileBoundsBuffers(i);u.draw(e,l.TRIANGLES,n,o,s,Dx.disabled,d,r.id,p,f,m);}function XE(e,t,i){if(!t.needsDEMTextureUpload)return;const r=e.context,n=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||e.getTileTexture(i.stride);const o=i.getPixels();t.demTexture?t.demTexture.update(o,{premultiply:!1}):t.demTexture=new My(r,o,n.R32F,{premultiply:!1}),t.needsDEMTextureUpload=!1;}function YE(e,t,i){const r=e.context,n=r.gl;if(!t.dem)return;const o=t.dem;if(r.activeTexture.set(n.TEXTURE1),XE(e,t,o),!t.demTexture)return;t.demTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE);const s=o.dim;r.activeTexture.set(n.TEXTURE0);let a=t.hillshadeFBO;if(!a){const e=new My(r,{width:s,height:s,data:null},n.RGBA);e.bind(n.LINEAR,n.CLAMP_TO_EDGE),a=t.hillshadeFBO=r.createFramebuffer(s,s,!0,"renderbuffer"),a.colorAttachment.set(e.texture);}r.bindFramebuffer.set(a.framebuffer),r.viewport.set([0,0,s,s]);const{tileBoundsBuffer:l,tileBoundsIndexBuffer:c,tileBoundsSegments:h}=e.getMercatorTileBoundsBuffers(),u=[];e.linearFloatFilteringSupported()&&u.push("TERRAIN_DEM_FLOAT_FORMAT"),e.getOrCreateProgram("hillshadePrepare",{defines:u}).draw(e,n.TRIANGLES,Mx.disabled,Sx.disabled,Cx.unblended,Dx.disabled,((e,t)=>{const i=t.stride,r=Au.create();return Au.ortho(r,0,cr,-cr,0,0,1),Au.translate(r,r,[0,-cr,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:e.overscaledZ}})(t.tileID,o),i.id,l,c,h),t.needsHillshadePrepare=!1;}const KE=e=>({u_matrix:new jl(e),u_image0:new kl(e),u_skirt_height:new Ol(e),u_ground_shadow_factor:new Fl(e)}),JE=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),QE=(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:u,u_viewport:d,u_grid_matrix:f?Float32Array.from(f):new Float32Array(9),u_skirt_height:p}),eM=(e,t)=>{if(t>0&&e.terrain&&H("Cutoff is currently disabled on terrain"),t<=0||e.terrain)return {shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,0]}};const i=e.transform,r=Math.max(Math.abs(i._zoom-(e.minCutoffZoom-1)),1),n=i.isLODDisabled(!1)?P(60,45,i.pitch):P(30,15,i.pitch),o=i._farZ-i._nearZ,s=t*i.height,a=((1-(l=n))*(.75*i.cameraToCenterDistance)+l*(i._farZ+s))*r;var l;return {shouldRenderCutoff:n<1,uniformValues:{u_cutoff_params:[i._nearZ,i._farZ,(a-i._nearZ)/o,(a-s-i._nearZ)/o]}}};function tM(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const iM=new class{constructor(){this.operations={};}newMorphing(e,t,i,r,n){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i);}else this.operations[e]={startTime:r,phase:0,duration:n,from:t,to:i,queued:null};}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return {from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,e)){delete this.operations[t];break}}}_nextOp(e,t){return !!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},rM={0:null,1:"TERRAIN_VERTEX_MORPHING"};function nM(e,t,i){if(0===t)return 0;const r=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*r}function oM(e,t){const i=1<<e.z;return !t&&(0===e.x||e.x===i-1)||0===e.y||e.y===i-1}const sM=e=>({u_matrix:e});function aM(e,t,i,r,n){if(n>0){const o=dt.now(),s=(o-e.timeAdded)/n,a=t?(o-t.timeAdded)/n:-1,l=i.getSource(),c=r.coveringZoomLevel({tileSize:l.tileSize,roundZoom:l.roundZoom}),h=!t||Math.abs(t.tileID.overscaledZ-c)>Math.abs(e.tileID.overscaledZ-c),u=h&&e.refreshedUponExpiration?1:z(h?s:1-a,0,1);return e.refreshedUponExpiration&&s>=1&&(e.refreshedUponExpiration=!1),t?{opacity:1,mix:1-u}:{opacity:u,mix:0}}return {opacity:1,mix:0}}class lM extends Lx{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},i=new Ew(Ww(),null),r=ST("mock-dem",t,i,e.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0;}_loadTile(e,t){e.state="loaded",t(null);}}class cM extends Lx{constructor(e){const t=ST("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new Ew(Ww(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}update(e,t,i){if(e.freezeTileCoverage)return;this.transform=e;const r=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((t,i)=>{if(t[i.key]="",!this._tiles[i.key]){const t=new Oy(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom);t.state="loaded",this._tiles[i.key]=t;}return t}),{});for(const e in this._tiles)e in r||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e]);}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e];}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}}class hM extends qu{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i;}}class uM extends Km{constructor(e,t){super(),this.painter=e,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[i,r,n]=function(e){const t=new za,i=new Wa,r=131;t.reserve(17161),i.reserve(33800);const n=cr/128,o=cr+n/2,s=o+n;for(let e=-n;e<s;e+=n)for(let i=-n;i<s;i+=n){const r=i<0||i>o||e<0||e>o?24575:0,n=z(Math.round(i),0,cr),s=z(Math.round(e),0,cr);t.emplaceBack(n+r,s);}const a=(e,t)=>{const n=t*r+e;i.emplaceBack(n+1,n,n+r),i.emplaceBack(n+r,n+r+1,n+1);};for(let e=1;e<129;e++)for(let t=1;t<129;t++)a(t,e);return [0,129].forEach((e=>{for(let t=0;t<130;t++)a(t,e),a(e,t);})),[t,i,32768]}(),o=e.context;this.gridBuffer=o.createVertexBuffer(i,Nu.members),this.gridIndexBuffer=o.createIndexBuffer(r),this.gridSegments=xl.simpleSegment(0,0,i.length,r.length),this.gridNoSkirtSegments=xl.simpleSegment(0,0,i.length,n),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new cM(t.map),this.orthoMatrix=Au.create(),Au.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,cr,0,cr,0,1);const s=o.gl;this._overlapStencilMode=new Sx({func:s.GEQUAL,mask:255},0,255,s.KEEP,s.KEEP,s.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=t,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new lM(t.map),this._pendingGroundEffectLayers=[];}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache();}));}update(e,t,i){if(e&&e.terrain){this._style!==e&&(this.style=e,this._evaluationZoom=void 0);const r=e.terrain.properties,n=0===e.terrain.drapeRenderMode,o=e.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=dt.now();const s=e.terrain&&e.terrain.scope,a=r.get("source"),l=n?this._mockSourceCache:e.getSourceCache(a,s);if(!l)return void H(`Couldn't find terrain source "${a}".`);if(this.sourceCache=l,this._exaggeration=o?this.calculateExaggeration(t):r.get("exaggeration"),!t.projection.requiresDraping&&o&&0===this._exaggeration)return void this._disable();this.enabled=!0;const c=()=>{this.sourceCache.used&&H(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const e=this.getScaledDemTileSize();this.sourceCache.update(t,e,!0),this.resetTileLookupCache(this.sourceCache.id);};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,c(),this._initializing=!0),c(),t.updateElevation(!0,i),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(t),this._emptyDEMTextureDirty=!0,this._previousZoom=t.zoom;}else this._disable();}calculateExaggeration(e){const t=this._previousCameraAltitude,i=e.getFreeCameraOptions().position.z/e.pixelsPerMeter*e.worldSize;this._previousCameraAltitude=i;const r=null!=t?i-t:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const n=e.zoom,o=this._style.terrain;if(!this._previousUpdateTimestamp)return o.getExaggeration(n);let s=n-this._previousZoom;const a=this._previousUpdateTimestamp;let l=n;null!=this._evaluationZoom&&(l=this._evaluationZoom,Math.abs(n-l)>.5&&(s=.5*(n-l+s)),s*r<0&&(l+=s)),this._evaluationZoom=l;const c=o.getExaggeration(l),h=c===o.getExaggeration(Math.max(0,l-.1));if(h&&Math.abs(c-this._exaggeration)<.01)return c;let u=Math.min(.1,.00375*(this._updateTimestamp-a));return (h||c<.1||Math.abs(s)<1e-4)&&(u=Math.min(.2,4*u)),Kr(this._exaggeration,c,u)}resetTileLookupCache(e){this._findCoveringTileCache[e]={};}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0);}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._mergedSourceCaches)this._style._mergedSourceCaches[e].usedForTerrain=!1;}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy();}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return [e,e]}set useVertexMorphing(e){this._useVertexMorphing=e;}updateTileBinding(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const t=this.proxySourceCache,i=this.painter.transform;this._initializing&&(this._initializing=0===i._centerAltitude&&-1===this.getAtPointOrZero(lp.fromLngLat(i.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=t.getIds().map((e=>{const r=t.getTileByID(e).tileID;return r.projMatrix=i.calculateProjMatrix(r.toUnwrapped()),r}));!function(e,t){const i=t.transform.pointCoordinate(t.transform.getCameraPoint()),r=new y(i.x,i.y);e.sort(((e,t)=>{if(t.overscaledZ-e.overscaledZ)return t.overscaledZ-e.overscaledZ;const i=new y(e.canonical.x+(1<<e.canonical.z)*e.wrap,e.canonical.y),n=new y(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),o=r.mult(1<<e.canonical.z);return o.x-=.5,o.y-=.5,o.distSqr(i)-o.distSqr(n)}));}(r,this.painter);const n=this.proxyToSource||{};this.proxyToSource={},r.forEach((e=>{this.proxyToSource[e.key]={};})),this.terrainTileForTile={};const o=this._style._mergedSourceCaches;for(const t in o){const i=o[t];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,e[t],n),i.usedForTerrain)continue;const r=e[t];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r);}this.proxiedCoords[t.id]=r.map((e=>new hM(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(n),this.renderingToTexture=!1;const s={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in s||(this._visibleDemTiles.push(t),s[i]=i);}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t);}));}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),XE(this.painter,r,n));}}_prepareDemTileUniforms(e,t,i,r){if(!t||null==t.demTexture)return !1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),s=r||"";return i[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],i[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return !this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const e=this.painter.context,t=e.gl;if(!this._emptyDepthBufferTexture){const i=new ef({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new My(e,i,t.RGBA,{premultiply:!1});}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce(((t,i)=>{if(!i.dem)return t;const r=i.dem.tree.minimums[0];return r>0&&e++,t+r}),0);return e?t/e:0}_updateEmptyDEMTexture(){const e=this.painter.context,t=e.gl;e.activeTexture.set(t.TEXTURE2);const i=this._getLoadedAreaMinimum(),[r,n]=(()=>{const e=new tf({width:1,height:1},new Float32Array([i]));return [t.R32F,e]})();this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(n,{premultiply:!1}):o=this._emptyDEMTexture=new My(e,n,r,{premultiply:!1}),o}setupElevationDraw(e,t,i){const r=this.painter.context,n=r.gl,o={u_dem:2,u_dem_prev:4,u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0};o.u_exaggeration=this.exaggeration();let s=null,a=null,l=1;if(i&&i.morphing&&this._useVertexMorphing){const t=i.morphing.srcDemTile,r=i.morphing.dstDemTile;l=i.morphing.phase,t&&r&&(this._prepareDemTileUniforms(e,t,o,"_prev")&&(a=t),this._prepareDemTileUniforms(e,r,o)&&(s=r));}const c=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?n.LINEAR:n.NEAREST,h=e=>{o.u_dem_size=1===e.size[0]?1:e.size[0]-2;};if(a&&s)r.activeTexture.set(n.TEXTURE2),s.demTexture.bind(c(s),n.CLAMP_TO_EDGE),r.activeTexture.set(n.TEXTURE4),a.demTexture.bind(c(a),n.CLAMP_TO_EDGE),s.demTexture&&h(s.demTexture),o.u_dem_lerp=l;else {s=this.terrainTileForTile[e.tileID.key],r.activeTexture.set(n.TEXTURE2);const t=this._prepareDemTileUniforms(e,s,o)?s.demTexture:this.emptyDEMTexture;t.bind(c(s),n.CLAMP_TO_EDGE),h(t);}if(r.activeTexture.set(n.TEXTURE3),i&&i.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),this._depthFBO&&(o.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),o.u_depth_size_inv=[1,1]),i&&i.useMeterToDem&&s){const e=(1<<s.tileID.canonical.z)*Qd(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;o.u_meter_to_dem=e;}if(i&&i.labelPlaneMatrixInv&&(o.u_label_plane_matrix_inv=i.labelPlaneMatrixInv),t.setTerrainUniformValues(r,o),"globe"===this.painter.transform.projection.name){const n=this.globeUniformValues(this.painter.transform,e.tileID.canonical,i&&i.useDenormalizedUpVectorScale);t.setGlobeUniformValues(r,n);}}globeUniformValues(e,t,i){const r=e.projection;return {u_tile_tl_up:r.upVector(t,0,0),u_tile_tr_up:r.upVector(t,cr,0),u_tile_br_up:r.upVector(t,cr,cr),u_tile_bl_up:r.upVector(t,0,cr),u_tile_up_scale:i?hd(1):r.upVectorScale(t,e.center.lat,e.worldSize).metersToTile}}renderToBackBuffer(e){const t=this.painter,i=this.painter.context;0!==e.length&&(i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height]),t.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(e,t,i,r,n){if("globe"===e.transform.projection.name)!function(e,t,i,r,n){const o=e.context,s=o.gl;let a,l;const c=e.transform,h=Ld(e,o,c),u=(t,i)=>{if(l===i)return;const r=[rM[i],"PROJECTION_GLOBE_VIEW"];h&&r.push("CUSTOM_ANTIALIASING");const n=e.isTileAffectedByFog(t);a=e.getOrCreateProgram("globeRaster",{defines:r,overrideFog:n}),l=i;},d=e.colorModeForRenderPass(),p=new Mx(s.LEQUAL,Mx.ReadWrite,e.depthRangeFor3D);iM.update(n);const f=Pd(c),m=[Kd(c.center.lng),Jd(c.center.lat)],_=e.globeSharedBuffers,g=[c.width*dt.devicePixelRatio,c.height*dt.devicePixelRatio],y=Float32Array.from(c.globeMatrix),x={useDenormalizedUpVectorScale:!0};{const c=e.transform,h=nM(c.zoom,t.exaggeration(),t.sourceCache._source.tileSize);l=-1;const v=s.TRIANGLES;for(const l of r){const r=i.getTile(l),b=Sx.disabled,w=t.prevTerrainTileForTile[l.key],T=t.terrainTileForTile[l.key];tM(w,T)&&iM.newMorphing(l.key,w,T,n,250),o.activeTexture.set(s.TEXTURE0),r.texture&&r.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const E=iM.getMorphValuesForProxy(l.key),A=E?1:0;E&&Lt(x,{morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:M(E.phase)}});const S=xd(l.canonical),I=Od(S.getCenter().lat),C=kd(l.canonical,S,I,c.worldSize/c._pixelsPerMercatorPixel),z=Ad(fd(l.canonical)),P=QE(c.expandedFarZProjMatrix,y,f,z,Dd(c.zoom),m,c.frustumCorners.TL,c.frustumCorners.TR,c.frustumCorners.BR,c.frustumCorners.BL,c.globeCenterInViewSpace,c.globeRadius,g,h,C);if(u(l,A),a&&(t.setupElevationDraw(r,a,x),e.uploadCommonUniforms(o,a,l.toUnwrapped()),_)){const[t,i,r]=_.getGridBuffers(I,0!==h);a.draw(e,v,p,b,d,Dx.backCCW,P,"globe_raster",t,i,r);}}}if(_&&(e.renderDefaultNorthPole||e.renderDefaultSouthPole)){const n=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];h&&n.push("CUSTOM_ANTIALIASING"),a=e.getOrCreateProgram("globeRaster",{defines:n});for(const n of r){const{x:r,y:l,z:h}=n.canonical,u=0===l,f=l===(1<<h)-1,[y,v,b,w]=_.getPoleBuffers(h,!1);if(w&&(u||f)){const l=i.getTile(n);o.activeTexture.set(s.TEXTURE0),l.texture&&l.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);let _=Rd(h,r,c);const T=Ad(fd(n.canonical)),E=(t,i)=>t.draw(e,s.TRIANGLES,p,Sx.disabled,d,Dx.disabled,QE(c.expandedFarZProjMatrix,_,_,T,0,m,c.frustumCorners.TL,c.frustumCorners.TR,c.frustumCorners.BR,c.frustumCorners.BL,c.globeCenterInViewSpace,c.globeRadius,g,0),"globe_pole_raster",i,b,w);t.setupElevationDraw(l,a,x),e.uploadCommonUniforms(o,a,n.toUnwrapped()),u&&e.renderDefaultNorthPole&&E(a,y),f&&e.renderDefaultSouthPole&&(_=Au.scale(Au.create(),_,[1,-1,1]),E(a,v));}}}}(e,t,i,r,n);else {const o=e.context,s=o.gl;let a,l;const c=e.shadowRenderer,h=eM(e,e.longestCutoffRange),u=t=>{if(l===t)return;const i=[];i.push(rM[t]),h.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),a=e.getOrCreateProgram("terrainRaster",{defines:i}),l=t;},d=e.colorModeForRenderPass(),p=new Mx(s.LEQUAL,Mx.ReadWrite,e.depthRangeFor3D);iM.update(n);const f=e.transform,m=nM(f.zoom,t.exaggeration(),t.sourceCache._source.tileSize);let _=[0,0,0];if(c){const t=e.style.directionalLight,i=e.style.ambientLight;t&&i&&(_=WA(t,i));}{l=-1;const g=s.TRIANGLES,[y,x]=[t.gridIndexBuffer,t.gridSegments];for(const l of r){const r=i.getTile(l),v=Sx.disabled,b=t.prevTerrainTileForTile[l.key],w=t.terrainTileForTile[l.key];tM(b,w)&&iM.newMorphing(l.key,b,w,n,250),o.activeTexture.set(s.TEXTURE0),r.texture&&r.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const T=iM.getMorphValuesForProxy(l.key),E=T?1:0;let A;T&&(A={morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:M(T.phase)}});const S=JE(l.projMatrix,oM(l.canonical,f.renderWorldCopies)?m/10:m,_);if(u(E),!a)continue;t.setupElevationDraw(r,a,A);const I=l.toUnwrapped();c&&c.setupShadows(I,a),e.uploadCommonUniforms(o,a,I,null,h),a.draw(e,g,p,v,d,Dx.backCCW,S,"terrain_raster",t.gridBuffer,y,x);}}}}(t,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,t.gpuTimingDeferredRenderEnd(),e.splice(0,e.length));}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const t=this.painter,i=this.painter.context,r=this.proxySourceCache,n=this.proxiedCoords[r.id],o=this._drapedRenderBatches.shift(),s=t.style.order,a=[];let l=0;for(const c of n){const n=r.getTileByID(c.proxyTileKey),h=r.proxyCachedFBO[c.key]?r.proxyCachedFBO[c.key][e]:void 0,u=void 0!==h?r.renderCache[h]:this.pool[l++],d=void 0!==h;if(n.texture=u.tex,d&&!u.dirty){a.push(n.tileID);continue}let p;i.bindFramebuffer.set(u.fb.framebuffer),this.renderedToTile=!1,u.dirty&&(i.clear({color:hi.transparent,stencil:0}),u.dirty=!1);for(let e=o.start;e<=o.end;++e){const r=t.style._mergedLayers[s[e]];if(r.isHidden(t.transform.zoom))continue;const n=t.style.getLayerSourceCache(r),o=n?this.proxyToSource[c.key][n.id]:[c];if(!o)continue;const a=o;i.viewport.set([0,0,u.fb.width,u.fb.height]),p!==(n?n.id:null)&&(this._setupStencil(u,o,r,n),p=n?n.id:null),t.renderLayer(t,n,r,a);}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const r=t.style._mergedLayers[s[e]];if(r.isHidden(t.transform.zoom))continue;const n=t.style.getLayerSourceCache(r),o=n?this.proxyToSource[c.key][n.id]:[c];if(!o)continue;const a=o;i.viewport.set([0,0,u.fb.width,u.fb.height]),p!==(n?n.id:null)&&(this._setupStencil(u,o,r,n),p=n?n.id:null),t.renderLayer(t,n,r,a);}this.renderedToTile?(u.dirty=!0,a.push(n.tileID)):d||--l,5===l&&(l=0,this.renderToBackBuffer(a));}return this.renderToBackBuffer(a),this.renderingToTexture=!1,i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height]),o.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,r=t;for(let n=0;n<t;++n)this._style.isLayerDraped(e._mergedLayers[e.order[n]])?i=Math.max(i,n):r=Math.min(r,n);return r>i}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter((e=>e.dem)).forEach((t=>{e=Math.min(e,t.dem.tree.minimums[0]);})),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter((e=>e.dem)).map((r=>{const n=r.tileID,o=1<<n.overscaledZ,{x:s,y:a}=n.canonical,l=s/o,c=(s+1)/o,h=a/o,u=(a+1)/o;return {minx:l,miny:h,maxx:c,maxy:u,t:r.dem.tree.raycastRoot(l,h,c,u,e,t,i),tile:r}}));r.sort(((e,t)=>(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const n of r){if(null==n.t)return null;const r=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,i);if(null!=r)return r}return null}_createFBO(){const e=this.painter.context,t=e.gl,i=this.drapeBufferSize;e.activeTexture.set(t.TEXTURE0);const r=new My(e,{width:i[0],height:i[1],data:null},t.RGBA);r.bind(t.LINEAR,t.CLAMP_TO_EDGE);const n=e.createFramebuffer(i[0],i[1],!0,null);return n.colorAttachment.set(r.texture),n.depthAttachment=new Tx(e,n.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,i[0],i[1]),this._stencilRef=0,n.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):n.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&t.texParameterf(t.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:n,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO());}_shouldDisableRenderCache(){if(this._style.hasLightTransitions())return !0;for(const e in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[e].hasTransition())return !0;return this._style.order.some((e=>{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return "custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()}))}_clearLineLayersFromRenderCache(){let e=!1;for(const t of this._style.getSources())if(t instanceof Vw){e=!0;break}if(!e)return;const t={};for(let e=0;e<this._style.order.length;++e){const i=this._style._mergedLayers[this._style.order[e]],r=this._style.getLayerSourceCache(i);if(r&&!t[r.id]&&!i.isHidden(this.painter.transform.zoom)&&"line"===i.type&&i.widthExpression()instanceof Ao){t[r.id]=!0;for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][r.id];if(t)for(const e of t)this._clearRenderCacheForTile(r.id,e);}}}}_clearRasterLayersFromRenderCache(){let e=!1;for(const t in this._style._mergedSourceCaches)if(this._style._mergedSourceCaches[t]._source instanceof jw){e=!0;break}if(!e)return;const t={};for(let e=0;e<this._style.order.length;++e){const i=this._style._mergedLayers[this._style.order[e]],r=this._style.getLayerSourceCache(i);if(!r||t[r.id])continue;if(i.isHidden(this.painter.transform.zoom)||"raster"!==i.type)continue;const n=i.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][r.id];if(t)for(const e of t){const t=aM(r.getTile(e),r.findLoadedParent(e,0),r,this.painter.transform,n);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(r.id,e);}}}}_setupDrapedRenderBatches(){const e=this._style.order,t=e.length;if(0===t)return;const i=[];this._pendingGroundEffectLayers=[];let r,n=0,o=this._style._mergedLayers[e[n]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++n<t;)o=this._style._mergedLayers[e[n]];for(;n<t;++n){const t=this._style._mergedLayers[e[n]];t.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(t)?void 0===r&&(r=n):("fill-extrusion"===t.type&&this._pendingGroundEffectLayers.push(n),void 0!==r&&(i.push({start:r,end:n-1}),r=void 0)));}if(void 0!==r&&i.push({start:r,end:n-1}),0!==i.length){const e=i[i.length-1],t=this._pendingGroundEffectLayers.every((t=>t>e.end));t||H("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.");}this._drapedRenderBatches=i;}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this.invalidateRenderCache){if(this.invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i<e.length;++i){const r=Object.values(e[i]);t.renderCachePool.push(...r);}}return}this._clearRasterLayersFromRenderCache();const i=this.proxyCoords,r=this._tilesDirty;for(let n=i.length-1;n>=0;n--){const o=i[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],n=this.proxyToSource[o.key];let s=0;for(const e in n){const t=n[e],o=i[e];if(!o||o.length!==t.length||t.some(((t,i)=>t!==o[i]||r[e]&&r[e].hasOwnProperty(t.key)))){s=-1;break}++s;}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(i).length;}}const n=[...this._drapedRenderBatches];n.sort(((e,t)=>t.end-t.start-(e.end-e.start)));for(const e of n)for(const r of i){if(t.proxyCachedFBO[r.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<50&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[r.key]={},t.proxyCachedFBO[r.key][e.start]=i,t.renderCache[i].dirty=!0);}this._tilesDirty={};}_setupStencil(e,t,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else {if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask";}this._stencilRef+s>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref);}clipOrMaskOverlapStencilType(){return "Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):Sx.disabled}_renderTileClippingMasks(e,t){const i=this.painter,r=this.painter.context,n=r.gl;i._tileClippingMaskIDs={},r.setColorMode(Cx.disabled),r.setDepthMode(Mx.disabled);const o=i.getOrCreateProgram("clippingMask");for(const r of e){const e=i._tileClippingMaskIDs[r.key]=--t;o.draw(i,n.TRIANGLES,Mx.disabled,new Sx({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),Cx.disabled,Dx.disabled,sM(r.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments);}}pointCoordinate(e){const t=this.painter.transform;if(e.x<0||e.x>t.width||e.y<0||e.y>t.height)return null;const i=[e.x,e.y,1,1];yu.transformMat4(i,i,t.pixelMatrixInverse),yu.scale(i,i,1/i[3]),i[0]/=t.worldSize,i[1]/=t.worldSize;const r=t._camera.position,n=Qd(1,t.center.lat),o=[r[0],r[1],r[2]/n,0],s=Du.subtract([],i.slice(0,3),o);Du.normalize(s,s);const a=this.raycast(o,s,this._exaggeration);return null!==a&&a?(Du.scaleAndAdd(o,o,s,a),o[3]=o[2],o[2]*=n,o):null}drawDepth(){const e=this.painter,t=e.context,i=this.proxySourceCache,r=Math.ceil(e.width),n=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===r&&this._depthFBO.height===n||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const e=t.gl,i=t.createFramebuffer(r,n,!0,"renderbuffer");t.activeTexture.set(e.TEXTURE0);const o=new My(t,{width:r,height:n,data:null},e.RGBA);o.bind(e.NEAREST,e.CLAMP_TO_EDGE),i.colorAttachment.set(o.texture);const s=t.createRenderbuffer(t.gl.DEPTH_COMPONENT16,r,n);i.depthAttachment.set(s),this._depthFBO=i,this._depthTexture=o;}t.bindFramebuffer.set(this._depthFBO.framebuffer),t.viewport.set([0,0,r,n]),function(e,t,i,r){if("globe"===e.transform.projection.name)return;const n=e.context,o=n.gl;n.clear({depth:1});const s=e.getOrCreateProgram("terrainDepth"),a=new Mx(o.LESS,Mx.ReadWrite,e.depthRangeFor3D);for(const n of r){const r=i.getTile(n),l=JE(n.projMatrix,0,[0,0,0]);t.setupElevationDraw(r,s),s.draw(e,o.TRIANGLES,a,Sx.disabled,Cx.unblended,Dx.backCCW,l,"terrain_depth",t.gridBuffer,t.gridIndexBuffer,t.gridNoSkirtSegments);}}(e,this,i,this.proxyCoords);}_setupProxiedCoordsForOrtho(e,t,i){if(e.getSource()instanceof Jb)return this._setupProxiedCoordsForImageSource(e,t,i);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const r=this.proxiedCoords[e.id]=[],n=this.proxyCoords;for(let t=0;t<n.length;t++){const o=n[t],s=this._findTileCoveringTileID(o,e);if(s){const t=this._createProxiedId(o,s,i[o.key]&&i[o.key][e.id]);r.push(t),this.proxyToSource[o.key][e.id]=[t];}}let o=!1;for(let n=0;n<t.length;n++){const s=e.getTile(t[n]);if(!s||!s.hasData())continue;const a=this._findTileCoveringTileID(s.tileID,this.proxySourceCache);if(a&&a.tileID.canonical.z!==s.tileID.canonical.z){const t=this.proxyToSource[a.tileID.key][e.id],n=this._createProxiedId(a.tileID,s,i[a.tileID.key]&&i[a.tileID.key][e.id]);t?t.splice(t.length-1,0,n):this.proxyToSource[a.tileID.key][e.id]=[n],r.push(n),o=!0;}}this._sourceTilesOverlap[e.id]=o;}_setupProxiedCoordsForImageSource(e,t,i){if(!e.getSource().loaded())return;const r=this.proxiedCoords[e.id]=[],n=this.proxyCoords,o=e.getSource(),s=o.tileID;if(!s)return;const a=new y(s.x,s.y)._div(1<<s.z),l=o.coordinates.map(lp.fromLngLat).reduce(((e,t)=>(e.min.x=Math.min(e.min.x,t.x-a.x),e.min.y=Math.min(e.min.y,t.y-a.y),e.max.x=Math.max(e.max.x,t.x-a.x),e.max.y=Math.max(e.max.y,t.y-a.y),e)),{min:new y(Number.MAX_VALUE,Number.MAX_VALUE),max:new y(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(e,t)=>{const i=e.wrap+e.canonical.x/(1<<e.canonical.z),r=e.canonical.y/(1<<e.canonical.z),n=cr/(1<<e.canonical.z),o=t.wrap+t.canonical.x/(1<<t.canonical.z),s=t.canonical.y/(1<<t.canonical.z);return i+n<o+l.min.x||i>o+l.max.x||r+n<s+l.min.y||r>s+l.max.y};for(let o=0;o<n.length;o++){const s=n[o];for(let n=0;n<t.length;n++){const o=e.getTile(t[n]);if(!o||!o.hasData())continue;if(c(s,o.tileID))continue;const a=this._createProxiedId(s,o,i[s.key]&&i[s.key][e.id]),l=this.proxyToSource[s.key][e.id];l?l.push(a):this.proxyToSource[s.key][e.id]=[a],r.push(a);}}}_createProxiedId(e,t,i){let r=this.orthoMatrix;if(i){const e=i.find((e=>e.key===t.tileID.key));if(e)return e}if(t.tileID.key!==e.key){const i=e.canonical.z-t.tileID.canonical.z;let n,o,s;r=Au.create();const a=t.tileID.wrap-e.wrap<<e.overscaledZ;i>0?(n=cr>>i,o=n*((t.tileID.canonical.x<<i)-e.canonical.x+a),s=n*((t.tileID.canonical.y<<i)-e.canonical.y)):(n=cr<<-i,o=cr*(t.tileID.canonical.x-(e.canonical.x+a<<-i)),s=cr*(t.tileID.canonical.y-(e.canonical.y<<-i))),Au.ortho(r,0,n,0,n,0,1),Au.translate(r,r,[o,s,0]);}return new hM(t.tileID,e.key,r)}_findTileCoveringTileID(e,t){let i=t.getTile(e);if(i&&i.hasData())return i;const r=this._findCoveringTileCache[t.id],n=r[e.key];if(i=n?t.getTileByID(n):null,i&&i.hasData()||null===n)return i;let o=i?i.tileID:e,s=o.overscaledZ;const a=t.getSource().minzoom,l=[];if(!n){const r=t.getSource().maxzoom;if(e.canonical.z>=r){const i=e.canonical.z-r;t.getSource().reparseOverscaled?(s=Math.max(e.canonical.z+2,t.transform.tileZoom),o=new qu(s,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i)):0!==i&&(s=r,o=new qu(s,e.wrap,r,e.canonical.x>>i,e.canonical.y>>i));}o.key!==e.key&&(l.push(o.key),i=t.getTile(o));}const c=e=>{l.forEach((t=>{r[t]=e;})),l.length=0;};for(s-=1;s>=a&&(!i||!i.hasData());s--){i&&c(i.tileID.key);const e=o.calculateScaledKey(s);if(i=t.getTileByID(e),i&&i.hasData())break;const n=r[e];if(null===n)break;void 0===n?l.push(e):i=t.getTileByID(n);}return c(i?i.tileID.key:null),i&&i.hasData()?i:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0;}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0;}}function dM(e,t,i){const r=function(e,t,i){const r=Du.dot(t,e),n=Du.dot(i,[.2126,.7152,.0722]),o=(e,t,i)=>(1-i)*e+i*t,s=o(1-.3*Math.min(n,1),1,Math.min(r+1,1));return o(.92,1,Math.asin(z(t[2],-1,1))/Math.PI+.5)*s}(e,[0,0,1],t),n=[0,0,0];Du.scale(n,i.slice(0,3),r);const o=[0,0,0];Du.scale(o,t.slice(0,3),e[2]);const s=[0,0,0];return Du.add(s,n,o),ae(s)}const pM=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],fM=["stars","fillExtrusion","fillExtrusionGroundEffect","model","symbolSDF","symbolIcon","symbolTextAndIcon"];class mM{static cacheKey(e,t,i,r){let n=`${t}${r?r.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(n+=`/${t}`);return n}constructor(e,t,i,r,n,o){const s=e.gl;this.program=s.createProgram(),this.configuration=r,this.name=t,this.fixedDefines=[...o];const a=r?r.getBinderAttributes():[],l=(i.staticAttributes||[]).concat(a);let c=r?r.defines():[];c=c.concat(o.map((e=>`#define ${e}`)));const h="#version 300 es\n";let u=h+c.concat("precision mediump float;",jE,VE.fragmentSource).join("\n");for(const e of i.fragmentIncludes)u+=`\n${NE[e]}`;u+=`\n${i.fragmentSource}`;let d=h+c.concat("precision highp float;",jE,VE.vertexSource).join("\n");for(const e of i.vertexIncludes)d+=`\n${NE[e]}`;d+=`\n${i.vertexSource}`;const p=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(p,u),s.compileShader(p),s.attachShader(this.program,p);const f=s.createShader(s.VERTEX_SHADER);if(s.isContextLost())this.failedToCreate=!0;else {s.shaderSource(f,d),s.compileShader(f),s.attachShader(this.program,f),this.attributes={},this.numAttributes=l.length;for(let e=0;e<this.numAttributes;e++)if(l[e]){const t=l[e].startsWith("a_")?l[e]:`a_${l[e]}`;s.bindAttribLocation(this.program,e,t),this.attributes[t]=e;}s.linkProgram(this.program),s.deleteShader(f),s.deleteShader(p),this.fixedUniforms=n(e),this.binderUniforms=r?r.getUniforms(e):[],o.includes("TERRAIN")&&(this.terrainUniforms=(e=>({u_dem:new kl(e),u_dem_prev:new kl(e),u_dem_tl:new Bl(e),u_dem_scale:new Ol(e),u_dem_tl_prev:new Bl(e),u_dem_scale_prev:new Ol(e),u_dem_size:new Ol(e),u_dem_lerp:new Ol(e),u_exaggeration:new Ol(e),u_depth:new kl(e),u_depth_size_inv:new Bl(e),u_meter_to_dem:new Ol(e),u_label_plane_matrix_inv:new jl(e)}))(e)),o.includes("GLOBE")&&(this.globeUniforms=(e=>({u_tile_tl_up:new Fl(e),u_tile_tr_up:new Fl(e),u_tile_br_up:new Fl(e),u_tile_bl_up:new Fl(e),u_tile_up_scale:new Ol(e)}))(e)),o.includes("FOG")&&(this.fogUniforms=(e=>({u_fog_matrix:new jl(e),u_fog_range:new Bl(e),u_fog_color:new Nl(e),u_fog_horizon_blend:new Ol(e),u_fog_vertical_limit:new Bl(e),u_fog_temporal_offset:new Ol(e),u_frustum_tl:new Fl(e),u_frustum_tr:new Fl(e),u_frustum_br:new Fl(e),u_frustum_bl:new Fl(e),u_globe_pos:new Fl(e),u_globe_radius:new Ol(e),u_globe_transition:new Ol(e),u_is_globe:new kl(e),u_viewport:new Bl(e)}))(e)),o.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(e=>({u_cutoff_params:new Nl(e)}))(e)),o.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(e=>({u_lighting_ambient_color:new Fl(e),u_lighting_directional_dir:new Fl(e),u_lighting_directional_color:new Fl(e),u_ground_radiance:new Fl(e)}))(e)),o.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(e=>({u_light_matrix_0:new jl(e),u_light_matrix_1:new jl(e),u_fade_range:new Bl(e),u_shadow_normal_offset:new Fl(e),u_shadow_intensity:new Ol(e),u_shadow_texel_size:new Ol(e),u_shadow_map_resolution:new Ol(e),u_shadow_direction:new Fl(e),u_shadow_bias:new Fl(e),u_shadowmap_0:new kl(e),u_shadowmap_1:new kl(e)}))(e));}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e]);}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const i=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const i=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const i=this.shadowUniforms;e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e]);}_drawDebugWireframe(e,t,i,r,n,o,s,a,l,c){const h=e.options.wireframe;if(!1===h.terrain&&!1===h.layers2D&&!1===h.layers3D)return;const u=e.context;if(!(()=>!(!h.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!h.layers2D||e._terrain&&e._terrain.renderingToTexture||!pM.includes(this.name))||!(!h.layers3D||!fM.includes(this.name)))())return;const d=u.gl,p=e.wireframeDebugCache.getLinesFromTrianglesBuffer(e.frameCounter,n,u);if(!p)return;const f=[...this.fixedDefines];f.push("DEBUG_WIREFRAME");const m=e.getOrCreateProgram(this.name,{config:this.configuration,defines:f});u.program.set(m.program);const _=(e,t,i)=>{if(t[e]&&i[e])for(const r in t[e])i[e][r]&&i[e][r].set(i.program,r,t[e][r].current);};l&&l.setUniforms(m.program,u,m.binderUniforms,s,{zoom:a}),_("fixedUniforms",this,m),_("terrainUniforms",this,m),_("globeUniforms",this,m),_("fogUniforms",this,m),_("lightsUniforms",this,m),_("shadowUniforms",this,m),p.bind(),u.setColorMode(new Cx([d.ONE,d.ONE_MINUS_SRC_ALPHA,d.ZERO,d.ONE],hi.transparent,[!0,!0,!0,!1])),u.setDepthMode(new Mx(t.func===d.LESS?d.LEQUAL:t.func,Mx.ReadOnly,t.range)),u.setStencilMode(Sx.disabled);const g=3*o.primitiveLength*2,y=3*o.primitiveOffset*2*2;c&&c>1?d.drawElementsInstanced(d.LINES,g,d.UNSIGNED_SHORT,y,c):d.drawElements(d.LINES,g,d.UNSIGNED_SHORT,y),n.bind(),u.program.set(this.program),u.setDepthMode(t),u.setStencilMode(i),u.setColorMode(r);}draw(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=e.context,g=_.gl;if(this.failedToCreate)return;_.program.set(this.program),_.setDepthMode(i),_.setStencilMode(r),_.setColorMode(n),_.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,s[e]);p&&p.setUniforms(this.program,_,this.binderUniforms,u,{zoom:d});const y={[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t],x=m&&m>0?1:void 0;for(const o of h.get()){const s=o.vaos||(o.vaos={});(s[a]||(s[a]=new $E)).bind(_,this,l,p?p.getPaintVertexBuffers():[],c,o.vertexOffset,f||[],x),m&&m>1?g.drawElementsInstanced(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2,m):g.drawElements(t,o.primitiveLength*y,g.UNSIGNED_SHORT,o.primitiveOffset*y*2),t===g.TRIANGLES&&this._drawDebugWireframe(e,i,r,n,c,o,u,d,p,m);}}}function _M(e,t){const i=Math.pow(2,t.tileID.overscaledZ),r=t.tileSize*Math.pow(2,e.transform.tileZoom)/i,n=r*(t.tileID.canonical.x+t.tileID.wrap*i),o=r*t.tileID.canonical.y;return {u_image:0,u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/rv(t,1,e.transform.tileZoom),u_pixel_coord_upper:[n>>16,o>>16],u_pixel_coord_lower:[65535&n,65535&o]}}const gM=Au.create(),yM=(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m)=>{const _=t.style.light,g=_.properties.get("position"),y=[g.x,g.y,g.z],x=Eu.create();"viewport"===_.properties.get("anchor")&&(Eu.fromRotation(x,-t.transform.angle),Du.transformMat3(y,y,x));const v=_.properties.get("color"),b=t.transform,w={u_matrix:e,u_lightpos:y,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[v.r,v.g,v.b],u_vertical_gradient:+i,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:gM,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:n,u_edge_radius:o,u_flood_light_color:u,u_vertical_scale:d,u_flood_light_intensity:p,u_ground_shadow_factor:f,u_emissive_strength:m};return "globe"===b.projection.name&&(w.u_tile_id=[s.canonical.x,s.canonical.y,1<<s.canonical.z],w.u_zoom_transition=l,w.u_inv_rot_matrix=h,w.u_merc_center=c,w.u_up_dir=b.projection.upVector(new ju(0,0,0),c[0]*cr,c[1]*cr),w.u_height_lift=a),w},xM=(e,t,i)=>({u_matrix:e,u_edge_radius:t,u_vertical_scale:i}),vM=(e,t,i,r,n,o,s,a,l,c,h,u,d,p)=>{const f=yM(e,t,i,r,n,o,s,l,c,h,u,d,p,1,[0,0,0],0),m={u_height_factor:-Math.pow(2,s.overscaledZ)/a.tileSize/8};return k(f,_M(t,a),m)},bM=(e,t)=>({u_matrix:e,u_emissive_strength:t}),wM=(e,t,i,r)=>k(bM(e,t),_M(i,r)),TM=(e,t,i)=>({u_matrix:e,u_world:i,u_emissive_strength:t}),EM=(e,t,i,r,n)=>k(wM(e,t,i,r),{u_world:n}),MM=(e,t,i,r)=>{const n=cr/i.tileSize;return {u_matrix:e,u_camera_to_center_distance:t.getCameraToCenterDistance(r),u_extrude_scale:[t.pixelsToGLUnits[0]/n,t.pixelsToGLUnits[1]/n]}},AM=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),SM=Au.create(),IM=(e,t,i,r,n,o,s)=>{const a=e.transform,l="globe"===a.projection.name,c=l?Cd(a.zoom,t.canonical)*a._pixelsPerMercatorPixel:rv(i,1,o),h={u_matrix:t.projMatrix,u_extrude_scale:c,u_intensity:s,u_inv_rot_matrix:SM,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){h.u_inv_rot_matrix=r,h.u_merc_center=n,h.u_tile_id=[t.canonical.x,t.canonical.y,1<<t.canonical.z],h.u_zoom_transition=Dd(a.zoom);const e=n[0]*cr,i=n[1]*cr;h.u_up_dir=a.projection.upVector(new ju(0,0,0),e,i);}return h},CM=(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b)=>{return {u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:r,u_grid_matrix:n,u_tl_parent:o,u_scale_parent:h,u_fade_t:u.mix,u_opacity:u.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:(T=d.paint.get("raster-saturation"),T>0?1-1/(1.001-T):-T),u_contrast_factor:(w=d.paint.get("raster-contrast"),w>0?1/(1-w):1+w),u_spin_weights:zM(d.paint.get("raster-hue-rotate")),u_perspective_transform:p,u_raster_elevation:f,u_tl_br:s,u_zoom_transition:a,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:PM(_,y),u_colorization_offset:DM(g,y),u_color_ramp:m,u_texture_offset:[v/(x+2*v),x/(x+2*v)],u_texture_res:[x+2*v,x+2*v],u_emissive_strength:b};var w,T;};function zM(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return [(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}function PM([e,t,i,r],[n,o]){if(n===o)return [0,0,0,0];const s=259/257/(o-n);return [e*s,t*s,i*s,r*s]}function DM(e,[t,i]){return t===i?0:((e-t)/(i-t)*259-1)/257}const RM=Au.create(),LM=(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g)=>{const y=n.transform,x={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:y.getCameraToCenterDistance(m),u_rotate_symbol:+i,u_aspect_ratio:y.width/y.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:s,u_coord_matrix:a,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:RM,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:RM,u_up_vector:[0,-1,0],u_icon_transition:g||0,u_icon_saturation:_};return "globe"===m.name&&(x.u_tile_id=[h.canonical.x,h.canonical.y,1<<h.canonical.z],x.u_zoom_transition=u,x.u_inv_rot_matrix=p,x.u_merc_center=d,x.u_camera_forward=y._camera.forward(),x.u_ecef_origin=function(e,t){const i=[0,0,0],r=Ad(fd(t.canonical));return Du.transformMat4(i,i,r),Du.transformMat4(i,i,e),i}(y.globeMatrix,h.toUnwrapped()),x.u_tile_matrix=Float32Array.from(y.globeMatrix),x.u_up_vector=f),x},kM=(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_)=>k(LM(e,t,i,r,n,o,s,a,l,c,u,d,p,f,m,_,1),{u_gamma_scale:r?n.transform.getCameraToCenterDistance(_)*Math.cos(n.terrain?0:n.transform._pitch):1,u_device_pixel_ratio:dt.devicePixelRatio,u_is_halo:+h,undefined:void 0}),OM=(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m)=>k(kM(e,t,i,r,n,o,s,a,!0,l,!0,h,u,d,p,f,m),{u_texsize_icon:c,u_texture_icon:1}),BM=(e,t,i,r)=>({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:r}),FM=(e,t,i,r,n,o,s)=>k(function(e,t,i,r){const n=i.imageManager.getPattern(e.toString(),t),{width:o,height:s}=i.imageManager.getPixelSize(t),a=Math.pow(2,r.tileID.overscaledZ),l=r.tileSize*Math.pow(2,i.transform.tileZoom)/a,c=l*(r.tileID.canonical.x+r.tileID.wrap*a),h=l*r.tileID.canonical.y;return {u_image:0,u_pattern_tl:n.tl,u_pattern_br:n.br,u_texsize:[o,s],u_pattern_size:n.displaySize,u_tile_units_to_pixels:1/rv(r,1,i.transform.tileZoom),u_pixel_coord_upper:[c>>16,h>>16],u_pixel_coord_lower:[65535&c,65535&h]}}(n,o,r,s),{u_matrix:e,u_emissive_strength:t,u_opacity:i}),NM={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,ShadowMap0:10},UM=(e,t,i,r,n,o,s,a,l,c,h,u,d=[0,0,0])=>{const p=r.style.light,f=p.properties.get("position"),m=[-f.x,-f.y,f.z],_=Eu.create();"viewport"===p.properties.get("anchor")&&(Eu.fromRotation(_,-r.transform.angle),Du.transformMat3(m,m,_));const g="MASK"===c.alphaMode,y=p.properties.get("color"),x=u.paint.get("model-ambient-occlusion-intensity"),v=u.paint.get("model-color").constantOr(hi.white),b=u.paint.get("model-color-mix-intensity").constantOr(0);return {u_matrix:e,u_lighting_matrix:t,u_normal_matrix:i,u_lightpos:m,u_lightintensity:p.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_camera_pos:d,u_opacity:n,u_baseTextureIsAlpha:0,u_alphaMask:+g,u_alphaCutoff:c.alphaCutoff,u_baseColorFactor:[o.r,o.g,o.b,o.a],u_emissiveFactor:[s[0],s[1],s[2],1],u_metallicFactor:a,u_roughnessFactor:l,u_baseColorTexture:NM.BaseColor,u_metallicRoughnessTexture:NM.MetallicRoughness,u_normalTexture:NM.Normal,u_occlusionTexture:NM.Occlusion,u_emissionTexture:NM.Emission,u_color_mix:[v.r,v.g,v.b,b],u_aoIntensity:x,u_emissive_strength:h}},VM=new Float32Array(16),jM=(e,t=VM,i=VM)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),GM={fillExtrusion:e=>({u_matrix:new jl(e),u_lightpos:new Fl(e),u_lightintensity:new Ol(e),u_lightcolor:new Fl(e),u_vertical_gradient:new Ol(e),u_opacity:new Ol(e),u_edge_radius:new Ol(e),u_ao:new Bl(e),u_tile_id:new Fl(e),u_zoom_transition:new Ol(e),u_inv_rot_matrix:new jl(e),u_merc_center:new Bl(e),u_up_dir:new Fl(e),u_height_lift:new Ol(e),u_flood_light_color:new Fl(e),u_vertical_scale:new Ol(e),u_flood_light_intensity:new Ol(e),u_ground_shadow_factor:new Fl(e),u_emissive_strength:new Ol(e)}),fillExtrusionDepth:e=>({u_matrix:new jl(e),u_edge_radius:new Ol(e),u_vertical_scale:new Ol(e)}),fillExtrusionPattern:e=>({u_matrix:new jl(e),u_lightpos:new Fl(e),u_lightintensity:new Ol(e),u_lightcolor:new Fl(e),u_vertical_gradient:new Ol(e),u_height_factor:new Ol(e),u_edge_radius:new Ol(e),u_ao:new Bl(e),u_tile_id:new Fl(e),u_zoom_transition:new Ol(e),u_inv_rot_matrix:new jl(e),u_merc_center:new Bl(e),u_up_dir:new Fl(e),u_height_lift:new Ol(e),u_image:new kl(e),u_texsize:new Bl(e),u_pixel_coord_upper:new Bl(e),u_pixel_coord_lower:new Bl(e),u_tile_units_to_pixels:new Ol(e),u_opacity:new Ol(e)}),fillExtrusionGroundEffect:e=>({u_matrix:new jl(e),u_opacity:new Ol(e),u_ao_pass:new Ol(e),u_meter_to_tile:new Ol(e),u_ao:new Bl(e),u_flood_light_intensity:new Ol(e),u_flood_light_color:new Fl(e),u_attenuation:new Ol(e),u_edge_radius:new Ol(e),u_fb:new kl(e),u_fb_size:new Ol(e)}),fill:e=>({u_matrix:new jl(e),u_emissive_strength:new Ol(e)}),fillPattern:e=>({u_matrix:new jl(e),u_emissive_strength:new Ol(e),u_image:new kl(e),u_texsize:new Bl(e),u_pixel_coord_upper:new Bl(e),u_pixel_coord_lower:new Bl(e),u_tile_units_to_pixels:new Ol(e)}),fillOutline:e=>({u_matrix:new jl(e),u_emissive_strength:new Ol(e),u_world:new Bl(e)}),fillOutlinePattern:e=>({u_matrix:new jl(e),u_emissive_strength:new Ol(e),u_world:new Bl(e),u_image:new kl(e),u_texsize:new Bl(e),u_pixel_coord_upper:new Bl(e),u_pixel_coord_lower:new Bl(e),u_tile_units_to_pixels:new Ol(e)}),circle:e=>({u_camera_to_center_distance:new Ol(e),u_extrude_scale:new $l(e),u_device_pixel_ratio:new Ol(e),u_matrix:new jl(e),u_inv_rot_matrix:new jl(e),u_merc_center:new Bl(e),u_tile_id:new Fl(e),u_zoom_transition:new Ol(e),u_up_dir:new Fl(e),u_emissive_strength:new Ol(e)}),collisionBox:e=>({u_matrix:new jl(e),u_camera_to_center_distance:new Ol(e),u_extrude_scale:new Bl(e)}),collisionCircle:e=>({u_matrix:new jl(e),u_inv_matrix:new jl(e),u_camera_to_center_distance:new Ol(e),u_viewport_size:new Bl(e)}),debug:e=>({u_color:new Ul(e),u_matrix:new jl(e),u_overlay:new kl(e),u_overlay_scale:new Ol(e)}),clippingMask:e=>({u_matrix:new jl(e)}),heatmap:e=>({u_extrude_scale:new Ol(e),u_intensity:new Ol(e),u_matrix:new jl(e),u_inv_rot_matrix:new jl(e),u_merc_center:new Bl(e),u_tile_id:new Fl(e),u_zoom_transition:new Ol(e),u_up_dir:new Fl(e)}),heatmapTexture:e=>({u_image:new kl(e),u_color_ramp:new kl(e),u_opacity:new Ol(e)}),hillshade:e=>({u_matrix:new jl(e),u_image:new kl(e),u_latrange:new Bl(e),u_light:new Bl(e),u_shadow:new Ul(e),u_highlight:new Ul(e),u_emissive_strength:new Ol(e),u_accent:new Ul(e)}),hillshadePrepare:e=>({u_matrix:new jl(e),u_image:new kl(e),u_dimension:new Bl(e),u_zoom:new Ol(e)}),line:e=>({u_matrix:new jl(e),u_pixels_to_tile_units:new $l(e),u_device_pixel_ratio:new Ol(e),u_units_to_pixels:new Bl(e),u_dash_image:new kl(e),u_gradient_image:new kl(e),u_image_height:new Ol(e),u_texsize:new Bl(e),u_tile_units_to_pixels:new Ol(e),u_alpha_discard_threshold:new Ol(e),u_trim_offset:new Bl(e),u_emissive_strength:new Ol(e)}),linePattern:e=>({u_matrix:new jl(e),u_texsize:new Bl(e),u_pixels_to_tile_units:new $l(e),u_device_pixel_ratio:new Ol(e),u_image:new kl(e),u_units_to_pixels:new Bl(e),u_tile_units_to_pixels:new Ol(e),u_alpha_discard_threshold:new Ol(e)}),raster:e=>({u_matrix:new jl(e),u_normalize_matrix:new jl(e),u_globe_matrix:new jl(e),u_merc_matrix:new jl(e),u_grid_matrix:new ql(e),u_tl_parent:new Bl(e),u_scale_parent:new Ol(e),u_fade_t:new Ol(e),u_opacity:new Ol(e),u_image0:new kl(e),u_image1:new kl(e),u_brightness_low:new Ol(e),u_brightness_high:new Ol(e),u_saturation_factor:new Ol(e),u_contrast_factor:new Ol(e),u_spin_weights:new Fl(e),u_perspective_transform:new Bl(e),u_raster_elevation:new Ol(e),u_tl_br:new Nl(e),u_zoom_transition:new Ol(e),u_merc_center:new Bl(e),u_cutoff_params:new Nl(e),u_colorization_mix:new Nl(e),u_colorization_offset:new Ol(e),u_color_ramp:new kl(e),u_texture_offset:new Bl(e),u_texture_res:new Bl(e),u_emissive_strength:new Ol(e)}),symbolIcon:e=>({u_is_size_zoom_constant:new kl(e),u_is_size_feature_constant:new kl(e),u_size_t:new Ol(e),u_size:new Ol(e),u_camera_to_center_distance:new Ol(e),u_rotate_symbol:new kl(e),u_aspect_ratio:new Ol(e),u_fade_change:new Ol(e),u_matrix:new jl(e),u_label_plane_matrix:new jl(e),u_coord_matrix:new jl(e),u_is_text:new kl(e),u_pitch_with_map:new kl(e),u_texsize:new Bl(e),u_tile_id:new Fl(e),u_zoom_transition:new Ol(e),u_inv_rot_matrix:new jl(e),u_merc_center:new Bl(e),u_camera_forward:new Fl(e),u_tile_matrix:new jl(e),u_up_vector:new Fl(e),u_ecef_origin:new Fl(e),u_texture:new kl(e),u_icon_transition:new Ol(e),u_icon_saturation:new Ol(e)}),symbolSDF:e=>({u_is_size_zoom_constant:new kl(e),u_is_size_feature_constant:new kl(e),u_size_t:new Ol(e),u_size:new Ol(e),u_camera_to_center_distance:new Ol(e),u_rotate_symbol:new kl(e),u_aspect_ratio:new Ol(e),u_fade_change:new Ol(e),u_matrix:new jl(e),u_label_plane_matrix:new jl(e),u_coord_matrix:new jl(e),u_is_text:new kl(e),u_pitch_with_map:new kl(e),u_texsize:new Bl(e),u_texture:new kl(e),u_gamma_scale:new Ol(e),u_device_pixel_ratio:new Ol(e),u_tile_id:new Fl(e),u_zoom_transition:new Ol(e),u_inv_rot_matrix:new jl(e),u_merc_center:new Bl(e),u_camera_forward:new Fl(e),u_tile_matrix:new jl(e),u_up_vector:new Fl(e),u_ecef_origin:new Fl(e),u_is_halo:new kl(e)}),symbolTextAndIcon:e=>({u_is_size_zoom_constant:new kl(e),u_is_size_feature_constant:new kl(e),u_size_t:new Ol(e),u_size:new Ol(e),u_camera_to_center_distance:new Ol(e),u_rotate_symbol:new kl(e),u_aspect_ratio:new Ol(e),u_fade_change:new Ol(e),u_matrix:new jl(e),u_label_plane_matrix:new jl(e),u_coord_matrix:new jl(e),u_is_text:new kl(e),u_pitch_with_map:new kl(e),u_texsize:new Bl(e),u_texsize_icon:new Bl(e),u_texture:new kl(e),u_texture_icon:new kl(e),u_gamma_scale:new Ol(e),u_device_pixel_ratio:new Ol(e),u_is_halo:new kl(e)}),background:e=>({u_matrix:new jl(e),u_emissive_strength:new Ol(e),u_opacity:new Ol(e),u_color:new Ul(e)}),backgroundPattern:e=>({u_matrix:new jl(e),u_emissive_strength:new Ol(e),u_opacity:new Ol(e),u_image:new kl(e),u_pattern_tl:new Bl(e),u_pattern_br:new Bl(e),u_texsize:new Bl(e),u_pattern_size:new Bl(e),u_pixel_coord_upper:new Bl(e),u_pixel_coord_lower:new Bl(e),u_tile_units_to_pixels:new Ol(e)}),terrainRaster:KE,terrainDepth:KE,skybox:e=>({u_matrix:new jl(e),u_sun_direction:new Fl(e),u_cubemap:new kl(e),u_opacity:new Ol(e),u_temporal_offset:new Ol(e)}),skyboxGradient:e=>({u_matrix:new jl(e),u_color_ramp:new kl(e),u_center_direction:new Fl(e),u_radius:new Ol(e),u_opacity:new Ol(e),u_temporal_offset:new Ol(e)}),skyboxCapture:e=>({u_matrix_3f:new ql(e),u_sun_direction:new Fl(e),u_sun_intensity:new Ol(e),u_color_tint_r:new Nl(e),u_color_tint_m:new Nl(e),u_luminance:new Ol(e)}),globeRaster:e=>({u_proj_matrix:new jl(e),u_globe_matrix:new jl(e),u_normalize_matrix:new jl(e),u_merc_matrix:new jl(e),u_zoom_transition:new Ol(e),u_merc_center:new Bl(e),u_image0:new kl(e),u_grid_matrix:new ql(e),u_skirt_height:new Ol(e),u_frustum_tl:new Fl(e),u_frustum_tr:new Fl(e),u_frustum_br:new Fl(e),u_frustum_bl:new Fl(e),u_globe_pos:new Fl(e),u_globe_radius:new Ol(e),u_viewport:new Bl(e)}),globeAtmosphere:e=>({u_frustum_tl:new Fl(e),u_frustum_tr:new Fl(e),u_frustum_br:new Fl(e),u_frustum_bl:new Fl(e),u_horizon:new Ol(e),u_transition:new Ol(e),u_fadeout_range:new Ol(e),u_color:new Nl(e),u_high_color:new Nl(e),u_space_color:new Nl(e),u_temporal_offset:new Ol(e),u_horizon_angle:new Ol(e)}),model:e=>({u_matrix:new jl(e),u_lighting_matrix:new jl(e),u_normal_matrix:new jl(e),u_lightpos:new Fl(e),u_lightintensity:new Ol(e),u_lightcolor:new Fl(e),u_camera_pos:new Fl(e),u_opacity:new Ol(e),u_baseColorFactor:new Nl(e),u_emissiveFactor:new Nl(e),u_metallicFactor:new Ol(e),u_roughnessFactor:new Ol(e),u_baseTextureIsAlpha:new kl(e),u_alphaMask:new kl(e),u_alphaCutoff:new Ol(e),u_baseColorTexture:new kl(e),u_metallicRoughnessTexture:new kl(e),u_normalTexture:new kl(e),u_occlusionTexture:new kl(e),u_emissionTexture:new kl(e),u_color_mix:new Nl(e),u_aoIntensity:new Ol(e),u_emissive_strength:new Ol(e)}),modelDepth:e=>({u_matrix:new jl(e),u_instance:new jl(e),u_node_matrix:new jl(e)}),groundShadow:e=>({u_matrix:new jl(e),u_ground_shadow_factor:new Fl(e)}),stars:e=>({u_matrix:new jl(e),u_up:new Fl(e),u_right:new Fl(e),u_intensity_multiplier:new Ol(e)})};let qM;function ZM(e,t,i,r,n,o,s){const a=e.context,l=a.gl,c=e.transform,h=e.getOrCreateProgram("collisionBox"),u=[];let d=0,p=0;for(let a=0;a<r.length;a++){const f=r[a],m=t.getTile(f),_=m.getBucket(i);if(!_)continue;const g=XT(f,_,c);let y=g;0===n[0]&&0===n[1]||(y=e.translatePosMatrix(g,m,n,o));const x=s?_.textCollisionBox:_.iconCollisionBox,v=_.collisionCircleArray;if(v.length>0){const e=Au.create(),t=y;Au.mul(e,_.placementInvProjMatrix,c.glCoordMatrix),Au.mul(e,e,_.placementViewportMatrix),u.push({circleArray:v,circleOffset:p,transform:t,invTransform:e,projection:_.getProjection()}),d+=v.length/4,p=d;}x&&(e.terrain&&e.terrain.setupElevationDraw(m,h),h.draw(e,l.LINES,Mx.disabled,Sx.disabled,e.colorModeForRenderPass(),Dx.disabled,MM(y,c,m,_.getProjection()),i.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,null,c.zoom,null,[x.collisionVertexBuffer,x.collisionVertexBufferExt]));}if(!s||!u.length)return;const f=e.getOrCreateProgram("collisionCircle"),m=new Za;m.resize(4*d),m._trim();let _=0;for(const e of u)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,r=e.circleArray[i+0],n=e.circleArray[i+1],o=e.circleArray[i+2],s=e.circleArray[i+3];m.emplace(_++,r,n,o,s,0),m.emplace(_++,r,n,o,s,1),m.emplace(_++,r,n,o,s,2),m.emplace(_++,r,n,o,s,3);}(!qM||qM.length<2*d)&&(qM=function(e){const t=2*e,i=new Wa;i.resize(t),i._trim();for(let e=0;e<t;e++){const t=6*e;i.uint16[t+0]=4*e+0,i.uint16[t+1]=4*e+1,i.uint16[t+2]=4*e+2,i.uint16[t+3]=4*e+2,i.uint16[t+4]=4*e+3,i.uint16[t+5]=4*e+0;}return i}(d));const g=a.createIndexBuffer(qM,!0),y=a.createVertexBuffer(m,h_.members,!0);for(const t of u){const r={u_matrix:t.transform,u_inv_matrix:t.invTransform,u_camera_to_center_distance:(x=c).getCameraToCenterDistance(t.projection),u_viewport_size:[x.width,x.height]};f.draw(e,l.TRIANGLES,Mx.disabled,Sx.disabled,e.colorModeForRenderPass(),Dx.disabled,r,i.id,y,g,xl.simpleSegment(0,2*t.circleOffset,t.circleArray.length,t.circleArray.length/2),null,c.zoom);}var x;y.destroy(),g.destroy();}const $M=Au.create();function WM({width:e,height:t,anchor:i,textOffset:r,textScale:n},o){const{horizontalAlign:s,verticalAlign:a}=F_(i),l=-(s-.5)*e,c=-(a-.5)*t,h=xg(i,r);return new y((l/n+h[0])*o,(c/n+h[1])*o)}function HM(e,t,i,r,n,o,s,a,l,c,h){const u=e.text.placedSymbolArray,d=e.text.dynamicLayoutVertexArray,p=e.icon.dynamicLayoutVertexArray,f={},m=e.getProjection(),_=YT(a,m,o),g=o.elevation,y=m.upVectorScale(a.canonical,o.center.lat,o.worldSize).metersToTile;d.clear();for(let p=0;p<u.length;p++){const x=u.get(p),{tileAnchorX:v,tileAnchorY:b,numGlyphs:w}=x,T=x.hidden||!x.crossTileID||e.allowVerticalPlacement&&!x.placedOrientation?null:r[x.crossTileID];if(T){let r=0,u=0,p=0;if(g){const e=g?g.getAtTileOffset(a,v,b):0,[t,i,n]=m.upVector(a.canonical,v,b);r=e*t*y,u=e*i*y,p=e*n*y;}let[E,M,A,S]=cv(x.projectedAnchorX+r,x.projectedAnchorY+u,x.projectedAnchorZ+p,i?_:s);const I=hv(o.getCameraToCenterDistance(m),S);let C=n.evaluateSizeForFeature(e.textSizeData,c,x)*I/u_;i&&(C*=e.tilePixelRatio/l);const z=WM(T,C);i?(({x:E,y:M,z:A}=m.projectTilePoint(v+z.x,b+z.y,a.canonical)),[E,M,A]=cv(E+r,M+u,A+p,s)):(t&&z._rotate(-o.angle),E+=z.x,M+=z.y,A=0);const P=e.allowVerticalPlacement&&x.placedOrientation===A_.vertical?Math.PI/2:0;for(let e=0;e<w;e++)dy(d,E,M,A,P);h&&x.associatedIconIndex>=0&&(f[x.associatedIconIndex]={x:E,y:M,z:A,angle:P});}else xv(w,d);}if(h){p.clear();const t=e.icon.placedSymbolArray;for(let e=0;e<t.length;e++){const i=t.get(e),{numGlyphs:r}=i,n=f[e];if(i.hidden||!n)xv(r,p);else {const{x:e,y:t,z:i,angle:o}=n;for(let n=0;n<r;n++)dy(p,e,t,i,o);}}e.icon.dynamicLayoutVertexBuffer.updateData(p);}e.text.dynamicLayoutVertexBuffer.updateData(d);}function XM(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function YM(e,t,i,r,n,o,s,a,l,c,h,u,d){const p=e.context,f=p.gl,m=e.transform,_="map"===a,g="map"===l,y=_&&"point"!==i.layout.get("symbol-placement"),x=_&&!g&&!y,v=void 0!==i.layout.get("symbol-sort-key").constantOr(1);let b=!1;const w=e.depthModeForSublayer(0,Mx.ReadOnly),T=[Kd(m.center.lng),Jd(m.center.lat)],E=i.layout.get("text-variable-anchor"),M="globe"===m.projection.name,A=[],S=[0,-1,0];let I=S;!M&&!m.mercatorFromTransition||_||(I=function(e){const t=e._camera.getWorldToCamera(e.worldSize,1),i=Au.multiply([],t,e.globeMatrix);Au.invert(i,i);const r=[0,0,0],n=[0,1,0,0];return yu.transformMat4(n,n,i),r[0]=n[0],r[1]=n[1],r[2]=n[2],Du.normalize(r,r),r}(m));for(const a of r){const r=t.getTile(a),l=r.getBucket(i);if(!l)continue;if("mercator"===l.projection.name&&M)continue;const u=n?l.text:l.icon;if(!u||l.fullyClipped||!u.segments.get().length)continue;const d=u.programConfigurations.get(i.id),p=n||l.sdfIcons,w=n?l.textSizeData:l.iconSizeData,C=g||0!==m.pitch,z=m_(w,m.zoom);let P,D,R,L,k=[0,0],O=null;if(n)D=r.glyphAtlasTexture?r.glyphAtlasTexture:null,R=f.LINEAR,P=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],l.iconsInText&&(k=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],O=r.imageAtlasTexture?r.imageAtlasTexture:null,L=C||e.options.rotating||e.options.zooming||"composite"===w.kind||"camera"===w.kind?f.LINEAR:f.NEAREST);else {const t=1!==i.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;D=r.imageAtlasTexture?r.imageAtlasTexture:null,R=p||e.options.rotating||e.options.zooming||t||C?f.LINEAR:f.NEAREST,P=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0];}const B="globe"===l.projection.name,F=B?I:S,N=B?Dd(m.zoom):0,U=YT(a,l.getProjection(),m),V=m.calculatePixelsToTileUnitsMatrix(r),j=sv(U,r.tileID.canonical,g,_,m,l.getProjection(),V),G=e.terrain&&g&&y?Au.invert(Au.create(),j):$M,q=lv(U,r.tileID.canonical,g,_,m,l.getProjection(),V),Z=E&&l.hasTextData(),$=l.hasIconTextFit()&&Z&&l.hasIconData();if(y){const t=m.elevation,i=t?t.getAtTileOffsetFunc(a,m.center.lat,m.worldSize,l.getProjection()):null,o=av(U,r.tileID.canonical,g,_,m,l.getProjection(),V);dv(l,U,e,n,o,q,g,c,i,a);}const W=y||n&&E||$,H=e.translatePosMatrix(U,r,o,s),X=W?$M:j,Y=e.translatePosMatrix(q,r,o,s,!0),K=l.getProjection().createInversionMatrix(m,a.canonical),J=i.paint.get("icon-image-cross-fade").constantOr(0),Q=[];e.terrainRenderModeElevated()&&g&&Q.push("PITCH_WITH_MAP_TERRAIN"),B&&(Q.push("PROJECTION_GLOBE_VIEW"),W&&Q.push("PROJECTED_POS_ON_VIEWPORT")),J>0&&Q.push("ICON_TRANSITION"),u.zOffsetVertexBuffer&&Q.push("Z_OFFSET");const ee=p&&0!==i.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);let te;p?te=l.iconsInText?OM(w.kind,z,x,g,e,H,X,Y,P,k,a,N,T,K,F,l.getProjection()):kM(w.kind,z,x,g,e,H,X,Y,n,P,!0,a,N,T,K,F,l.getProjection()):(h<1&&Q.push("SATURATION"),te=LM(w.kind,z,x,g,e,H,X,Y,n,P,a,N,T,K,F,l.getProjection(),h,J));const ie={program:e.getOrCreateProgram(XM(p,n,l),{config:d,defines:Q}),buffers:u,uniformValues:te,atlasTexture:D,atlasTextureIcon:O,atlasInterpolation:R,atlasInterpolationIcon:L,isSDF:p,hasHalo:ee,tile:r,labelPlaneMatrixInv:G};if(v&&l.canOverlap){b=!0;const e=u.segments.get();for(const t of e)A.push({segments:new xl([t]),sortKey:t.sortKey,state:ie});}else A.push({segments:u.segments,sortKey:0,state:ie});}b&&A.sort(((e,t)=>e.sortKey-t.sortKey));for(const t of A){const r=t.state;if(e.terrain&&e.terrain.setupElevationDraw(r.tile,r.program,{useDepthForOcclusion:m.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:r.labelPlaneMatrixInv}),p.activeTexture.set(f.TEXTURE0),r.atlasTexture&&r.atlasTexture.bind(r.atlasInterpolation,f.CLAMP_TO_EDGE),r.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),e.uploadCommonLightUniforms(e.context,r.program),r.hasHalo){const n=r.uniformValues;n.u_is_halo=1,KM(r.buffers,t.segments,i,e,r.program,w,u,d,n,2),n.u_is_halo=0;}else {if(r.isSDF){const n=r.uniformValues;r.hasHalo&&(n.u_is_halo=1,KM(r.buffers,t.segments,i,e,r.program,w,u,d,n,1)),n.u_is_halo=0;}KM(r.buffers,t.segments,i,e,r.program,w,u,d,r.uniformValues,1);}}}function KM(e,t,i,r,n,o,s,a,l,c){const h=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer];n.draw(r,r.context.gl.TRIANGLES,o,s,a,Dx.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),h,c);}function JM(e,t,i,r,n,o,s){const a=e.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1);let h,u,d,p,f;s?(u=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=a.LINES):(u=c?"fillPattern":"fill",h=a.TRIANGLES);for(const m of r){const r=t.getTile(m);if(c&&!r.patternsLoaded())continue;const _=r.getBucket(i);if(!_)continue;e.prepareDrawTile();const g=_.programConfigurations.get(i.id),y=e.isTileAffectedByFog(m),x=e.getOrCreateProgram(u,{config:g,overrideFog:y});c&&(e.context.activeTexture.set(a.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),g.updatePaintBuffers());const v=l.constantOr(null);if(v&&r.imageAtlas){const e=r.imageAtlas.patternPositions[v.toString()];e&&g.setConstantPatternPositions(e);}const b=e.translatePosMatrix(m.projMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),w=i.paint.get("fill-emissive-strength");if(s){p=_.indexBuffer2,f=_.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[a.drawingBufferWidth,a.drawingBufferHeight];d="fillOutlinePattern"===u&&c?EM(b,w,e,r,t):TM(b,w,t);}else p=_.indexBuffer,f=_.segments,d=c?wM(b,w,e,r):bM(b,w);e.uploadCommonUniforms(e.context,x,m.toUnwrapped()),x.draw(e,h,n,e.stencilModeForClipping(m),o,Dx.disabled,d,i.id,_.layoutVertexBuffer,p,f,i.paint,e.transform.zoom,g,void 0);}}function QM(e,t,i,r,n,o,s,a){i.resetLayerRenderingStats();const l=e.context,c=l.gl,h=e.transform,u=i.paint.get("fill-extrusion-pattern"),d=u.constantOr(1),p=i.paint.get("fill-extrusion-opacity"),f=e.style.enable3dLights(),m=i.paint.get(f&&!d?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),_=[i.paint.get("fill-extrusion-ambient-occlusion-intensity"),m],g=i.layout.get("fill-extrusion-edge-radius"),y=g>0&&!i.paint.get("fill-extrusion-rounded-roof"),x=y?0:g,v="globe"===h.projection.name?Ib():0,b="globe"===h.projection.name,w=b?Dd(h.zoom):0,T=[Kd(h.center.lng),Jd(h.center.lat)],E=i.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),M=i.paint.get("fill-extrusion-flood-light-intensity"),A=i.paint.get("fill-extrusion-vertical-scale"),S=eM(e,i.paint.get("fill-extrusion-cutoff-fade-range")),I=i.paint.get("fill-extrusion-emissive-strength"),C=[];let z;b&&C.push("PROJECTION_GLOBE_VIEW"),_[0]>0&&C.push("FAUX_AO"),y&&C.push("ZERO_ROOF_RADIUS"),a&&C.push("HAS_CENTROID"),M>0&&C.push("FLOOD_LIGHT"),S.shouldRenderCutoff&&C.push("RENDER_CUTOFF");const P="shadow"===e.renderPass,D=e.shadowRenderer,R=P&&!!D;e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0);let L=[0,0,0];if(D){const t=e.style.directionalLight,i=e.style.ambientLight;t&&i&&(L=WA(t,i)),z=C.concat(["SHADOWS_SINGLE_CASCADE"]);}const k=R?"fillExtrusionDepth":d?"fillExtrusionPattern":"fillExtrusion",O=i.getLayerRenderingStats();for(const f of r){const r=t.getTile(f),m=r.getBucket(i);if(!m||m.projection.name!==h.projection.name)continue;let g=!1;D&&(g=0===D.getMaxCascadeForTile(f.toUnwrapped()));const y=e.isTileAffectedByFog(f),R=m.programConfigurations.get(i.id),B=e.getOrCreateProgram(k,{config:R,defines:g?z:C,overrideFog:y});if(e.terrain&&e.terrain.setupElevationDraw(r,B,{useMeterToDem:!0}),!m.centroidVertexBuffer){const e=B.attributes.a_centroid_pos;void 0!==e&&c.vertexAttrib2f(e,0,0);}!P&&D&&D.setupShadows(r.tileID.toUnwrapped(),B,"vector-tile",r.tileID.overscaledZ),d&&(e.context.activeTexture.set(c.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),R.updatePaintBuffers());const F=u.constantOr(null);if(F&&r.imageAtlas){const e=r.imageAtlas.patternPositions[F.toString()];e&&R.setConstantPatternPositions(e);}const N=i.paint.get("fill-extrusion-vertical-gradient");let U;if(P&&D){if(oA(r.tileID,m,e))continue;const t=D.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());U=xM(t,x,A);}else {const t=e.translatePosMatrix(f.expandedProjMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),n=h.projection.createInversionMatrix(h,f.canonical);U=d?vM(t,e,N,p,_,x,f,r,v,w,T,n,E,A):yM(t,e,N,p,_,x,f,v,w,T,n,E,A,M,L,I);}e.uploadCommonUniforms(l,B,f.toUnwrapped(),null,S);let V=m.segments;if("mercator"===h.projection.name&&!P&&(V=m.getVisibleSegments(r.tileID,e.terrain,e.transform.getFrustum(0)),!V.get().length))continue;if(O)if(P)for(const e of V.get())O.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of V.get())O.numRenderedVerticesInTransparentPass+=e.primitiveLength;const j=[];(e.terrain||a)&&j.push(m.centroidVertexBuffer),b&&j.push(m.layoutVertexExtBuffer),B.draw(e,l.gl.TRIANGLES,n,o,s,Dx.backCCW,U,i.id,m.layoutVertexBuffer,m.indexBuffer,V,i.paint,e.transform.zoom,R,j);}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1);}function eA(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y){const x=e.context,v=x.gl,b=e.transform,w=e.transform.zoom,T=[],E=eM(e,i.paint.get("fill-extrusion-cutoff-fade-range"));"clear"===c?(T.push("CLEAR_SUBPASS"),y&&(T.push("CLEAR_FROM_TEXTURE"),x.activeTexture.set(v.TEXTURE0),y.bind(v.LINEAR,v.CLAMP_TO_EDGE))):"sdf"===c&&T.push("SDF_SUBPASS"),_&&T.push("HAS_CENTROID"),E.shouldRenderCutoff&&T.push("RENDER_CUTOFF");const M=i.layout.get("fill-extrusion-edge-radius"),A=(t,r,c,g,v)=>{const b=r.programConfigurations.get(i.id),A=e.isTileAffectedByFog(t),S=e.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:T,overrideFog:A}),I=((e,t,i,r,n,o,s,a,l,c,h)=>({u_matrix:t,u_opacity:i,u_ao_pass:r?1:0,u_meter_to_tile:n,u_ao:o,u_flood_light_intensity:s,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:h}))(0,g,h,l,v,[u,d*v],p,f,m,w>=17?0:M*v,y?y.size[0]:0),C=[];_&&C.push(r.hiddenByLandmarkVertexBuffer),e.uploadCommonUniforms(x,S,t.toUnwrapped(),null,E),S.draw(e,x.gl.TRIANGLES,n,o,s,a,I,i.id,r.vertexBuffer,r.indexBuffer,c,i.paint,w,b,C);};for(const n of r){const r=t.getTile(n),o=r.getBucket(i);if(!o||o.projection.name!==b.projection.name||!o.groundEffect||o.groundEffect&&!o.groundEffect.hasData())continue;const s=o.groundEffect,a=1/o.tileToMeter;{const t=e.translatePosMatrix(n.projMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),o=s.getDefaultSegment();A(n,s,o,t,a);}if(g)for(let o=0;o<4;o++){const s=$u[o](n),l=t.getTile(s);if(!l)continue;const c=l.getBucket(i);if(!c||c.projection.name!==b.projection.name||!c.groundEffect||c.groundEffect&&!c.groundEffect.hasData())continue;const h=c.groundEffect;let u,d;0===o?(u=[-cr,0,0],d=1):1===o?(u=[cr,0,0],d=0):2===o?(u=[0,-cr,0],d=3):(u=[0,cr,0],d=2);const p=h.regionSegments[d];if(!p)continue;const f=new Float32Array(16);Au.translate(f,n.projMatrix,u),A(n,h,p,e.translatePosMatrix(f,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),a);}}}function tA(e,t,i,r,n,o,s){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const a=o?o.findDEMTileFor(i):null;if(!(a&&a.dem||s))return;const l=e=>{const i=t.getSource().minzoom,r=e=>{const i=t.getTileByID(e);if(i&&i.hasData())return i.getBucket(n)},o=[0,-1,1];for(const t of o){if(e.overscaledZ+t<i)continue;const n=r(e.calculateScaledKey(e.overscaledZ+t));if(n)return n}},c=[0,0,0],h=(e,t)=>(c[0]=Math.min(e.min.y,t.min.y),c[1]=Math.max(e.max.y,t.max.y),c[2]=cr-t.min.x>e.max.x?t.min.x-cr:e.max.x,c),u=(e,t)=>(c[0]=Math.min(e.min.x,t.min.x),c[1]=Math.max(e.max.x,t.max.x),c[2]=cr-t.min.y>e.max.y?t.min.y-cr:e.max.y,c),d=[(e,t)=>h(e,t),(e,t)=>h(t,e),(e,t)=>u(e,t),(e,t)=>u(t,e)],p=(e,t,r,n,s,l,c)=>{if(!o)return 0;const h=[[l?r:e,l?e:r,0],[l?r:t,l?t:r,0]],u=c<0?cr+c:c,d=[l?u:(e+t)/2,l?(e+t)/2:u,0];return 0===r&&c<0||0!==r&&c>0?o.getForTilePoints(s,[d],!0,n):h.push(d),o.getForTilePoints(i,h,!0,a),Math.max(h[0][2],h[1][2],d[2])/o.exaggeration()};for(let e=0;e<4;e++){const t=r.borderFeatureIndices[e];if(0===t.length)continue;const n=$u[e](i),a=l(n);if(!(a&&a instanceof vb))continue;if(r.borderDoneWithNeighborZ[e]===a.canonical.z)continue;0===a.centroidVertexArray.length&&a.createCentroidsBuffer();const c=o?o.findDEMTileFor(n):null;if(!(c&&c.dem||s))continue;const h=(e<2?1:5)-e,u=a.borderDoneWithNeighborZ[h]!==r.canonical.z,g=a.borderFeatureIndices[h];let x=0;if(r.canonical.z!==a.canonical.z){for(const e of t)r.showCentroid(r.featuresOnBorder[e]);if(u)for(const e of g)a.showCentroid(a.featuresOnBorder[e]);r.borderDoneWithNeighborZ[e]=a.canonical.z,a.borderDoneWithNeighborZ[h]=r.canonical.z;}for(const i of t){const t=r.featuresOnBorder[i],o=r.centroidData[t.centroidDataIndex],l=t.borders[e];let u;for(;x<g.length;){u=a.featuresOnBorder[g[x]];const e=u.borders[h];if(e[1]>l[0]+3||e[0]>l[0]-3)break;a.showCentroid(u),x++;}if(u&&x<g.length){const i=x;let v=0;for(;!(u.borders[h][0]>l[1]-3)&&(v++,++x!==g.length);)u=a.featuresOnBorder[g[x]];if(u=a.featuresOnBorder[g[i]],v>1){const e=u.borders[h];Math.abs(l[0]-e[0])<3&&Math.abs(l[1]-e[1])<3&&(v=1,x=i+1);}else if(0===v){r.showCentroid(t);continue}const b=a.centroidData[u.centroidDataIndex];s&&1===v&&(((m=o).flags|(_=b).flags)&cb?(m.flags|=cb,_.flags|=cb):(m.flags&=2147483647,_.flags&=2147483647));let w=new y(0,0);if(v>1)x=i;else if(c&&c.dem&&!(t.intersectsCount()>1||u.intersectsCount()>1)){const t=d[e](o,b),i=e%2?cr-1:0;f=p(t[0],Math.min(cr-1,t[1]),i,c,n,e<2,t[2]),w=new y(Math.ceil(7*(f+450)),0);}o.centroidXY=b.centroidXY=w,r.writeCentroidToBuffer(o),a.writeCentroidToBuffer(b);}else r.showCentroid(t);}r.borderDoneWithNeighborZ[e]=a.canonical.z,a.borderDoneWithNeighborZ[h]=r.canonical.z;}var f,m,_;(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(e);}const iA=[1,0,0],rA=[0,1,0],nA=[0,0,1];function oA(e,t,i){const r=i.transform,n=i.shadowRenderer;if(!n)return !0;const o=e.toUnwrapped(),s=r.tileSize*n._cascades[i.currentShadowCascade].scale;let a=t.maxHeight;if(r.elevation){const t=r.elevation.getMinMaxForTile(e);t&&(a+=t.max);}const l=[...n.shadowDirection];l[2]=-l[2];const c=n.computeSimplifiedTileShadowVolume(o,a,s,l);if(!c)return !1;const h=[iA,rA,nA,l,[l[0],0,l[2]],[0,l[1],l[2]]],u="globe"===r.projection.name,d=r.scaleZoom(s),p=Qu.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,d,!u),f=n.getCurrentCascadeFrustum();return 0===p.intersectsPrecise(c.vertices,c.planes,h)||0===f.intersectsPrecise(c.vertices,c.planes,h)}function sA(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),r=i-t,n=.2*e.height,o=t+n;return [t,i,(o-n-t)/r,(o-t)/r]}const aA=new hi(1,0,0,1),lA=new hi(0,1,0,1),cA=new hi(0,0,1,1),hA=new hi(1,0,1,1),uA=new hi(0,1,1,1);function dA(e,t,i){const r=e.context,n=e.transform,o=r.gl,s="globe"===n.projection.name,a=s?["PROJECTION_GLOBE_VIEW"]:[];let l=i.projMatrix;if(s&&Dd(n.zoom)>0){const e=Sd(_d(i.canonical,n));l=Au.multiply(new Float32Array(16),n.globeMatrix,e),Au.multiply(l,n.projMatrix,l);}const c=e.getOrCreateProgram("debug",{defines:a}),h=t.getTileByID(i.key);e.terrain&&e.terrain.setupElevationDraw(h,c);const u=Mx.disabled,d=Sx.disabled,p=e.colorModeForRenderPass(),f="$debug";r.activeTexture.set(o.TEXTURE0),e.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),s?h._makeGlobeTileDebugBuffers(e.context,n):h._makeDebugTileBoundsBuffers(e.context,n.projection);const m=h._tileDebugBuffer||e.debugBuffer,_=h._tileDebugIndexBuffer||e.debugIndexBuffer,g=h._tileDebugSegments||e.debugSegments;c.draw(e,o.LINE_STRIP,u,d,p,Dx.disabled,AM(l,hi.red),f,m,_,g,null,null,null,[h._globeTileDebugBorderBuffer]);const y=h.latestRawTileData,x=Math.floor((y&&y.byteLength||0)/1024),v=t.getTile(i).tileSize,b=512/Math.min(v,512)*(i.overscaledZ/n.zoom)*.5;let w=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(w+=` => ${i.overscaledZ}`),w+=` ${x}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE);}(e,w);const T=h._tileDebugTextBuffer||e.debugBuffer,E=h._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,M=h._tileDebugTextSegments||e.debugSegments;c.draw(e,o.TRIANGLES,u,d,Cx.alphaBlended,Dx.disabled,AM(l,hi.transparent,b),f,T,E,M,null,null,null,[h._globeTileDebugTextBuffer]);}function pA(e,t,i,r){mA(e,0,t+i/2,e.transform.width,i,r);}function fA(e,t,i,r){mA(e,t-i/2,0,i,e.transform.height,r);}function mA(e,t,i,r,n,o){const s=e.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*dt.devicePixelRatio,i*dt.devicePixelRatio,r*dt.devicePixelRatio,n*dt.devicePixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST);}const _A=Ia([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:gA}=_A;function yA(e,t,i,r){e.emplaceBack(t,i,r);}class xA{constructor(e){this.vertexArray=new tl,this.indices=new Wa,yA(this.vertexArray,-1,-1,1),yA(this.vertexArray,1,-1,1),yA(this.vertexArray,-1,1,1),yA(this.vertexArray,1,1,1),yA(this.vertexArray,-1,-1,-1),yA(this.vertexArray,1,-1,-1),yA(this.vertexArray,-1,1,-1),yA(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=e.createVertexBuffer(this.vertexArray,gA),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=xl.simpleSegment(0,0,36,12);}}function vA(e,t,i,r,n,o){const s=e.context.gl,a=t.paint.get("sky-atmosphere-color"),l=t.paint.get("sky-atmosphere-halo-color"),c=t.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,i,r,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(Eu.fromMat4(Eu.create(),r),n,c,a,l);s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+o,t.skyboxTexture,0),i.draw(e,s.TRIANGLES,Mx.disabled,Sx.disabled,Cx.unblended,Dx.frontCW,h,"skyboxCapture",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}const bA=Ia([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class wA{constructor(e){const t=new Ka;t.emplaceBack(-1,1,1,0,0),t.emplaceBack(1,1,1,1,0),t.emplaceBack(1,-1,1,1,1),t.emplaceBack(-1,-1,1,0,1);const i=new Wa;i.emplaceBack(0,1,2),i.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(t,bA.members),this.indexBuffer=e.createIndexBuffer(i),this.segments=xl.simpleSegment(0,0,4,2);}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy();}}const TA=Ia([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_size_scale",components:1},{type:"Float32",name:"a_fade_opacity",components:1}]);class EA{constructor(){this.colorModeAlphaBlendedWriteRGB=new Cx([1,Ix,1,Ix],hi.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Cx([1,0,1,0],hi.transparent,[!1,!1,!1,!0]);}update(e){const t=e.context;if(!this.atmosphereBuffer){this.atmosphereBuffer=new wA(t);const e=100,i=200,r=function(e){const t=Xn(30),i=[];for(let e=0;e<16e3;++e){const e=2*Math.PI*t(),r=Math.acos(1-2*t())-.5*Math.PI;i.push(Du.fromValues(Math.cos(r)*Math.cos(e),Math.cos(r)*Math.sin(e),Math.sin(r)));}return i}(),n=Xn(300),o=new Ja,s=new Wa;let a=0;for(let t=0;t<r.length;++t){const l=Du.scale([],r[t],200),c=Math.max(0,1+.01*e*(1*n()-.5)),h=Math.max(0,1+.01*i*(1*n()-.5));o.emplaceBack(l[0],l[1],l[2],-1,-1,c,h),o.emplaceBack(l[0],l[1],l[2],1,-1,c,h),o.emplaceBack(l[0],l[1],l[2],1,1,c,h),o.emplaceBack(l[0],l[1],l[2],-1,1,c,h),s.emplaceBack(a+0,a+1,a+2),s.emplaceBack(a+0,a+2,a+3),a+=4;}this.starsVx=t.createVertexBuffer(o,TA.members),this.starsIdx=t.createIndexBuffer(s),this.starsSegments=xl.simpleSegment(0,0,o.length,s.length);}}destroy(){this.atmosphereBuffer&&this.atmosphereBuffer.destroy(),this.starsVx&&this.starsVx.destroy(),this.starsIdx&&this.starsIdx.destroy();}drawAtmosphereGlow(e,t){const i=e.context,r=i.gl,n=e.transform,o=new Mx(r.LEQUAL,Mx.ReadOnly,[0,1]),s=Dd(n.zoom),a=t.properties.get("color").toArray01(),l=t.properties.get("high-color").toArray01(),c=t.properties.get("space-color").toArray01PremultipliedAlpha(),h=5e-4,u=z((t.properties.get("horizon-blend")-0)/1*.2495+h,5e-4,.25),d=Ld(e,i,n)&&u===h?n.worldSize/(2*Math.PI*1.025)-1:n.globeRadius,p=e.frameCounter/1e3%1,f=Du.length(n.globeCenterInViewSpace),m=Math.sqrt(Math.pow(f,2)-Math.pow(d,2)),_=Math.acos(m/f),g=t=>{const h="globe"===n.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];t&&h.push("ALPHA_PASS");const d=e.getOrCreateProgram("globeAtmosphere",{defines:h}),f=((e,t,i,r,n,o,s,a,l,c,h,u)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:r,u_horizon:n,u_transition:o,u_fadeout_range:s,u_color:a,u_high_color:l,u_space_color:c,u_temporal_offset:h,u_horizon_angle:u}))(n.frustumCorners.TL,n.frustumCorners.TR,n.frustumCorners.BR,n.frustumCorners.BL,n.frustumCorners.horizon,s,u,a,l,c,p,_);e.uploadCommonUniforms(i,d);const m=this.atmosphereBuffer;m&&d.draw(e,r.TRIANGLES,o,Sx.disabled,t?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Dx.backCW,f,t?"atmosphere_glow_alpha":"atmosphere_glow",m.vertexBuffer,m.indexBuffer,m.segments);};g(!1),g(!0);}drawStars(e,t){const i=z(t.properties.get("star-intensity"),0,1);if(0===i)return;const r=e.context,n=r.gl,o=e.transform,s=e.getOrCreateProgram("stars"),a=Iu.identity([]);Iu.rotateX(a,a,-o._pitch),Iu.rotateZ(a,a,-o.angle),Iu.rotateX(a,a,w(o._center.lat)),Iu.rotateY(a,a,-w(o._center.lng));const l=Au.fromQuat(new Float32Array(16),a),c=Au.multiply([],o.starsProjMatrix,l),h=Eu.fromMat4([],l),u=Eu.invert([],h),d=[0,1,0];Du.transformMat3(d,d,u),Du.scale(d,d,.15);const p=[1,0,0];Du.transformMat3(p,p,u),Du.scale(p,p,.15);const f=((e,t,i,r)=>({u_matrix:Float32Array.from(e),u_up:t,u_right:i,u_intensity_multiplier:r}))(c,d,p,i);e.uploadCommonUniforms(r,s),this.starsVx&&this.starsIdx&&s.draw(e,n.TRIANGLES,Mx.disabled,Sx.disabled,this.colorModeAlphaBlendedWriteRGB,Dx.disabled,f,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments);}}function MA(e,t){const i=[...e],r=t.cameraWorldSizeForFog/t.worldSize,n=Au.identity([]);return Au.scale(n,n,[r,r,1]),Au.multiply(i,n,i),Au.multiply(i,t.worldToFogMatrix,i),i}function AA(e,t,i,r){const n=i.material,o=r.context,{baseColorTexture:s,metallicRoughnessTexture:a}=n.pbrMetallicRoughness,{normalTexture:l,occlusionTexture:c,emissionTexture:h}=n;function u(t,i,r){if(t&&(e.push(i),o.activeTexture.set(o.gl.TEXTURE0+r),t.gfxTexture)){const{minFilter:e,magFilter:i,wrapS:r,wrapT:n}=t.sampler;t.gfxTexture.bindExtraParam(e,i,r,n);}}u(s,"HAS_TEXTURE_u_baseColorTexture",NM.BaseColor),u(a,"HAS_TEXTURE_u_metallicRoughnessTexture",NM.MetallicRoughness),u(l,"HAS_TEXTURE_u_normalTexture",NM.Normal),u(c,"HAS_TEXTURE_u_occlusionTexture",NM.Occlusion),u(h,"HAS_TEXTURE_u_emissionTexture",NM.Emission),i.texcoordBuffer&&(e.push("HAS_ATTRIBUTE_a_uv_2f"),t.push(i.texcoordBuffer)),i.colorBuffer&&(e.push(12===i.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),t.push(i.colorBuffer)),i.normalBuffer&&(e.push("HAS_ATTRIBUTE_a_normal_3f"),t.push(i.normalBuffer)),i.pbrBuffer&&(e.push("HAS_ATTRIBUTE_a_pbr"),e.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),t.push(i.pbrBuffer)),"OPAQUE"!==n.alphaMode&&"MASK"!==n.alphaMode||e.push("UNPREMULT_TEXTURE_IN_SHADER"),n.defined||e.push("DIFFUSE_SHADED"),e.push("USE_STANDARD_DERIVATIVES");}function SA(e,t,i,r,n,o){const s=i.paint.get("model-opacity"),a=t.context,l=new Mx(t.context.gl.LEQUAL,Mx.ReadWrite,t.depthRangeFor3D),c=t.transform,h=e.mesh,u=h.material,d=u.pbrMetallicRoughness,p=t.style.fog;let f;f="pixels"===t.transform.projection.zAxisUnit?[...e.nodeModelMatrix]:Au.multiply([],r.zScaleMatrix,e.nodeModelMatrix),Au.multiply(f,r.negCameraPosMatrix,f);const m=Au.invert([],f);Au.transpose(m,m);const _=i.paint.get("model-emissive-strength").constantOr(0),g=UM(new Float32Array(e.worldViewProjection),new Float32Array(f),new Float32Array(m),t,s,d.baseColorFactor,u.emissiveFactor,d.metallicFactor,d.roughnessFactor,u,_,i),y={defines:[]},x=[];AA(y.defines,x,h,t);const v=t.shadowRenderer;v&&(v.useNormalOffset=!1);let b=null;if(p){const i=MA(e.nodeModelMatrix,t.transform);if(b=new Float32Array(i),"globe"!==c.projection.name){const e=h.aabb.min,t=h.aabb.max,[r,n]=p.getOpacityForBounds(i,e[0],e[1],t[0],t[1]);y.overrideFog=r>=fw||n>=fw;}}const w=eM(t,i.paint.get("model-cutoff-fade-range"));w.shouldRenderCutoff&&y.defines.push("RENDER_CUTOFF");const T=t.getOrCreateProgram("model",y);t.uploadCommonUniforms(a,T,null,b,w),"shadow"!==t.renderPass&&v&&v.setupShadowsFromMatrix(e.nodeModelMatrix,T),T.draw(t,a.gl.TRIANGLES,l,n,o,h.material.doubleSided?Dx.disabled:Dx.backCCW,g,i.id,h.vertexBuffer,h.indexBuffer,h.segments,i.paint,t.transform.zoom,void 0,x);}function IA(e,t,i,r,n,o,s){let a;a="globe"===e.projection.name?Av(i,e):[...i],Au.multiply(a,a,t.matrix);const l=Au.multiply([],r,a);if(t.meshes)for(const e of t.meshes){if("BLEND"!==e.material.alphaMode){s.push({mesh:e,depth:0,modelIndex:n,worldViewProjection:l,nodeModelMatrix:a});continue}const t=Du.transformMat4([],e.centroid,l);t[2]>0&&o.push({mesh:e,depth:t[2],modelIndex:n,worldViewProjection:l,nodeModelMatrix:a});}if(t.children)for(const a of t.children)IA(e,a,i,r,n,o,s);}function CA(e,t,i,r){const n=i.shadowRenderer;if(!n)return;const o=n.getShadowPassDepthMode(),s=n.getShadowPassColorMode(),a=n.calculateShadowPassMatrixFromMatrix(t),l=jM(a);i.getOrCreateProgram("modelDepth",{defines:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,o,Sx.disabled,s,Dx.backCCW,l,r.id,e.vertexBuffer,e.indexBuffer,e.segments,r.paint,i.transform.zoom,void 0,void 0);}function zA(e,t,i){const r=t.updateZoomBasedPaintProperties(),n=function(e,t,i){let r,n,o,s=e.terrain?e.terrain.exaggeration():0;if(e.terrain&&s>0){const t=e.terrain,n=t.findDEMTileFor(i);n&&n.dem?r=Jm.create(t,i,n):s=0;}if(0===s&&(t.terrainElevationMin=0,t.terrainElevationMax=0),s===t.validForExaggeration&&(0===s||r&&r._demTile&&r._demTile.tileID===t.validForDEMTile.id&&r._dem._timestamp===t.validForDEMTile.timestamp))return !1;for(const e in t.instancesPerModel){const i=t.instancesPerModel[e];for(let e=0;e<i.instancedDataArray.length;++e){const a=(r?s*r.getElevationAt(0|i.instancedDataArray.float32[16*e],0|i.instancedDataArray.float32[16*e+1],!0,!0):0)+i.instancesEvaluatedElevation[e];i.instancedDataArray.float32[16*e+6]=a,n=n?Math.min(t.terrainElevationMin,a):a,o=o?Math.max(t.terrainElevationMax,a):a;}}return t.terrainElevationMin=n||0,t.terrainElevationMax=o||0,t.validForExaggeration=s,t.validForDEMTile=r&&r._demTile?{id:r._demTile.tileID,timestamp:r._dem._timestamp}:{id:void 0,timestamp:0},!0}(e,t,i);(r||n)&&(t.uploaded=!1,t.upload(e.context));}const PA={shadowUniformsInitialized:!1,useSingleShadowCascade:!1,tileMatrix:new Float64Array(16),shadowTileMatrix:new Float32Array(16),aabb:new ed([0,0,0],[cr,cr,0])};function DA(e,t){const i=1<<e.canonical.z,r=t.getFreeCameraOptions().position,n=t.elevation,o=e.canonical.x/i,s=(e.canonical.x+1)/i,a=e.canonical.y/i,l=(e.canonical.y+1)/i;let c=t._centerAltitude;if(n){const t=n.getMinMaxForTile(e);t&&t.max>c&&(c=t.max);}const h=z(r.x,o,s)-r.x,u=z(r.y,a,l)-r.y,d=Qd(c,t.center.lat)-r.z;return t._zoomFromMercatorZ(Math.sqrt(h*h+u*u+d*d))}function RA(e,t,i,r,n,o,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,h=l&&c?c.getShadowPassDepthMode():new Mx(a.gl.LEQUAL,Mx.ReadWrite,e.depthRangeFor3D),u=e.isTileAffectedByFog(o);if(i.meshes)for(const d of i.meshes){const p=["MODEL_POSITION_ON_GPU"],f=[];let m,_,g;r.instancedDataArray.length>20&&p.push("INSTANCED_ARRAYS");const y=eM(e,t.paint.get("model-cutoff-fade-range"));if(y.shouldRenderCutoff&&p.push("RENDER_CUTOFF"),l&&c)m=e.getOrCreateProgram("modelDepth",{defines:p}),_=jM(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(i.matrix)),g=c.getShadowPassColorMode();else {AA(p,f,d,e),m=e.getOrCreateProgram("model",{defines:p,overrideFog:u});const r=d.material,l=r.pbrMetallicRoughness,h=t.paint.get("model-opacity"),x=t.paint.get("model-emissive-strength").constantOr(0);_=UM(o.expandedProjMatrix,Float32Array.from(i.matrix),new Float32Array(16),e,h,l.baseColorFactor,r.emissiveFactor,l.metallicFactor,l.roughnessFactor,r,x,t,n),c&&(s.shadowUniformsInitialized?m.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(o.toUnwrapped(),m,"model-tile",o.overscaledZ),s.shadowUniformsInitialized=!0)),g=y.shouldRenderCutoff||h<1||"OPAQUE"!==r.alphaMode?Cx.alphaBlended:Cx.unblended;}e.uploadCommonUniforms(a,m,o.toUnwrapped(),null,y);const x=d.material.doubleSided?Dx.disabled:Dx.backCCW;if(r.instancedDataArray.length>20)f.push(r.instancedDataBuffer),m.draw(e,a.gl.TRIANGLES,h,Sx.disabled,g,x,_,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,f,r.instancedDataArray.length);else {const i=l?"u_instance":"u_normal_matrix";for(let n=0;n<r.instancedDataArray.length;++n)_[i]=new Float32Array(r.instancedDataArray.arrayBuffer,64*n,16),m.draw(e,a.gl.TRIANGLES,h,Sx.disabled,g,x,_,t.id,d.vertexBuffer,d.indexBuffer,d.segments,t.paint,e.transform.zoom,void 0,f);}}if(i.children)for(const a of i.children)RA(e,t,a,r,n,o,s);}const LA=[1,-1,1];function kA(e,t,i,r){if(!i.modelManager)return !0;const n=i.modelManager;if(!i.shadowRenderer)return !0;const o=i.shadowRenderer,s=t.aabb;let a=!0,l=e.maxHeight;if(0===l){let t=0;for(const i in e.instancesPerModel){const e=n.getModel(i,r);e?t=Math.max(t,Math.max(Math.max(e.aabb.max[0],e.aabb.max[1]),e.aabb.max[2])):a=!1;}l=e.maxScale*t*1.41+e.maxVerticalOffset,a&&(e.maxHeight=l);}s.max[2]=l,s.min[2]+=e.terrainElevationMin,s.max[2]+=e.terrainElevationMax,Du.transformMat4(s.min,s.min,t.tileMatrix),Du.transformMat4(s.max,s.max,t.tileMatrix);const c=s.intersects(o.getCurrentCascadeFrustum());return 0===i.currentShadowCascade&&(e.isInsideFirstShadowMapFrustum=2===c),0===c}class OA{}class BA{constructor(){this._storage=new Map;}getLinesFromTrianglesBuffer(e,t,i){{const i=this._storage.get(t.id);if(i)return i.lastUsedFrameIdx=e,i.buf}const r=i.gl,n=r.getBufferParameter(r.ELEMENT_ARRAY_BUFFER,r.BUFFER_SIZE),o=new ArrayBuffer(n),s=new Int16Array(o);r.getBufferSubData(r.ELEMENT_ARRAY_BUFFER,0,new Int16Array(o));const a=new ja;for(let e=0;e<n/2;e+=3){const t=s[e],i=s[e+1],r=s[e+2];a.emplaceBack(t,i),a.emplaceBack(i,r),a.emplaceBack(r,t);}const l=i.bindVertexArrayOES.current,c=new OA;return c.buf=new Fy(i,a),c.lastUsedFrameIdx=e,this._storage.set(t.id,c),i.bindVertexArrayOES.set(l),c.buf}update(e){for(const[t,i]of this._storage)e-i.lastUsedFrameIdx>30&&(i.buf.destroy(),this._storage.delete(t));}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e);}}const FA={symbol:function(e,t,i,r,n){if("translucent"!==e.renderPass)return;const o=Sx.disabled,s=e.colorModeForRenderPass();i.layout.get("text-variable-anchor")&&function(e,t,i,r,n,o,s){const a=t.transform,l="map"===n,c="map"===o;for(const t of e){const e=r.getTile(t),n=e.getBucket(i);if(!n||!n.text||!n.text.segments.get().length)continue;const o=m_(n.textSizeData,a.zoom),h=YT(t,n.getProjection(),a),u=a.calculatePixelsToTileUnitsMatrix(e),d=sv(h,e.tileID.canonical,c,l,a,n.getProjection(),u),p=n.hasIconTextFit()&&n.hasIconData();if(o){const i=Math.pow(2,a.zoom-e.tileID.overscaledZ);HM(n,l,c,s,__,a,d,t,i,o,p);}}}(r,e,i,t,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),n),0!==i.paint.get("icon-opacity").constantOr(1)&&YM(e,t,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),i.paint.get("icon-color-saturation"),o,s),0!==i.paint.get("text-opacity").constantOr(1)&&YM(e,t,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),i.paint.get("icon-color-saturation"),o,s),t.map.showCollisionBoxes&&(ZM(e,t,i,r,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),!0),ZM(e,t,i,r,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),!1));},circle:function(e,t,i,r){if("translucent"!==e.renderPass)return;const n=i.paint.get("circle-opacity"),o=i.paint.get("circle-stroke-width"),s=i.paint.get("circle-stroke-opacity"),a=void 0!==i.layout.get("circle-sort-key").constantOr(1),l=i.paint.get("circle-emissive-strength");if(0===n.constantOr(1)&&(0===o.constantOr(1)||0===s.constantOr(1)))return;const c=e.context,h=c.gl,u=e.transform,d=e.depthModeForSublayer(0,Mx.ReadOnly),p=Sx.disabled,f=e.colorModeForDrapableLayerRenderPass(l),m="globe"===u.projection.name,_=[Kd(u.center.lng),Jd(u.center.lat)],g=[];for(let n=0;n<r.length;n++){const o=r[n],s=t.getTile(o),l=s.getBucket(i);if(!l||l.projection.name!==u.projection.name)continue;const c=l.programConfigurations.get(i.id),h=Gp(i),d=e.isTileAffectedByFog(o);m&&h.push("PROJECTION_GLOBE_VIEW");const p=e.getOrCreateProgram("circle",{config:c,defines:h,overrideFog:d}),f=l.layoutVertexBuffer,y=l.globeExtVertexBuffer,x=l.indexBuffer,v=u.projection.createInversionMatrix(u,o.canonical),b={programConfiguration:c,program:p,layoutVertexBuffer:f,globeExtVertexBuffer:y,indexBuffer:x,uniformValues:jp(e,o,s,v,_,i),tile:s};if(a){const e=l.segments.get();for(const t of e)g.push({segments:new xl([t]),sortKey:t.sortKey,state:b});}else g.push({segments:l.segments,sortKey:0,state:b});}a&&g.sort(((e,t)=>e.sortKey-t.sortKey));const y={useDepthForOcclusion:u.depthOcclusionForSymbolsAndCircles};for(const t of g){const{programConfiguration:r,program:n,layoutVertexBuffer:o,globeExtVertexBuffer:s,indexBuffer:a,uniformValues:l,tile:m}=t.state,_=t.segments;e.terrain&&e.terrain.setupElevationDraw(m,n,y),e.uploadCommonUniforms(c,n,m.tileID.toUnwrapped()),n.draw(e,h.TRIANGLES,d,p,f,Dx.disabled,l,i.id,o,a,_,i.paint,u.zoom,r,[s]);}},heatmap:function(e,t,i,r){if(0!==i.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const n=e.context,o=n.gl,s=Sx.disabled,a=new Cx([o.ONE,o.ONE,o.ONE,o.ONE],hi.transparent,[!0,!0,!0,!0]);!function(e,t,i,r){const n=e.gl,o=t.width*r,s=t.height*r;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),a=i.heatmapFbo=e.createFramebuffer(o,s,!0,null),function(e,t,i,r,n,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,n,o,0,s.RGBA,e.extRenderToTextureHalfFloat?s.HALF_FLOAT:s.UNSIGNED_BYTE,null),r.colorAttachment.set(i);}(e,0,t,a,o,s);}else n.bindTexture(n.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer);}(n,e,i,"globe"===e.transform.projection.name?.5:.25),n.clear({color:hi.transparent});const l=e.transform,c="globe"===l.projection.name,h=c?["PROJECTION_GLOBE_VIEW"]:[],u=c?Dx.frontCCW:Dx.disabled,d=[Kd(l.center.lng),Jd(l.center.lat)];for(let p=0;p<r.length;p++){const f=r[p];if(t.hasRenderableParent(f))continue;const m=t.getTile(f),_=m.getBucket(i);if(!_||_.projection.name!==l.projection.name)continue;const g=e.isTileAffectedByFog(f),y=_.programConfigurations.get(i.id),x=e.getOrCreateProgram("heatmap",{config:y,defines:h,overrideFog:g}),{zoom:v}=e.transform;e.terrain&&e.terrain.setupElevationDraw(m,x),e.uploadCommonUniforms(n,x,f.toUnwrapped());const b=l.projection.createInversionMatrix(l,f.canonical);x.draw(e,o.TRIANGLES,Mx.disabled,s,a,u,IM(e,f,m,b,d,v,i.paint.get("heatmap-intensity")),i.id,_.layoutVertexBuffer,_.indexBuffer,_.segments,i.paint,e.transform.zoom,y,c?[_.globeExtVertexBuffer]:null);}n.viewport.set([0,0,e.width,e.height]);}else "translucent"===e.renderPass&&(e.context.setColorMode(e.colorModeForRenderPass()),function(e,t){const i=e.context,r=i.gl,n=t.heatmapFbo;if(!n)return;i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1);let o=t.colorRampTexture;o||(o=t.colorRampTexture=new My(i,t.colorRamp,r.RGBA)),o.bind(r.LINEAR,r.CLAMP_TO_EDGE),e.getOrCreateProgram("heatmapTexture").draw(e,r.TRIANGLES,Mx.disabled,Sx.disabled,e.colorModeForRenderPass(),Dx.disabled,((e,t,i,r)=>({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,t),t.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,t.paint,e.transform.zoom);}(e,i));},line:function(e,t,i,r){if("translucent"!==e.renderPass)return;const n=i.paint.get("line-opacity"),o=i.paint.get("line-width");if(0===n.constantOr(1)||0===o.constantOr(1))return;const s=i.paint.get("line-emissive-strength"),a=e.depthModeForSublayer(0,Mx.ReadOnly),l=e.colorModeForDrapableLayerRenderPass(s),c=e.terrain&&e.terrain.renderingToTexture?1:dt.devicePixelRatio,h=i.paint.get("line-dasharray"),u=h.constantOr(1),d=i.layout.get("line-cap"),p=i.paint.get("line-pattern"),f=p.constantOr(1),m=i.paint.get("line-pattern").constantOr(1),_=1!==i.paint.get("line-opacity").constantOr(1);let g=!m&&_;const y=i.paint.get("line-gradient"),x=f?"linePattern":"line",v=e.context,b=v.gl,w=Gb(i);e.terrain&&e.terrain.clipOrMaskOverlapStencilType()&&(g=!1);for(const n of r){const r=t.getTile(n);if(f&&!r.patternsLoaded())continue;const o=r.getBucket(i);if(!o)continue;e.prepareDrawTile();const s=o.programConfigurations.get(i.id),m=e.isTileAffectedByFog(n),_=e.getOrCreateProgram(x,{config:s,defines:w,overrideFog:m}),T=p.constantOr(null);if(T&&r.imageAtlas){const e=r.imageAtlas.patternPositions[T.toString()];e&&s.setConstantPatternPositions(e);}const E=h.constantOr(null),M=d.constantOr(null);if(!f&&E&&M&&r.lineAtlas){const e=r.lineAtlas.getDash(E,M);e&&s.setConstantPatternPositions(e);}let[A,S]=i.paint.get("line-trim-offset");if("round"===M||"square"===M){const e=1;A!==S&&(0===A&&(A-=e),1===S&&(S+=e));}const I=e.terrain?n.projMatrix:null,C=f?Ub(e,r,i,I,c):Nb(e,r,i,I,o.lineClipsArray.length,c,[A,S]);if(y){const r=o.gradients[i.id];let s=r.texture;if(i.gradientVersion!==r.version){let a=256;if(i.stepInterpolant){const i=t.getSource().maxzoom,r=n.canonical.z===i?Math.ceil(1<<e.transform.maxZoom-n.canonical.z):1;a=z(U(o.maxLineLength/cr*1024*r),256,v.maxTextureSize);}r.gradient=of({expression:i.gradientExpression(),evaluationKey:"lineProgress",resolution:a,image:r.gradient||void 0,clips:o.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new My(v,r.gradient,b.RGBA),r.version=i.gradientVersion,s=r.texture;}v.activeTexture.set(b.TEXTURE1),s.bind(i.stepInterpolant?b.NEAREST:b.LINEAR,b.CLAMP_TO_EDGE);}u&&(v.activeTexture.set(b.TEXTURE0),r.lineAtlasTexture&&r.lineAtlasTexture.bind(b.LINEAR,b.REPEAT),s.updatePaintBuffers()),f&&(v.activeTexture.set(b.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(b.LINEAR,b.CLAMP_TO_EDGE),s.updatePaintBuffers()),e.uploadCommonUniforms(v,_,n.toUnwrapped());const P=t=>{_.draw(e,b.TRIANGLES,a,t,l,Dx.disabled,C,i.id,o.layoutVertexBuffer,o.indexBuffer,o.segments,i.paint,e.transform.zoom,s,[o.layoutVertexBuffer2]);};if(g){const t=e.stencilModeForClipping(n).ref;0===t&&e.terrain&&v.clear({stencil:0});const i={func:b.EQUAL,mask:255};C.u_alpha_discard_threshold=.8,P(new Sx(i,t,255,b.KEEP,b.KEEP,b.INVERT)),C.u_alpha_discard_threshold=0,P(new Sx(i,t,255,b.KEEP,b.KEEP,b.KEEP));}else P(e.stencilModeForClipping(n));}g&&(e.resetStencilClippingMasks(),e.terrain&&v.clear({stencil:0}));},fill:function(e,t,i,r){const n=i.paint.get("fill-color"),o=i.paint.get("fill-opacity");if(0===o.constantOr(1))return;const s=i.paint.get("fill-emissive-strength"),a=e.colorModeForDrapableLayerRenderPass(s),l=i.paint.get("fill-pattern"),c=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===n.constantOr(hi.transparent).a&&1===o.constantOr(0)?"opaque":"translucent";if(e.renderPass===c){const n=e.depthModeForSublayer(1,"opaque"===e.renderPass?Mx.ReadWrite:Mx.ReadOnly);JM(e,t,i,r,n,a,!1);}if("translucent"===e.renderPass&&i.paint.get("fill-antialias")){const n=e.depthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,Mx.ReadOnly);JM(e,t,i,r,n,a,!0);}},"fill-extrusion":function(e,t,i,r){const n=i.paint.get("fill-extrusion-opacity"),o=e.context,s=o.gl,a=e.terrain,l=a&&a.renderingToTexture,c=i.paint.get("fill-extrusion-cutoff-fade-range");if(0===n)return;const h=e.conflationActive&&e.layerUsedInConflation(i,t.getSource());if(h&&function(e,t,i,r){for(const n of r){const r=t.getTile(n).getBucket(i);r&&(r.updateReplacement(n,e.replacementSource),r.uploadCentroid(e.context));}}(e,t,i,r),a||h)for(const n of r){const r=t.getTile(n).getBucket(i);r&&tA(e.context,t,n,r,i,a,h);}if("shadow"===e.renderPass&&e.shadowRenderer){const o=e.shadowRenderer;if(a&&n<.65&&i._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof Ao)return;const s=o.getShadowPassDepthMode(),l=o.getShadowPassColorMode();QM(e,t,i,r,s,Sx.disabled,l,h);}else if("translucent"===e.renderPass){const u=!i.paint.get("fill-extrusion-pattern").constantOr(1);if(!l){const o=new Mx(e.context.gl.LEQUAL,Mx.ReadWrite,e.depthRangeFor3D);0===c&&1===n&&u?QM(e,t,i,r,o,Sx.disabled,Cx.unblended,h):(QM(e,t,i,r,o,Sx.disabled,Cx.disabled,h),QM(e,t,i,r,o,e.stencilModeFor3D(),e.colorModeForRenderPass(),h),e.resetStencilClippingMasks());}if(e.style.enable3dLights()&&u&&(!a&&"globe"!==e.transform.projection.name||l)){const n=i.paint.get("fill-extrusion-opacity"),c=i.paint.get("fill-extrusion-ambient-occlusion-intensity"),u=i.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),d=i.paint.get("fill-extrusion-flood-light-intensity"),p=i.paint.get("fill-extrusion-flood-light-color").toArray01().slice(0,3),f=c>0&&u>0,m=d>0,_=(e,t,i)=>(1-i)*e+i*t,g=o=>{const a=e.depthModeForSublayer(1,Mx.ReadOnly,s.LEQUAL,!0),l=i.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),f=_(.1,3,l),m=e._showOverdrawInspector;if(!m){const l=new Sx({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),m=new Cx([s.ONE,s.ONE,s.ONE,s.ONE],hi.transparent,[!1,!1,!1,!0],s.MIN);eA(e,t,i,r,a,l,m,Dx.disabled,o,"sdf",n,c,u,d,p,f,h,!1);}{const l=m?Sx.disabled:new Sx({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),_=m?e.colorModeForRenderPass():new Cx([s.ONE_MINUS_DST_ALPHA,s.DST_ALPHA,s.ONE,s.ONE],hi.transparent,[!0,!0,!0,!0]);eA(e,t,i,r,a,l,_,Dx.disabled,o,"color",n,c,u,d,p,f,h,!1);}};if(l){const l=(o,a,l)=>{const f=e.depthModeForSublayer(1,Mx.ReadOnly,s.LEQUAL,!1),m=i.paint.get(o?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),g=_(.1,3,m);{const l=new Cx([s.ONE,s.ONE,s.ONE,s.ONE],hi.transparent,[!1,!1,!1,!0]);eA(e,t,i,r,f,Sx.disabled,l,Dx.disabled,o,"clear",n,c,u,d,p,g,h,a);}{const l=new Sx({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),m=new Cx([s.ONE,s.ONE,s.ONE,s.ONE],hi.transparent,[!1,!1,!1,!0],s.MIN);eA(e,t,i,r,f,l,m,Dx.disabled,o,"sdf",n,c,u,d,p,g,h,a);}{const l=o?s.ZERO:s.ONE_MINUS_DST_ALPHA,m=new Sx({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),_=new Cx([l,s.DST_ALPHA,s.ONE_MINUS_DST_ALPHA,s.ZERO],hi.transparent,[!0,!0,!0,!0]);eA(e,t,i,r,f,m,_,Dx.disabled,o,"color",n,c,u,d,p,g,h,a);}{const m=new Cx([s.ONE,s.ONE,s.ONE,o?s.ZERO:s.ONE],hi.transparent,[!1,!1,!1,!0],o?s.FUNC_ADD:s.MAX);eA(e,t,i,r,f,Sx.disabled,m,Dx.disabled,o,"clear",n,c,u,d,p,g,h,a,l);}};if(f||m){let t;if(e.prepareDrawTile(),a){const e=a.drapeBufferSize[0],i=a.drapeBufferSize[1];t=a.framebufferCopyTexture,t&&(!t||t.size[0]===e&&t.size[1]===i)||(t&&t.destroy(),t=a.framebufferCopyTexture=new My(o,new ef({width:e,height:i}),s.RGBA)),t.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.copyTexImage2D(s.TEXTURE_2D,0,s.RGBA,0,0,e,i,0);}f&&l(!0,!1,t),m&&l(!1,!0,t);}}else f&&g(!0),m&&g(!1);}}},hillshade:function(e,t,i,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const n=e.context,o=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||o?[{},r]:e.stencilConfigForOverlap(r);for(const r of a){const n=t.getTile(r);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)YE(e,n,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,Mx.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):s[r.overscaledZ];HE(e,r,n,i,t,c,l);}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks();},raster:function(e,t,i,r,n,o){if("translucent"!==e.renderPass)return;if(0===i.paint.get("raster-opacity"))return;const s=e.context,a=s.gl,l=t.getSource(),c=function(e,t,i){const r=e.paint.get("raster-color"),n=[],o=e.paint.get("raster-resampling"),s=e.paint.get("raster-color-mix"),a=e.paint.get("raster-color-range"),l=[s[0],s[1],s[2],0],c=s[3],h="nearest"===o?i.NEAREST:i.LINEAR;if(r&&n.push("RASTER_COLOR"),r){t.activeTexture.set(i.TEXTURE2);let r=e.colorRampTexture;r||(r=e.colorRampTexture=new My(t,e.colorRamp,i.RGBA)),r.bind(i.LINEAR,i.CLAMP_TO_EDGE);}return {mix:l,range:a,offset:c,defines:n,resampling:h}}(i,s,a),h=c.defines,u="globe"===e.transform.projection.name;let d=!1;if(l instanceof Jb&&!r.length){if(!u)return;if(l.onNorthPole)d=!0,h.push("GLOBE_POLES");else {if(!l.onSouthPole)return;d=!0,h.push("GLOBE_POLES");}}const p=i.paint.get("raster-emissive-strength"),f=e.colorModeForDrapableLayerRenderPass(p),m=e.terrain&&e.terrain.renderingToTexture,_=l instanceof Jb&&0!==i.paint.get("raster-elevation"),g=!e.options.moving,y="nearest"===i.paint.get("raster-resampling")?a.NEAREST:a.LINEAR;if(d){const r=t.getSource();if(!(r instanceof Jb))return;const n=r.texture;if(!n)return;const o=e.globeSharedBuffers;if(!o)return;const l=new Mx(a.LEQUAL,Mx.ReadWrite,e.depthRangeFor3D),h=Float32Array.from(e.transform.expandedFarZProjMatrix);let u=Rd(0,0,e.transform);const d=Float32Array.from(Ad(fd(new ju(0,0,0)))),m={opacity:1,mix:0};e.terrain&&e.terrain.prepareDrawTile(),s.activeTexture.set(a.TEXTURE0),n.bind(y,a.CLAMP_TO_EDGE),s.activeTexture.set(a.TEXTURE1),n.bind(y,a.CLAMP_TO_EDGE),n.useMipmap&&s.extTextureFilterAnisotropic&&e.transform.pitch>20&&a.texParameterf(a.TEXTURE_2D,s.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,s.extTextureFilterAnisotropicMax);const[_,g,x,v]=o.getPoleBuffers(0,!0);let b;r.onNorthPole?(b=_,e.renderDefaultNorthPole=!1):(u=Au.scale(Au.create(),u,[1,-1,1]),b=g,e.renderDefaultSouthPole=!1);const w=((e,t,i,r,n,o,s,a,l,c,h,u)=>CM(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],[0,0,0,0],0,[0,0],[0,0,0,0],1,r,n,o||[0,0],s,2,l,c,h,1,0,u))(h,d,u,m,i,r.perspectiveTransform||[0,0],i.paint.get("raster-elevation"),0,c.mix,c.offset,c.range,p),T=e.getOrCreateProgram("raster",{defines:c.defines});return e.uploadCommonUniforms(s,T,null),void T.draw(e,a.TRIANGLES,l,Sx.disabled,f,Dx.disabled,w,i.id,b,x,v)}if(!r.length)return;const[x,v]=l instanceof Jb||m?[{},r]:e.stencilConfigForOverlap(r),b=v[v.length-1].overscaledZ,w=_&&u;w&&c.defines.push("PROJECTION_GLOBE_VIEW"),_&&c.defines.push("RENDER_CUTOFF");for(const r of v){const n=r.toUnwrapped(),h=t.getTile(r);if(m&&(!h||!h.hasData()))continue;if(!h.texture)continue;let d,v;m?(d=Mx.disabled,v=r.projMatrix):_?(d=new Mx(a.LEQUAL,Mx.ReadWrite,e.depthRangeFor3D),v=u?Float32Array.from(e.transform.expandedFarZProjMatrix):e.transform.calculateProjMatrix(n,g)):(d=e.depthModeForSublayer(r.overscaledZ-b,1===i.paint.get("raster-opacity")?Mx.ReadWrite:Mx.ReadOnly,a.LESS),v=e.transform.calculateProjMatrix(n,g));const T=e.terrain&&m?e.terrain.stencilModeForRTTOverlap(r):x[r.overscaledZ],E=o?0:i.paint.get("raster-fade-duration");h.registerFadeDuration(E);const M=t.findLoadedParent(r,0),A=aM(h,M,t,e.transform,E);let S,I;e.terrain&&e.terrain.prepareDrawTile(),s.activeTexture.set(a.TEXTURE0),h.texture&&h.texture.bind(y,a.CLAMP_TO_EDGE),s.activeTexture.set(a.TEXTURE1),M?(M.texture&&M.texture.bind(y,a.CLAMP_TO_EDGE),S=Math.pow(2,M.tileID.overscaledZ-h.tileID.overscaledZ),I=[h.tileID.canonical.x*S%1,h.tileID.canonical.y*S%1]):h.texture&&h.texture.bind(y,a.CLAMP_TO_EDGE),h.texture&&h.texture.useMipmap&&s.extTextureFilterAnisotropic&&e.transform.pitch>20&&a.texParameterf(a.TEXTURE_2D,s.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,s.extTextureFilterAnisotropicMax);const C=e.transform,z=l instanceof Jb?l.perspectiveTransform:[0,0],P=_?sA(C):[0,0,0,0];let D,R,L,k,O,B;if(w&&l instanceof Jb&&l.coordinates.length>3){D=Float32Array.from(Ad(fd(new ju(0,0,0)))),R=Float32Array.from(C.globeMatrix),L=Float32Array.from(Pd(C)),k=[Kd(C.center.lng),Jd(C.center.lat)],B=[Kd(l.coordinates[1][0]),Jd(l.coordinates[1][1]),Kd(l.coordinates[3][0]),Jd(l.coordinates[3][1])];const t=new sc(l.coordinates[1],l.coordinates[3]);O=Float32Array.from(kd(new ju(0,0,0),t,0,C.worldSize/e.transform._pixelsPerMercatorPixel));}else D=new Float32Array(16),R=new Float32Array(9),L=new Float32Array(16),k=[0,0],O=new Float32Array(16),B=[0,0,0,0];const F=CM(v,D,R,L,O,I||[0,0],B,Dd(e.transform.zoom),k,P,S||1,A,i,z,_?i.paint.get("raster-elevation"):0,2,c.mix,c.offset,c.range,1,0,p),N=e.isTileAffectedByFog(r),U=e.getOrCreateProgram("raster",{defines:c.defines,overrideFog:N});if(e.uploadCommonUniforms(s,U,n),l instanceof Jb){if(m||!u)l.boundsBuffer&&l.boundsSegments&&U.draw(e,a.TRIANGLES,d,Sx.disabled,f,Dx.disabled,F,i.id,l.boundsBuffer,e.quadTriangleIndexBuffer,l.boundsSegments);else if(e.globeSharedBuffers){const[t,r,n]=e.globeSharedBuffers.getGridBuffers(0,!1);U.draw(e,a.TRIANGLES,d,Sx.disabled,f,Dx.frontCCW,F,i.id,t,r,n),U.draw(e,a.TRIANGLES,d,Sx.disabled,f,Dx.backCCW,F,i.id,t,r,n);}}else {const{tileBoundsBuffer:t,tileBoundsIndexBuffer:r,tileBoundsSegments:n}=e.getTileBoundsBuffers(h);U.draw(e,a.TRIANGLES,d,T,f,Dx.disabled,F,i.id,t,r,n);}}e.resetStencilClippingMasks();},background:function(e,t,i,r){const n=i.paint.get("background-color"),o=i.paint.get("background-opacity"),s=i.paint.get("background-emissive-strength");if(0===o)return;const a=e.context,l=a.gl,c=e.transform,h=c.tileSize,u=i.paint.get("background-pattern");if(e.isPatternMissing(u,i.scope))return;const d=!u&&1===n.a&&1===o&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==d)return;const p=Sx.disabled,f=e.depthModeForSublayer(0,"opaque"===d?Mx.ReadWrite:Mx.ReadOnly),m=e.colorModeForDrapableLayerRenderPass(s),_=u?"backgroundPattern":"background";let g,y=r;y||(g=e.getBackgroundTiles(),y=Object.values(g).map((e=>e.tileID))),u&&(a.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context,i.scope));for(const d of y){const y=e.isTileAffectedByFog(d),x=e.getOrCreateProgram(_,{overrideFog:y}),v=d.toUnwrapped(),b=r?d.projMatrix:e.transform.calculateProjMatrix(v);e.prepareDrawTile();const w=t?t.getTile(d):g?g[d.key]:new Oy(d,h,c.zoom,e),T=u?FM(b,s,o,e,u,i.scope,{tileID:d,tileSize:h}):BM(b,s,o,n);e.uploadCommonUniforms(a,x,v);const{tileBoundsBuffer:E,tileBoundsIndexBuffer:M,tileBoundsSegments:A}=e.getTileBoundsBuffers(w);x.draw(e,l.TRIANGLES,f,p,m,Dx.disabled,T,i.id,E,M,A);}},sky:function(e,t,i){const r=e._atmosphere?Dd(e.transform.zoom):1,n=i.paint.get("sky-opacity")*r;if(0===n)return;const o=e.context,s=i.paint.get("sky-type"),a=new Mx(o.gl.LEQUAL,Mx.ReadOnly,[0,1]),l=e.frameCounter/1e3%1;"atmosphere"===s?"offscreen"===e.renderPass?i.needsSkyboxCapture(e)&&(function(e,t,i,r){const n=e.context,o=n.gl;let s=t.skyboxFbo;if(!s){s=t.skyboxFbo=n.createFramebuffer(32,32,!0,null),t.skyboxGeometry=new xA(n),t.skyboxTexture=n.gl.createTexture(),o.bindTexture(o.TEXTURE_CUBE_MAP,t.skyboxTexture),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MAG_FILTER,o.LINEAR);for(let e=0;e<6;++e)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,o.RGBA,32,32,0,o.RGBA,o.UNSIGNED_BYTE,null);}n.bindFramebuffer.set(s.framebuffer),n.viewport.set([0,0,32,32]);const a=t.getCenter(e,!0),l=e.getOrCreateProgram("skyboxCapture"),c=new Float64Array(16);Au.identity(c),Au.rotateY(c,c,.5*-Math.PI),vA(e,t,l,c,a,0),Au.identity(c),Au.rotateY(c,c,.5*Math.PI),vA(e,t,l,c,a,1),Au.identity(c),Au.rotateX(c,c,.5*-Math.PI),vA(e,t,l,c,a,2),Au.identity(c),Au.rotateX(c,c,.5*Math.PI),vA(e,t,l,c,a,3),Au.identity(c),vA(e,t,l,c,a,4),Au.identity(c),Au.rotateY(c,c,Math.PI),vA(e,t,l,c,a,5),n.viewport.set([0,0,e.width,e.height]);}(e,i),i.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform,l=e.getOrCreateProgram("skybox");o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,r,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),0,r,n);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,i,Sx.disabled,e.colorModeForRenderPass(),Dx.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}(e,i,a,n,l):"gradient"===s&&"sky"===e.renderPass&&function(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform,l=e.getOrCreateProgram("skyboxGradient");t.skyboxGeometry||(t.skyboxGeometry=new xA(o)),o.activeTexture.set(s.TEXTURE0);let c=t.colorRampTexture;c||(c=t.colorRampTexture=new My(o,t.colorRamp,s.RGBA)),c.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=((e,t,i,r,n)=>({u_matrix:e,u_color_ramp:0,u_center_direction:t,u_radius:w(i),u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),t.paint.get("sky-gradient-radius"),r,n);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,i,Sx.disabled,e.colorModeForRenderPass(),Dx.backCW,h,"skyboxGradient",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment);}(e,i,a,n,l);},debug:function(e,t,i){for(let r=0;r<i.length;r++)dA(e,t,i[r]);},custom:function(e,t,i,r){const n=e.context,o=i.implementation;if(!e.transform.projection.unsupportedLayers||!e.transform.projection.unsupportedLayers.includes("custom")||e.terrain&&(e.terrain.renderingToTexture||"offscreen"===e.renderPass)&&i.isLayerDraped(t)){if("offscreen"===e.renderPass){const t=o.prerender;if(t){if(e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),"globe"===e.transform.projection.name){const i=e.transform.pointMerc;t.call(o,n.gl,e.transform.customLayerMatrix(),e.transform.getProjection(),e.transform.globeToMercatorMatrix(),Dd(e.transform.zoom),[i.x,i.y],e.transform.pixelsPerMeterRatio);}else t.call(o,n.gl,e.transform.customLayerMatrix());n.setDirty(),e.setBaseState();}}else if("translucent"===e.renderPass){if(e.terrain&&e.terrain.renderingToTexture){const t=o.renderToTile;if(t){const i=r[0].canonical,s=new lp(i.x+r[0].wrap*(1<<i.z),i.y,i.z);n.setDepthMode(Mx.disabled),n.setStencilMode(Sx.disabled),n.setColorMode(e.colorModeForRenderPass()),e.setCustomLayerDefaults(),t.call(o,n.gl,s),n.setDirty(),e.setBaseState();}return}e.setCustomLayerDefaults(),n.setColorMode(e.colorModeForRenderPass()),n.setStencilMode(Sx.disabled);const t="3d"===o.renderingMode?new Mx(e.context.gl.LEQUAL,Mx.ReadWrite,e.depthRangeFor3D):e.depthModeForSublayer(0,Mx.ReadOnly);if(n.setDepthMode(t),"globe"===e.transform.projection.name){const t=e.transform.pointMerc;o.render(n.gl,e.transform.customLayerMatrix(),e.transform.getProjection(),e.transform.globeToMercatorMatrix(),Dd(e.transform.zoom),[t.x,t.y],e.transform.pixelsPerMeterRatio);}else o.render(n.gl,e.transform.customLayerMatrix());n.setDirty(),e.setBaseState(),n.bindFramebuffer.set(null);}}else H("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.");},model:function(e,t,i,r){if("opaque"===e.renderPass)return;const n=i.paint.get("model-opacity");if(0===n)return;const o=i.paint.get("model-cast-shadows");if("shadow"===e.renderPass){if(!o)return;if(e.terrain&&n<.65&&i._transitionablePaint._values["model-opacity"].value.expression instanceof Ao)return}const s=e.shadowRenderer,a=i.paint.get("model-receive-shadows");s&&(s.useNormalOffset=!0,a||(s.enabled=!1));const l=()=>{s&&(s.useNormalOffset=!0,a||(s.enabled=!0));},c=t.getSource();if("light-beam"===e.renderPass&&"batched-model"!==c.type)return;if("vector"===c.type||"geojson"===c.type)return function(e,t,i,r){const n=e.transform;if("mercator"!==n.projection.name)return void H(`Drawing 3D models for ${n.projection.name} projection is not yet implemented`);const o=n.getFreeCameraOptions().position;if(!e.modelManager)return;const s=e.modelManager,a=e.shadowRenderer;if(!i._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const l=i._unevaluatedLayout._values["model-id"],c={...i.layout.get("model-id").parameters};for(const h of r){const r=t.getTile(h).getBucket(i);if(!r||r.projection.name!==n.projection.name)continue;const u=DA(h,n);c.zoom=u;const d=l.possiblyEvaluate(c);if(zA(e,r,h),PA.shadowUniformsInitialized=!1,PA.useSingleShadowCascade=!!a&&0===a.getMaxCascadeForTile(h.toUnwrapped()),"shadow"===e.renderPass&&a){if(1===e.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const t=n.calculatePosMatrix(h.toUnwrapped(),n.worldSize);if(PA.tileMatrix.set(t),PA.shadowTileMatrix=Float32Array.from(a.calculateShadowPassMatrixFromMatrix(t)),PA.aabb.min.fill(0),PA.aabb.max[0]=PA.aabb.max[1]=cr,PA.aabb.max[2]=0,kA(r,PA,e,i.scope))continue}const p=1<<h.canonical.z,f=[((o.x-h.wrap)*p-h.canonical.x)*cr,(o.y*p-h.canonical.y)*cr,o.z*p*cr];for(let t in r.instancesPerModel){const n=r.instancesPerModel[t];n.features.length>0&&(t=d.evaluate(n.features[0].feature,{}));const o=s.getModel(t,i.scope);if(o&&o.uploaded)for(const t of o.nodes)RA(e,i,t,n,f,h,PA);}}}(e,t,i,r),void l();if(!c.loaded())return;if("batched-model"===c.type)return function(e,t,i,r){const n=e.context,o=e.transform,s=e.style.fog,a=e.shadowRenderer;if("mercator"!==o.projection.name)return void H(`Drawing 3D landmark models for ${o.projection.name} projection is not yet implemented`);const l=e.transform.getFreeCameraOptions().position,c=Du.scale([],[l.x,l.y,l.z],e.transform.worldSize);Du.negate(c,c);const h=Au.identity([]),u=op(o.center.lat,o.zoom),d=Au.fromScaling([],[1,1,1/u]);Au.translate(h,h,c);const p=i.paint.get("model-opacity"),f=new Mx(n.gl.LEQUAL,Mx.ReadWrite,e.depthRangeFor3D),m=new Mx(n.gl.LEQUAL,Mx.ReadOnly,e.depthRangeFor3D),_=function(l,c){for(const u of r){const r=t.getTile(u).getBucket(i);if(!r||!r.uploaded)continue;let _=!1;a&&(_=0===a.getMaxCascadeForTile(u.toUnwrapped()));const g=o.calculatePosMatrix(u.toUnwrapped(),o.worldSize),y=r.modelTraits;for(const t of r.getNodesInfo()){if(t.hiddenByReplacement)continue;if(!t.node.meshes)continue;const r=t.node,x="light-beam"===e.renderPass,v=[...g],b=t.evaluatedScale;let w=0;e.terrain&&r.elevation&&(w=r.elevation*e.terrain.exaggeration()),Au.translate(v,v,[(r.anchor?r.anchor[0]:0)*(b[0]-1),(r.anchor?r.anchor[1]:0)*(b[1]-1),w]),b!==Iv&&Au.scale(v,v,b),Au.multiply(v,v,r.matrix);const T=Au.multiply([],d,v);Au.multiply(T,h,T);const E=Au.invert([],T);Au.transpose(E,E),Au.scale(E,E,LA);const M=Au.multiply([],o.expandedFarZProjMatrix,v);for(let h=0;h<r.meshes.length;++h){const d=r.meshes[h],g=h===r.lightMeshIndex;if(g){if(!x&&!e.terrain&&e.shadowRenderer){e.currentLayer<e.firstLightBeamLayer&&(e.firstLightBeamLayer=e.currentLayer);continue}}else if(x)continue;const b={defines:[]},w=[];AA(b.defines,w,d,e),4&y||b.defines.push("DIFFUSE_SHADED"),_&&b.defines.push("SHADOWS_SINGLE_CASCADE");const A="shadow"===e.renderPass;if(A){CA(d,v,e,i);continue}let S=null;if(s){const t=MA(v,e.transform);if(S=new Float32Array(t),"globe"!==o.projection.name){const e=d.aabb.min,i=d.aabb.max,[r,n]=s.getOpacityForBounds(t,e[0],e[1],i[0],i[1]);b.overrideFog=r>=fw||n>=fw;}}const I=e.getOrCreateProgram("model",b);!A&&a&&(a.useNormalOffset=!!d.normalBuffer,a.setupShadowsFromMatrix(v,I,a.useNormalOffset)),e.uploadCommonUniforms(n,I,u.toUnwrapped(),S);const C=d.material,z=C.pbrMetallicRoughness;z.metallicFactor=.9,z.roughnessFactor=.5;const P=0,D=UM(new Float32Array(M),new Float32Array(T),new Float32Array(E),e,p,z.baseColorFactor,C.emissiveFactor,z.metallicFactor,z.roughnessFactor,C,P,i);I.draw(e,n.gl.TRIANGLES,c&&!g?f:m,Sx.disabled,l?g||p<1||t.hasTranslucentParts?Cx.alphaBlended:Cx.unblended:Cx.disabled,Dx.backCCW,D,i.id,d.vertexBuffer,d.indexBuffer,d.segments,i.paint,e.transform.zoom,void 0,w);}}}};((function(e,t,i,r){const n=e.terrain?e.terrain.exaggeration():0,o=e.transform.zoom;for(const s of r){const r=t.getTile(s).getBucket(i);r&&(e.conflationActive&&r.updateReplacement(s,e.replacementSource),r.evaluateScale(e,i),e.terrain&&n>0&&r.elevationUpdate(e.terrain,n,s,i.source),r.needsReEvaluation(e,o,i)&&r.evaluate(i));}}))(e,t,i,r),1===p?_(!0,!0):(_(!1,!0),_(!0,!1));}(e,t,i,r),void l();const h=c.getModels(),u=[],d=e.transform.getFreeCameraOptions().position,p=Du.scale([],[d.x,d.y,d.z],e.transform.worldSize);Du.negate(p,p);const f=[],m=[];let _=0;for(const t of h){const r=i.paint.get("model-rotation").constantOr(null),n=i.paint.get("model-scale").constantOr(null),o=i.paint.get("model-translation").constantOr(null);t.computeModelMatrix(e,r,n,o,!0,!0,!1);const s=Au.identity([]),a=op(t.position.lat,e.transform.zoom),l=Au.fromScaling([],[1,1,1/a]);Au.translate(s,s,p),u.push({zScaleMatrix:l,negCameraPosMatrix:s});for(const i of t.nodes)IA(e.transform,i,t.matrix,e.transform.expandedFarZProjMatrix,_,f,m);_++;}if(f.sort(((e,t)=>t.depth-e.depth)),"shadow"!==e.renderPass){if(1===n)for(const t of m)SA(t,e,i,u[t.modelIndex],Sx.disabled,e.colorModeForRenderPass());else {for(const t of m)SA(t,e,i,u[t.modelIndex],Sx.disabled,Cx.disabled);for(const t of m)SA(t,e,i,u[t.modelIndex],e.stencilModeFor3D(),e.colorModeForRenderPass());e.resetStencilClippingMasks();}for(const t of f)SA(t,e,i,u[t.modelIndex],Sx.disabled,e.colorModeForRenderPass());l();}else {for(const t of m)CA(t.mesh,t.nodeModelMatrix,e,i);for(const t of f)CA(t.mesh,t.nodeModelMatrix,e,i);l();}}},NA={modelUpload:function(e,t,i){const r=t.getSource();if(!r.loaded())return;if("vector"===r.type||"geojson"===r.type)return void(e.modelManager&&e.modelManager.upload(e,i));if("batched-model"===r.type)return;const n=r.getModels();for(const t of n)t.upload(e.context);}};class UA{constructor(e,t,i){this.context=new Rx(e,t),this.transform=i,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=Lx.maxUnderzooming+Lx.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new Xv,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new qA(this),this._wireframeDebugCache=new BA,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0;}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new uM(this,e));const r=this._terrain;this.transform.elevation=i?r:null,r.update(e,this.transform,t),this.transform.elevation&&!r.enabled&&(this.transform.elevation=null);}_updateFog(e){const t=e.fog;if(!t||"globe"===this.transform.projection.name||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=t.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n;}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(e,t){if(this.width=e*dt.devicePixelRatio,this.height=t*dt.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._mergedLayers[e].resize();}setup(){const e=this.context,i=new za;i.emplaceBack(0,0),i.emplaceBack(cr,0),i.emplaceBack(0,cr),i.emplaceBack(cr,cr),this.tileExtentBuffer=e.createVertexBuffer(i,Nu.members),this.tileExtentSegments=xl.simpleSegment(0,0,4,2);const r=new za;r.emplaceBack(0,0),r.emplaceBack(cr,0),r.emplaceBack(0,cr),r.emplaceBack(cr,cr),this.debugBuffer=e.createVertexBuffer(r,Nu.members),this.debugSegments=xl.simpleSegment(0,0,4,5);const n=new za;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(n,Nu.members),this.viewportSegments=xl.simpleSegment(0,0,4,2);const o=new Da;o.emplaceBack(0,0,0,0),o.emplaceBack(cr,0,cr,0),o.emplaceBack(0,cr,0,cr),o.emplaceBack(cr,cr,cr,cr),this.mercatorBoundsBuffer=e.createVertexBuffer(o,Ly.members),this.mercatorBoundsSegments=xl.simpleSegment(0,0,4,2);const s=new Wa;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(s);const a=new el;for(const e of [0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=e.createIndexBuffer(a),this.emptyTexture=new My(e,new ef({width:1,height:1},Uint8Array.of(0,0,0,0)),e.gl.RGBA),this.identityMat=Au.create();const l=this.context.gl;this.stencilClearMode=new Sx({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(t.performance.now());}getMercatorTileBoundsBuffers(){return {tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,Mx.disabled,this.stencilClearMode,Cx.disabled,Dx.disabled,sM(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={});}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const r=this.context,n=r.gl;this.nextStencilID+i.length>256&&this.clearStencil(),r.setColorMode(Cx.disabled),r.setDepthMode(Mx.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),r=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);o.draw(this,n.TRIANGLES,Mx.disabled,new Sx({func:n.ALWAYS,mask:0},r,255,n.KEEP,n.KEEP,n.REPLACE),Cx.disabled,Dx.disabled,sM(e.projMatrix),"$clipping",s,a,l);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Sx({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new Sx({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let i=0;i<n;i++)e[i+r]=new Sx({func:t.GEQUAL,mask:255},i+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=n,[e,i]}return [{[r]:Sx.disabled},i]}colorModeForRenderPass(){const e=this.context.gl;if(this._showOverdrawInspector){const t=1/8;return new Cx([e.CONSTANT_COLOR,e.ONE,e.CONSTANT_COLOR,e.ONE],new hi(t,t,t,0),[!0,!0,!0,!0])}return "opaque"===this.renderPass?Cx.unblended:Cx.alphaBlended}colorModeForDrapableLayerRenderPass(e){const t=this.context.gl;return (()=>this.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Cx([t.ONE,t.ONE_MINUS_SRC_ALPHA,t.CONSTANT_ALPHA,t.ONE_MINUS_SRC_ALPHA],new hi(0,0,0,void 0===e?0:e),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,r=!1){if(!this.opaquePassEnabledForLayer()&&!r)return Mx.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new Mx(i||this.context.gl.LEQUAL,t,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,i){this._wireframeDebugCache.update(this.frameCounter),this.style=e,this.options=i;const r=this.style._mergedLayers,n=this.style.order,o=n.map((e=>r[e])),s=this.style._mergedSourceCaches;this.imageManager=e.imageManager,this.modelManager=e.modelManager,this.symbolFadeChange=e.placement.symbolFadeChange(dt.now()),this.imageManager.beginFrame();let a=0,l=!1;for(const e in s){const t=s[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++a);}const c={},h={},u={},d={},p={};for(const e in s){const t=s[e];c[e]=t.getVisibleCoordinates(),h[e]=c[e].slice().reverse(),u[e]=t.getVisibleCoordinates(!0).reverse(),d[e]=t.getShadowCasterCoordinates(),p[e]=t.sortCoordinatesByDistance(c[e]);}const f=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(a){const e=[];for(const t of o)this.layerUsedInConflation(t,f(t))&&e.push(t);if(e&&e.length>1){const t=[];for(const i of e){const e=this.style.getLayerSourceCache(i);e&&e.used&&e.getSource().usedInConflation&&t.push({layer:i.fqid,cache:e});}this.replacementSource.setSources(t),l=!0;}}l||this.replacementSource.clear(),this.conflationActive=l,this.minCutoffZoom=0,this.longestCutoffRange=0;for(const e of o){const t=e.cutoffRange();if(this.longestCutoffRange=Math.max(t,this.longestCutoffRange),t>0){const t=f(e);t&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom)),e.minzoom&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom));}}this.opaquePassCutoff=1/0;for(let e=0;e<o.length;e++)if(o[e].is3D()){this.opaquePassCutoff=e;break}const m=this.style&&this.style.fog;m?(this._fogVisible=0!==m.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=m.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(u),this.opaquePassCutoff=0);const _=this._shadowRenderer;if(_){_.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in s)for(const t of c[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),_.addShadowReceiver(t.toUnwrapped(),e.min,e.max);}}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new Gd(this.context));for(const t of o){if(t.isHidden(this.transform.zoom))continue;const i=e.getLayerSourceCache(t);this.uploadLayer(this,t,i);}if(this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new EA),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),!Ye.has(this.context.gl))return;this.renderPass="offscreen";for(const t of o){const i=e.getLayerSourceCache(t);if(!t.hasOffscreenPass()||t.isHidden(this.transform.zoom))continue;const r=i?h[i.id]:void 0;("custom"===t.type||"raster"===t.type||t.isSky()||r&&r.length)&&this.renderLayer(this,i,t,r);}this.depthRangeFor3D=[0,1-(o.length+2)*this.numSublayers*this.depthEpsilon];const g=this.terrain;g&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&!this.transform.isOrthographic&&g.drawDepth(),this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,d)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const y="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),x=(()=>{if(i.showOverdrawInspector)return hi.black;if(this.style.fog&&this.transform.projection.supportsFog&&!y){const e=this.style.fog.properties.get("color").toArray01();return new hi(...e)}if(this.style.fog&&this.transform.projection.supportsFog&&y){const e=this.style.fog.properties.get("space-color").toArray01();return new hi(...e)}return hi.transparent})();if(this.context.clear({color:x,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&y&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=n.length-1;this.currentLayer>=0;this.currentLayer--){const t=o[this.currentLayer],i=e.getLayerSourceCache(t);if(t.isSky())continue;const r=i?(t.is3D()?p:h)[i.id]:void 0;this._renderTileClippingMasks(t,i,r),this.renderLayer(this,i,t,r);}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&y&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||Dd(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer<n.length;this.currentLayer++){const t=o[this.currentLayer],i=e.getLayerSourceCache(t);t.isSky()&&this.renderLayer(this,i,t,i?h[i.id]:void 0);}this.renderPass="translucent",this.currentLayer=0,this.firstLightBeamLayer=Number.MAX_SAFE_INTEGER;let v=0;for(_&&(v=_.getShadowCastingLayerCount());this.currentLayer<n.length;){const t=o[this.currentLayer],i=e.getLayerSourceCache(t);if(t.isSky()){++this.currentLayer;continue}if(g&&this.style.isLayerDraped(t)){if(t.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=g.renderBatch(this.currentLayer);continue}let r;if(i&&(r=("symbol"===t.type?u:t.is3D()?p:h)[i.id]),this._renderTileClippingMasks(t,i,i?c[i.id]:void 0),this.renderLayer(this,i,t,r),!g&&_&&v>0&&t.hasShadowPass()&&0==--v&&(_.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const t=this.currentLayer;for(this.renderPass="light-beam",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=t;this.currentLayer++){const t=o[this.currentLayer];if(!t.hasLightBeamPass())continue;const i=e.getLayerSourceCache(t);this.renderLayer(this,i,t,i?h[i.id]:void 0);}this.currentLayer=t,this.renderPass="translucent";}++this.currentLayer;}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let t=null;o.forEach((i=>{const r=e.getLayerSourceCache(i);r&&!i.isHidden(this.transform.zoom)&&r.getVisibleCoordinates().length&&(!t||t.getSource().maxzoom<r.getSource().maxzoom)&&(t=r);})),t&&this.options.showTileBoundaries&&FA.debug(this,t,t.getVisibleCoordinates());}this.options.showPadding&&function(e){const t=e.transform.padding;pA(e,e.transform.height-(t.top||0),3,aA),pA(e,t.bottom||0,3,lA),fA(e,t.left||0,3,cA),fA(e,e.transform.width-(t.right||0),3,hA);const i=e.transform.centerPoint;!function(e,t,i,r){mA(e,t-1,i-10,2,20,r),mA(e,t-10,i-1,20,2,r);}(e,i.x,e.transform.height-i.y,uA);}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(t.performance.now()),this.saveCanvasCopy()),l||(this.conflationActive=!1);}uploadLayer(e,t,i){this.gpuTimingStart(t),(!e.transform.projection.unsupportedLayers||!e.transform.projection.unsupportedLayers.includes(t.type)||e.terrain&&"custom"===t.type)&&NA[`${t.type}Upload`]&&NA[`${t.type}Upload`](e,i,t.scope),this.gpuTimingEnd();}renderLayer(e,t,i,r){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||"model"===i.type||"raster"===i.type||r&&r.length)&&(this.id=i.id,this.gpuTimingStart(i),(!e.transform.projection.unsupportedLayers||!e.transform.projection.unsupportedLayers.includes(i.type)||e.terrain&&"custom"===i.type)&&FA[i.type](e,t,i,r,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd());}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery,i=this.context.gl;let r=this.gpuTimers[e.id];r||(r=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:i.createQuery()}),r.calls++,i.beginQuery(t.TIME_ELAPSED_EXT,r.query);}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const e=this.context.extTimerQuery,t=this.context.gl,i=t.createQuery();this.deferredRenderGpuTimeQueries.push(i),t.beginQuery(e.TIME_ELAPSED_EXT,i);}}gpuTimingDeferredRenderEnd(){this.options.gpuTimingDeferredRender&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT);}gpuTimingEnd(){this.options.gpuTiming&&this.context.gl.endQuery(this.context.extTimerQuery.TIME_ELAPSED_EXT);}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}collectDeferredRenderGpuQueries(){const e=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],e}queryGpuTimers(e){const t={};for(const i in e){const r=e[i],n=this.context.extTimerQuery,o=n.getQueryParameter(r.query,this.context.gl.QUERY_RESULT)/1e6;n.deleteQueryEXT(r.query),t[i]=o;}return t}queryGpuTimeDeferredRender(e){if(!this.options.gpuTimingDeferredRender)return 0;const t=this.context.extTimerQuery,i=this.context.gl;let r=0;for(const n of e)r+=t.getQueryParameter(n,i.QUERY_RESULT)/1e6,t.deleteQueryEXT(n);return r}translatePosMatrix(e,t,i,r,n){if(!i[0]&&!i[1])return e;const o=n?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(o){const e=Math.sin(o),t=Math.cos(o);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t];}const s=[n?i[0]:rv(t,i[0],this.transform.zoom),n?i[1]:rv(t,i[1],this.transform.zoom),0],a=new Float32Array(16);return Au.translate(a,e,s),a}saveTileTexture(e){const t=e.size[0],i=this._tileTextures[t];i?i.push(e):this._tileTextures[t]=[e];}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e,t){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString(),t)}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i){const r=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,n=this.terrain&&0===this.terrain.exaggeration(),o=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(o.push("LIGHTING_3D_MODE"),o.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):r||o.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass?this._shadowMapDebug||o.push("DEPTH_TEXTURE"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?o.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"):o.push("RENDER_SHADOWS","DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(o.push("TERRAIN"),this.linearFloatFilteringSupported()&&o.push("TERRAIN_DEM_FLOAT_FORMAT"),n&&o.push("ZERO_EXAGGERATION")),"globe"===this.transform.projection.name&&o.push("GLOBE"),!this._fogVisible||r||void 0!==t&&!t||o.push("FOG","FOG_DITHERING"),r&&o.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&o.push("OVERDRAW_INSPECTOR"),o}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],r=t&&t.config,n=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),o=mM.cacheKey(GE[e],e,n,r);return this.cache[o]||(this.cache[o]=new mM(this.context,e,GE[e],r,GM[e],n)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault();}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD);}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=t.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new My(this.context,this.debugOverlayCanvas,this.context.gl.RGBA));}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy();}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile();}uploadCommonLightUniforms(e,t){if(this.style.enable3dLights()){const i=this.style.directionalLight,r=this.style.ambientLight;if(i&&r){const n=((e,t)=>{const i=e.properties.get("direction"),r=e.properties.get("color").toArray01(),n=e.properties.get("intensity"),o=t.properties.get("color").toArray01(),s=t.properties.get("intensity"),a=[i.x,i.y,i.z],l=se(o,s),c=se(r,n);return {u_lighting_ambient_color:l,u_lighting_directional_dir:a,u_lighting_directional_color:c,u_ground_radiance:dM(a,c,l)}})(i,r);t.setLightsUniformValues(e,n);}}}uploadCommonUniforms(e,t,i,r,n){if(this.uploadCommonLightUniforms(e,t),this.terrain&&this.terrain.renderingToTexture)return;const o=this.style.fog;if(o){const n=o.getOpacity(this.transform.pitch),s=((e,t,i,r,n,o,s,a,l,c,h,u)=>{const d=e.transform,p=t.properties.get("color").toArray01();p[3]=r;const f=e.frameCounter/1e3%1,[m,_]=t.properties.get("vertical-range");return {u_fog_matrix:i?d.calculateFogTileMatrix(i):u||e.identityMat,u_fog_range:t.getFovAdjustedRange(d._fov),u_fog_color:p,u_fog_horizon_blend:t.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(m,_),_],u_fog_temporal_offset:f,u_frustum_tl:n,u_frustum_tr:o,u_frustum_br:s,u_frustum_bl:a,u_globe_pos:l,u_globe_radius:c,u_viewport:h,u_globe_transition:Dd(d.zoom),u_is_globe:+("globe"===d.projection.name)}})(this,o,i,n,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*dt.devicePixelRatio,this.transform.height*dt.devicePixelRatio],r);t.setFogUniformValues(e,s);}n&&t.setCutoffUniformValues(e,n.uniformValues);}setTileLoadedFlag(e){this.tileLoaded=e;}saveCanvasCopy(){const e=this.canvasCopy();e&&(this.frameCopies.push(e),this.tileLoaded=!1);}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return {canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return !1;const e=this.style&&this.style.fog;return !!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,t=this._backgroundTiles={},i=this.transform.coveringTiles({tileSize:512});for(const r of i)t[r.key]=e[r.key]||new Oy(r,512,this.transform.tileZoom,this);return t}clearBackgroundTiles(){this._backgroundTiles={};}layerUsedInConflation(e,t){return !(!e.is3D()||e.minzoom&&e.minzoom>this.transform.zoom||"building"!==e.sourceLayer&&(!t||"batched-model"!==t.type))}isTileAffectedByFog(e){if(!this.style||!this.style.fog)return !1;if("globe"===this.transform.projection.name)return !0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=fw||t[1]>=fw}}const VA=2048;class jA{constructor(e,t){this.aabb=e,this.lastCascade=t;}}class GA{add(e,t){const i=this.receivers[e.key];void 0!==i?(i.aabb.min[0]=Math.min(i.aabb.min[0],t.min[0]),i.aabb.min[1]=Math.min(i.aabb.min[1],t.min[1]),i.aabb.min[2]=Math.min(i.aabb.min[2],t.min[2]),i.aabb.max[0]=Math.max(i.aabb.max[0],t.max[0]),i.aabb.max[1]=Math.max(i.aabb.max[1],t.max[1]),i.aabb.max[2]=Math.max(i.aabb.max[2],t.max[2])):this.receivers[e.key]=new jA(t,null);}clear(){this.receivers={};}get(e){return this.receivers[e.key]}computeRequiredCascades(e,t,i){const r=ed.fromPoints(e.points);let n=0;for(const e in this.receivers){const o=this.receivers[e];if(!o)continue;if(!r.intersectsAabb(o.aabb))continue;o.aabb.min=r.closestPoint(o.aabb.min),o.aabb.max=r.closestPoint(o.aabb.max);const s=o.aabb.getCorners();for(let e=0;e<i.length;e++){let r=!0;for(const n of s){const o=[n[0]*t,n[1]*t,n[2]];if(Du.transformMat4(o,o,i[e].matrix),o[0]<-1||o[0]>1||o[1]<-1||o[1]>1){r=!1;break}}if(o.lastCascade=e,n=Math.max(n,e),r)break}}return n+1}}class qA{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new GA,this._depthMode=new Mx(e.context.gl.LEQUAL,Mx.ReadWrite,[0,1]),this._uniformValues={u_light_matrix_0:new Float32Array(16),u_light_matrix_1:new Float32Array(16),u_shadow_intensity:0,u_fade_range:[0,0],u_shadow_normal_offset:[1,1,1],u_shadow_texel_size:1,u_shadow_map_resolution:1,u_shadow_direction:[0,0,1],u_shadow_bias:[36e-5,.0012,.012],u_shadowmap_0:0,u_shadowmap_1:0},this.useNormalOffset=!1;}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[];}updateShadowParameters(e,t){const i=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!t||!t.properties)return;const r=t.properties.get("shadow-intensity");if(!t.shadowsEnabled()||r<=0)return;if(this._shadowLayerCount=i.style.order.reduce(((t,r)=>{const n=i.style._mergedLayers[r];return t+(n.hasShadowPass()&&!n.isHidden(e.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this._enabled)return;const n=i.context,o=VA,s=VA;if(0===this._cascades.length)for(let e=0;e<2;++e){const e=i._shadowMapDebug,t=n.gl,r=n.createFramebuffer(o,s,e,"texture"),a=new My(n,{width:o,height:s,data:null},t.DEPTH_COMPONENT);if(r.depthAttachment.set(a.texture),e){const e=new My(n,{width:o,height:s,data:null},t.RGBA);r.colorAttachment.set(e.texture);}this._cascades.push({framebuffer:r,texture:a,matrix:[],far:0,boundingSphereRadius:0,frustum:new Qu,scale:0});}this.shadowDirection=$A(t);let a=0;if(e.elevation){const t=e.elevation,i=[1e4,-1e4];t.visibleDemTiles.filter((e=>e.dem)).forEach((e=>{const t=e.dem.tree;i[0]=Math.min(i[0],t.minimums[0]),i[1]=Math.max(i[1],t.maximums[0]);})),1e4!==i[0]&&(a=(i[1]-i[0])*t.exaggeration());}const l=1.5*e.cameraToCenterDistance,c=3*l,h=new Float64Array(16);for(let t=0;t<2;++t){const i=this._cascades[t];let r=e.height/50,n=1;0===t?n=l:(r=l,n=c);const[o,s]=HA(e,this.shadowDirection,r,n,VA,a);i.scale=e.scale,i.matrix=o,i.boundingSphereRadius=s,Au.invert(h,i.matrix),i.frustum=Qu.fromInvProjectionMatrix(h,1,0,!0),i.far=n;}this._uniformValues.u_fade_range=[.75*this._cascades[1].far,this._cascades[1].far],this._uniformValues.u_shadow_intensity=r,this._uniformValues.u_shadow_direction=[this.shadowDirection[0],this.shadowDirection[1],this.shadowDirection[2]],this._uniformValues.u_shadow_texel_size=.00048828125,this._uniformValues.u_shadow_map_resolution=VA,this._uniformValues.u_shadowmap_0=NM.ShadowMap0,this._uniformValues.u_shadowmap_1=NM.ShadowMap0+1,this._groundShadowTiles=i.transform.coveringTiles({tileSize:512,renderWorldCopies:!0});const u=i.transform.elevation;for(const e of this._groundShadowTiles){let t={min:0,max:0};if(u){const i=u.getMinMaxForTile(e);i&&(t=i);}this.addShadowReceiver(e.toUnwrapped(),t.min,t.max);}}get enabled(){return this._enabled}set enabled(e){this._enabled=e;}drawShadowPass(e,t){if(!this._enabled)return;const i=this.painter,r=i.context;this._numCascadesToRender=this._receivers.computeRequiredCascades(i.transform.getFrustum(0),i.transform.worldSize,this._cascades),r.viewport.set([0,0,VA,VA]);for(let n=0;n<this._numCascadesToRender;++n){i.currentShadowCascade=n,r.bindFramebuffer.set(this._cascades[n].framebuffer.framebuffer),r.clear({color:hi.white,depth:1});for(const r of e.order){const n=e._mergedLayers[r];if(!n.hasShadowPass()||n.isHidden(i.transform.zoom))continue;const o=e.getLayerSourceCache(n),s=o?t[o.id]:void 0;("model"===n.type||s&&s.length)&&i.renderLayer(i,o,n,s);}}i.currentShadowCascade=0;}drawGroundShadows(){if(!this._enabled)return;const e=this.painter,t=e.style,i=e.context,r=t.directionalLight,n=t.ambientLight;if(!r||!n)return;const o=[],s=eM(e,e.longestCutoffRange);s.shouldRenderCutoff&&o.push("RENDER_CUTOFF");const a=WA(r,n),l=new Mx(i.gl.LEQUAL,Mx.ReadOnly,e.depthRangeFor3D);for(const t of this._groundShadowTiles){const r=t.toUnwrapped(),n=e.isTileAffectedByFog(t),c=e.getOrCreateProgram("groundShadow",{defines:o,overrideFog:n});this.setupShadows(r,c),e.uploadCommonUniforms(i,c,r,null,s);const h={u_matrix:e.transform.calculateProjMatrix(r),u_ground_shadow_factor:a};c.draw(e,i.gl.TRIANGLES,l,Sx.disabled,Cx.multiply,Dx.disabled,h,"ground_shadow",e.tileExtentBuffer,e.quadTriangleIndexBuffer,e.tileExtentSegments,{},e.transform.zoom,null,null);}}getShadowPassColorMode(){return this.painter._shadowMapDebug?Cx.unblended:Cx.disabled}getShadowPassDepthMode(){return this._depthMode}getShadowCastingLayerCount(){return this._shadowLayerCount}calculateShadowPassMatrixFromTile(e){const t=this.painter.transform,i=t.calculatePosMatrix(e,t.worldSize);return Au.multiply(i,this._cascades[this.painter.currentShadowCascade].matrix,i),Float32Array.from(i)}calculateShadowPassMatrixFromMatrix(e){return Au.multiply(e,this._cascades[this.painter.currentShadowCascade].matrix,e),Float32Array.from(e)}setupShadows(e,t,i,r=0){if(!this._enabled)return;const n=this.painter.transform,o=this.painter.context,s=o.gl,a=this._uniformValues,l=new Float64Array(16),c=n.calculatePosMatrix(e,n.worldSize);for(let e=0;e<2;e++)Au.multiply(l,this._cascades[e].matrix,c),a[0===e?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(l),o.activeTexture.set(s.TEXTURE0+NM.ShadowMap0+e),this._cascades[e].texture.bind(s.NEAREST,s.CLAMP_TO_EDGE);if(this.useNormalOffset=!!i,this.useNormalOffset){const t=ap(e.canonical),o=2/n.tileSize*cr/VA,s=o*this._cascades[0].boundingSphereRadius,l=o*this._cascades[1].boundingSphereRadius,c=("vector-tile"===i?1:3)/Math.pow(2,r-e.canonical.z-(1-n.zoom+Math.floor(n.zoom)));a.u_shadow_normal_offset=[t,s*c,l*c],a.u_shadow_bias=[6e-5,.0012,.012];}else a.u_shadow_bias=[36e-5,.0012,.012];t.setShadowUniformValues(o,a);}setupShadowsFromMatrix(e,t,i=!1){if(!this._enabled)return;const r=this.painter.context,n=r.gl,o=this._uniformValues,s=new Float64Array(16);for(let t=0;t<2;t++)Au.multiply(s,this._cascades[t].matrix,e),o[0===t?"u_light_matrix_0":"u_light_matrix_1"]=Float32Array.from(s),r.activeTexture.set(n.TEXTURE0+NM.ShadowMap0+t),this._cascades[t].texture.bind(n.NEAREST,n.CLAMP_TO_EDGE);if(this.useNormalOffset=i,i){const e=5;o.u_shadow_normal_offset=[1,e,e],o.u_shadow_bias=[6e-5,.0012,.012];}else o.u_shadow_bias=[36e-5,.0012,.012];t.setShadowUniformValues(r,o);}getShadowUniformValues(){return this._uniformValues}getCurrentCascadeFrustum(){return this._cascades[this.painter.currentShadowCascade].frustum}computeSimplifiedTileShadowVolume(e,t,i,r){if(r[2]>=0)return {};const n=function(e,t,i){const r=i/(1<<e.canonical.z);return new ed([e.canonical.x*r+e.wrap*i,e.canonical.y*r+e.wrap*i,0],[(e.canonical.x+1)*r+e.wrap*i,(e.canonical.y+1)*r+e.wrap*i,t])}(e,t,i).getCorners(),o=t/-r[2];r[0]<0?(Du.add(n[0],n[0],[r[0]*o,0,0]),Du.add(n[3],n[3],[r[0]*o,0,0])):r[0]>0&&(Du.add(n[1],n[1],[r[0]*o,0,0]),Du.add(n[2],n[2],[r[0]*o,0,0])),r[1]<0?(Du.add(n[0],n[0],[0,r[1]*o,0]),Du.add(n[1],n[1],[0,r[1]*o,0])):r[1]>0&&(Du.add(n[2],n[2],[0,r[1]*o,0]),Du.add(n[3],n[3],[0,r[1]*o,0]));const s={};return s.vertices=n,s.planes=[ZA(n[1],n[0],n[4]),ZA(n[2],n[1],n[5]),ZA(n[3],n[2],n[6]),ZA(n[0],n[3],n[7])],s}addShadowReceiver(e,t,i){this._receivers.add(e,ed.fromTileIdAndHeight(e,t,i));}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function ZA(e,t,i){const r=Du.sub([],i,t),n=Du.sub([],e,t),o=Du.cross([],r,n),s=Du.length(o);return 0===s?[0,0,1,0]:(Du.scale(o,o,1/s),[o[0],o[1],o[2],-Du.dot(o,t)])}function $A(e){const t=e.properties.get("direction"),i=J(t.x,t.y,t.z);i[2]=z(i[2],0,75);const r=K([i[0],i[1],i[2]]);return Du.fromValues(r.x,r.y,r.z)}function WA(e,t){const i=e.properties.get("color"),r=e.properties.get("intensity"),n=e.properties.get("direction"),o=[n.x,n.y,n.z],s=t.properties.get("color"),a=t.properties.get("intensity"),l=Math.max(Du.dot([0,0,1],o),0),c=[0,0,0];Du.scale(c,s.toArray01Linear().slice(0,3),a);const h=[0,0,0];return Du.scale(h,i.toArray01Linear().slice(0,3),l*r),ae([c[0]>0?c[0]/(c[0]+h[0]):0,c[1]>0?c[1]/(c[1]+h[1]):0,c[2]>0?c[2]/(c[2]+h[2]):0])}function HA(e,t,i,r,n,o){const s=e.zoom,a=e.scale,l=e.worldSize,c=1/l,h=e.aspect,u=Math.sqrt(1+h*h)*Math.tan(.5*e.fovX),d=u*u,p=r-i,f=r+i;let m,_;d>p/f?(m=r,_=r*u):(m=.5*f*(1+d),_=.5*Math.sqrt(p*p+2*(r*r+i*i)*d+f*f*d*d));const g=e.projection.pixelsPerMeter(e.center.lat,l),y=e._camera.getCameraToWorldMercator(),x=[0,0,-m*c];Du.transformMat4(x,x,y);let v=_*c;const b=e._edgeInsets;if(!(0===b.left&&0===b.top&&0===b.right&&0===b.bottom||b.left===b.right&&b.top===b.bottom)){const t=e._camera.getWorldToCamera(e.worldSize,"meters"===e.projection.zAxisUnit?g:1),n=e._camera.getCameraToClipPerspective(e._fov,e.width/e.height,i,r);n[8]=2*-e.centerOffset.x/e.width,n[9]=2*e.centerOffset.y/e.height;const o=new Float64Array(16);Au.mul(o,n,t);const c=new Float64Array(16);Au.invert(c,o);const h=Qu.fromInvProjectionMatrix(c,l,s,!0);for(const t of h.points){const i=((w=t)[0]/=a,w[1]/=a,w[2]=Qd(w[2],e._center.lat),w);v=Math.max(v,Du.len(Du.subtract([],x,i)));}}var w;v*=n/(n-1);const T=Math.acos(t[2]),E=Math.atan2(-t[0],-t[1]),M=new Yx;M.position=x,M.setPitchBearing(T,E);const A=M.getWorldToCamera(l,g),S=v*l,I=Math.min(e._mercatorZfromZoom(17)*l*-2,-2*S),C=M.getCameraToClipOrthographic(-S,S,-S,S,I,(S+o*g)/t[2]),z=new Float64Array(16);Au.multiply(z,C,A);const P=Du.fromValues(Math.floor(1e6*x[0])/1e6*l,Math.floor(1e6*x[1])/1e6*l,0),D=.5*n,R=[0,0,0];Du.transformMat4(R,P,z),Du.scale(R,R,D);const L=[Math.floor(R[0]),Math.floor(R[1]),Math.floor(R[2])],k=[0,0,0];Du.sub(k,R,L),Du.scale(k,k,-1/D);const O=new Float64Array(16);return Au.identity(O),Au.translate(O,O,k),Au.multiply(z,O,z),[z,S]}class XA extends zt{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.numModelsLoading={};}loadModel(e,t){return fT(this.requestManager.transformRequest(t,ye.Model).url).then((t=>{if(!t)return;const i=TT(t),r=new Cv(e,void 0,void 0,i);return r.computeBoundsAndApplyParent(),r})).catch((i=>{this.fire(new Ct(new Error(`Could not load model ${e} from ${t}: ${i.message}`)));}))}load(e,t){this.models[t]||(this.models[t]={});const i=Object.keys(e);this.numModelsLoading[t]=(this.numModelsLoading[t]||0)+i.length;const r=[];for(const t of i)r.push(this.loadModel(t,e[t]));Promise.allSettled(r).then((e=>{for(let r=0;r<e.length;r++){const{status:n,value:o}=e[r];"fulfilled"===n&&o&&(this.models[t][i[r]]=o);}this.numModelsLoading[t]-=i.length,this.fire(new It("data",{dataType:"style"}));})).catch((e=>{this.fire(new Ct(new Error(`Could not load models: ${e.message}`)));}));}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return !1;return !0}hasModel(e,t){return !!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.hasModel(e,i)&&this.removeModel(e,i),this.load({[e]:this.requestManager.normalizeModelURL(t)},i);}addModels(e,t){const i={};for(const t in e)i[t]=this.requestManager.normalizeModelURL(e[t]);this.load(i,t);}removeModel(e,t){this.models[t]||(this.models[t]={});const i=this.models[t][e];delete this.models[t][e],i.destroy();}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const i in this.models[t])this.models[t][i].upload(e.context);}}const YA=(e,t)=>Ss(e,t&&t.filter((e=>"source.canvas"!==e.identifier))),KA=O(OT,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection","setCamera","addImport","removeImport","setImportUrl","setImportData","setImportConfig"]),JA=O(OT,["setCenter","setZoom","setBearing","setPitch"]),QA={version:8,layers:[],sources:{}},eS={duration:300,delay:0},tS=new Set(["fill","line","background","hillshade","raster"]);class iS extends zt{constructor(e,t={}){super(),this.map=e,this.scope=t.scope||"",this.fragments=[],this.importDepth=t.importDepth||0,this.importsCache=t.importsCache||new Map,this.resolvedImports=t.resolvedImports||new Set,this.transition=k({},eS),this._buildingIndex=new DT(this),this.crossTileSymbolIndex=new CE,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=t.styleChanges||new Ea,this.dispatcher=t.dispatcher?t.dispatcher:new Ew(Ww(),this),t.imageManager?this.imageManager=t.imageManager:(this.imageManager=new aw,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=t.glyphManager?t.glyphManager:new og(e._requestManager,t.localFontFamily?2:t.localIdeographFontFamily?1:0,t.localFontFamily||t.localIdeographFontFamily),t.modelManager?this.modelManager=t.modelManager:(this.modelManager=new XA(e._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this.options=new Map,this._configDependentLayers=new Set,this._config=t.config,this.dispatcher.broadcast("setReferrer",ve());const i=this;this._rtlTextPluginCallback=iS.registerForPluginStateChange((e=>{i.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,t)=>{if(Qs(e),t&&t.every((e=>e)))for(const e in i._sourceCaches){const t=i._sourceCaches[e],r=t.getSource().type;"vector"!==r&&"geojson"!==r||t.reload();}}));})),this.on("data",(e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getOwnSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i);}}));}loadURL(e,t={}){this.fire(new It("dataloading",{dataType:"style"}));const i="boolean"==typeof t.validate?t.validate:!Pe(e);e=this.map._requestManager.normalizeStyleURL(e,t.accessToken),this.resolvedImports.add(e);const r=this.importsCache.get(e);if(r)return this._load(r,i);const n=this.map._requestManager.transformRequest(e,ye.Style);this._request=we(n,((t,r)=>{if(this._request=null,t)this.fire(new Ct(t));else if(r)return this.importsCache.set(e,r),this._load(r,i)}));}loadJSON(e,t={}){this.fire(new It("dataloading",{dataType:"style"})),this._request=dt.frame((()=>{this._request=null,this._load(e,!1!==t.validate);}));}loadEmpty(){this.fire(new It("dataloading",{dataType:"style"})),this._load(QA,!1);}_loadImports(e,t){if(this.importDepth>=4)return H("Style doesn't support nesting deeper than 5"),Promise.resolve();const i=[];for(const r of e){const e=this._createFragmentStyle(r),n=new Promise((t=>{e.once("style.import.load",t),e.once("error",t);})).then((()=>this.mergeAll()));if(i.push(n),this.resolvedImports.has(r.url)){e.loadEmpty();continue}const o=r.data||this.importsCache.get(r.url);o?e.loadJSON(o,{validate:t}):r.url?e.loadURL(r.url,{validate:t}):e.loadEmpty(),this.fragments.push({style:e,id:r.id,config:r.config});}return Promise.allSettled(i)}_createFragmentStyle(e){const t=this.scope?va(e.id,this.scope):e.id,i=new iS(this.map,{scope:t,styleChanges:this._changes,importDepth:this.importDepth+1,importsCache:this.importsCache,resolvedImports:new Set(this.resolvedImports),dispatcher:this.dispatcher,imageManager:this.imageManager,glyphManager:this.glyphManager,modelManager:this.modelManager,config:e.config});return i.setEventedParent(this.map,{style:i}),i}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options});const e=this.isRootStyle();this._shouldPrecompile=e,this.fire(new It(e?"style.load":"style.import.load"));}_load(e,t){const i=e.schema;if(this.isRootStyle()&&(e.fragment||i&&!1!==e.fragment)){const i=k({},QA,{imports:[{id:"basemap",data:e,url:""}]});return void this._load(i,t)}if(this.setConfig(this._config,i),t&&YA(this,ms(e)))return;this._loaded=!0,this.stylesheet=$(e);for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1,isInitialLoad:!0});e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(e.glyphs,this.scope);const r=kT(this.stylesheet.layers);if(this._order=r.map((e=>e.id)),this.stylesheet.light&&H("The `light` root property is deprecated, prefer using `lights` with `flat` light type instead."),this.stylesheet.lights)if(1===this.stylesheet.lights.length&&"flat"===this.stylesheet.lights[0].type){const e=this.stylesheet.lights[0];this.light=new cw(e.properties,e.id);}else this.setLights(this.stylesheet.lights);this.light||(this.light=new cw(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const e of r){const t=ow(e,this.options);t.setScope(this.scope),t.isConfigDependent&&this._configDependentLayers.add(t.fqid),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize();const i=this.getOwnLayerSourceCache(t),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();i&&t.canCastShadows()&&r&&(i.castsShadows=!0);}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const n=this.stylesheet.terrain;n&&(void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=dt.hasCanvasFingerprintNoise()),this.disableElevatedTerrain?H("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."):this.terrainSetForDrapingOnly()||this._createTerrain(n,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new It("data",{dataType:"style"})),e.imports?this._loadImports(e.imports,t).then((()=>this._reloadImports())):this._reloadImports();}isRootStyle(){return 0===this.importDepth}mergeAll(){let e,t,i,r,n,o,s,a;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((l=>{if(l.stylesheet){if(null!=l.light&&(e=l.light),l.stylesheet.lights)for(const e of l.stylesheet.lights)"ambient"===e.type&&null!=l.ambientLight&&(t=l.ambientLight),"directional"===e.type&&null!=l.directionalLight&&(i=l.directionalLight);r=this._prioritizeTerrain(r,l.terrain,l.stylesheet.terrain),l.stylesheet.fog&&null!=l.fog&&(n=l.fog),null!=l.stylesheet.camera&&(a=l.stylesheet.camera),null!=l.stylesheet.projection&&(o=l.stylesheet.projection),null!=l.stylesheet.transition&&(s=l.stylesheet.transition);}})),this.light=e,this.ambientLight=t,this.directionalLight=i,this.fog=n,null===r?delete this.terrain:this.terrain=r,this.camera=a||{"camera-projection":"perspective"},this.projection=o||{name:"mercator"},this.transition=k({},eS,s),this.mergeSources(),this.mergeLayers();}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i);};t(this);}_prioritizeTerrain(e,t,i){const r=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:r?e:null:null!=t&&(!e||r||t&&1===t.drapeRenderMode)?t:e}mergeTerrain(){let e;this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((t=>{e=this._prioritizeTerrain(e,t.terrain,t.stylesheet.terrain);})),null===e?delete this.terrain:this.terrain=e;}mergeProjection(){let e;this.forEachFragmentStyle((t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection);})),this.projection=e||{name:"mercator"};}mergeSources(){const e={},t={},i={};this.forEachFragmentStyle((r=>{for(const t in r._sourceCaches){const i=va(t,r.scope);e[i]=r._sourceCaches[t];}for(const e in r._otherSourceCaches){const i=va(e,r.scope);t[i]=r._otherSourceCaches[e];}for(const e in r._symbolSourceCaches){const t=va(e,r.scope);i[t]=r._symbolSourceCaches[e];}})),this._mergedSourceCaches=e,this._mergedOtherSourceCaches=t,this._mergedSymbolSourceCaches=i;}mergeLayers(){const e={},t=[],i={};this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((i=>{for(const r of i._order){const n=i._layers[r];if("slot"===n.type){const t=ba(r);if(e[t])continue;e[t]=[];}n.slot&&e[n.slot]?e[n.slot].push(n):t.push(n);}})),this._mergedOrder=[];const r=(t=[])=>{for(const n of t)if("slot"===n.type){const t=ba(n.id);e[t]&&r(e[t]);}else {const e=va(n.id,n.scope);this._mergedOrder.push(e),i[e]=n,n.is3D()&&(this._has3DLayers=!0),"circle"===n.type&&(this._hasCircleLayers=!0),"symbol"===n.type&&(this._hasSymbolLayers=!0);}};r(t),this._mergedLayers=i,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged();}terrainSetForDrapingOnly(){return !!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera=k({},this.stylesheet.camera,e),this.camera=this.stylesheet.camera,this}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.mergeProjection(),this._updateMapProjection();}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null));}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection));}_loadSprite(e){this._spriteRequest=function(e,t,i){let r,n,o;const s=dt.devicePixelRatio>1?"@2x":"";let a=we(t.transformRequest(t.normalizeSpriteURL(e,s,".json"),ye.SpriteJSON),((e,t)=>{a=null,o||(o=e,r=t,c());})),l=Ie(t.transformRequest(t.normalizeSpriteURL(e,s,".png"),ye.SpriteImage),((e,t)=>{l=null,o||(o=e,n=t,c());}));function c(){if(o)i(o);else if(r&&n){const e=dt.getImageData(n),t={};for(const i in r){const{width:n,height:o,x:s,y:a,sdf:l,pixelRatio:c,stretchX:h,stretchY:u,content:d}=r[i],p=new ef({width:n,height:o});ef.copy(e,p,{x:s,y:a},{x:0,y:0},{width:n,height:o}),t[i]={data:p,pixelRatio:c,sdf:l,stretchX:h,stretchY:u,content:d};}i(null,t);}}return {cancel(){a&&(a.cancel(),a=null),l&&(l.cancel(),l=null);}}}(e,this.map._requestManager,((e,t)=>{if(this._spriteRequest=null,e)this.fire(new Ct(e));else if(t)for(const e in t)this.imageManager.addImage(e,this.scope,t[e]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new It("data",{dataType:"style"}));}));}_validateLayer(e){const t=this.getOwnSource(e.source);if(!t)return;const i=e.sourceLayer;i&&("geojson"===t.type||t.vectorLayerIds&&-1===t.vectorLayerIds.indexOf(i))&&this.fire(new Ct(new Error(`Source layer "${i}" does not exist on source "${t.id}" as specified by style layer "${e.id}"`)));}loaded(){if(!this._loaded)return !1;if(Object.keys(this._changes.getUpdatedSourceCaches()).length)return !1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return !1;if(!this.imageManager.isLoaded())return !1;if(!this.modelManager.isLoaded())return !1;for(const{style:e}of this.fragments)if(!e.loaded())return !1;return !0}_serializeImports(){if(this.stylesheet.imports)return this.stylesheet.imports.map(((e,t)=>{const i=this.fragments[t];return i&&i.style&&(e.data=i.style.serialize()),e}))}_serializeSources(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize());}return e}_serializeLayers(e){const t=[];for(const i of e){const e=this._layers[i];e&&"custom"!==e.type&&t.push(e.serialize());}return t}hasLightTransitions(){return !(!this.light||!this.light.hasTransition())||!(!this.ambientLight||!this.ambientLight.hasTransition())||!(!this.directionalLight||!this.directionalLight.hasTransition())}hasFogTransition(){return !!this.fog&&this.fog.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return !0;if(this.hasFogTransition())return !0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}isLayerDraped(e){return !!this.terrain&&("function"==typeof e.isLayerDraped?e.isLayerDraped(this.getLayerSourceCache(e)):tS.has(e.type))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(e){const t=this.getOwnLayer(e);if(t)return t;this.fire(new Ct(new Error(`The layer '${e}' does not exist in the map's style.`)));}_checkSource(e){const t=this.getOwnSource(e);if(t)return t;this.fire(new Ct(new Error(`The source '${e}' does not exist in the map's style.`)));}update(e){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(e),this.directionalLight&&this.directionalLight.recalculate(e);const t=this.calculateLightsBrightness();e.brightness=t||0,t!==this._brightness&&(this._brightness=t,this.dispatcher.broadcast("setBrightness",t));const i=this._changes.isDirty();if(this._changes.isDirty()){const t=this._changes.getLayerUpdatesByScope();for(const e in t){const{updatedIds:i,removedIds:r}=t[e];(i||r)&&this._updateWorkerLayers(e,i,r);}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(e),this.light&&this.light.updateTransitions(e),this.ambientLight&&this.ambientLight.updateTransitions(e),this.directionalLight&&this.directionalLight.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._changes.reset();}const r={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];r[e]=t.used,t.used=!1;}for(const t of this._mergedOrder){const i=this._mergedLayers[t];if(i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)){const e=this.getLayerSourceCache(i);e&&(e.used=!0);}if(!this._precompileDone&&this._shouldPrecompile)for(let t=i.minzoom||0;t<(i.maxzoom||25.5);t++){const t=this.map.painter;if(t){const r=i.getProgramIds();if(!r)continue;for(const n of r){const r=i.getDefaultProgramParams(n,e.zoom);r&&(t.style=this,this.fog&&(t._fogVisible=!0,r.overrideFog=!0,t.getOrCreateProgram(n,r)),t._fogVisible=!1,r.overrideFog=!1,t.getOrCreateProgram(n,r),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(r.overrideRtt=!0,t.getOrCreateProgram(n,r)));}}}}this._shouldPrecompile&&(this._precompileDone=!0);for(const e in r){const t=this._mergedSourceCaches[e];r[e]!==t.used&&t.getSource().fire(new It("data",{sourceDataType:"visibility",dataType:"source",sourceId:t.getSource().id}));}this.light&&this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),i&&this.fire(new It("data",{dataType:"style"}));}_updateTilesForChangedImages(){const e=this._changes.getUpdatedImages();if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changes.resetUpdatedImages();}}_updateWorkerLayers(e,t,i){const r=this.getFragmentStyle(e);r&&this.dispatcher.broadcast("updateLayers",{layers:t?r._serializeLayers(t):[],scope:e,removedIds:i||[],options:r.options});}setState(e){if(this._checkLoaded(),YA(this,ms(e)))return !1;(e=$(e)).layers=kT(e.layers);const t=function(e,t){if(!e)return [{command:OT.setStyle,args:[t]}];let i=[];try{if(!x(e.version,t.version))return [{command:OT.setStyle,args:[t]}];x(e.center,t.center)||i.push({command:OT.setCenter,args:[t.center]}),x(e.zoom,t.zoom)||i.push({command:OT.setZoom,args:[t.zoom]}),x(e.bearing,t.bearing)||i.push({command:OT.setBearing,args:[t.bearing]}),x(e.pitch,t.pitch)||i.push({command:OT.setPitch,args:[t.pitch]}),x(e.sprite,t.sprite)||i.push({command:OT.setSprite,args:[t.sprite]}),x(e.glyphs,t.glyphs)||i.push({command:OT.setGlyphs,args:[t.glyphs]}),x(e.imports,t.imports)||function(e=[],t=[],i){t=t||[];const r=(e=e||[]).map(jT),n=t.map(jT),o=e.reduce(GT,{}),s=t.reduce(GT,{}),a=r.slice();let l,c,h,u;for(l=0,c=0;l<r.length;l++)h=r[l],s.hasOwnProperty(h)?c++:(i.push({command:OT.removeImport,args:[h]}),a.splice(a.indexOf(h,c),1));for(l=0,c=0;l<n.length;l++)h=n[n.length-1-l],a[a.length-1-l]!==h&&(o.hasOwnProperty(h)?(i.push({command:OT.removeImport,args:[h]}),a.splice(a.lastIndexOf(h,a.length-c),1)):c++,u=a[a.length-l],i.push({command:OT.addImport,args:[s[h],u]}),a.splice(a.length-l,0,h));for(const e of t){const t=o[e.id];if(!t||x(t,e))continue;x(t.config,e.config)||i.push({command:OT.setImportConfig,args:[e.id,e.config]}),x(t.url,e.url)||i.push({command:OT.setImportUrl,args:[e.id,e.url]});const r=e.data;x(t&&t.data,r)||i.push({command:OT.setImportData,args:[e.id,r]});}}(e.imports,t.imports,i),x(e.transition,t.transition)||i.push({command:OT.setTransition,args:[t.transition]}),x(e.light,t.light)||i.push({command:OT.setLight,args:[t.light]}),x(e.fog,t.fog)||i.push({command:OT.setFog,args:[t.fog]}),x(e.projection,t.projection)||i.push({command:OT.setProjection,args:[t.projection]}),x(e.lights,t.lights)||i.push({command:OT.setLights,args:[t.lights]}),x(e.camera,t.camera)||i.push({command:OT.setCamera,args:[t.camera]});const r={},n=[];!function(e,t,i,r){let n;for(n in t=t||{},e=e||{})e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||FT(n,i,r));for(n in t){if(!t.hasOwnProperty(n))continue;const o=t[n];e.hasOwnProperty(n)?x(e[n],o)||("geojson"===e[n].type&&"geojson"===o.type&&UT(e,t,n)?i.push({command:OT.setGeoJSONSourceData,args:[n,o.data]}):NT(n,t,i,r)):BT(n,t,i);}}(e.sources,t.sources,n,r);const o=[];e.layers&&e.layers.forEach((e=>{e.source&&r[e.source]?i.push({command:OT.removeLayer,args:[e.id]}):o.push(e);}));let s=e.terrain;s&&r[s.source]&&(i.push({command:OT.setTerrain,args:[void 0]}),s=void 0),i=i.concat(n),x(s,t.terrain)||i.push({command:OT.setTerrain,args:[t.terrain]}),function(e,t,i){t=t||[];const r=(e=e||[]).map(jT),n=t.map(jT),o=e.reduce(GT,{}),s=t.reduce(GT,{}),a=r.slice(),l=Object.create(null);let c,h,u,d,p,f,m;for(c=0,h=0;c<r.length;c++)u=r[c],s.hasOwnProperty(u)?h++:(i.push({command:OT.removeLayer,args:[u]}),a.splice(a.indexOf(u,h),1));for(c=0,h=0;c<n.length;c++)u=n[n.length-1-c],a[a.length-1-c]!==u&&(o.hasOwnProperty(u)?(i.push({command:OT.removeLayer,args:[u]}),a.splice(a.lastIndexOf(u,a.length-h),1)):h++,f=a[a.length-c],i.push({command:OT.addLayer,args:[s[u],f]}),a.splice(a.length-c,0,u),l[u]=!0);for(c=0;c<n.length;c++)if(u=n[c],d=o[u],p=s[u],!l[u]&&!x(d,p))if(x(d.source,p.source)&&x(d["source-layer"],p["source-layer"])&&x(d.type,p.type)){for(m in VT(d.layout,p.layout,i,u,null,OT.setLayoutProperty),VT(d.paint,p.paint,i,u,null,OT.setPaintProperty),x(d.slot,p.slot)||i.push({command:OT.setSlot,args:[u,p.slot]}),x(d.filter,p.filter)||i.push({command:OT.setFilter,args:[u,p.filter]}),x(d.minzoom,p.minzoom)&&x(d.maxzoom,p.maxzoom)||i.push({command:OT.setLayerZoomRange,args:[u,p.minzoom,p.maxzoom]}),d)d.hasOwnProperty(m)&&"layout"!==m&&"paint"!==m&&"filter"!==m&&"metadata"!==m&&"minzoom"!==m&&"maxzoom"!==m&&"slot"!==m&&(0===m.indexOf("paint.")?VT(d[m],p[m],i,u,m.slice(6),OT.setPaintProperty):x(d[m],p[m])||i.push({command:OT.setLayerProperty,args:[u,m,p[m]]}));for(m in p)p.hasOwnProperty(m)&&!d.hasOwnProperty(m)&&"layout"!==m&&"paint"!==m&&"filter"!==m&&"metadata"!==m&&"minzoom"!==m&&"maxzoom"!==m&&"slot"!==m&&(0===m.indexOf("paint.")?VT(d[m],p[m],i,u,m.slice(6),OT.setPaintProperty):x(d[m],p[m])||i.push({command:OT.setLayerProperty,args:[u,m,p[m]]}));}else i.push({command:OT.removeLayer,args:[u]}),f=a[a.lastIndexOf(u)+1],i.push({command:OT.addLayer,args:[p,f]});}(o,t.layers,i);}catch(e){console.warn("Unable to compute style diff:",e),i=[{command:OT.setStyle,args:[t]}];}return i}(this.serialize(),e).filter((e=>!(e.command in JA)));if(0===t.length)return !1;const i=t.filter((e=>!(e.command in KA)));if(i.length>0)throw new Error(`Unimplemented: ${i.map((e=>e.command)).join(", ")}.`);return t.forEach((e=>{this[e.command].apply(this,e.args);})),this.stylesheet=e,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(e,t){return this.getImage(e)?this.fire(new Ct(new Error("An image with this name already exists."))):(this.imageManager.addImage(e,this.scope,t),this._afterImageUpdated(e),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t);}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e,this.scope),this._afterImageUpdated(e),this):this.fire(new Ct(new Error("No image with this name exists.")))}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(this.scope),this._changes.updateImage(e),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages}),this.fire(new It("data",{dataType:"style"}));}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,i={}){return this._checkLoaded(),this._validate(Ms,`models.${e}`,t,null,i)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(e){return this.hasModel(e)?(this.modelManager.removeModel(e,this.scope),this):this.fire(new Ct(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(e,t,i={}){if(this._checkLoaded(),void 0!==this.getOwnSource(e))throw new Error(`There is already a source with ID "${e}".`);if(!t.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(t).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(t.type)>=0&&this._validate(_s,`sources.${e}`,t,null,i))return;this.map&&this.map._collectResourceTiming&&(t.collectResourceTiming=!0);const r=ST(e,t,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id})));const n=e=>{const t=(e?"symbol:":"other:")+r.id,i=va(t,this.scope),n=this._sourceCaches[t]=new Lx(i,r,e);(e?this._symbolSourceCaches:this._otherSourceCaches)[r.id]=n,n.onAdd(this.map);};n(!1),"vector"!==t.type&&"geojson"!==t.type||n(!0),r.onAdd&&r.onAdd(this.map),i.isInitialLoad||(this.mergeSources(),this._changes.setDirty());}removeSource(e){this._checkLoaded();const t=this.getOwnSource(e);if(!t)throw new Error("There is no source with this ID");for(const t in this._layers)if(this._layers[t].source===e)return this.fire(new Ct(new Error(`Source "${e}" cannot be removed while layer "${t}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===e)return this.fire(new Ct(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const i=this.getOwnSourceCaches(e);for(const e of i){const t=ba(e.id);delete this._sourceCaches[t],this._changes.discardSourceCacheUpdate(e.id),e.fire(new It("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles();}return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],this.mergeSources(),t.setEventedParent(null),t.onRemove&&t.onRemove(this.map),this._changes.setDirty(),this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getOwnSource(e).setData(t),this._changes.setDirty();}getOwnSource(e){const t=this.getOwnSourceCache(e);return t&&t.getSource()}getOwnSources(){const e=[];for(const t in this._otherSourceCaches){const i=this.getOwnSourceCache(t);i&&e.push(i.getSource());}return e}setLights(e){if(this._checkLoaded(),!e)return delete this.ambientLight,void delete this.directionalLight;const t=this._getTransitionParameters();for(const i of e){if(this._validate(ys,"lights",i))return;switch(i.type){case"ambient":if(this.ambientLight){const e=this.ambientLight;e.set(i),e.updateTransitions(t);}else this.ambientLight=new Mw(i,Aw,this.scope,this.options);break;case"directional":if(this.directionalLight){const e=this.directionalLight;e.set(i),e.updateTransitions(t);}else this.directionalLight=new Mw(i,Sw,this.scope,this.options);}}const i=new oa(this.z||0,t);this.ambientLight&&this.ambientLight.recalculate(i),this.directionalLight&&this.directionalLight.recalculate(i),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness);}calculateLightsBrightness(){const e=this.directionalLight,t=this.ambientLight;if(!e||!t)return;const i=e=>.2126*(e[0]<=.03928?e[0]/12.92:Math.pow((e[0]+.055)/1.055,2.4))+.7152*(e[1]<=.03928?e[1]/12.92:Math.pow((e[1]+.055)/1.055,2.4))+.0722*(e[2]<=.03928?e[2]/12.92:Math.pow((e[2]+.055)/1.055,2.4)),r=e.properties.get("color").toArray01(),n=e.properties.get("intensity"),o=e.properties.get("direction"),s=1-J(o.x,o.y,o.z)[2]/90,a=i(r)*n*s,l=t.properties.get("color").toArray01(),c=t.properties.get("intensity");return (a+i(l)*c)/2}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return !!this.ambientLight&&!!this.directionalLight}getFragmentStyle(e){if(!e)return this;if(xa(e)){const t=function(e){const t=e.indexOf(ya);return t>=0?e.slice(t+1):""}(e),i=this.fragments.find((({id:e})=>e===t));if(!i)throw new Error(`Style import not found: ${e}`);const r=ba(e);return i.style.getFragmentStyle(r)}{const t=this.fragments.find((({id:t})=>t===e));if(!t)throw new Error(`Style import not found: ${e}`);return t.style}}getConfigProperty(e,t){const i=this.getFragmentStyle(e);if(!i)return null;const r=i.options.get(t),n=r?r.value||r.default:null;return n?n.serialize():null}setConfigProperty(e,t,i){const r=Eo(i);if("success"!==r.result)return void YA(this,r.value);const n=r.value.expression,o=this.getFragmentStyle(e);if(!o)return;const s=o.options.get(t);s&&(o.options.set(t,{...s,value:n}),o.updateConfigDependencies());}setConfig(e,t){if(this._config=e,e||t)if(t){this.options.clear();for(const i in t){let r,n;const o=Eo(t[i].default);if("success"===o.result&&(r=o.value.expression),e&&void 0!==e[i]){const t=Eo(e[i]);"success"===t.result&&(n=t.value.expression);}const{minValue:s,maxValue:a,stepValue:l,type:c,values:h}=t[i];r?this.options.set(i,{default:r,value:n,minValue:s,maxValue:a,stepValue:l,type:c,values:h}):this.fire(new Ct(new Error(`No schema defined for config option "${i}".`)));}}else this.fire(new Ct(new Error("Attempting to set config for a style without schema.")));}updateConfigDependencies(){for(const e of this._configDependentLayers){const t=this.getLayer(e);t&&(t.possiblyEvaluateVisibility(),this._updateLayer(t));}this.ambientLight&&this.ambientLight.scope===this.scope&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.scope===this.scope&&this.directionalLight.updateConfig(this.options),this._changes.setDirty();}addLayer(e,t,i={}){this._checkLoaded();const r=e.id;if(this._layers[r])return void this.fire(new Ct(new Error(`Layer with id "${r}" already exists on this map`)));let n;if("custom"===e.type){if(YA(this,function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t}(e)))return;n=ow(e,this.options);}else {if("object"==typeof e.source&&(this.addSource(r,e.source),e=k(e=$(e),{source:r})),this._validate(bs,`layers.${r}`,e,{arrayIndex:-1},i))return;n=ow(e,this.options),this._validateLayer(n),n.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[n.id]=n.serialize();}n.isConfigDependent&&this._configDependentLayers.add(n.fqid),n.setScope(this.scope);let o=this._order.length;if(t){const e=this._order.indexOf(t);if(-1===e)return void this.fire(new Ct(new Error(`Layer with id "${t}" does not exist on this map.`)));n.slot===this._layers[t].slot?o=e:H(`Layer with id "${t}" has a different slot. Layers can only be rearranged within the same slot.`);}this._order.splice(o,0,r),this._layerOrderChanged=!0,this._layers[r]=n;const s=this.getOwnLayerSourceCache(n),a=!!this.directionalLight&&this.directionalLight.shadowsEnabled();s&&n.canCastShadows()&&a&&(s.castsShadows=!0);const l=this._changes.getRemovedLayer(n);if(l&&n.source&&s&&"custom"!==n.type){this._changes.discardLayerRemoval(n);const e=va(n.source,n.scope);l.type!==n.type?this._changes.updateSourceCache(e,"clear"):(this._changes.updateSourceCache(e,"reload"),s.pause());}this._updateLayer(n),n.onAdd&&n.onAdd(this.map),n.scope=this.scope,this.mergeLayers();}moveLayer(e,t){this._checkLoaded();const i=this._checkLayer(e);if(!i)return;if(e===t)return;const r=this._order.indexOf(e);this._order.splice(r,1);let n=this._order.length;if(t){const e=this._order.indexOf(t);if(-1===e)return void this.fire(new Ct(new Error(`Layer with id "${t}" does not exist on this map.`)));i.slot===this._layers[t].slot?n=e:H(`Layer with id "${t}" has a different slot. Layers can only be rearranged within the same slot.`);}this._order.splice(n,0,e),this._changes.setDirty(),this._layerOrderChanged=!0,this.mergeLayers();}removeLayer(e){this._checkLoaded();const t=this._checkLayer(e);if(!t)return;t.setEventedParent(null);const i=this._order.indexOf(e);this._order.splice(i,1),delete this._layers[e],delete this._serializedLayers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const r=this.getOwnLayerSourceCache(t);if(r&&r.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}r.castsShadows=e;}t.onRemove&&t.onRemove(this.map),this.mergeLayers();}getOwnLayer(e){return this._layers[e]}hasLayer(e){return e in this._mergedLayers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return !0;return !1}setLayerZoomRange(e,t,i){this._checkLoaded();const r=this._checkLayer(e);r&&(r.minzoom===t&&r.maxzoom===i||(null!=t&&(r.minzoom=t),null!=i&&(r.maxzoom=i),this._updateLayer(r)));}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i));}setFilter(e,t,i={}){this._checkLoaded();const r=this._checkLayer(e);if(r&&!x(r.filter,t))return null==t?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(ws,`layers.${r.id}.filter`,t,{layerType:r.type},i)||(r.filter=$(t),this._updateLayer(r)))}getFilter(e){const t=this._checkLayer(e);if(t)return $(t.filter)}setLayoutProperty(e,t,i,r={}){this._checkLoaded();const n=this._checkLayer(e);n&&(x(n.getLayoutProperty(t),i)||(n.setLayoutProperty(t,i,r),n.isConfigDependent&&this._configDependentLayers.add(n.fqid),this._updateLayer(n)));}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(e,t,i,r={}){this._checkLoaded();const n=this._checkLayer(e);if(!n)return;if(x(n.getPaintProperty(t),i))return;const o=n.setPaintProperty(t,i,r);n.isConfigDependent&&this._configDependentLayers.add(n.fqid),o&&this._updateLayer(n),this._changes.updatePaintProperties(n);}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(e,t){this._checkLoaded();const i=e.source,r=e.sourceLayer,n=this._checkSource(i);if(!n)return;const o=n.type;if("geojson"===o&&r)return void this.fire(new Ct(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===o&&!r)return void this.fire(new Ct(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new Ct(new Error("The feature id parameter must be provided.")));const s=this.getOwnSourceCaches(i);for(const i of s)i.setFeatureState(r,e.id,t);}removeFeatureState(e,t){this._checkLoaded();const i=e.source,r=this._checkSource(i);if(!r)return;const n=r.type,o="vector"===n?e.sourceLayer:void 0;if("vector"===n&&!o)return void this.fire(new Ct(new Error("The sourceLayer parameter must be provided for vector source types.")));if(t&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new Ct(new Error("A feature id is required to remove its specific state property.")));const s=this.getOwnSourceCaches(i);for(const i of s)i.removeFeatureState(o,e.id,t);}getFeatureState(e){this._checkLoaded();const t=e.source,i=e.sourceLayer,r=this._checkSource(t);if(r){if("vector"!==r.type||i)return void 0===e.id&&this.fire(new Ct(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(t)[0].getFeatureState(i,e.id);this.fire(new Ct(new Error("The sourceLayer parameter must be provided for vector source types.")));}}setTransition(e){return this.stylesheet.transition=k({},this.stylesheet.transition,e),this.transition=this.stylesheet.transition,this}getTransition(){return k({},this.stylesheet.transition)}serialize(){this._checkLoaded();const e=this.getTerrain(),t=e&&this.terrain&&this.terrain.scope===this.scope?e:this.stylesheet.terrain;return Z({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:t,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:this._serializeSources(),layers:this._serializeLayers(this._order)},(e=>void 0!==e))}_updateLayer(e){this._changes.updateLayer(e);const t=this.getLayerSourceCache(e),i=va(e.source,e.scope),r=this._changes.getUpdatedSourceCaches();e.source&&!r[i]&&t&&"raster"!==t.getSource().type&&(this._changes.updateSourceCache(i,"reload"),t.pause()),e.invalidateCompiledFilter();}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._mergedLayers[e].type,i=this.order,r={},n=[];for(let o=i.length-1;o>=0;o--){const s=i[o];if(t(s)){r[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)n.push(t);}}}n.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const o=[];for(let s=i.length-1;s>=0;s--){const a=i[s];if(t(a))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(r[t.layer.id]<s)break;o.push(t),n.pop();}else for(const t of e){const e=t[a];if(e)for(const t of e)o.push(t.feature);}}return o}queryRenderedFeatures(e,t,i){t&&t.filter&&this._validate(ws,"queryRenderedFeatures.filter",t.filter,null,t),t.scope=this.scope,t.availableImages=this._availableImages,t.serializedLayers=this._serializedLayers;const r={};if(t&&t.layers){if(!Array.isArray(t.layers))return this.fire(new Ct(new Error("parameters.layers must be an Array."))),[];for(const e of t.layers){const t=this._mergedLayers[e];if(!t)return this.fire(new Ct(new Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];r[t.source]=!0;}}const n=[],o=t.serializedLayers||{},s=t&&t.layers?t.layers.some((e=>{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),a=Iw.createFromScreenPoints(e,i);for(const e in this._mergedSourceCaches){const l=this._mergedSourceCaches[e].getSource();if(!l||l.scope!==t.scope)continue;const c=this._mergedSourceCaches[e].getSource().id;t.layers&&!r[c]||n.push(CT(this._mergedSourceCaches[e],this._mergedLayers,o,a,t,i,s,!!this.map._showQueryGeometry));}return this.placement&&n.push(function(e,t,i,r,n,o,s){const a={},l=o.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(PT);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,n.filter,n.layers,n.availableImages,e);for(const e in r){const t=a[e]=a[e]||[],n=r[e];n.sort(((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of n)t.push(e);}}for(const t in a)a[t].forEach((r=>{const n=r.feature,o=i(e[t]);if(!o)return;const s=o.getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=s;}));return a}(this._mergedLayers,o,this.getLayerSourceCache.bind(this),a.screenGeometry,t,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(e,t){t&&t.filter&&this._validate(ws,"querySourceFeatures.filter",t.filter,null,t);const i=this.getOwnSourceCaches(e);let r=[];for(const e of i)r=r.concat(zT(e,t));return r}addSourceType(e,t,i){return iS.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(iS.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(e,t,i={}){this._checkLoaded();const r=this.light.getLight();let n=!1;for(const t in e)if(!x(e[t],r[t])){n=!0;break}if(!n)return;const o=this._getTransitionParameters();this.light.setLight(e,t,i),this.light.updateTransitions(o);}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0);}setTerrain(e,t=1){if(this._checkLoaded(),!e)return delete this.terrain,null===e?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let i=e;const r=null==e.source;if(1===t){if("object"==typeof i.source){const e="terrain-dem-src";this.addSource(e,i.source),i=$(i),i=k(i,{source:e});}const e=k({},i),t={};if(this.terrain&&r){e.source=this.terrain.get().source;const i=this.terrain?this.getFragmentStyle(this.terrain.scope):null;i&&(t.style=i.serialize());}if(this._validate(xs,"terrain",e,t))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&t!==this.terrain.drapeRenderMode){if(!i)return;this._createTerrain(i,t),this.fire(new It("data",{dataType:"style"}));}else {const t=this.terrain,r=t.get();for(const e of Object.keys(Pt.terrain))!i.hasOwnProperty(e)&&Pt.terrain[e].default&&(i[e]=Pt.terrain[e].default);for(const i in e)if(!x(e[i],r[i])){t.set(e,this.options),this.stylesheet.terrain=e;const i=this._getTransitionParameters({duration:0});t.updateTransitions(i),this.fire(new It("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0;}_createFog(e){const t=this.fog=new vw(e,this.map.transform);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity();}));}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const t=this.fog;if(!x(t.get(),e)){t.set(e),this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}}else this._createFog(e);this._markersNeedUpdate=!0;}_getTransitionParameters(e){return {now:dt.now(),transition:k(this.transition,e)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i in this._mergedLayers)this.isLayerDraped(this._mergedLayers[i])?e.push(i):t.push(i);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t);}_createTerrain(e,t){const i=this.terrain=new uw(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const r=this._getTransitionParameters({duration:0});i.updateTransitions(r);}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t);}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t);}}_validate(e,t,i,r,n={}){if(n&&!1===n.validate)return !1;const o=k({},this.serialize());return YA(this,e.call(ms,k({key:t,style:o,value:i,styleSpec:Pt},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),ta.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.dispatcher.remove());}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles();}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles();}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload();}reloadSources(){for(const e of this.getSources())e.reload&&e.reload();}updateSources(e){let t;this.directionalLight&&(t=$A(this.directionalLight));for(const i in this._mergedSourceCaches)this._mergedSourceCaches[i].update(e,void 0,void 0,t);}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload();}}_updatePlacement(e,t,i,r,n=!1){let o=!1,s=!1;const a={},l={};for(const t of this._mergedOrder){const i=this._mergedLayers[t];if("symbol"!==i.type)continue;const r=va(i.source,i.scope);let n=a[r];if(!n){const e=this.getLayerSourceCache(i);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));l[r]=t.slice(),n=a[r]=t.sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const s=this.crossTileSymbolIndex.addLayer(i,n,e.center.lng,e.projection);o=o||s;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),n=n||this._layerOrderChanged||0===i,this._layerOrderChanged&&this.fire(new It("neworder")),(n||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(dt.now(),e.zoom))&&(this.pauseablePlacement=new gE(e,this._mergedOrder,n,t,i,r,this.placement,this.fog&&e.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,a,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(dt.now()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(const e of this._mergedOrder){const t=this._mergedLayers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,a[va(t.source,t.scope)]);}return !this.pauseablePlacement.isDone()||this.placement.hasTransitions(dt.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles();}addImport(e){this._checkLoaded();const t=this.stylesheet.imports=this.stylesheet.imports||[],i=t.findIndex((({id:t})=>t===e.id));return -1!==i?this.fire(new Ct(new Error(`Import with id '${e.id}' already exists in the map's style.`))):(t.push(e),this._loadImports([e],!0),this)}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],r=this.getImportIndex(e);if(-1===r)return this;i[r].url=t;const n=this.fragments[r];return n.style=this._createFragmentStyle(i[r]),n.style.on("style.import.load",(()=>this.mergeAll())),n.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),r=this.stylesheet.imports||[];return -1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete r[i].data,this.setImportUrl(e,r[i].url))}setImportConfig(e,t){this._checkLoaded();const i=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===i)return this;t?r[i].config=t:delete r[i].config;const n=this.fragments[i],o=n.style.stylesheet&&n.style.stylesheet.schema;return n.config=t,n.style.setConfig(t,o),n.style.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);return -1===i||(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports()),this}getImportIndex(e){const t=(this.stylesheet.imports||[]).findIndex((t=>t.id===e));return -1===t&&this.fire(new Ct(new Error(`Import '${e}' does not exist in the map's style and cannot be updated.`))),t}getLayer(e){return this._mergedLayers[e]}getSources(){const e=[];for(const t in this._mergedOtherSourceCaches){const i=this._mergedOtherSourceCaches[t];i&&e.push(i.getSource());}return e}getSource(e,t){const i=this.getSourceCache(e,t);return i&&i.getSource()}getLayerSource(e){const t=this.getLayerSourceCache(e);return t&&t.getSource()}getSourceCache(e,t){const i=va(e,t);return this._mergedOtherSourceCaches[i]}getLayerSourceCache(e){const t=va(e.source,e.scope);return "symbol"===e.type?this._mergedSymbolSourceCaches[t]:this._mergedOtherSourceCaches[t]}getSourceCaches(e){const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),t}updateSourceCaches(){const e=this._changes.getUpdatedSourceCaches();for(const t in e){const i=e[t];"reload"===i?this.reloadSource(t):"clear"===i&&this.clearSource(t);}}updateLayers(e){const t=this._changes.getUpdatedPaintProperties();for(const i of t){const t=this.getLayer(i);t&&t.updateTransitions(e);}}getImages(e,t,i){this.imageManager.getImages(t.icons,t.scope,i),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons);};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source]);}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,t.scope,i);}getResource(e,t,i){return be(t,i)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return "symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(e){const t=this.getOwnSourceCaches(e);return 0===t.length?(this.fire(new Ct(new Error(`There is no source with ID '${e}'`))),!1):t.every((e=>e.loaded()))}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches");}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain);}}function rS(e,t){let i=!1,r=null;const n=()=>{r=null,i&&(e(),r=setTimeout(n,t),i=!1);};return ()=>(i=!0,r||n(),r)}iS.getSourceType=function(e){return AT[e]},iS.setSourceType=function(e,t){AT[e]=t;},iS.registerForPluginStateChange=function(e){return e({pluginStatus:Ks,pluginURL:Js}),ta.on("pluginStateChange",e),e};class nS{constructor(e){this._hashName=e&&encodeURIComponent(e),j(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=rS(this._updateHashUnthrottled.bind(this),300);}addTo(e){return this._map=e,t.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),t.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return "";const i=oS(e);if(this._hashName){const e=this._hashName;let r=!1;const n=t.location.hash.slice(1).split("&").map((t=>{const n=t.split("=")[0];return n===e?(r=!0,`${n}=${i}`):t})).filter((e=>e));return r||n.push(`${e}=${i}`),`#${n.join("&")}`}return `#${i}`}_getCurrentHash(){const e=t.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((e=>e.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e);})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const e=this._map;if(!e)return !1;const t=this._getCurrentHash();if(t.length>=3&&!t.some((e=>isNaN(e)))){const i=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:i,pitch:+(t[4]||0)}),!0}return !1}_updateHashUnthrottled(){const e=t.location.href.replace(/(#.+)?$/,this.getHashString());t.history.replaceState(t.history.state,null,e);}}function oS(e,t){const i=e.getCenter(),r=Math.round(100*e.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,n),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let h=t?`/${s}/${a}/${r}`:`${r}/${a}/${s}`;return (l||c)&&(h+="/"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const sS={linearity:.3,easing:I(0,0,.3,1)},aS=k({deceleration:2500,maxSpeed:1400},sS),lS=k({deceleration:20,maxSpeed:1400},sS),cS=k({deceleration:1e3,maxSpeed:360},sS),hS=k({deceleration:1e3,maxSpeed:90},sS);class uS{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:dt.now(),settings:e});}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=dt.now();for(;e.length>0&&t-e[0].time>160;)e.shift();}_onMoveEnd(e){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const t={zoom:0,bearing:0,pitch:0,pan:new y(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)t.zoom+=e.zoomDelta||0,t.bearing+=e.bearingDelta||0,t.pitch+=e.pitchDelta||0,e.panDelta&&t.pan._add(e.panDelta),e.around&&(t.around=e.around),e.pinchAround&&(t.pinchAround=e.pinchAround);const i=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(t.pan.mag()){const n=pS(t.pan.mag(),i,k({},aS,e||{}));r.offset=t.pan.mult(n.amount/t.pan.mag()),r.center=this._map.transform.center,dS(r,n);}if(t.zoom){const e=pS(t.zoom,i,lS);r.zoom=this._map.transform.zoom+e.amount,dS(r,e);}if(t.bearing){const e=pS(t.bearing,i,cS);r.bearing=this._map.transform.bearing+z(e.amount,-179,179),dS(r,e);}if(t.pitch){const e=pS(t.pitch,i,hS);r.pitch=this._map.transform.pitch+e.amount,dS(r,e);}if(r.zoom||r.bearing){const e=void 0===t.pinchAround?t.around:t.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter();}return this.clear(),r.noMoveStart=!0,r}}function dS(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing);}function pS(e,t,i){const{maxSpeed:r,linearity:n,deceleration:o}=i,s=z(e*n/(t/1e3),-r,r),a=Math.abs(s)/(o*n);return {easing:i.easing,duration:1e3*a,amount:s*(a/2)}}class fS extends It{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i,r={}){const n=wt(t.getCanvasContainer(),i);super(e,k({point:n,lngLat:t.unproject(n),originalEvent:i},r)),this._defaultPrevented=!1,this.target=t;}}class mS extends It{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){const r="touchend"===e?i.changedTouches:i.touches,n=Tt(t.getCanvasContainer(),r),o=n.map((e=>t.unproject(e))),s=n.reduce(((e,t,i,r)=>e.add(t.div(r.length))),new y(0,0));super(e,{points:n,point:s,lngLats:o,lngLat:t.unproject(s),originalEvent:i}),this._defaultPrevented=!1;}}class _S extends It{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1;}}class gS{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){this._mousedownPos=void 0;}wheel(e){return this._firePreventable(new _S(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new fS(e.type,this._map,e))}mouseup(e){this._map.fire(new fS(e.type,this._map,e));}preclick(e){const t=k({},e);t.type="preclick",this._map.fire(new fS(t.type,this._map,t));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new fS(e.type,this._map,e)));}dblclick(e){return this._firePreventable(new fS(e.type,this._map,e))}mouseover(e){this._map.fire(new fS(e.type,this._map,e));}mouseout(e){this._map.fire(new fS(e.type,this._map,e));}touchstart(e){return this._firePreventable(new mS(e.type,this._map,e))}touchmove(e){this._map.fire(new mS(e.type,this._map,e));}touchend(e){this._map.fire(new mS(e.type,this._map,e));}touchcancel(e){this._map.fire(new mS(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class yS{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0;}mousemove(e){this._map.fire(new fS(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new fS("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new fS(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class xS{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1;}isEnabled(){return !!this._enabled}isActive(){return !!this._active}enable(){this.isEnabled()||(this._enabled=!0);}disable(){this.isEnabled()&&(this._enabled=!1);}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(yt(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t,r=this._startPos,n=this._lastPos;if(!r||!n||n.equals(i)||!this._box&&i.dist(r)<this._clickTolerance)return;this._lastPos=i,this._box||(this._box=pt("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const o=Math.min(r.x,i.x),s=Math.max(r.x,i.x),a=Math.min(r.y,i.y),l=Math.max(r.y,i.y);this._map._requestDomTask((()=>{this._box&&(this._box.style.transform=`translate(${o}px,${a}px)`,this._box.style.width=s-o+"px",this._box.style.height=l-a+"px");}));}mouseupWindow(e,t){if(!this._active)return;const i=this._startPos,r=t;if(i&&0===e.button){if(this.reset(),bt(),i.x!==r.x||i.y!==r.y)return this._map.fire(new It("boxzoomend",{originalEvent:e})),{cameraAnimation:e=>e.fitScreenCoordinates(i,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e);}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e));}blur(){this.reset();}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),xt(),delete this._startPos,delete this._lastPos;}_fireEvent(e,t){return this._map.fire(new It(e,{originalEvent:t}))}}function vS(e,t){const i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}class bS{constructor(e){this.reset(),this.numTouches=e.numTouches;}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1;}touchstart(e,t,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),i.length===this.numTouches&&(this.centroid=function(e){const t=new y(0,0);for(const i of e)t._add(i);return t.div(e.length)}(t),this.touches=vS(i,t)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=vS(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0);}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class wS{constructor(e){this.singleTap=new bS(e),this.numTaps=e.numTaps,this.reset();}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset();}touchstart(e,t,i){this.singleTap.touchstart(e,t,i);}touchmove(e,t,i){this.singleTap.touchmove(e,t,i);}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class TS{constructor(){this._zoomIn=new wS({numTouches:1,numTaps:2}),this._zoomOut=new wS({numTouches:2,numTaps:1}),this.reset();}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset();}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i);}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i);}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),n=this._zoomOut.touchend(e,t,i);return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}const ES={0:1,2:2};class MS{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1;}blur(){this.reset();}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0;}_correctButton(e,t){return !1}_move(e,t){return {}}mousedown(e,t){if(this._lastPoint)return;const i=Et(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i);}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const i=ES[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(i,t)}mouseupWindow(e){this._lastPoint&&Et(e)===this._eventButton&&(this._moved&&bt(),this.reset());}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class AS extends MS{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0);}_correctButton(e,t){return 0===t&&!e.ctrlKey}_move(e,t){return {around:t,panDelta:t.sub(e)}}}class SS extends MS{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const i=.8*(t.x-e.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(e){e.preventDefault();}}class IS extends MS{_correctButton(e,t){return 0===t&&e.ctrlKey||2===t}_move(e,t){const i=-.5*(t.y-e.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(e){e.preventDefault();}}class CS{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._minTouches=1,this._clickTolerance=t.clickTolerance||1,this.reset(),j(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this);}reset(){this._active=!1,this._touches={},this._sum=new y(0,0);}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active&&!(i.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===i.length&&!ie())return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer));}return e.cancelable&&e.preventDefault(),this._calculateTransform(e,t,i)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&i.length<this._minTouches&&this.reset();}touchcancel(){this.reset();}_calculateTransform(e,t,i){i.length>0&&(this._active=!0);const r=vS(i,t),n=new y(0,0),o=new y(0,0);let s=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(n._add(t),o._add(t.sub(i)),s++,r[e]=t);}if(this._touches=r,s<this._minTouches||!o.mag())return;const a=o.div(s);return this._sum._add(a),this._sum.mag()<this._clickTolerance?void 0:{around:n.div(s),panDelta:a}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"));}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset();}isEnabled(){return !!this._enabled}isActive(){return !!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=pt("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`);}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null");}),500);}}class zS{constructor(){this.reset();}reset(){this._active=!1,this._firstTwoTouches=void 0;}_start(e){}_move(e,t,i){return {}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]));}touchmove(e,t,i){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[n,o]=r,s=PS(i,t,n),a=PS(i,t,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=PS(i,t,r),s=PS(i,t,n);o&&s||(this._active&&bt(),this.reset());}touchcancel(){this.reset();}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}function PS(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}function DS(e,t){return Math.log(e/t)/Math.LN2}class RS extends zS{reset(){super.reset(),this._distance=0,this._startDistance=0;}_start(e){this._startDistance=this._distance=e[0].dist(e[1]);}_move(e,t){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(DS(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:DS(this._distance,i),pinchAround:t}}}function LS(e,t){return 180*e.angleWith(t)/Math.PI}class kS extends zS{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0;}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1]);}_move(e,t){const i=this._vector;if(this._vector=e[0].sub(e[1]),i&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:LS(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=25/(Math.PI*this._minDiameter)*360,i=this._startVector;if(!i)return !1;const r=LS(e,i);return Math.abs(r)<t}}function OS(e){return Math.abs(e.y)>Math.abs(e.x)}class BS extends zS{constructor(e){super(),this._map=e;}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0;}_start(e){this._lastPoints=e,OS(e[0].sub(e[1]))&&(this._valid=!1);}_move(e,t,i){const r=this._lastPoints;if(!r)return;const n=e[0].sub(r[0]),o=e[1].sub(r[1]);return this._map._cooperativeGestures&&!ie()&&i.touches.length<3||(this._valid=this.gestureBeginsVertically(n,o,i.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+o.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return OS(e)&&OS(t)&&o}}const FS={panStep:100,bearingStep:15,pitchStep:10};class NS{constructor(){const e=FS;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1;}blur(){this.reset();}reset(){this._active=!1;}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:US,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0;}enableRotation(){this._rotationDisabled=!1;}}function US(e){return e*(2-e)}const VS=4.000244140625;class jS{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._handler=t,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,j(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this);}setZoomRate(e){this._defaultZoomRate=e;}setWheelZoomRate(e){this._wheelZoomRate=e;}isEnabled(){return !!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return !!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker());}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()));}wheel(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(e.ctrlKey||e.metaKey||this.isZooming()||ie()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer));}let i=e.deltaMode===t.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const r=dt.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%VS==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(n*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),e.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=e,this._delta-=i,this._active||this._start(e)),e.preventDefault();}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e);}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=wt(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame());}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._map.transform;"wheel"===this._type&&e.projection.wrap&&(e._center.lng>=180||e._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const t=()=>e._terrainEnabled()&&this._aroundCoord?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>VS?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const n=t(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(s*r))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0;}const i="number"==typeof this._targetZoom?this._targetZoom:t(),r=this._startZoom,n=this._easing;let o,s=!1;if("wheel"===this._type&&r&&n){const e=Math.min((dt.now()-this._lastWheelEventTime)/200,1);o=Kr(r,i,n(e)),e<1?this._frameId||(this._frameId=!0):s=!0;}else o=i,s=!0;this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;}),200));let a=o-t();return a*this._lastDelta<0&&(a=0),{noInertia:!0,needsRenderFrame:!s,zoomDelta:a,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let t=C;if(this._prevEase){const e=this._prevEase,i=(dt.now()-e.start)/e.duration,r=e.easing(i+.01)-e.easing(i),n=.27/Math.sqrt(r*r+1e-4)*.01;t=I(n,Math.sqrt(.0729-n*n),.25,1);}return this._prevEase={start:dt.now(),duration:e,easing:t},t}blur(){this.reset();}reset(){this._active=!1;}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=pt("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(t.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`);}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null");}),200);}}class GS{constructor(e,t){this._clickZoom=e,this._tapZoom=t;}enable(){this._clickZoom.enable(),this._tapZoom.enable();}disable(){this._clickZoom.disable(),this._tapZoom.disable();}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class qS{constructor(){this.reset();}reset(){this._active=!1;}blur(){this.reset();}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e});}}}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class ZS{constructor(){this._tap=new wS({numTouches:1,numTaps:1}),this.reset();}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset();}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i));}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,i);}touchend(e,t,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(e,t,i)&&(this._tapTime=e.timeStamp);}touchcancel(){this.reset();}enable(){this._enabled=!0;}disable(){this._enabled=!1,this.reset();}isEnabled(){return this._enabled}isActive(){return this._active}}class $S{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i;}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan");}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan");}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class WS{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i;}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable();}disable(){this._mouseRotate.disable(),this._mousePitch.disable();}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class HS{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0;}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate");}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate");}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable();}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable();}}const XS=e=>e.zoom||e.drag||e.pitch||e.rotate;class YS extends It{}class KS{constructor(){this.constants=[1,1,.01],this.radius=0;}setup(e,t){const i=Du.sub([],t,e);this.radius=Du.length(i[2]<0?Du.div([],i,this.constants):[i[0],i[1],0]);}projectRay(e){Du.div(e,e,this.constants),Du.normalize(e,e),Du.mul(e,e,this.constants);const t=Du.scale([],e,this.radius);if(t[2]>0){const e=Du.scale([],[0,0,1],Du.dot(t,[0,0,1])),i=Du.scale([],Du.normalize([],[t[0],t[1],0]),this.radius),r=Du.add([],t,Du.scale([],Du.sub([],Du.add([],i,e),t),2));t[0]=r[0],t[1]=r[1];}return t}}function JS(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class QS{constructor(e,i){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new uS(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new KS,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),j(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[t.document,"mousemove",{capture:!0}],[t.document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[t,"blur",void 0]];for(const[e,i,r]of this._listeners)e.addEventListener(i,e===t.document?this.handleWindowEvent:this.handleEvent,r);}destroy(){for(const[e,i,r]of this._listeners)e.removeEventListener(i,e===t.document?this.handleWindowEvent:this.handleEvent,r);}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new gS(t,e));const r=t.boxZoom=new xS(t,e);this._add("boxZoom",r);const n=new TS,o=new qS;t.doubleClickZoom=new GS(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new ZS;this._add("tapDragZoom",s);const a=t.touchPitch=new BS(t);this._add("touchPitch",a);const l=new SS(e),c=new IS(e);t.dragRotate=new WS(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new AS(e),u=new CS(t,e);t.dragPan=new $S(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const d=new kS,p=new RS;t.touchZoomRotate=new HS(i,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new yS(t));const f=t.scrollZoom=new jS(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new NS;this._add("keyboard",m);for(const i of ["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[i]&&t[i].enable(e[i]);}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t;}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[],this._originalZoom=void 0;}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return !0;return !1}isZooming(){return !!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return !!this._eventsInProgress.rotate}isMoving(){return !!XS(this._eventsInProgress)||this.isZooming()}_isDragging(){return !!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return !0;return !1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`);}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,r=i?void 0:e,n={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?Tt(this._el,a):i?void 0:wt(this._el,e);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let u;this._blockedByActive(s,h,i)?c.reset():c[t||e.type]&&(u=c[t||e.type](e,l,a),this.mergeHandlerResult(n,o,u,i,r),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(s[i]=c);}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=r);this._previousActiveHandlers=s,(Object.keys(c).length||JS(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||JS(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=n;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map));}mergeHandlerResult(e,t,i,r,n){if(!i)return;k(e,i);const o={handlerName:r,originalEvent:i.originalEvent||n};void 0!==i.zoomDelta&&(t.zoom=o),void 0!==i.panDelta&&(t.drag=o),void 0!==i.pitchDelta&&(t.pitch=o),void 0!==i.bearingDelta&&(t.rotate=o);}_applyChanges(){const e={},t={},i={};for(const[r,n,o]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new y(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.aroundCoord&&(e.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),k(t,n),k(i,o);this._updateMapTransform(e,t,i),this._changes=[];}_updateMapTransform(e,t,i){const r=this._map,n=r.transform,o=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!JS(e)){const e=n.zoom;n.cameraElevationReference="sea",null!=this._originalZoom&&n._orthographicProjectionAtLowPitch&&"globe"!==n.projection.name&&0===n.pitch?(n.cameraElevationReference="ground",n.zoom=this._originalZoom):(n.recenterOnTerrain(),n.cameraElevationReference="ground"),e!==n.zoom&&this._map._update(!0);}if(n._isCameraConstrained&&r._stop(!0),!JS(e))return void this._fireEvents(t,i,!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,around:h,aroundCoord:u,pinchAround:d}=e;n._isCameraConstrained&&(a>0&&(a=0),n._isCameraConstrained=!1),void 0!==d&&(h=d),(a||(e=>t[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=o(n.pointCoordinate3D(h)),this._originalZoom=n.zoom,this._trackingEllipsoid.setup(n._camera.position,this._dragOrigin)),n.cameraElevationReference="sea",r._stop(!0),h=h||r.transform.centerPoint,l&&(n.bearing+=l),c&&(n.pitch+=c),n._updateCameraState();const p=[0,0,0];if(s)if("mercator"===n.projection.name){const e=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(n.screenPointToMercatorRay(h.sub(s)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1];}else {const e=n.pointCoordinate(h);if("globe"===n.projection.name){s=s.rotate(-n.angle);const t=n._pixelsPerMercatorPixel/n.worldSize;p[0]=-s.x*sp(tp(e.y))*t,p[1]=-s.y*sp(n.center.lat)*t;}else {const t=n.pointCoordinate(h.sub(s));e&&t&&(p[0]=t.x-e.x,p[1]=t.y-e.y);}}const f=n.zoom,m=[0,0,0];if(a){const e=o(u||n.pointCoordinate3D(h)),t={dir:Du.normalize([],Du.sub([],e,n._camera.position))};if(t.dir[2]<0){const i=n.zoomDeltaToMovement(e,a);Du.scale(m,t.dir,i);}}const _=Du.add(p,p,m);n._translateCameraConstrained(_),a&&Math.abs(n.zoom-f)>1e-4&&n.recenterOnTerrain(),n.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0);}_fireEvents(e,t,i){const r=XS(this._eventsInProgress),n=XS(e),o={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(o[`${t}start`]=i),this._eventsInProgress[t]=e[t];}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(const e in o)this._fireEvent(e,o[e]);n&&this._fireEvent("move",n.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i);}const s={};let a;for(const e in this._eventsInProgress){const{handlerName:i,originalEvent:r}=this._eventsInProgress[e];this._handlersById[i].isActive()||(delete this._eventsInProgress[e],a=t[i]||r,s[`${e}end`]=a);}for(const e in s)this._fireEvent(e,s[e]);const l=XS(this._eventsInProgress);if(i&&(r||n)&&!l){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),t=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;e?(t(e.bearing||this._map.getBearing())&&(e.bearing=0),this._map.easeTo(e,{originalEvent:a})):(this._map.fire(new It("moveend",{originalEvent:a})),t(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1;}}_fireEvent(e,t){this._map.fire(new It(e,t?{originalEvent:t}:{}));}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{this._frameId=void 0,this.handleEvent(new YS("renderFrame",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}const eI="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class tI extends zt{constructor(e,t){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=t.bearingSnap,this._respectPrefersReducedMotion=!1!==t.respectPrefersReducedMotion,j(["_renderFrameCallback"],this);}getCenter(){return new Wd(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(e,t,i){return e=y.convert(e).mult(-1),this.panTo(this.transform.center,k({offset:e},t),i)}panTo(e,t,i){return this.easeTo(k({center:e},t),i)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,t,i){return this.easeTo(k({zoom:e},t),i)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,t,i){return this.easeTo(k({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,k({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(k({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}cameraForBounds(e,t){e=sc.convert(e);const i=t&&t.bearing||0,r=t&&t.pitch||0,n=e.getNorthWest(),o=e.getSouthEast();return this._cameraForBounds(this.transform,n,o,i,r,t)}_extendCameraOptions(e){const t={top:0,bottom:0,right:0,left:0};if("number"==typeof(e=k({padding:t,offset:[0,0],maxZoom:this.transform.maxZoom},e)).padding){const t=e.padding;e.padding={top:t,bottom:t,right:t,left:t};}return e.padding=k(t,e.padding),e}_minimumAABBFrustumDistance(e,t){const i=t.max[0]-t.min[0],r=t.max[1]-t.min[1];return i/r>e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):r/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(e,t,i,r,n,o){const s=e.clone(),a=this._extendCameraOptions(o);s.bearing=r,s.pitch=n;const l=Wd.convert(t),c=Wd.convert(i),h=.5*(l.lat+c.lat),u=.5*(l.lng+c.lng),d=wd(h,u),p=Du.normalize([],d),f=Du.normalize([],Du.cross([],p,[0,1,0])),m=Du.cross([],f,p),_=[f[0],f[1],f[2],0,m[0],m[1],m[2],0,p[0],p[1],p[2],0,0,0,0,1],g=[d,wd(l.lat,l.lng),wd(c.lat,l.lng),wd(c.lat,c.lng),wd(l.lat,c.lng),wd(h,l.lng),wd(h,c.lng),wd(l.lat,u),wd(c.lat,u)];let y=ed.fromPoints(g.map((e=>[Du.dot(f,e),Du.dot(m,e),Du.dot(p,e)])));const x=Du.transformMat4([],y.center,_);0===Du.squaredLength(x)&&Du.set(x,0,0,1),Du.normalize(x,x),Du.scale(x,x,rd),s.center=function([e,t,i]){const r=Math.hypot(e,t,i),n=Math.atan2(e,i),o=.5*Math.PI-Math.acos(-t/r);return new Wd(T(n),T(o))}(x);const v=s.getWorldToCameraMatrix(),b=Au.invert(new Float64Array(16),v);y=ed.applyTransform(y,Au.multiply([],v,_)),Du.transformMat4(x,x,v);const w=.5*(y.max[2]-y.min[2]),E=this._minimumAABBFrustumDistance(s,y),M=Du.scale([],[0,0,1],w),A=Du.add(M,x,M),S=E+(0===s.pitch?0:Du.distance(x,A)),I=s.globeCenterInViewSpace,C=Du.sub([],x,[I[0],I[1],I[2]]);Du.normalize(C,C),Du.scale(C,C,S);const z=Du.add([],x,C);Du.transformMat4(z,z,b);const P=qd/rd,D=Du.length(z),R=Qd(Math.max(D*P-qd,Number.EPSILON),0),L=Math.min(s.zoomFromMercatorZAdjusted(R),a.maxZoom);return L>.5*(td+id)?(s.setProjection({name:"mercator"}),s.zoom=L,this._cameraForBounds(s,t,i,r,n,o)):{center:s.center,zoom:L,bearing:r,pitch:n}}queryTerrainElevation(e,t){const i=this.transform.elevation;return i?(t=k({},{exaggerated:!0},t),i.getAtPoint(lp.fromLngLat(e),null,t.exaggerated)):null}_cameraForBounds(e,t,i,r,n,o){if("globe"===e.projection.name)return this._cameraForBoundsOnGlobe(e,t,i,r,n,o);const s=e.clone(),a=this._extendCameraOptions(o),l=s.padding;s.bearing=r,s.pitch=n;const c=Wd.convert(t),h=Wd.convert(i),u=new Wd(c.lng,h.lat),d=new Wd(h.lng,c.lat),p=s.project(c),f=s.project(h),m=this.queryTerrainElevation(c),_=this.queryTerrainElevation(h),g=this.queryTerrainElevation(u),x=this.queryTerrainElevation(d),v=[[p.x,p.y,Math.min(m||0,_||0,g||0,x||0)],[f.x,f.y,Math.max(m||0,_||0,g||0,x||0)]];let b=ed.fromPoints(v);const T=s.getWorldToCameraMatrix(),E=Au.invert(new Float64Array(16),T);b=ed.applyTransform(b,T);const M=Du.sub([],b.max,b.min),A=l.left||0,S=l.right||0,I=l.bottom||0,C=l.top||0,{left:z,right:P,top:D,bottom:R}=a.padding,L=.5*(A+S),k=.5*(C+I),O=Math.min(s.scaleZoom(s.scale*Math.min((s.width-(A+S+z+P))/M[0],(s.height-(I+C+R+D))/M[1])),a.maxZoom),B=s.scale/s.zoomScale(O);b=new ed([b.min[0]-(z+L)*B,b.min[1]-(R+k)*B,b.min[2]],[b.max[0]+(P+L)*B,b.max[1]+(D+k)*B,b.max[2]]);const F=.5*M[2],N=this._minimumAABBFrustumDistance(s,b),U=[0,0,1,0];yu.transformMat4(U,U,T),yu.normalize(U,U);const V=Du.scale([],U,N+F),j=Du.add([],b.center,V),G=("number"==typeof a.offset.x&&"number"==typeof a.offset.y?new y(a.offset.x,a.offset.y):y.convert(a.offset)).rotate(-w(r));b.center[0]-=G.x*B,b.center[1]+=G.y*B,Du.transformMat4(b.center,b.center,E),Du.transformMat4(j,j,E);const q=[b.center[0],b.center[1],j[2]*s.pixelsPerMeter];Du.scale(q,q,1/s.worldSize);const Z=ep(q[0]),$=tp(q[1]),W=Math.min(s._zoomFromMercatorZ(q[2]),a.maxZoom),H=new Wd(Z,$);return s.mercatorFromTransition&&W<.5*(td+id)?(s.setProjection({name:"globe"}),s.zoom=W,this._cameraForBounds(s,t,i,r,n,o)):{center:H,zoom:W,bearing:r,pitch:n}}fitBounds(e,t,i){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,i)}fitScreenCoordinates(e,t,i,r,n){const o=y.convert(e),s=y.convert(t),a=new y(Math.min(o.x,s.x),Math.min(o.y,s.y)),l=new y(Math.max(o.x,s.x),Math.max(o.y,s.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(o,s))return this;const c=this.transform.pointLocation3D(a),h=this.transform.pointLocation3D(l),u=this.transform.pointLocation3D(new y(a.x,l.y)),d=this.transform.pointLocation3D(new y(l.x,a.y)),p=[Math.min(c.lng,h.lng,u.lng,d.lng),Math.min(c.lat,h.lat,u.lat,d.lat)],f=[Math.max(c.lng,h.lng,u.lng,d.lng),Math.max(c.lat,h.lat,u.lat,d.lat)],m=r&&r.pitch?r.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,p,f,i,m,r);return this._fitInternal(_,r,n)}_fitInternal(e,t,i){return e?(delete(t=k(e,t)).padding,t.linear?this.easeTo(t,i):this.flyTo(t,i)):this}jumpTo(e,t){this.stop();const i=e.preloadOnly?this.transform.clone():this.transform;let r=!1,n=!1,o=!1;return "zoom"in e&&i.zoom!==+e.zoom&&(r=!0,i.zoom=+e.zoom),void 0!==e.center&&(i.center=Wd.convert(e.center)),"bearing"in e&&i.bearing!==+e.bearing&&(n=!0,i.bearing=+e.bearing),"pitch"in e&&i.pitch!==+e.pitch&&(o=!0,i.pitch=+e.pitch),null==e.padding||i.isPaddingEqual(e.padding)||(i.padding=e.padding),e.preloadOnly?(this._preloadTiles(i),this):(this.fire(new It("movestart",t)).fire(new It("move",t)),r&&this.fire(new It("zoomstart",t)).fire(new It("zoom",t)).fire(new It("zoomend",t)),n&&this.fire(new It("rotatestart",t)).fire(new It("rotate",t)).fire(new It("rotateend",t)),o&&this.fire(new It("pitchstart",t)).fire(new It("pitch",t)).fire(new It("pitchend",t)),this.fire(new It("moveend",t)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||H(eI),this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,t){const i=this.transform;if(!i.projection.supportsFreeCamera)return H(eI),this;this.stop();const r=i.zoom,n=i.pitch,o=i.bearing;i.setFreeCameraOptions(e);const s=r!==i.zoom,a=n!==i.pitch,l=o!==i.bearing;return this.fire(new It("movestart",t)).fire(new It("move",t)),s&&this.fire(new It("zoomstart",t)).fire(new It("zoom",t)).fire(new It("zoomend",t)),l&&this.fire(new It("rotatestart",t)).fire(new It("rotate",t)).fire(new It("rotateend",t)),a&&this.fire(new It("pitchstart",t)).fire(new It("pitch",t)).fire(new It("pitchend",t)),this.fire(new It("moveend",t)),this}easeTo(e,t){this._stop(!1,e.easeId),(!1===(e=k({offset:[0,0],duration:500,easing:C},e)).animate||this._prefersReducedMotion(e))&&(e.duration=0);const i=this.transform,r=this.getZoom(),n=this.getBearing(),o=this.getPitch(),s=this.getPadding(),a="zoom"in e?+e.zoom:r,l="bearing"in e?this._normalizeBearing(e.bearing,n):n,c="pitch"in e?+e.pitch:o,h="padding"in e?e.padding:i.padding,u=y.convert(e.offset);let d,p,f;if("globe"===i.projection.name){const t=lp.fromLngLat(i.center),r=u.rotate(-i.angle);t.x+=r.x/i.worldSize,t.y+=r.y/i.worldSize;const n=t.toLngLat(),o=Wd.convert(e.center||n);this._normalizeCenter(o),d=i.centerPoint.add(r),p=new y(t.x,t.y).mult(i.worldSize),f=new y(Kd(o.lng),Jd(o.lat)).mult(i.worldSize).sub(p);}else {d=i.centerPoint.add(u);const t=i.pointLocation(d),r=Wd.convert(e.center||t);this._normalizeCenter(r),p=i.project(t),f=i.project(r).sub(p);}const m=i.zoomScale(a-r);let _,g;e.around&&(_=Wd.convert(e.around),g=i.locationPoint(_));const x=this._zooming||a!==r,v=this._rotating||n!==l,b=this._pitching||c!==o,w=!i.isPaddingEqual(h),T=i=>y=>{if(x&&(i.zoom=Kr(r,a,y)),v&&(i.bearing=Kr(n,l,y)),b&&(i.pitch=Kr(o,c,y)),w&&(i.interpolatePadding(s,h,y),d=i.centerPoint.add(u)),_)i.setLocationAtPoint(_,g);else {const e=i.zoomScale(i.zoom-r),t=a>r?Math.min(2,m):Math.max(.5,m),n=Math.pow(t,1-y),o=i.unproject(p.add(f.mult(y*n)).mult(e));i.setLocationAtPoint(i.renderWorldCopies?o.wrap():o,d);}return e.preloadOnly||this._fireMoveEvents(t),i};if(e.preloadOnly){const t=this._emulate(T,e.duration,i);return this._preloadTiles(t),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=v,this._pitching=b,this._padding=w,this._easeId=e.easeId,this._prepareEase(t,e.noMoveStart,E),this._ease(T(i),(e=>{"sea"===i.cameraElevationReference&&i.recenterOnTerrain(),this._afterEase(t,e);}),e),this}_prepareEase(e,t,i={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),t||i.moving||this.fire(new It("movestart",e)),this._zooming&&!i.zooming&&this.fire(new It("zoomstart",e)),this._rotating&&!i.rotating&&this.fire(new It("rotatestart",e)),this._pitching&&!i.pitching&&this.fire(new It("pitchstart",e));}_fireMoveEvents(e){this.fire(new It("move",e)),this._zooming&&this.fire(new It("zoom",e)),this._rotating&&this.fire(new It("rotate",e)),this._pitching&&this.fire(new It("pitch",e));}_afterEase(e,t){if(this._easeId&&t&&this._easeId===t)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const i=this._zooming,r=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,i&&this.fire(new It("zoomend",e)),r&&this.fire(new It("rotateend",e)),n&&this.fire(new It("pitchend",e)),this.fire(new It("moveend",e));}flyTo(e,t){if(this._prefersReducedMotion(e)){const i=O(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(i,t)}this.stop(),e=k({offset:[0,0],speed:1.2,curve:1.42,easing:C},e);const i=this.transform,r=this.getZoom(),n=this.getBearing(),o=this.getPitch(),s=this.getPadding(),a="zoom"in e?z(+e.zoom,i.minZoom,i.maxZoom):r,l="bearing"in e?this._normalizeBearing(e.bearing,n):n,c="pitch"in e?+e.pitch:o,h="padding"in e?e.padding:i.padding,u=i.zoomScale(a-r),d=y.convert(e.offset);let p=i.centerPoint.add(d);const f=i.pointLocation(p),m=Wd.convert(e.center||f);this._normalizeCenter(m);const _=i.project(f),g=i.project(m).sub(_);let x=e.curve;const v=Math.max(i.width,i.height),b=v/u,w=g.mag();if("minZoom"in e){const t=z(Math.min(e.minZoom,r,a),i.minZoom,i.maxZoom),n=v/i.zoomScale(t-r);x=Math.sqrt(n/w*2);}const T=x*x;function E(e){const t=(b*b-v*v+(e?-1:1)*T*T*w*w)/(2*(e?b:v)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function M(e){return (Math.exp(e)-Math.exp(-e))/2}function A(e){return (Math.exp(e)+Math.exp(-e))/2}const S=E(0);let I=function(e){return A(S)/A(S+x*e)},P=function(e){return v*((A(S)*(M(t=S+x*e)/A(t))-M(S))/T)/w;var t;},D=(E(1)-S)/x;if(Math.abs(w)<1e-6||!isFinite(D)){if(Math.abs(v-b)<1e-6)return this.easeTo(e,t);const i=b<v?-1:1;D=Math.abs(Math.log(b/v))/x,P=function(){return 0},I=function(e){return Math.exp(i*x*e)};}e.duration="duration"in e?+e.duration:1e3*D/("screenSpeed"in e?+e.screenSpeed/x:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0);const R=n!==l,L=c!==o,B=!i.isPaddingEqual(h),F=i=>u=>{const f=u*D,y=1/I(f);i.zoom=1===u?a:r+i.scaleZoom(y),R&&(i.bearing=Kr(n,l,u)),L&&(i.pitch=Kr(o,c,u)),B&&(i.interpolatePadding(s,h,u),p=i.centerPoint.add(d));const x=1===u?m:i.unproject(_.add(g.mult(P(f))).mult(y));return i.setLocationAtPoint(i.renderWorldCopies?x.wrap():x,p),i._updateCameraOnTerrain(),e.preloadOnly||this._fireMoveEvents(t),i};if(e.preloadOnly){const t=this._emulate(F,e.duration,i);return this._preloadTiles(t),this}return this._zooming=!0,this._rotating=R,this._pitching=L,this._padding=B,this._prepareEase(t,!1),this._ease(F(i),(()=>this._afterEase(t)),e),this}isEasing(){return !!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t);}if(!e){const e=this.handlers;e&&e.stop(!1);}return this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=dt.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_renderFrameCallback(){const e=Math.min((dt.now()-this._easeStart)/this._easeOptions.duration,1),t=this._onEaseFrame;t&&t(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop();}_normalizeBearing(e,t){e=D(e,-180,180);const i=Math.abs(e-t);return Math.abs(e-360-t)<i&&(e-=360),Math.abs(e+360-t)<i&&(e+=360),e}_normalizeCenter(e){const t=this.transform;if(t.maxBounds)return;if("globe"!==t.projection.name&&!t.renderWorldCopies)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0;}_prefersReducedMotion(e){return this._respectPrefersReducedMotion&&dt.prefersReducedMotion&&!(e&&e.essential)}_emulate(e,t,i){const r=Math.ceil(15*t/1e3),n=[],o=e(i.clone());for(let e=0;e<=r;e++){const t=o(e/r);n.push(t.clone());}return n}}class iI{constructor(e={}){this.options=e,j(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this);}getDefaultPosition(){return "bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=pt("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=pt("button","mapboxgl-ctrl-attrib-button",this._container),pt("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=pt("div","mapboxgl-ctrl-attrib-inner",this._container),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0;}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",i);}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"));}_updateEditLink(){let e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const t=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||n.ACCESS_TOKEN}];if(e){const i=t.reduce(((e,i,r)=>(i.value&&(e+=`${i.key}=${i.value}${r<t.length-1?"&":""}`),e)),"?");e.href=`${n.FEEDBACK_URL}/${i}#${oS(this._map,!0)}`,e.rel="noopener nofollow",this._setElementTitle(e,"MapFeedback");}}_updateData(e){!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink());}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id;}const t=this._map.style._mergedSourceCaches;for(const i in t){const r=t[i];if(r.used){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution);}}e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,i)=>{for(let r=i+1;r<e.length;r++)if(e[r].indexOf(t)>=0)return !1;return !0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null);}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show");}}class rI{constructor(){j(["_updateLogo","_updateCompact"],this);}onAdd(e){this._map=e,this._container=pt("div","mapboxgl-ctrl");const t=pt("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact);}getDefaultPosition(){return "bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none");}_logoRequired(){if(!this._map.style)return !0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return !0;for(const t in e){const i=e[t].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return !1}return !0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact");}}}class nI{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}function oI(e,t,i){if(e=new Wd(e.lng,e.lat),t){const r=new Wd(e.lng-360,e.lat),n=new Wd(e.lng+360,e.lat),o=360*Math.ceil(Math.abs(e.lng-i.center.lng)/360),s=i.locationPoint(e).distSqr(t),a=t.x<0||t.y<0||t.x>i.width||t.y>i.height;i.locationPoint(r).distSqr(t)<s&&(a||Math.abs(r.lng-i.center.lng)<o)?e=r:i.locationPoint(n).distSqr(t)<s&&(a||Math.abs(n.lng-i.center.lng)<o)&&(e=n);}for(;Math.abs(e.lng-i.center.lng)>180;){const t=i.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=i.width&&t.y<=i.height)break;e.lng>i.center.lng?e.lng-=360:e.lng+=360;}return e}const sI={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class aI extends zt{constructor(e,i){if(super(),(e instanceof t.HTMLElement||i)&&(e=k({element:e},i)),j(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=e&&e.occludedOpacity||.2,e&&e.element)this._element=e.element,this._offset=y.convert(e&&e.offset||[0,0]);else {this._defaultMarker=!0,this._element=pt("div");const t=41,i=27,r=ft("svg",{display:"block",height:t*this._scale+"px",width:i*this._scale+"px",viewBox:`0 0 ${i} ${t}`},this._element),n=ft("radialGradient",{id:"shadowGradient"},ft("defs",{},r));ft("stop",{offset:"10%","stop-opacity":.4},n),ft("stop",{offset:"100%","stop-opacity":.05},n),ft("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},r),ft("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},r),ft("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},r),ft("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},r),this._offset=y.convert(e&&e.offset||[0,-14]);}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.hasAttribute("role")||this._element.setAttribute("role","img"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(e=>{e.preventDefault();})),this._element.addEventListener("mousedown",(e=>{e.preventDefault();}));const r=this._element.classList;for(const e in sI)r.remove(`mapboxgl-marker-anchor-${e}`);r.add(`mapboxgl-marker-anchor-${this._anchor}`);const n=e&&e.className?e.className.trim().split(/\s+/):[];r.add(...n),this._popup=null;}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=Wd.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,e._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false");}return this}_onKeyPress(e){const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup();}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return !1;const i=e.unproject(t),r=e.getFreeCameraOptions();if(!r.position)return !1;const n=r.position.toLngLat();return n.distanceTo(i)<.9*n.distanceTo(this._lngLat)}_evaluateOpacity(){const e=this._map;if(!e)return;const t=this._pos;if(!t||t.x<0||t.x>e.transform.width||t.y<0||t.y>e.transform.height)return void this._clearFadeTimer();const i=e.unproject(t);let r;e._showingGlobe()&&Nd(e.transform,this._lngLat)?r=0:(r=1-e._queryFogOpacity(i),e.transform._terrainEnabled()&&e.getTerrain()&&this._behindTerrain()&&(r*=this._occludedOpacity)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),this._fadeTimer=null;}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null);}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${sI[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `;}_calculateXYTransform(){const e=this._pos,t=this._map,i=this.getPitchAlignment();if(!t||!e||"map"!==i)return "";if(!t._showingGlobe()){const e=t.getPitch();return e?`rotateX(${e}deg)`:""}const r=T(Fd(t.transform,this._lngLat)),n=e.sub(Bd(t.transform)),o=Math.abs(n.x)+Math.abs(n.y);if(0===o)return "";const s=r/o;return `rotateX(${-n.y*s}deg) rotateY(${n.x*s}deg)`}_calculateZTransform(){const e=this._pos,t=this._map;if(!t||!e)return "";let i=0;const r=this.getRotationAlignment();if("map"===r)if(t._showingGlobe()){const e=t.project(new Wd(this._lngLat.lng,this._lngLat.lat+.001)),r=t.project(new Wd(this._lngLat.lng,this._lngLat.lat-.001)).sub(e);i=T(Math.atan2(r.y,r.x))-90;}else i=-t.getBearing();else if("horizon"===r){const r=P(4,6,t.getZoom()),n=Bd(t.transform);n.y+=r*t.transform.height;const o=e.sub(n),s=T(Math.atan2(o.y,o.x));i=(s>90?s-270:s+90)*(1-r);}return i+=this._rotation,i?`rotateZ(${i}deg)`:""}_update(e){t.cancelAnimationFrame(this._updateFrameId);const i=this._map;i&&(i.transform.renderWorldCopies&&(this._lngLat=oI(this._lngLat,this._pos,i.transform)),this._pos=i.project(this._lngLat),!0===e?this._updateFrameId=t.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM());})):this._pos=this._pos.round(),i._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(i._showingGlobe()||i.getTerrain()||i.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)));})));}getOffset(){return this._offset}setOffset(e){return this._offset=y.convert(e),this._update(),this}addClassName(e){return this._element.classList.add(e),this}removeClassName(e){return this._element.classList.remove(e),this}toggleClassName(e){return this._element.classList.toggle(e)}_onMove(e){const t=this._map;if(!t)return;const i=this._pointerdownPos,r=this._positionDelta;if(i&&r){if(!this._isDragging){const r=this._clickTolerance||t._clickTolerance;if(e.point.dist(i)<r)return;this._isDragging=!0;}this._pos=e.point.sub(r),this._lngLat=t.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new It("dragstart"))),this.fire(new It("drag"));}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const e=this._map;e&&(e.off("mousemove",this._onMove),e.off("touchmove",this._onMove)),"active"===this._state&&this.fire(new It("dragend")),this._state="inactive";}_addDragHandler(e){const t=this._map,i=this._pos;t&&i&&this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(i),this._pointerdownPos=e.point,this._state="pending",t.on("mousemove",this._onMove),t.on("touchmove",this._onMove),t.once("mouseup",this._onUp),t.once("touchend",this._onUp));}setDraggable(e){this._draggable=!!e;const t=this._map;return t&&(e?(t.on("mousedown",this._addDragHandler),t.on("touchstart",this._addDragHandler)):(t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return "auto"===this._rotationAlignment||"horizon"===this._rotationAlignment&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e||"auto",this._update(),this}getPitchAlignment(){return "auto"===this._pitchAlignment?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(e){return this._occludedOpacity=e||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const lI={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},cI=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function hI(e=new y(0,0),t="bottom"){if("number"==typeof e){const i=Math.round(Math.sqrt(.5*Math.pow(e,2)));switch(t){case"top":return new y(0,e);case"top-left":return new y(i,i);case"top-right":return new y(-i,i);case"bottom":return new y(0,-e);case"bottom-left":return new y(i,-i);case"bottom-right":return new y(-i,-i);case"left":return new y(e,0);case"right":return new y(-e,0)}return new y(0,0)}return e instanceof y||Array.isArray(e)?y.convert(e):y.convert(e[t]||[0,0])}class uI{constructor(e){this.jumpTo(e);}getValue(e){if(e<=this._startTime)return this._start;if(e>=this._endTime)return this._end;const t=M((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-t)+this._end*t}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e;}easeTo(e,t,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i;}}const dI={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},pI={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,antialias:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1},fI={showCompass:!0,showZoom:!0,visualizePitch:!1};class mI{constructor(e,t,i=!1){this._clickTolerance=10,this.element=t,this.mouseRotate=new SS({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,i&&(this.mousePitch=new IS({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),j(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),t.addEventListener("mousedown",this.mousedown),t.addEventListener("touchstart",this.touchstart,{passive:!1}),t.addEventListener("touchmove",this.touchmove),t.addEventListener("touchend",this.touchend),t.addEventListener("touchcancel",this.reset);}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),yt();}move(e,t){const i=this.map,r=this.mouseRotate.mousemoveWindow(e,t),n=r&&r.bearingDelta;if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),n=r&&r.pitchDelta;n&&i.setPitch(i.getPitch()+n);}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp();}offTemp(){xt(),t.removeEventListener("mousemove",this.mousemove),t.removeEventListener("mouseup",this.mouseup);}mousedown(e){this.down(k({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),wt(this.element,e)),t.addEventListener("mousemove",this.mousemove),t.addEventListener("mouseup",this.mouseup);}mousemove(e){this.move(e,wt(this.element,e));}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp();}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=Tt(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos));}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=Tt(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos));}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset();}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp();}}const _I={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},gI={maxWidth:100,unit:"metric"},yI={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},xI={version:i,supported:rt,setRTLTextPlugin:function(e,t,i=!1){if(Ks===Ws||Ks===Hs||Ks===Xs)throw new Error("setRTLTextPlugin cannot be called multiple times.");Js=dt.resolveURL(e),Ks=Ws,Ys=t,ea(),i||ra();},getRTLTextPluginStatus:ia,Map:class extends tI{constructor(e){Qe.mark(Je.create);const i=e;if(null!=(e=k({},pI,e)).minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(e.antialias&&function(e){const t=e.navigator?e.navigator.userAgent:null;return !!function(e){if(null==te){const t=e.navigator?e.navigator.userAgent:null;te=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")));}return te}(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))}(t)&&(e.antialias=!1,H("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Tv(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),e),this._interactive=e.interactive,this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=e.crossSourceCollisions,this._collectResourceTiming=e.collectResourceTiming,this._language=this._parseLanguage(e.language),this._worldview=e.worldview,this._renderTaskQueue=new nI,this._domRenderTaskQueue=new nI,this._controls=[],this._markers=[],this._popups=[],this._mapId=F(),this._locale=k({},dI,e.locale),this._clickTolerance=e.clickTolerance,this._cooperativeGestures=e.cooperativeGestures,this._performanceMetricsCollection=e.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new uI(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new ze(e.transformRequest,e.accessToken,e.testMode),this._silenceAuthErrors=!!e.testMode,this._contextCreateOptions=e.contextCreateOptions?{...e.contextCreateOptions}:{},"string"==typeof e.container){if(this._container=t.document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container.toString()}' not found.`)}else {if(!(e.container instanceof t.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container;}if(this._container.childNodes.length>0&&H("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),e.maxBounds&&this.setMaxBounds(e.maxBounds),j(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");if(this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),void 0!==t&&(this._fullscreenchangeEvent="onfullscreenchange"in t.document?"fullscreenchange":"webkitfullscreenchange",t.addEventListener("online",this._onWindowOnline,!1),t.addEventListener("resize",this._onWindowResize,!1),t.addEventListener("orientationchange",this._onWindowResize,!1),t.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),t.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new QS(this,e),this._localFontFamily=e.localFontFamily,this._localIdeographFontFamily=e.localIdeographFontFamily,(e.style||!e.testMode)&&this.setStyle(e.style||n.DEFAULT_STYLE,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),e.projection&&this.setProjection(e.projection),e.hash&&(this._hash=new nS("string"==typeof e.hash&&e.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==i.center&&null==i.zoom||(this.transform._unmodified=!1),this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch});const t=e.bounds;t&&(this.resize(),this.fitBounds(t,k({},e.fitBoundsOptions,{duration:0})));}this.resize(),e.attributionControl&&this.addControl(new iI({customAttribution:e.customAttribution})),this._logoControl=new rI,this.addControl(this._logoControl,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet);})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new It(`${e.dataType}data`,e));})),this.on("dataloading",(e=>{this.fire(new It(`${e.dataType}dataloading`,e));}));}_getMapId(){return this._mapId}addControl(e,t){if(void 0===t&&(t=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new Ct(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const i=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[t];return -1!==t.indexOf("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new Ct(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(e);return t>-1&&this._controls.splice(t,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const t=!this._moving;return t&&this.fire(new It("movestart",e)).fire(new It("move",e)),this.fire(new It("resize",e)),t&&this.fire(new It("moveend",e)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(sc.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()<e?this.setZoom(e):this.fire(new It("zoomstart")).fire(new It("zoom")).fire(new It("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e=null==e?22:e)>=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new It("zoomstart")).fire(new It("zoom")).fire(new It("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()<e?this.setPitch(e):this.fire(new It("pitchstart")).fire(new It("pitch")).fire(new It("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e=null==e?85:e)>85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new It("pitchstart")).fire(new It("pitch")).fire(new It("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return "auto"===e?t.navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((e=>"auto"===e?t.navigator.language:e)):e}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style.reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style.reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return "globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.projection)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const e=this.transform,t=e.projection.name;let i;"globe"===t&&e.zoom>=id?(e.setMercatorFromTransition(),i=!0):"mercator"===t&&e.zoom<id&&(e.setProjection({name:"globe"}),i=!0),i&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate());}_prioritizeAndUpdateProjection(e,t){return this._updateProjection(e||t||{name:"mercator"})}_updateProjection(e){let t;return t="globe"===e.name&&this.transform.zoom>=id?this.transform.setMercatorFromTransition():this.transform.setProjection(e),this.style.applyProjectionUpdate(),t&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(e){return this.transform.locationPoint3D(Wd.convert(e))}unproject(e){return this.transform.pointLocation3D(y.convert(e))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e))),s=o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?r||(r=!0,i.call(this,new fS(e,this,n.originalEvent,{features:s}))):r=!1;},o=()=>{r=!1;};return {layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=n=>{const o=t.filter((e=>this.getLayer(e)));(o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?r=!0:r&&(r=!1,i.call(this,new fS(e,this,n.originalEvent)));},o=t=>{r&&(r=!1,i.call(this,new fS(e,this,t.originalEvent)));};return {layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=e=>{const r=t.filter((e=>this.getLayer(e))),n=r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];n.length&&(e.features=n,i.call(this,e),delete e.features);};return {layers:new Set(t),listener:i,delegates:{[e]:r}}}}on(e,t,i){if(void 0===i)return super.on(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const r=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,i){if(void 0===i)return super.once(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const r=this._createDelegatedListener(e,t,i);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){if(void 0===i)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);for(const e of t)if(!this._isValidId(e))return this;const r=(e,t)=>{if(e.size!==t.size)return !1;for(const i of e)if(!t.has(i))return !1;return !0},n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(e=>{for(let n=0;n<e.length;n++){const o=e[n];if(o.listener===i&&r(o.layers,t)){for(const e in o.delegates)this.off(e,o.delegates[e]);return e.splice(n,1),this}}})(n),this}queryRenderedFeatures(e,t){if(!this.style)return [];if(void 0!==t||void 0===e||e instanceof y||Array.isArray(e)||(t=e,e=void 0),e=e||[[0,0],[this.transform.width,this.transform.height]],(t=t||{}).layers&&Array.isArray(t.layers))for(const e of t.layers)if(!this._isValidId(e))return [];return this.style.queryRenderedFeatures(e,t,this.transform)}querySourceFeatures(e,t){return this._isValidId(e)?this.style.querySourceFeatures(e,t):[]}isPointOnSurface(e){const{name:t}=this.transform.projection;return "globe"!==t&&"mercator"!==t&&H(`${t} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(y.convert(e))}setStyle(e,t){return !1!==(t=k({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},t)).diff&&t.localIdeographFontFamily===this._localIdeographFontFamily&&t.localFontFamily===this._localFontFamily&&this.style&&e?(this._diffStyle(e,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._localFontFamily=t.localFontFamily,this._updateStyle(e,t))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e&&(this.style=new iS(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e):this.style.loadJSON(e)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new iS(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty());}_diffStyle(e,t){if("string"==typeof e){const i=this._requestManager.normalizeStyleURL(e),r=this._requestManager.transformRequest(i,ye.Style);we(r,((e,i)=>{e?this.fire(new Ct(e)):i&&this._updateDiff(i,t);}));}else "object"==typeof e&&this._updateDiff(e,t);}_updateDiff(e,t){try{this.style.setState(e)&&this._update(!0);}catch(i){H(`Unable to perform style diff: ${i.message||i.error||i}. Rebuilding the style from scratch.`),this._updateStyle(e,t);}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(H("There is no style added to the map."),!1)}_isValidId(e){return null==e?(this.fire(new Ct(new Error("IDs can't be empty."))),!1):!xa(e)||(this.fire(new Ct(new Error(`IDs can't contain special symbols: "${e}".`))),!1)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return !!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return !1}}return !0}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i);}removeSource(e){return this._isValidId(e)?(this.style.removeSource(e),this._updateTerrain(),this._update(!0)):this}getSource(e){return this._isValidId(e)?this.style.getOwnSource(e):null}addImage(e,i,{pixelRatio:r=1,sdf:n=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof t.HTMLImageElement||t.ImageBitmap&&i instanceof t.ImageBitmap){const{width:t,height:l,data:c}=dt.getImageData(i);this.style.addImage(e,{data:new ef({width:t,height:l},c),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0});}else if(void 0===i.width||void 0===i.height)this.fire(new Ct(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else {const{width:t,height:l}=i,c=i;this.style.addImage(e,{data:new ef({width:t,height:l},new Uint8Array(c.data)),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0,userImage:c}),c.onAdd&&c.onAdd(this,e);}}updateImage(e,i){this._lazyInitEmptyStyle();const r=this.style.getImage(e);if(!r)return void this.fire(new Ct(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof t.HTMLImageElement||t.ImageBitmap&&i instanceof t.ImageBitmap?dt.getImageData(i):i,{width:o,height:s}=n;void 0!==o&&void 0!==s?o===r.data.width&&s===r.data.height?(r.data.replace(n.data,!(i instanceof t.HTMLImageElement||t.ImageBitmap&&i instanceof t.ImageBitmap)),this.style.updateImage(e,r)):this.fire(new Ct(new Error(`The width and height of the updated image (${o}, ${s})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`))):this.fire(new Ct(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));}hasImage(e){return e?!!this.style&&!!this.style.getImage(e):(this.fire(new Ct(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(e,i){Ie(this._requestManager.transformRequest(e,ye.Image),((e,r)=>{i(e,r instanceof t.HTMLImageElement?dt.getImageData(r):r);}));}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t);}hasModel(e){return e?this.style.hasModel(e):(this.fire(new Ct(new Error("Missing required model id"))),!1)}removeModel(e){this.style.removeModel(e);}listModels(){return this.style.listModels()}addLayer(e,t){return this._isValidId(e.id)?(this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)):this}moveLayer(e,t){return this._isValidId(e)?(this.style.moveLayer(e,t),this._update(!0)):this}removeLayer(e){return this._isValidId(e)?(this.style.removeLayer(e),this._update(!0)):this}getLayer(e){return this._isValidId(e)?this.style.getOwnLayer(e):null}setLayerZoomRange(e,t,i){return this._isValidId(e)?(this.style.setLayerZoomRange(e,t,i),this._update(!0)):this}setFilter(e,t,i={}){return this._isValidId(e)?(this.style.setFilter(e,t,i),this._update(!0)):this}getFilter(e){return this._isValidId(e)?this.style.getFilter(e):null}setPaintProperty(e,t,i,r={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,r),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,r={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,r),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}setLights(e){if(this._lazyInitEmptyStyle(),e&&1===e.length&&"flat"===e[0].type){const t=e[0];t.properties?this.style.setFlatLight(t.properties,t.id,{}):this.style.setFlatLight({},"flat");}else this.style.setLights(e),this.painter.terrain&&(this.painter.terrain.invalidateRenderCache=!0);return this._update(!0)}getLights(){const e=this.style.getLights()||[];return 0===e.length&&e.push({id:this.style.light.id,type:"flat",properties:this.style.getFlatLight()}),e}setLight(e,t={}){return console.log("The `map.setLight` function is deprecated, prefer using `map.setLights` with `flat` light type instead."),this.setLights([{id:"flat",type:"flat",properties:e}])}getLight(){return console.log("The `map.getLight` function is deprecated, prefer using `map.getLights` instead."),this.style.getFlatLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}setCamera(e){return this.style.setCamera(e),this._triggerCameraUpdate(e)}_triggerCameraUpdate(e){return this._update(this.transform.setOrthographicProjectionAtLowPitch("orthographic"===e["camera-projection"]))}getCamera(){return this.style.camera}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(Wd.convert(e),this.transform):0}setFeatureState(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}removeFeatureState(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}getFeatureState(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300;let r,n,o,s=this._container;for(;s&&(!n||!o);){const e=t.getComputedStyle(s).transform;e&&"none"!==e&&(r=e.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(n=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(o=r[3])),s=s.parentElement;}this._containerWidth=n?Math.abs(e/n):e,this._containerHeight=o?Math.abs(i/o):i;}_detectMissingCSS(){"rgb(250, 128, 114)"!==t.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&H("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.");}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=pt("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=pt("div","mapboxgl-canvas-container",e);this._canvas=pt("canvas","mapboxgl-canvas",t),this._interactive&&(t.classList.add("mapboxgl-interactive"),this._canvas.setAttribute("tabindex","0")),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=pt("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((e=>{r[e]=pt("div",`mapboxgl-ctrl-${e}`,i);})),this._container.addEventListener("scroll",this._onMapScroll,!1);}_resizeCanvas(e,t){const i=dt.devicePixelRatio||1;this._canvas.width=i*Math.ceil(e),this._canvas.height=i*Math.ceil(t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`;}_addMarker(e){this._markers.push(e);}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1);}_addPopup(e){this._popups.push(e);}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1);}_setupPainter(){const e=k({},rt.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),t=this._canvas.getContext("webgl2",e);t?(Ke(t,!0),this.painter=new UA(t,this._contextCreateOptions,this.transform),this.on("data",(e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0);})),o.testSupport(t)):this.fire(new Ct(new Error("Failed to initialize WebGL")));}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new It("webglcontextlost",{originalEvent:e}));}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new It("webglcontextrestored",{originalEvent:e}));}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e);}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e);}_render(e){let i;this.fire(new It("renderstart"));const r=this.painter.context.extTimerQuery,n=dt.now(),o=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(i=o.createQuery(),o.beginQuery(r.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],t.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],t.performance.now())),this._renderTaskQueue.run(e),this._domRenderTaskQueue.run(e),this._removed)return;this._updateProjectionTransition();const s=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,t=this.transform.pitch,i=dt.now(),r=new oa(e,{now:i,fadeDuration:s,pitch:t,transition:this.style.transition});this.style.update(r);}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(n),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(n),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,s,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,wireframe:{terrain:this.showTerrainWireframe,layers2D:this.showLayers2DWireframe,layers3D:this.showLayers3DWireframe},showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:s,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new It("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new It("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const e=dt.now()-n;o.endQuery(r.TIME_ELAPSED_EXT),setTimeout((()=>{const r=o.getQueryParameter(i,o.QUERY_RESULT)/1e6;o.deleteQuery(i),this.fire(new It("gpu-timing-frame",{cpuTime:e,gpuTime:r})),t.performance.mark("frame-gpu",{startTime:n,detail:{gpuTime:r}});}),50);}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout((()=>{const t=this.painter.queryGpuTimers(e);this.fire(new It("gpu-timing-layer",{layerTimes:t}));}),50);}if(this.listens("gpu-timing-deferred-render")){const e=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const t=this.painter.queryGpuTimeDeferredRender(e);this.fire(new It("gpu-timing-deferred-render",{gpuTime:t}));}),50);}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(l||this._repaint)this.triggerRepaint();else {const e=!this.isMoving()&&this.loaded();if(e&&(a=this._updateAverageElevation(n,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new It("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new It("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1;}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,Qe.mark(Je.fullLoad),this._performanceMetricsCollection&&We(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate());}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update();}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);const r=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(r||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let n=this.transform.sampleAverageElevation();this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-n);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(n),i(n);this._averageElevation.easeTo(n,e,300);}else if(o>1e-4)return this._averageElevation.jumpTo(n),i(n)}return !!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){Xe(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(e=>{if(e&&(e.message===Ce||401===e.status)){const e=this.painter.context.gl;Ke(e,!1),this._logoControl instanceof rI&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new Ct(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")));}})),Ze(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}));}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e);}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function n(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,i){let r=i[1]-i[0];const n=e.length/4;for(let o=0;o<t.length;o++){const s=t[o];let a=0;for(let t=0;t<s.length;t+=4)s[t]===e[t]&&s[t+1]===e[t+1]&&s[t+2]===e[t+2]&&s[t+3]===e[t+3]&&(a+=1);r+=(i[o+2]-i[o+1])*(1-a/n);}return r}remove(){this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),void 0!==t&&(t.removeEventListener("resize",this._onWindowResize,!1),t.removeEventListener("orientationchange",this._onWindowResize,!1),t.removeEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),t.removeEventListener("online",this._onWindowOnline,!1),t.removeEventListener("visibilitychange",this._onVisibilityChange,!1));const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),Ye.delete(this.painter.context.gl),this._removed=!0,this.fire(new It("remove"));}triggerRepaint(){this._triggerFrame(!0);}_triggerFrame(e){this._renderNextFrame=this._renderNextFrame||e,this.style&&!this._frame&&(this._frame=dt.frame((e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e);})));}_preloadTiles(e){return R(this.style?Object.values(this.style._sourceCaches):[],((t,i)=>t._preloadTiles(e,i)),(()=>{this.triggerRepaint();})),this}_onWindowOnline(){this._update();}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update();}_onVisibilityChange(){"hidden"===t.document.visibilityState&&this._visibilityHidden++;}get showTileBoundaries(){return !!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update());}get showTerrainWireframe(){return !!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update());}get showLayers2DWireframe(){return !!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._update());}get showLayers3DWireframe(){return !!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._update());}get speedIndexTiming(){return !!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update());}get showPadding(){return !!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update());}get showCollisionBoxes(){return !!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update());}get showOverdrawInspector(){return !!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update());}get repaint(){return !!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint());}get vertices(){return !!this._vertices}set vertices(e){this._vertices=e,this._update();}get showTileAABBs(){return !!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update());}_setCacheLimits(e,t){!function(e,t){ce=e,he=t;}(e,t);}get version(){return i}},NavigationControl:class{constructor(e){this.options=k({},fI,e),this._container=pt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this.options.showZoom&&(j(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e});})),pt("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(e=>{this._map&&this._map.zoomOut({},{originalEvent:e});})),pt("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(j(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}));})),this._compassIcon=pt("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"));}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),i=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString());}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=t);}));}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new mI(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0);}_createButton(e,t){const i=pt("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i);}},GeolocateControl:class extends zt{constructor(e){super(),this.options=k({geolocation:t.navigator.geolocation},_I,e),j(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=rS(this._updateMarkerRotation,20),this._numberOfWatches=0;}onAdd(e){return this._map=e,this._container=pt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1;}_checkGeolocationSupport(e){const i=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t);};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==t.navigator.permissions?t.navigator.permissions.query({name:"geolocation"}).then((e=>i("denied"!==e.state))).catch((()=>i())):i();}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return !!t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");}}_onSuccess(e){if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new It("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new It("geolocate",e)),this._finish();}}_updateCamera(e){const t=new Wd(e.coords.longitude,e.coords.latitude),i=e.coords.accuracy,r=k({bearing:this._map.getBearing()},this.options.fitBoundsOptions);this._map.fitBounds(t.toBounds(i),r,{geolocateSource:!0});}_updateMarker(e){if(e){const t=new Wd(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(t).addTo(this._map),this._userLocationDotMarker.setLngLat(t).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove();}_updateCircleRadius(){const e=this._map.transform,t=Qd(1,e._center.lat)*e.worldSize,i=Math.ceil(2*this._accuracy*t);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}px`;}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius();}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._userLocationDotMarker.addClassName("mapboxgl-user-location-show-heading")):(this._userLocationDotMarker.removeClassName("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0));}_onError(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch();}else {if(3===e.code&&this._noTimeout)return;this._setErrorState();}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new It("error",e)),this._finish();}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0;}_setupUI(e){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(e=>e.preventDefault())),this._geolocateButton=pt("button","mapboxgl-ctrl-geolocate",this._container),pt("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){H("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e);}else {const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e);}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=pt("div","mapboxgl-user-location"),this._dotElement.appendChild(pt("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(pt("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new aI({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=pt("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new aI({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new It("trackuserlocationend")));}));}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled());}trigger(){if(!this._setup)return H("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new It("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new It("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new It("trackuserlocationstart"));}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error");}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener();}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_addDeviceOrientationListener(){const e=()=>{t.addEventListener("ondeviceorientationabsolute"in t?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation);};void 0!==t.DeviceMotionEvent&&"function"==typeof t.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e();})).catch(console.error):e();}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),t.removeEventListener("deviceorientation",this._onDeviceOrientation),t.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null);}},AttributionControl:iI,ScaleControl:class{constructor(e){this.options=k({},gI,e),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return !1}}(),j(["_update","_setScale","setUnit"],this);}getDefaultPosition(){return "bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,r=t._containerWidth/2-e/2,n=t.unproject([r,i]),o=t.unproject([r+e,i]),s=n.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot");}else "nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter");}_setScale(e,t,i){this._map._requestDomTask((()=>{const r=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(t),n=r/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(r):`${r}&nbsp;${yI[i]}`,this._container.style.width=e*n+"px";}));}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=pt("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0;}_setLanguage(e){this._language=e,this._update();}setUnit(e){this.options.unit=e,this._update();}},FullscreenControl:class{constructor(e){this._fullscreen=!1,e&&e.container&&(e.container instanceof t.HTMLElement?this._container=e.container:H("Full screen control 'container' must be a DOM element.")),j(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in t.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in t.document&&(this._fullscreenchange="webkitfullscreenchange");}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=pt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",H("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,t.document.removeEventListener(this._fullscreenchange,this._changeIcon);}_checkFullscreenSupport(){return !(!t.document.fullscreenEnabled&&!t.document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=pt("button","mapboxgl-ctrl-fullscreen",this._controlContainer);pt("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.document.addEventListener(this._fullscreenchange,this._changeIcon);}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e);}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(t.document.fullscreenElement||t.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle());}_onClickFullscreen(){this._isFullscreen()?t.document.exitFullscreen?t.document.exitFullscreen():t.document.webkitCancelFullScreen&&t.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen();}},Popup:class extends zt{constructor(e){super(),this.options=k(Object.create(lI),e),j(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[]);}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),e._addPopup(this),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new It("open")),this}isOpen(){return !!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),e._canvasContainer&&e._canvasContainer.classList.remove("mapboxgl-track-pointer"),e._removePopup(this),this._map=void 0),this.fire(new It("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=Wd.convert(e),this._pos=null,this._trackPointer=!1,this._update();const t=this._map;return t&&(t.on("move",this._update),t.off("mousemove",this._onMouseEvent),t._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(t.document.createTextNode(e))}setHTML(e){const i=t.document.createDocumentFragment(),r=t.document.createElement("body");let n;for(r.innerHTML=e;n=r.firstChild,n;)i.appendChild(n);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=pt("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=pt("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="&#215;",e.addEventListener("click",this._onClose);}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point);}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,i=this._container,r=this._pos;if(!t||!i||!r)return "bottom";const n=i.offsetWidth,o=i.offsetHeight,s=r.x<n/2,a=r.x>t.transform.width-n/2;if(r.y+e<o)return s?"top-left":a?"top-right":"top";if(r.y>t.transform.height-o){if(s)return "bottom-left";if(a)return "bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ");}_update(e){const t=this._map,i=this._content;if(!t||!this._lngLat&&!this._trackPointer||!i)return;let r=this._container;if(r||(r=this._container=pt("div","mapboxgl-popup",t.getContainer()),this._tip=pt("div","mapboxgl-popup-tip",r),r.appendChild(i)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),t.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=oI(this._lngLat,this._pos,t.transform)),!this._trackPointer||e){const i=this._pos=this._trackPointer&&e?e:t.project(this._lngLat),r=hI(this.options.offset),n=this._anchor=this._getAnchor(r.y),o=hI(this.options.offset,n),s=i.add(o).round();t._requestDomTask((()=>{this._container&&n&&(this._container.style.transform=`${sI[n]} translate(${s.x}px,${s.y}px)`);}));}if(!this._marker&&t._showingGlobe()){const e=Nd(t.transform,this._lngLat)?0:1;this._setOpacity(e);}this._updateClassList();}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(cI);e&&e.focus();}_onClose(){this.remove();}_setOpacity(e){this._container&&(this._container.style.opacity=`${e}`),this._content&&(this._content.style.pointerEvents=e?"auto":"none");}},Marker:aI,Style:iS,LngLat:Wd,LngLatBounds:sc,Point:y,MercatorCoordinate:lp,FreeCameraOptions:Xx,Evented:zt,config:n,prewarm:function(){Ww().acquire(qw);},clearPrewarmedResources:function(){const e=$w;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(qw),$w=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"));},get accessToken(){return n.ACCESS_TOKEN},set accessToken(e){n.ACCESS_TOKEN=e;},get baseApiUrl(){return n.API_URL},set baseApiUrl(e){n.API_URL=e;},get workerCount(){return Zw.workerCount},set workerCount(e){Zw.workerCount=e;},get maxParallelImageRequests(){return n.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){n.MAX_PARALLEL_IMAGE_REQUESTS=e;},clearStorage(e){!function(e){if(!pe())return;const i=t.caches.delete(le);e&&i.catch(e).then((()=>e()));}(e);},workerUrl:"",workerClass:null,get dracoUrl(){return Jw()},set dracoUrl(e){!function(e){Xw=dt.resolveURL(e),Kw||(Kw=new Ew(Ww(),new zt)),Kw.broadcast("setDracoUrl",Xw);}(e);},setNow:dt.setNow,restoreNow:dt.restoreNow};e.A=Tw,e.D=Ym,e.E=cr,e.F=Qm,e.K=xE,e.O=qu,e.P=y,e.T=Zv,e.V=hm,e.a=Kf,e.b=fm,e.c=ow,e.d=class extends zt{constructor(e,t,i,r,n,o){super(),this.actor=e,this.layerIndex=t,this.availableImages=i,this.loadVectorData=n||Uw,this.loading={},this.loaded={},this.deduped=new Nw(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler,this.brightness=o;}loadTile(e,t){const i=e.uid,r=e&&e.request,n=r&&r.collectResourceTiming,o=this.loading[i]=new Bw(e);o.abort=this.loadVectorData(e,((s,a)=>{const l=!this.loading[i];if(delete this.loading[i],l||s||!a)return o.status="done",l||(this.loaded[i]=o),t(s);const c=a.rawData,h={};a.expires&&(h.expires=a.expires),a.cacheControl&&(h.cacheControl=a.cacheControl),o.vectorTile=a.vectorTile||new cm(new km(c));const u=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((e,i)=>{if(e||!i)return t(e);const o={};if(n){const e=it(r);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)));}t(null,k({rawTileData:c.slice(0)},i,h,o));}));};this.isSpriteLoaded?u():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(u,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom}):u();})),this.loaded=this.loaded||{},this.loaded[i]=o;}));}reloadTile(e,t){const i=this.loaded,r=e.uid,n=this;if(i&&i[r]){const o=i[r];o.showCollisionBoxes=e.showCollisionBoxes,o.projection=e.projection,o.brightness=e.brightness,o.tileTransform=Pg(e.tileID.canonical,e.projection),o.extraShadowCaster=e.extraShadowCaster;const s=(e,i)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,n.layerIndex,this.availableImages,n.actor,r)),t(e,i);};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s());}else t(null,void 0);}abortTile(e,t){const i=e.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),t();}removeTile(e,t){const i=this.loaded,r=e.uid;i&&i[r]&&delete i[r],t();}},e.e=Eo,e.f=it,e.g=d,e.h=we,e.i=Te,e.j=function(e,t){const i=TT(e);for(const e of i){for(const t of e.meshes)ET(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(MT(e.lights,t)));}return i},e.k=oa,e.l=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==aT){const i=new Uint32Array(e,0,7),[,,r,n,o,s]=i;t=i.byteLength+n+o+s+o,(r!==e.byteLength||t>=e.byteLength)&&H("Invalid b3dm header information.");}return pT(e,t)},e.m=ty,e.n=na,e.o=It,e.p=_,e.q=function(e){fe(),ue&&ue.then((t=>{t.keys().then((i=>{for(let r=0;r<i.length-e;r++)t.delete(i[r]);}));}));},e.r=RT,e.s=xI,e.t=ap,e.v=L,e.w=t;}));
45
+
46
+ define(["./shared"],(function(e){"use strict";function t(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let r="[";for(const o of e)r+=`${t(o)},`;return `${r}]`}let r="{";for(const o of Object.keys(e).sort())r+=`${o}:${t(e[o])},`;return `${r}}`}function r(r){let o="";for(const i of e.r)o+=`/${t(r[i])}`;return o}class o{constructor(e){this.keyCache={},this._layers={},this._layerConfigs={},e&&this.replace(e);}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t);}update(t,o,i){this._options=i;for(const r of t){this._layerConfigs[r.id]=r;const t=this._layers[r.id]=e.c(r,this._options);t.setScope(this.scope),t.compileFilter(),this.keyCache[r.id]&&delete this.keyCache[r.id];}for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const s=function(e,t){const o={};for(let i=0;i<e.length;i++){const s=t&&t[e[i].id]||r(e[i]);t&&(t[e[i].id]=s);let n=o[s];n||(n=o[s]=[]),n.push(e[i]);}const i=[];for(const e in o)i.push(o[e]);return i}(e.v(this._layerConfigs),this.keyCache);for(const e of s){const t=e.map((e=>this._layers[e.id])),r=t[0];if("none"===r.visibility)continue;const o=r.source||"";let i=this.familiesBySource[o];i||(i=this.familiesBySource[o]={});const s=r.sourceLayer||"_geojsonTileLayer";let n=i[s];n||(n=i[s]=[]),n.push(t);}}}class i{loadTile(t,r){const{uid:o,encoding:i,rawImageData:s,padding:n}=t,a=e.w.ImageBitmap&&s instanceof e.w.ImageBitmap?this.getImageData(s,n):s;r(null,new e.D(o,a,i,n<1));}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const r=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),r}}function s(e,t){if(0!==e.length){n(e[0],t);for(var r=1;r<e.length;r++)n(e[r],!t);}}function n(e,t){for(var r=0,o=0,i=0,s=e.length,n=s-1;i<s;n=i++){var a=(e[i][0]-e[n][0])*(e[n][1]+e[i][1]),l=r+a;o+=Math.abs(r)>=Math.abs(a)?r-l+a:a-l+r,r=l;}r+o>=0!=!!t&&e.reverse();}var a=e.g((function e(t,r){var o,i=t&&t.type;if("FeatureCollection"===i)for(o=0;o<t.features.length;o++)e(t.features[o],r);else if("GeometryCollection"===i)for(o=0;o<t.geometries.length;o++)e(t.geometries[o],r);else if("Feature"===i)e(t.geometry,r);else if("Polygon"===i)s(t.coordinates,r);else if("MultiPolygon"===i)for(o=0;o<t.coordinates.length;o++)s(t.coordinates[o],r);return t}));const l=e.V.prototype.toGeoJSON;var h={exports:{}},u=e.p,c=e.a.VectorTileFeature,f=d;function d(e,t){this.options=t||{},this.features=e,this.length=e.length;}function p(e,t){this.id="number"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096;}d.prototype.feature=function(e){return new p(this.features[e],this.options.extent)},p.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var t=0;t<e.length;t++){for(var r=e[t],o=[],i=0;i<r.length;i++)o.push(new u(r[i][0],r[i][1]));this.geometry.push(o);}return this.geometry},p.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var e=this.geometry,t=1/0,r=-1/0,o=1/0,i=-1/0,s=0;s<e.length;s++)for(var n=e[s],a=0;a<n.length;a++){var l=n[a];t=Math.min(t,l.x),r=Math.max(r,l.x),o=Math.min(o,l.y),i=Math.max(i,l.y);}return [t,o,r,i]},p.prototype.toGeoJSON=c.prototype.toGeoJSON;var g=e.b,m=f;function y(e){var t=new g;return function(e,t){for(var r in e.layers)t.writeMessage(3,v,e.layers[r]);}(e,t),t.finish()}function v(e,t){var r;t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);var o={keys:[],values:[],keycache:{},valuecache:{}};for(r=0;r<e.length;r++)o.feature=e.feature(r),t.writeMessage(2,w,o);var i=o.keys;for(r=0;r<i.length;r++)t.writeStringField(3,i[r]);var s=o.values;for(r=0;r<s.length;r++)t.writeMessage(4,I,s[r]);}function w(e,t){var r=e.feature;void 0!==r.id&&t.writeVarintField(1,r.id),t.writeMessage(2,x,e),t.writeVarintField(3,r.type),t.writeMessage(4,b,r);}function x(e,t){var r=e.feature,o=e.keys,i=e.values,s=e.keycache,n=e.valuecache;for(var a in r.properties){var l=r.properties[a],h=s[a];if(null!==l){void 0===h&&(o.push(a),s[a]=h=o.length-1),t.writeVarint(h);var u=typeof l;"string"!==u&&"boolean"!==u&&"number"!==u&&(l=JSON.stringify(l));var c=u+":"+l,f=n[c];void 0===f&&(i.push(l),n[c]=f=i.length-1),t.writeVarint(f);}}}function S(e,t){return (t<<3)+(7&e)}function M(e){return e<<1^e>>31}function b(e,t){for(var r=e.loadGeometry(),o=e.type,i=0,s=0,n=r.length,a=0;a<n;a++){var l=r[a],h=1;1===o&&(h=l.length),t.writeVarint(S(1,h));for(var u=3===o?l.length-1:l.length,c=0;c<u;c++){1===c&&1!==o&&t.writeVarint(S(2,u-1));var f=l[c].x-i,d=l[c].y-s;t.writeVarint(M(f)),t.writeVarint(M(d)),i+=f,s+=d;}3===o&&t.writeVarint(S(7,1));}}function I(e,t){var r=typeof e;"string"===r?t.writeStringField(1,e):"boolean"===r?t.writeBooleanField(7,e):"number"===r&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e));}h.exports=y,h.exports.fromVectorTileJs=y,h.exports.fromGeojsonVt=function(e,t){t=t||{};var r={};for(var o in e)r[o]=new m(e[o].features,t),r[o].name=o,r[o].version=t.version,r[o].extent=t.extent;return y({layers:r})},h.exports.GeoJSONWrapper=m;var k=e.g(h.exports);const P={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},_=Math.fround||(L=new Float32Array(1),e=>(L[0]=+e,L[0]));var L;const T=3,C=5,O=6;class j{constructor(e){this.options=Object.assign(Object.create(P),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:r,maxZoom:o}=this.options;t&&console.time("total time");const i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;const s=[];for(let t=0;t<e.length;t++){const r=e[t];if(!r.geometry)continue;const[o,i]=r.geometry.coordinates,n=_(z(o)),a=_(D(i));s.push(n,a,1/0,t,-1,1),this.options.reduce&&s.push(0);}let n=this.trees[o+1]=this._createTree(s);t&&console.timeEnd(i);for(let e=o;e>=r;e--){const r=+Date.now();n=this.trees[e]=this._createTree(this._cluster(n,e)),t&&console.log("z%d: %d clusters in %dms",e,n.numItems,+Date.now()-r);}return t&&console.timeEnd("total time"),this}getClusters(e,t){let r=((e[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[1]));let i=180===e[2]?180:((e[2]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)r=-180,i=180;else if(r>i){const e=this.getClusters([r,o,180,s],t),n=this.getClusters([-180,o,i,s],t);return e.concat(n)}const n=this.trees[this._limitZoom(t)],a=n.range(z(r),D(s),z(i),D(o)),l=n.data,h=[];for(const e of a){const t=this.stride*e;h.push(l[t+C]>1?F(l,t,this.clusterProps):this.points[l[t+T]]);}return h}getChildren(e){const t=this._getOriginId(e),r=this._getOriginZoom(e),o="No cluster with the specified id.",i=this.trees[r];if(!i)throw new Error(o);const s=i.data;if(t*this.stride>=s.length)throw new Error(o);const n=this.options.radius/(this.options.extent*Math.pow(2,r-1)),a=i.within(s[t*this.stride],s[t*this.stride+1],n),l=[];for(const t of a){const r=t*this.stride;s[r+4]===e&&l.push(s[r+C]>1?F(s,r,this.clusterProps):this.points[s[r+T]]);}if(0===l.length)throw new Error(o);return l}getLeaves(e,t,r){const o=[];return this._appendLeaves(o,e,t=t||10,r=r||0,0),o}getTile(e,t,r){const o=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:s,radius:n}=this.options,a=n/s,l=(r-a)/i,h=(r+1+a)/i,u={features:[]};return this._addTileFeatures(o.range((t-a)/i,l,(t+1+a)/i,h),o.data,t,r,i,u),0===t&&this._addTileFeatures(o.range(1-a/i,l,1,h),o.data,i,r,i,u),t===i-1&&this._addTileFeatures(o.range(0,l,a/i,h),o.data,-1,r,i,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const r=this.getChildren(e);if(t++,1!==r.length)break;e=r[0].properties.cluster_id;}return t}_appendLeaves(e,t,r,o,i){const s=this.getChildren(t);for(const t of s){const s=t.properties;if(s&&s.cluster?i+s.point_count<=o?i+=s.point_count:i=this._appendLeaves(e,s.cluster_id,r,o,i):i<o?i++:e.push(t),e.length===r)break}return i}_createTree(t){const r=new e.K(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let e=0;e<t.length;e+=this.stride)r.add(t[e],t[e+1]);return r.finish(),r.data=t,r}_addTileFeatures(e,t,r,o,i,s){for(const n of e){const e=n*this.stride,a=t[e+C]>1;let l,h,u;if(a)l=Z(t,e,this.clusterProps),h=t[e],u=t[e+1];else {const r=this.points[t[e+T]];l=r.properties;const[o,i]=r.geometry.coordinates;h=z(o),u=D(i);}const c={type:1,geometry:[[Math.round(this.options.extent*(h*i-r)),Math.round(this.options.extent*(u*i-o))]],tags:l};let f;f=a||this.options.generateId?t[e+T]:this.points[t[e+T]].id,void 0!==f&&(c.id=f),s.features.push(c);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:r,extent:o,reduce:i,minPoints:s}=this.options,n=r/(o*Math.pow(2,t)),a=e.data,l=[],h=this.stride;for(let r=0;r<a.length;r+=h){if(a[r+2]<=t)continue;a[r+2]=t;const o=a[r],u=a[r+1],c=e.within(a[r],a[r+1],n),f=a[r+C];let d=f;for(const e of c){const r=e*h;a[r+2]>t&&(d+=a[r+C]);}if(d>f&&d>=s){let e,s=o*f,n=u*f,p=-1;const g=((r/h|0)<<5)+(t+1)+this.points.length;for(const o of c){const l=o*h;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+C];s+=a[l]*u,n+=a[l+1]*u,a[l+4]=g,i&&(e||(e=this._map(a,r,!0),p=this.clusterProps.length,this.clusterProps.push(e)),i(e,this._map(a,l)));}a[r+4]=g,l.push(s/d,n/d,1/0,g,-1,d),i&&l.push(p);}else {for(let e=0;e<h;e++)l.push(a[r+e]);if(d>1)for(const e of c){const r=e*h;if(!(a[r+2]<=t)){a[r+2]=t;for(let e=0;e<h;e++)l.push(a[r+e]);}}}}return l}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,r){if(e[t+C]>1){const o=this.clusterProps[e[t+O]];return r?Object.assign({},o):o}const o=this.points[e[t+T]].properties,i=this.options.map(o);return r&&i===o?Object.assign({},i):i}}function F(e,t,r){return {type:"Feature",id:e[t+T],properties:Z(e,t,r),geometry:{type:"Point",coordinates:[(o=e[t],360*(o-.5)),E(e[t+1])]}};var o;}function Z(e,t,r){const o=e[t+C],i=o>=1e4?`${Math.round(o/1e3)}k`:o>=1e3?Math.round(o/100)/10+"k":o,s=e[t+O],n=-1===s?{}:Object.assign({},r[s]);return Object.assign(n,{cluster:!0,cluster_id:e[t+T],point_count:o,point_count_abbreviated:i})}function z(e){return e/360+.5}function D(e){const t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function E(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}var N={exports:{}};N.exports=function(){function e(r,o,i,s){for(var n,a=s,l=i-o>>1,h=i-o,u=r[o],c=r[o+1],f=r[i],d=r[i+1],p=o+3;p<i;p+=3){var g=t(r[p],r[p+1],u,c,f,d);if(g>a)n=p,a=g;else if(g===a){var m=Math.abs(p-l);m<h&&(n=p,h=m);}}a>s&&(n-o>3&&e(r,o,n,s),r[n+2]=a,i-n>3&&e(r,n,i,s));}function t(e,t,r,o,i,s){var n=i-r,a=s-o;if(0!==n||0!==a){var l=((e-r)*n+(t-o)*a)/(n*n+a*a);l>1?(r=i,o=s):l>0&&(r+=n*l,o+=a*l);}return (n=e-r)*n+(a=t-o)*a}function r(e,t,r,i){var s={id:void 0===e?null:e,type:t,geometry:r,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,r=e.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)o(e,t);else if("Polygon"===r||"MultiLineString"===r)for(var i=0;i<t.length;i++)o(e,t[i]);else if("MultiPolygon"===r)for(i=0;i<t.length;i++)for(var s=0;s<t[i].length;s++)o(e,t[i][s]);}(s),s}function o(e,t){for(var r=0;r<t.length;r+=3)e.minX=Math.min(e.minX,t[r]),e.minY=Math.min(e.minY,t[r+1]),e.maxX=Math.max(e.maxX,t[r]),e.maxY=Math.max(e.maxY,t[r+1]);}function i(e,t,o,l){if(t.geometry){var h=t.geometry.coordinates,u=t.geometry.type,c=Math.pow(o.tolerance/((1<<o.maxZoom)*o.extent),2),f=[],d=t.id;if(o.promoteId?d=t.properties[o.promoteId]:o.generateId&&(d=l||0),"Point"===u)s(h,f);else if("MultiPoint"===u)for(var p=0;p<h.length;p++)s(h[p],f);else if("LineString"===u)n(h,f,c,!1);else if("MultiLineString"===u){if(o.lineMetrics){for(p=0;p<h.length;p++)n(h[p],f=[],c,!1),e.push(r(d,"LineString",f,t.properties));return}a(h,f,c,!1);}else if("Polygon"===u)a(h,f,c,!0);else {if("MultiPolygon"!==u){if("GeometryCollection"===u){for(p=0;p<t.geometry.geometries.length;p++)i(e,{id:d,geometry:t.geometry.geometries[p],properties:t.properties},o,l);return}throw new Error("Input data is not a valid GeoJSON object.")}for(p=0;p<h.length;p++){var g=[];a(h[p],g,c,!0),f.push(g);}}e.push(r(d,u,f,t.properties));}}function s(e,t){t.push(l(e[0])),t.push(h(e[1])),t.push(0);}function n(t,r,o,i){for(var s,n,a=0,u=0;u<t.length;u++){var c=l(t[u][0]),f=h(t[u][1]);r.push(c),r.push(f),r.push(0),u>0&&(a+=i?(s*f-c*n)/2:Math.sqrt(Math.pow(c-s,2)+Math.pow(f-n,2))),s=c,n=f;}var d=r.length-3;r[2]=1,e(r,0,d,o),r[d+2]=1,r.size=Math.abs(a),r.start=0,r.end=r.size;}function a(e,t,r,o){for(var i=0;i<e.length;i++){var s=[];n(e[i],s,r,o),t.push(s);}}function l(e){return e/360+.5}function h(e){var t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function u(e,t,o,i,s,n,a,l){if(i/=t,n>=(o/=t)&&a<i)return e;if(a<o||n>=i)return null;for(var h=[],u=0;u<e.length;u++){var d=e[u],g=d.geometry,m=d.type,y=0===s?d.minX:d.minY,v=0===s?d.maxX:d.maxY;if(y>=o&&v<i)h.push(d);else if(!(v<o||y>=i)){var w=[];if("Point"===m||"MultiPoint"===m)c(g,w,o,i,s);else if("LineString"===m)f(g,w,o,i,s,!1,l.lineMetrics);else if("MultiLineString"===m)p(g,w,o,i,s,!1);else if("Polygon"===m)p(g,w,o,i,s,!0);else if("MultiPolygon"===m)for(var x=0;x<g.length;x++){var S=[];p(g[x],S,o,i,s,!0),S.length&&w.push(S);}if(w.length){if(l.lineMetrics&&"LineString"===m){for(x=0;x<w.length;x++)h.push(r(d.id,m,w[x],d.tags));continue}"LineString"!==m&&"MultiLineString"!==m||(1===w.length?(m="LineString",w=w[0]):m="MultiLineString"),"Point"!==m&&"MultiPoint"!==m||(m=3===w.length?"Point":"MultiPoint"),h.push(r(d.id,m,w,d.tags));}}}return h.length?h:null}function c(e,t,r,o,i){for(var s=0;s<e.length;s+=3){var n=e[s+i];n>=r&&n<=o&&(t.push(e[s]),t.push(e[s+1]),t.push(e[s+2]));}}function f(e,t,r,o,i,s,n){for(var a,l,h=d(e),u=0===i?m:y,c=e.start,f=0;f<e.length-3;f+=3){var p=e[f],v=e[f+1],w=e[f+2],x=e[f+3],S=e[f+4],M=0===i?p:v,b=0===i?x:S,I=!1;n&&(a=Math.sqrt(Math.pow(p-x,2)+Math.pow(v-S,2))),M<r?b>r&&(l=u(h,p,v,x,S,r),n&&(h.start=c+a*l)):M>o?b<o&&(l=u(h,p,v,x,S,o),n&&(h.start=c+a*l)):g(h,p,v,w),b<r&&M>=r&&(l=u(h,p,v,x,S,r),I=!0),b>o&&M<=o&&(l=u(h,p,v,x,S,o),I=!0),!s&&I&&(n&&(h.end=c+a*l),t.push(h),h=d(e)),n&&(c+=a);}var k=e.length-3;p=e[k],v=e[k+1],w=e[k+2],(M=0===i?p:v)>=r&&M<=o&&g(h,p,v,w),k=h.length-3,s&&k>=3&&(h[k]!==h[0]||h[k+1]!==h[1])&&g(h,h[0],h[1],h[2]),h.length&&t.push(h);}function d(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function p(e,t,r,o,i,s){for(var n=0;n<e.length;n++)f(e[n],t,r,o,i,s,!1);}function g(e,t,r,o){e.push(t),e.push(r),e.push(o);}function m(e,t,r,o,i,s){var n=(s-t)/(o-t);return e.push(s),e.push(r+(i-r)*n),e.push(1),n}function y(e,t,r,o,i,s){var n=(s-r)/(i-r);return e.push(t+(o-t)*n),e.push(s),e.push(1),n}function v(e,t){for(var o=[],i=0;i<e.length;i++){var s,n=e[i],a=n.type;if("Point"===a||"MultiPoint"===a||"LineString"===a)s=w(n.geometry,t);else if("MultiLineString"===a||"Polygon"===a){s=[];for(var l=0;l<n.geometry.length;l++)s.push(w(n.geometry[l],t));}else if("MultiPolygon"===a)for(s=[],l=0;l<n.geometry.length;l++){for(var h=[],u=0;u<n.geometry[l].length;u++)h.push(w(n.geometry[l][u],t));s.push(h);}o.push(r(n.id,a,s,n.tags));}return o}function w(e,t){var r=[];r.size=e.size,void 0!==e.start&&(r.start=e.start,r.end=e.end);for(var o=0;o<e.length;o+=3)r.push(e[o]+t,e[o+1],e[o+2]);return r}function x(e,t){if(e.transformed)return e;var r,o,i,s=1<<e.z,n=e.x,a=e.y;for(r=0;r<e.features.length;r++){var l=e.features[r],h=l.geometry,u=l.type;if(l.geometry=[],1===u)for(o=0;o<h.length;o+=2)l.geometry.push(S(h[o],h[o+1],t,s,n,a));else for(o=0;o<h.length;o++){var c=[];for(i=0;i<h[o].length;i+=2)c.push(S(h[o][i],h[o][i+1],t,s,n,a));l.geometry.push(c);}}return e.transformed=!0,e}function S(e,t,r,o,i,s){return [Math.round(r*(e*o-i)),Math.round(r*(t*o-s))]}function M(e,t,r,o,i){for(var s=t===i.maxZoom?0:i.tolerance/((1<<t)*i.extent),n={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:r,y:o,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},a=0;a<e.length;a++){n.numFeatures++,b(n,e[a],s,i);var l=e[a].minX,h=e[a].minY,u=e[a].maxX,c=e[a].maxY;l<n.minX&&(n.minX=l),h<n.minY&&(n.minY=h),u>n.maxX&&(n.maxX=u),c>n.maxY&&(n.maxY=c);}return n}function b(e,t,r,o){var i=t.geometry,s=t.type,n=[];if("Point"===s||"MultiPoint"===s)for(var a=0;a<i.length;a+=3)n.push(i[a]),n.push(i[a+1]),e.numPoints++,e.numSimplified++;else if("LineString"===s)I(n,i,e,r,!1,!1);else if("MultiLineString"===s||"Polygon"===s)for(a=0;a<i.length;a++)I(n,i[a],e,r,"Polygon"===s,0===a);else if("MultiPolygon"===s)for(var l=0;l<i.length;l++){var h=i[l];for(a=0;a<h.length;a++)I(n,h[a],e,r,!0,0===a);}if(n.length){var u=t.tags||null;if("LineString"===s&&o.lineMetrics){for(var c in u={},t.tags)u[c]=t.tags[c];u.mapbox_clip_start=i.start/i.size,u.mapbox_clip_end=i.end/i.size;}var f={geometry:n,type:"Polygon"===s||"MultiPolygon"===s?3:"LineString"===s||"MultiLineString"===s?2:1,tags:u};null!==t.id&&(f.id=t.id),e.features.push(f);}}function I(e,t,r,o,i,s){var n=o*o;if(o>0&&t.size<(i?n:o))r.numPoints+=t.length/3;else {for(var a=[],l=0;l<t.length;l+=3)(0===o||t[l+2]>n)&&(r.numSimplified++,a.push(t[l]),a.push(t[l+1])),r.numPoints++;i&&function(e,t){for(var r=0,o=0,i=e.length,s=i-2;o<i;s=o,o+=2)r+=(e[o]-e[s])*(e[o+1]+e[s+1]);if(r>0===t)for(o=0,i=e.length;o<i/2;o+=2){var n=e[o],a=e[o+1];e[o]=e[i-2-o],e[o+1]=e[i-1-o],e[i-2-o]=n,e[i-1-o]=a;}}(a,s),e.push(a);}}function k(e,t){var r=(t=this.options=function(e,t){for(var r in t)e[r]=t[r];return e}(Object.create(this.options),t)).debug;if(r&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var o=function(e,t){var r=[];if("FeatureCollection"===e.type)for(var o=0;o<e.features.length;o++)i(r,e.features[o],t,o);else i(r,"Feature"===e.type?e:{geometry:e},t);return r}(e,t);this.tiles={},this.tileCoords=[],r&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(o=function(e,t){var r=t.buffer/t.extent,o=e,i=u(e,1,-1-r,r,0,-1,2,t),s=u(e,1,1-r,2+r,0,-1,2,t);return (i||s)&&(o=u(e,1,-r,1+r,0,-1,2,t)||[],i&&(o=v(i,1).concat(o)),s&&(o=o.concat(v(s,-1)))),o}(o,t)).length&&this.splitTile(o,0,0,0),r&&(o.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)));}function P(e,t,r){return 32*((1<<e)*r+t)+e}return k.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},k.prototype.splitTile=function(e,t,r,o,i,s,n){for(var a=[e,t,r,o],l=this.options,h=l.debug;a.length;){o=a.pop(),r=a.pop(),t=a.pop(),e=a.pop();var c=1<<t,f=P(t,r,o),d=this.tiles[f];if(!d&&(h>1&&console.time("creation"),d=this.tiles[f]=M(e,t,r,o,l),this.tileCoords.push({z:t,x:r,y:o}),h)){h>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,r,o,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var p="z"+t;this.stats[p]=(this.stats[p]||0)+1,this.total++;}if(d.source=e,i){if(t===l.maxZoom||t===i)continue;var g=1<<i-t;if(r!==Math.floor(s/g)||o!==Math.floor(n/g))continue}else if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue;if(d.source=null,0!==e.length){h>1&&console.time("clipping");var m,y,v,w,x,S,b=.5*l.buffer/l.extent,I=.5-b,k=.5+b,_=1+b;m=y=v=w=null,x=u(e,c,r-b,r+k,0,d.minX,d.maxX,l),S=u(e,c,r+I,r+_,0,d.minX,d.maxX,l),e=null,x&&(m=u(x,c,o-b,o+k,1,d.minY,d.maxY,l),y=u(x,c,o+I,o+_,1,d.minY,d.maxY,l),x=null),S&&(v=u(S,c,o-b,o+k,1,d.minY,d.maxY,l),w=u(S,c,o+I,o+_,1,d.minY,d.maxY,l),S=null),h>1&&console.timeEnd("clipping"),a.push(m||[],t+1,2*r,2*o),a.push(y||[],t+1,2*r,2*o+1),a.push(v||[],t+1,2*r+1,2*o),a.push(w||[],t+1,2*r+1,2*o+1);}}},k.prototype.getTile=function(e,t,r){var o=this.options,i=o.extent,s=o.debug;if(e<0||e>24)return null;var n=1<<e,a=P(e,t=(t%n+n)%n,r);if(this.tiles[a])return x(this.tiles[a],i);s>1&&console.log("drilling down to z%d-%d-%d",e,t,r);for(var l,h=e,u=t,c=r;!l&&h>0;)h--,u=Math.floor(u/2),c=Math.floor(c/2),l=this.tiles[P(h,u,c)];return l&&l.source?(s>1&&console.log("found parent tile z%d-%d-%d",h,u,c),s>1&&console.time("drilling down"),this.splitTile(l.source,h,u,c,e,t,r),s>1&&console.timeEnd("drilling down"),this.tiles[a]?x(this.tiles[a],i):null):null},function(e,t){return new k(e,t)}}();var J=e.g(N.exports);function Y(t,r){const o=t.tileID.canonical;if(!this._geoJSONIndex)return r(null,null);const i=this._geoJSONIndex.getTile(o.z,o.x,o.y);if(!i)return r(null,null);const s=new class{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.E,this.length=t.length,this._features=t;}feature(t){return new class{constructor(t){this._feature=t,this.extent=e.E,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10));}loadGeometry(){if(1===this._feature.type){const t=[];for(const r of this._feature.geometry)t.push([new e.P(r[0],r[1])]);return t}{const t=[];for(const r of this._feature.geometry){const o=[];for(const t of r)o.push(new e.P(t[0],t[1]));t.push(o);}return t}}toGeoJSON(e,t,r){return l.call(this,e,t,r)}}(this._features[t])}}(i.features);let n=k(s);0===n.byteOffset&&n.byteLength===n.buffer.byteLength||(n=new Uint8Array(n)),r(null,{vectorTile:s,rawData:n.buffer});}class G extends e.d{constructor(e,t,r,o,i,s){super(e,t,r,o,Y,s),i&&(this.loadGeoJSON=i);}loadData(t,r){const o=t&&t.request,i=o&&o.collectResourceTiming;this.loadGeoJSON(t,((s,n)=>{if(s||!n)return r(s);if("object"!=typeof n)return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{a(n,!0);try{if(t.filter){const r=e.e(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===r.result)throw new Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(", "));const o=n.features.filter((e=>r.value.evaluate({zoom:0},e)));n={type:"FeatureCollection",features:o};}this._geoJSONIndex=t.cluster?new j(function({superclusterOptions:t,clusterProperties:r}){if(!r||!t)return t;const o={},i={},s={accumulated:null,zoom:0},n={properties:null},a=Object.keys(r);for(const t of a){const[s,n]=r[t],a=e.e(n),l=e.e("string"==typeof s?[s,["accumulated"],["get",t]]:s);o[t]=a.value,i[t]=l.value;}return t.map=e=>{n.properties=e;const t={};for(const e of a)t[e]=o[e].evaluate(s,n);return t},t.reduce=(e,t)=>{n.properties=t;for(const t of a)s.accumulated=e[t],e[t]=i[t].evaluate(s,n);},t}(t)).load(n.features):J(n,t.geojsonVtOptions);}catch(s){return r(s)}this.loaded={};const l={};if(i){const r=e.f(o);r&&(l.resourceTiming={},l.resourceTiming[t.source]=JSON.parse(JSON.stringify(r)));}r(null,l);}}));}reloadTile(e,t){const r=this.loaded;return r&&r[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,r){if(t.request)e.h(t.request,r);else {if("string"!=typeof t.data)return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return r(null,JSON.parse(t.data))}catch(e){return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId));}catch(e){t(e);}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId));}catch(e){t(e);}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset));}catch(e){t(e);}}}class W{constructor(t,r){this.tileID=new e.O(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=r;}parse(t,r,o,i){this.status="parsing";const s=new e.O(o.tileID.overscaledZ,o.tileID.wrap,o.tileID.canonical.z,o.tileID.canonical.x,o.tileID.canonical.y),n={},a=r.familiesBySource[o.source],l=new e.F(s,o.promoteId);return l.bucketLayerIDs=[],e.l(t).then((t=>{if(!t)return i(new Error("Could not parse tile"));const r=e.j(t,1/e.t(o.tileID.canonical)),h=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features"),u=new e.k(this.zoom,{brightness:this.brightness});for(const o in a)for(const i of a[o]){const o=i[0],a=t.json.extensionsUsed;o.recalculate(u,[]);const l=new e.T(r,s,a&&a.includes("MAPBOX_mesh_features"),this.brightness);h||(l.needsUpload=!0),n[o.fqid]=l,l.evaluate(o);}this.status="done",i(null,{buckets:n,featureIndex:l});})).catch((e=>i(new Error(e.message))))}}class X{constructor(e,t,r,o,i,s){this.actor=e,this.layerIndex=t,this.brightness=s,this.loading={},this.loaded={};}loadTile(t,r){const o=t.uid,i=this.loading[o]=new W(t,this.brightness);e.i(t.request,((e,s)=>{const n=!this.loading[o];return delete this.loading[o],n||e?(i.status="done",n||(this.loaded[o]=i),r(e)):s&&0!==s.byteLength?void i.parse(s,this.layerIndex,t,((e,t)=>{i.status="done",this.loaded=this.loaded||{},this.loaded[o]=i,e||!t?r(e):r(null,t);})):(i.status="done",this.loaded[o]=i,r())}));}reloadTile(e,t){const r=this.loaded,o=e.uid;if(r&&r[o]){const i=r[o];i.projection=e.projection,i.brightness=e.brightness;const s=(r,o)=>{i.reloadCallback&&(delete i.reloadCallback,this.loadTile(e,t)),t(r,o);};"parsing"===i.status?i.reloadCallback=s:"done"===i.status&&this.loadTile(e,t);}}abortTile(e,t){const r=e.uid;this.loading[r]&&delete this.loading[r],t();}removeTile(e,t){const r=this.loaded,o=e.uid;r&&r[o]&&delete r[o],t();}}class V{constructor(t){this.self=t,this.actor=new e.A(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.m({name:"mercator"}),this.workerSourceTypes={vector:e.d,geojson:G,"batched-model":X},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t;},this.self.registerRTLTextPlugin=t=>{if(e.n.isParsed())throw new Error("RTL text plugin already registered.");e.n.applyArabicShaping=t.applyArabicShaping,e.n.processBidirectionalText=t.processBidirectionalText,e.n.processStyledBidirectionalText=t.processStyledBidirectionalText;};}clearCaches(e,t,r){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],r();}checkIfReady(e,t,r){r();}setReferrer(e,t){this.referrer=t;}spriteLoaded(t,{scope:r,isLoaded:o}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][r]=o,this.workerSources[t]&&this.workerSources[t][r])for(const i in this.workerSources[t][r]){const s=this.workerSources[t][r][i];for(const t in s)s[t]instanceof e.d&&(s[t].isSpriteLoaded=o,s[t].fire(new e.o("isSpriteLoaded")));}}setImages(e,{scope:t,images:r},o){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=r,this.workerSources[e]&&this.workerSources[e][t]){for(const o in this.workerSources[e][t]){const i=this.workerSources[e][t][o];for(const e in i)i[e].availableImages=r;}o();}else o();}setProjection(t,r){this.projections[t]=e.m(r);}setBrightness(e,t,r){this.brightness=t,r();}setLayers(e,t,r){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),r();}updateLayers(e,t,r){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),r();}loadTile(e,t,r){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,r);}loadDEMTile(e,t,r){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,r);}reloadTile(e,t,r){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,r);}abortTile(e,t,r){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,r);}removeTile(e,t,r){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,r);}removeSource(e,t,r){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const o=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==o.removeSource?o.removeSource(t,r):r();}loadWorkerSource(e,t,r){try{this.self.importScripts(t.url),r();}catch(e){r(e.toString());}}syncRTLPluginState(t,r,o){try{e.n.setState(r);const t=e.n.getPluginURL();if(e.n.isLoaded()&&!e.n.isParsed()&&null!=t){this.self.importScripts(t);const r=e.n.isParsed();o(r?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),r);}}catch(e){o(e.toString());}}setDracoUrl(e,t){this.dracoUrl=t;}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let r=this.availableImages[e][t];return r||(r=[]),r}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let r=this.layerIndexes[e][t];return r||(r=this.layerIndexes[e][t]=new o,r.scope=t),r}getWorkerSource(e,t,r,o){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][o]||(this.workerSources[e][o]={}),this.workerSources[e][o][t]||(this.workerSources[e][o][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),!this.workerSources[e][o][t][r]){const i={send:(t,r,o,i,s,n)=>{this.actor.send(t,r,o,e,s,n);},scheduler:this.actor.scheduler};this.workerSources[e][o][t][r]=new this.workerSourceTypes[t](i,this.getLayerIndex(e,o),this.getAvailableImages(e,o),this.isSpriteLoaded[e][o],void 0,this.brightness);}return this.workerSources[e][o][t][r]}getDEMWorkerSource(e,t,r){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][r]||(this.demWorkerSources[e][r]={}),this.demWorkerSources[e][r][t]||(this.demWorkerSources[e][r][t]=new i),this.demWorkerSources[e][r][t]}enforceCacheSizeLimit(t,r){e.q(r);}getWorkerPerformanceMetrics(e,t,r){r(void 0,void 0);}}return "undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new V(self)),V}));
47
+
48
+ define(["./shared"],(function(e){"use strict";return e.s}));
49
+
50
+ //
51
+ // Our custom intro provides a specialized "define()" function, called by the
52
+ // AMD modules below, that sets up the worker blob URL and then executes the
53
+ // main module, storing its exported value as 'mapboxgl'
54
+
55
+
56
+ var mapboxgl$1 = mapboxgl;
57
+
58
+ return mapboxgl$1;
59
+
60
+ }));
61
+ //# sourceMappingURL=mapbox-gl.js.map
62
+ </script>
10
63
  <!-- <script src="./sfmap.min.js"></script> -->
11
64
  </head>
12
65
  <body>